set up jai config

This commit is contained in:
2026-04-14 12:39:18 -04:00
parent 759c614d5d
commit fb0835f2c5
4 changed files with 103 additions and 10 deletions

View File

@@ -0,0 +1,3 @@
vim.keymap.set("n", ":w<CR>", function()
require("compile-mode").recompile()
end, { buffer = true })

44
after/ftplugin/jai.lua Normal file
View File

@@ -0,0 +1,44 @@
vim.keymap.set("n", "gd", function()
-- grab the word under the cursor
local word = vim.fn.expand("<cword>")
print(word)
-- search for "def <word>" or "class <word>" in the current project
local command = string.format("rg --no-heading -n -g '*.jai' '^%s[[:space:]]*:' ~/.local/jai ./", word)
local results = vim.fn.systemlist(command)
if #results == 0 then
print("no definition found for " .. word)
return
end
-- populate the quickfix list and open it
local qf = {}
for _, line in ipairs(results) do
local file, lnum, text = line:match("^(.+):(%d+):(.*)$")
if file then
table.insert(qf, {
filename = file,
lnum = tonumber(lnum),
text = text,
})
end
end
if #qf == 1 then
vim.cmd.edit(string.format("+%d %s", qf[1].lnum, qf[1].filename))
return
end
vim.fn.setqflist(qf)
vim.cmd.copen()
end, { buffer = true, desc = "Go to definition (jai)" })
vim.keymap.set("n", "<leader>fj", function()
require("telescope.builtin").find_files({
cwd = "/Users/grant/.local/jai",
})
end, { buffer = true, desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fJ", function()
require("telescope.builtin").live_grep({
cwd = "/Users/grant/.local/jai",
})
end, { buffer = true, desc = "Telescope find files" })

View File

@@ -1,8 +1,10 @@
vim.g.mapleader = " "
vim.g.maplocalleader = ","
vim.o.shiftwidth = 4
vim.o.tabstop = 4
vim.opt.expandtab = true -- Convert tabs to spaces
vim.opt.tabstop = 4 -- Number of spaces per tab
vim.opt.shiftwidth = 4 -- Spaces used for autoindent
vim.opt.softtabstop = 4 -- Spaces inserted when pressing Tab
vim.o.number = true
@@ -32,8 +34,9 @@ vim.o.timeoutlen = 300
-- Configure how new splits should be opened
vim.o.splitright = true
vim.o.splitbelow = true
vim.o.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
vim.o.list = false
-- vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
-- Preview substitutions live, as you type!
vim.o.inccommand = "split"
@@ -70,8 +73,8 @@ vim.diagnostic.config({
underline = { severity = { min = vim.diagnostic.severity.WARN } },
-- Can switch between these as you prefer
virtual_text = false, -- Text shows up at the end of the line
virtual_lines = true, -- Text shows up underneath the line, with virtual lines
virtual_text = true, -- Text shows up at the end of the line
virtual_lines = false, -- Text shows up underneath the line, with virtual lines
-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
jump = { float = true },
@@ -84,8 +87,9 @@ vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" }
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover({ border = "rounded" })
end)
vim.keymap.set("n", "grd", vim.lsp.buf.definition)
vim.lsp.enable({ "lua_ls", "dartls" })
vim.lsp.enable({ "lua_ls", "dartls", "clangd", "ols" })
local github = "https://github.com/"
vim.pack.add({
@@ -102,17 +106,31 @@ vim.pack.add({
github .. "tjdevries/colorbuddy.nvim",
github .. "hgranthorner/ghosttybuddy.nvim",
github .. "nvim-treesitter/nvim-treesitter",
github .. "rluba/jai.vim",
github .. "m00qek/baleia.nvim",
github .. "ej-shafran/compile-mode.nvim",
})
-- Telescope
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>ff", function()
require("telescope.builtin").find_files({
cwd = require("oil").get_current_dir(),
})
end, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fc", function()
builtin.find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "Telescope find config" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fg", function()
builtin.live_grep({
cwd = require("oil").get_current_dir(),
})
end, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
vim.keymap.set("n", "<leader>fm", builtin.marks, { desc = "Telescope marks" })
vim.keymap.set("n", "<leader>f/", builtin.current_buffer_fuzzy_find, { desc = "Telescope current buffer" })
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("telescope-lsp-attach", { clear = true }),
callback = function(event)
@@ -142,6 +160,7 @@ require("mini.surround").setup()
require("mini.snippets").setup()
-- Neogit
require("neogit").setup({ kind = "split" })
vim.keymap.set("n", "<leader>gg", "<CMD>Neogit<CR>")
-- Conform
@@ -153,6 +172,8 @@ require("conform").setup({
python = { "ruff" },
-- You can customize some of the format options for the filetype (:help conform.format)
rust = { "rustfmt", lsp_format = "fallback" },
cpp = { "clang-format" },
odin = { "odinfmt" },
-- Conform will run the first available formatter
javascript = { "prettierd", "prettier", stop_after_first = true },
},
@@ -180,8 +201,21 @@ vim.api.nvim_create_autocmd("FileType", {
vim.treesitter.start()
-- folds, provided by Neovim
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.wo.foldmethod = "expr"
vim.wo.foldmethod = "manual"
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
-- compile mode
require("compile-mode")
vim.g.compile_mode = {
default_command = {
jai = "jai -quiet %",
},
baleia_setup = true,
bang_expansion = true,
}
vim.keymap.set("n", "<leader>r", function()
require("compile-mode").recompile()
end)

View File

@@ -1,5 +1,9 @@
{
"plugins": {
"baleia.nvim": {
"rev": "32617940adb2eea56e85a64883a19961ceac9641",
"src": "https://github.com/m00qek/baleia.nvim"
},
"blink.cmp": {
"rev": "451168851e8e2466bc97ee3e026c3dcb9141ce07",
"src": "https://github.com/saghen/blink.cmp",
@@ -9,6 +13,10 @@
"rev": "8b968581e5c19d22a861d5f3fe5dbd83394fa681",
"src": "https://github.com/tjdevries/colorbuddy.nvim"
},
"compile-mode.nvim": {
"rev": "ce34ad9e69cb6a2d9f71017f4cb090195fb9fc09",
"src": "https://github.com/ej-shafran/compile-mode.nvim"
},
"conform.nvim": {
"rev": "086a40dc7ed8242c03be9f47fbcee68699cc2395",
"src": "https://github.com/stevearc/conform.nvim"
@@ -21,6 +29,10 @@
"rev": "50c205548d8b037b7ff6378fca6d21146f0b6161",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"jai.vim": {
"rev": "591aa0a75e9bb859028248b65a1a38d46b8d8576",
"src": "https://github.com/rluba/jai.vim"
},
"mini.nvim": {
"rev": "af5f75c9ce572a4d1f0c77d6fb4ea764d16c1b3c",
"src": "https://github.com/nvim-mini/mini.nvim"