diff options
| -rw-r--r-- | ftplugin/jai.lua | 179 | ||||
| -rw-r--r-- | lua/config/settings.lua | 13 | ||||
| -rw-r--r-- | lua/plugins/colorscheme.lua | 5 | ||||
| -rw-r--r-- | lua/plugins/colourscheme.lua | 9 | ||||
| -rw-r--r-- | lua/plugins/init.lua | 3 | ||||
| -rw-r--r-- | lua/plugins/jai.lua | 3 | ||||
| -rw-r--r-- | lua/plugins/mini.lua | 42 | ||||
| -rw-r--r-- | lua/plugins/mini/clues.lua | 13 | ||||
| -rw-r--r-- | lua/plugins/mini/files.lua | 9 | ||||
| -rw-r--r-- | lua/plugins/mini/highlight.lua | 8 | ||||
| -rw-r--r-- | lua/plugins/mini/pick.lua | 7 | ||||
| -rw-r--r-- | lua/plugins/mini/starter.lua | 30 | ||||
| -rw-r--r-- | lua/plugins/todotxt.lua | 4 | ||||
| -rw-r--r-- | nvim-pack-lock.json | 44 | ||||
| -rw-r--r-- | queries/jai/context.scm | 8 | ||||
| -rw-r--r-- | queries/jai/highlights.scm | 261 | ||||
| -rw-r--r-- | queries/jai/indents.scm | 67 |
17 files changed, 629 insertions, 76 deletions
diff --git a/ftplugin/jai.lua b/ftplugin/jai.lua new file mode 100644 index 0000000..f3fb7eb --- /dev/null +++ b/ftplugin/jai.lua @@ -0,0 +1,179 @@ +---- Miscellaneous settings and keymaps +-- Recognise jai file type +vim.filetype.add({ extension = { jai = 'jai' }}) + +---- Jails: the LSP server for Jai +local SETUP_LSP = true +if SETUP_LSP then + -- https://github.com/SogoCZE/Jails.git + -- Install to path, or put the full path in cmd below + vim.lsp.config.jails = { + cmd = { 'jails' }, + root_markers = { '.git', 'build.jai' }, + filetypes = { 'jai' } + } + vim.lsp.enable('jails') + -- Check if things are working with `:checkhealth lsp` + -- Restart with `:lsp restart` (nvim 0.12+) +end + +---- Tree-sitter highlighting +local SETUP_TREESITTER = true +if SETUP_TREESITTER then + -- Register {language} with {filetype} + vim.treesitter.language.register('jai', 'jai') + + -- Build https://github.com/constantitus/tree-sitter-jai + --[[ + git clone https://github.com/constantitus/tree-sitter-jai ~/opt/tree-sitter-jai + cd ~/opt/tree-sitter-jai + cmake . -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build + # DLL now inside build/ + + # You must also copy the queries/ directory to your configuration path + # for highlighting etc. to work + cp ~/opt/tree-sitter-jai/queries/* ~/.config/nvim-jai/queries/jai/ + ]] + -- Tell neovim about the treesitter plugin and its DLL path + vim.treesitter.language.add('jai', { path = vim.fn.expand('~/opt/tree-sitter-jai/build/libtree-sitter-jai.so') }) + + -- Automatically start treesitter on filetypes that we have a treesitter installation for + vim.api.nvim_create_autocmd('FileType', { + pattern = '*', + group = vim.api.nvim_create_augroup('config-autotreesitter', { clear = true }), + callback = function(ev) + local filetype = vim.bo[ev.buf].filetype + local tsname = vim.treesitter.language.get_lang(filetype) + if tsname and vim.treesitter.language.add(tsname) then + vim.treesitter.start(ev.buf) + -- If treesitter AND vim regex highlighting modes are desired, turn it on like this + -- vim.bo[ev.buf].syntax = 'ON' + end + end, + }) +end + +---- Debugger +local SETUP_DEBUGGER = true +if SETUP_DEBUGGER then + -- Install plugins + vim.pack.add({ + 'https://github.com/mfussenegger/nvim-dap', + }) + + -- List of debug adaptor installation guides: + -- https://codeberg.org/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation + -- For codelldb, extract the .vsix file somewhere, and update the path below. + -- https://github.com/vadimcn/codelldb/releases + local dap = require('dap') + dap.adapters.codelldb = { + type = 'executable', + command = vim.fn.expand('~/opt/codelldb/extension/adapter/codelldb'), + -- On windows you may have to uncomment this: + -- detached = false, + } + + dap.configurations.jai = { + { + name = 'Launch file', + type = 'codelldb', + request = 'launch', + program = '${command:pickFile}', + cwd = '${workspaceFolder}', + stopOnEntry = false, + sourceLanguages = { 'jai' }, + } + } + dap.configurations.c = dap.configurations.jai + dap.configurations.cpp = dap.configurations.jai + dap.configurations.rust = dap.configurations.jai + + vim.keymap.set("n", "<F1>", dap.continue, { desc = 'Debug: continue' }) + vim.keymap.set("n", "<F5>", dap.continue, { desc = 'Debug: continue' }) + vim.keymap.set("n", "<F2>", dap.step_into, { desc = 'Debug: step into' }) + vim.keymap.set("n", "<F3>", dap.step_over, { desc = 'Debug: step over' }) + vim.keymap.set("n", "<F4>", dap.step_out, { desc = 'Debug: step out' }) + vim.keymap.set("n", "<F6>", dap.step_back, { desc = 'Debug: step back' }) + vim.keymap.set("n", "<F8>", dap.restart, { desc = 'Debug: restart' }) + vim.keymap.set("n", "<F9>", dap.close, { desc = 'Debug: stop' }) + + vim.keymap.set("n", "<space>dc", dap.run_to_cursor, { desc = 'Debug: Run to cursor' }) + vim.keymap.set('n', '<space>db', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', '<space>dB', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint with condition' }) + vim.keymap.set('n', '<space>dg', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end, { desc = 'Debug: log point' }) + vim.keymap.set('n', '<space>dr', function() require('dap').repl.open() end, { desc = 'Debug: open REPL'} ) + vim.keymap.set('n', '<space>dl', function() require('dap').run_last() end, { desc = 'Debug: run last' }) + vim.keymap.set({'n', 'v'}, '<space>dh', function() + require('dap.ui.widgets').hover() + end) + vim.keymap.set({'n', 'v'}, '<space>dp', function() + require('dap.ui.widgets').preview() + end) + + -- Fancy UI. Adds multiple panes such as watch window, locals, ... when the debugger starts + local SETUP_DEBUGGER_FANCY_UI = true + if SETUP_DEBUGGER_FANCY_UI then + vim.pack.add({ + 'https://github.com/rcarriga/nvim-dap-ui', + 'https://github.com/nvim-neotest/nvim-nio', -- dependency of nvim-dap-ui + }) + + local dapui = require('dapui') + dapui.setup() + dap.listeners.before.attach.dapui_config = function() dapui.open() end + dap.listeners.before.launch.dapui_config = function() dapui.open() end + dap.listeners.before.event_terminated.dapui_config = function() dapui.close() end + dap.listeners.before.event_exited.dapui_config = function() dapui.close() end + + vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' }) + -- Eval variable under cursor + vim.keymap.set({'n', 'v'}, "<space>dd", function() + require("dapui").eval() + end, { desc = 'Debug: Evaluate' }) + end +end + +---- Settings and keymaps +-- Error format for compiler message recognition +local jai_errfmt = [[%f:%l\,%v: %t%\a\*:%m]] +vim.o.errorformat = jai_errfmt .. ',' .. vim.o.errorformat + +-- keymap to open the Jai installation directory in a new tab, for :grep +vim.keymap.set('n', '<space>jm', function() + local jaipath = '~/opt/jai' + vim.cmd.tabedit(jaipath .. '/modules/Basic/Print.jai') + vim.cmd.tcd(jaipath) +end, { desc = 'Open Jai modules (and how_tos) directory' }) + +-- Select a jai file to build +vim.keymap.set('n', '<space>jb', function() + local jai_files = vim.fs.find(function(name, path) + return string.match(name, '.*%.jai$') + end, { limit = 50, type = 'file' }) + if jai_files then + vim.ui.select(jai_files, { prompt='Select a file to build'}, function(item) + if item then + vim.opt.makeprg = 'jai "' .. item .. '"' + print("Make program set to " .. vim.opt.makeprg:get()) + vim.cmd.make() -- optional, build it too + end + end) + else + print("No Jai files found") + end +end, { desc = 'Select a Jai file to build' }) + +-- m<enter> to call :make, to build what we just put into the makeprg above +vim.keymap.set('n', 'm<CR>', '<cmd>make<CR>') + +vim.keymap.set({'n', 'v'}, '<F12>', function() vim.lsp.buf.definition() end, { desc = 'LSP: Go to definition' }) + +-- Recommended to use UI2 if available. See :help ui2 +local _, ui2 = pcall(require, 'vim._core.ui2') +if ui2 then ui2.enable() end + +-- Just for me ;) +vim.opt_global.background = 'light' diff --git a/lua/config/settings.lua b/lua/config/settings.lua index 00fca50..652d522 100644 --- a/lua/config/settings.lua +++ b/lua/config/settings.lua @@ -1,3 +1,11 @@ +vim.g.mapleader = " " + +-- navigate vim panes better +vim.keymap.set('n', '<C-k>', ':wincmd k<CR>') +vim.keymap.set('n', '<C-j>', ':wincmd j<CR>') +vim.keymap.set('n', '<C-h>', ':wincmd h<CR>') +vim.keymap.set('n', '<C-l>', ':wincmd l<CR>') + -- enable line number and relative line numbers vim.opt.number = true vim.opt.relativenumber = true @@ -13,7 +21,7 @@ vim.opt.splitbelow = true vim.opt.splitright = true -- disable line wrapping -vim.opt.wrap = false +vim.opt.wrap = true -- enable global statusline vim.opt.laststatus = 3 @@ -55,7 +63,7 @@ vim.opt.completeopt = "menuone,noinsert,noselect" -- enable signcolumn vim.opt.signcolumn = "yes" --- enable rounded borders +-- enable rounded borders (nvim 0.11+) vim.opt.winborder = "rounded" -- better file handling @@ -66,6 +74,7 @@ vim.opt.undofile = true vim.opt.undodir = vim.fn.expand("~/.local/state/nvim/undo") vim.opt.autoread = true vim.opt.autowrite = false +vim.opt.clipboard = 'unnamedplus' -- durations for completion and other stuff vim.opt.updatetime = 300 diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua deleted file mode 100644 index 464ab75..0000000 --- a/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,5 +0,0 @@ -vim.pack.add({ - { src = "https://github.com/rose-pine/neovim", name = "rose-pine" }, -}) -vim.o.background = "dark" -vim.cmd([[colorscheme rose-pine]]) diff --git a/lua/plugins/colourscheme.lua b/lua/plugins/colourscheme.lua new file mode 100644 index 0000000..3f7c434 --- /dev/null +++ b/lua/plugins/colourscheme.lua @@ -0,0 +1,9 @@ +vim.pack.add({"https://github.com/serhez/teide.nvim"}) + +local function ColorMyPencils() + vim.cmd([[colorscheme teide-darker]]) + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +ColorMyPencils() diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1ce2bb7..59ef1a3 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,6 +1,7 @@ -require("plugins.colorscheme") +require("plugins.colourscheme") require("plugins.treesitter") require("plugins.lsp") +require("plugins.jai") require("plugins.mini") require("plugins.mini.init") require("plugins.markdown") diff --git a/lua/plugins/jai.lua b/lua/plugins/jai.lua new file mode 100644 index 0000000..646fcc1 --- /dev/null +++ b/lua/plugins/jai.lua @@ -0,0 +1,3 @@ +vim.pack.add({'https://github.com/rluba/jai.vim'}) + + diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 61f3388..e54a6d9 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -1,25 +1,29 @@ -vim.pack.add({ - { src = "https://github.com/nvim-mini/mini.nvim" }, -}) - --- git related stuff -require("mini.git").setup() -require("mini.diff").setup() +vim.pack.add({ { src = "https://github.com/nvim-mini/mini.nvim" } }) -- setup statusline -require("mini.statusline").setup() - --- move lines -require("mini.move").setup() - --- easy split args -require("mini.splitjoin").setup() +require('mini.statusline').setup({ + use_icons = true, +}) --- surround actions -require("mini.surround").setup() +-- colorscheme integration +require("teide").setup({ + integration = { + mini = true, + }, +}) -- amazing fast indent scope highlight plugin -require("mini.indentscope").setup() +require('mini.indentscope').setup({ + draw = { + delay = 100, + predicate = function(scope) return not scope.body.is_incomplete end, + priority = 2, + } +}) + +-- git related stuff +require('mini.git').setup() +require('mini.diff').setup() --- nice simple notifications inside neovim -require("mini.notify").setup() +-- load mini sub-modules +require("plugins.mini.init") diff --git a/lua/plugins/mini/clues.lua b/lua/plugins/mini/clues.lua index e7d32aa..d4bdc38 100644 --- a/lua/plugins/mini/clues.lua +++ b/lua/plugins/mini/clues.lua @@ -1,4 +1,4 @@ --- setup mini.clues, whickey but much simpler +-- setup mini.clue, whichkey but much simpler local miniclue = require('mini.clue') miniclue.setup({ triggers = { @@ -31,27 +31,20 @@ miniclue.setup({ -- `z` key { mode = 'n', keys = 'z' }, { mode = 'x', keys = 'z' }, - - -- add in support for built in completion - { mode = 'i', keys = '<C-x>' }, }, clues = { - -- Enhance this by adding descriptions for <Leader> mapping groups miniclue.gen_clues.builtin_completion(), miniclue.gen_clues.g(), miniclue.gen_clues.marks(), miniclue.gen_clues.registers(), miniclue.gen_clues.windows(), miniclue.gen_clues.z(), - -- add some clues to custom stuff + -- group labels { mode = "n", keys = "<Leader>f", desc = "Find" }, { mode = "n", keys = "<Leader>fg", desc = "Git" }, { mode = "n", keys = "<Leader>l", desc = "Lsp" }, - { mode = "n", keys = "<Leader>s", desc = "Treesitter" }, - { mode = "n", keys = "<Leader>v", desc = "Visits" }, - - -- built in completion + -- built-in completion hints { mode = 'i', keys = '<C-x><C-f>', desc = 'File names' }, { mode = 'i', keys = '<C-x><C-l>', desc = 'Whole lines' }, { mode = 'i', keys = '<C-x><C-o>', desc = 'Omni completion' }, diff --git a/lua/plugins/mini/files.lua b/lua/plugins/mini/files.lua index 4285838..a1ac24f 100644 --- a/lua/plugins/mini/files.lua +++ b/lua/plugins/mini/files.lua @@ -27,11 +27,10 @@ vim.api.nvim_create_autocmd('User', { pattern = 'MiniFilesBufferCreate', callback = function(args) local b = args.data.buf_id - vim.keymap.set('n', 'g~', set_cwd, { buffer = b, desc = 'Set cwd' }) - vim.keymap.set('n', 'gX', ui_open, { buffer = b, desc = 'OS open' }) - vim.keymap.set('n', 'gy', yank_path, { buffer = b, desc = 'Yank path' }) + vim.keymap.set('n', 'g~', set_cwd, { buffer = b, desc = 'Set cwd' }) + vim.keymap.set('n', 'gX', ui_open, { buffer = b, desc = 'OS open' }) + vim.keymap.set('n', 'gy', yank_path, { buffer = b, desc = 'Yank path' }) end, }) --- setup keybinding for mini.files -vim.keymap.set("n", "<Leader>e", function() minifiles_toggle() end, { desc = "Toggle mini.files explorer" }) +vim.keymap.set("n", "<leader>e", function() minifiles_toggle() end, { desc = "Toggle mini.files explorer" }) diff --git a/lua/plugins/mini/highlight.lua b/lua/plugins/mini/highlight.lua index 0c74d33..93c6576 100644 --- a/lua/plugins/mini/highlight.lua +++ b/lua/plugins/mini/highlight.lua @@ -2,10 +2,10 @@ local hipatterns = require("mini.hipatterns") hipatterns.setup({ highlighters = { - fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' }, - hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' }, - todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' }, - note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' }, + fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' }, + hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' }, + todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' }, + note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' }, hex_color = hipatterns.gen_highlighter.hex_color(), }, diff --git a/lua/plugins/mini/pick.lua b/lua/plugins/mini/pick.lua index e9a1a9f..762ad9b 100644 --- a/lua/plugins/mini/pick.lua +++ b/lua/plugins/mini/pick.lua @@ -1,5 +1,8 @@ -- setup picker with icons -require("mini.icons").setup() +require("mini.icons").setup({ + style = 'glyph', + use_file_extension = function(ext, file) return true end, +}) require("mini.pick").setup({ options = { use_cache = true, @@ -10,7 +13,7 @@ require("mini.pick").setup({ require("mini.extra").setup() -- mini.pick keybindings -local patterns = { "fixme", "hack", "todo", "note", } +local patterns = { "fixme", "hack", "todo", "note" } vim.keymap.set("n", "<Leader>ff", ":Pick files<CR>", { desc = "Search file in directory" }) vim.keymap.set("n", "<Leader>fw", ":Pick grep_live<CR>", { desc = "Search for word in directory" }) vim.keymap.set("n", "<Leader>fh", ":Pick help<CR>", { desc = "Search neovim help" }) diff --git a/lua/plugins/mini/starter.lua b/lua/plugins/mini/starter.lua index 782eddf..0e0ac30 100644 --- a/lua/plugins/mini/starter.lua +++ b/lua/plugins/mini/starter.lua @@ -1,38 +1,16 @@ --- minimal session manager -require("mini.sessions").setup() - -vim.keymap.set("n", "<Leader>sc", function() MiniSessions.write() end, { desc = "Create new session/project" }) -vim.keymap.set("n", "<Leader>ss", function() MiniSessions.select("read") end, { desc = "Select session/project" }) - --- nice file/directory visit tracker -require("mini.visits").setup() - --- setup some basic label keybindings -local map_vis = function(keys, call, desc) - local rhs = '<Cmd>lua MiniVisits.' .. call .. '<CR>' - vim.keymap.set('n', '<Leader>' .. keys, rhs, { desc = desc }) -end - -map_vis('vv', 'add_label()', 'Add label') -map_vis('vV', 'remove_label()', 'Remove label') -map_vis('vc', 'add_label("core")', 'Add to core') -map_vis('vC', 'remove_label("core")', 'Remove from core') -vim.keymap.set("n", "<Leader>fv", ":Pick visit_paths<CR>", { desc = "Search visited files" }) -vim.keymap.set("n", "<Leader>fc", ":Pick visit_paths filter='core'<CR>", - { desc = "Search visited files with tag 'core'" }) - --- simple startup startup screen +-- simple startup screen local starter = require('mini.starter') starter.setup({ + header = "hello, friend", + footer = "you're gay for my code, you're code gay.", evaluate_single = true, items = { starter.sections.builtin_actions(), - starter.sections.sessions(5, true), starter.sections.recent_files(5, true), starter.sections.recent_files(5, false), }, content_hooks = { starter.gen_hook.adding_bullet(), - starter.gen_hook.aligning("center", "center") + starter.gen_hook.aligning("center", "center"), }, }) diff --git a/lua/plugins/todotxt.lua b/lua/plugins/todotxt.lua index 7794ae3..c005690 100644 --- a/lua/plugins/todotxt.lua +++ b/lua/plugins/todotxt.lua @@ -3,8 +3,8 @@ vim.pack.add({ }) require("todotxt").setup({ - todotxt = vim.env.HOME .. "/docs/sb/todo/todo.txt", - donetxt = vim.env.HOME .. "/docs/sb/todo/done.txt", + todotxt = vim.env.HOME .. "/dox/todo/todo.txt", + donetxt = vim.env.HOME .. "/dox/todo/done.txt", ghost_text = { enable = true, mappings = { diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index 019ae85..15988b5 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -1,9 +1,25 @@ { "plugins": { + "LuaSnip": { + "rev": "3732756842a2f7e0e76a7b0487e9692072857277", + "src": "https://github.com/L3MON4D3/LuaSnip" + }, + "aniuwu.nvim": { + "rev": "561d51248b5cfe58301e5c6a239492841e81a015", + "src": "https://github.com/demonkingswarn/aniuwu.nvim" + }, + "cmp-nvim-lsp": { + "rev": "cbc7b02bb99fae35cb42f514762b89b5126651ef", + "src": "https://github.com/hrsh7th/cmp-nvim-lsp" + }, "conform.nvim": { "rev": "086a40dc7ed8242c03be9f47fbcee68699cc2395", "src": "https://github.com/stevearc/conform.nvim" }, + "jai.vim": { + "rev": "591aa0a75e9bb859028248b65a1a38d46b8d8576", + "src": "https://github.com/rluba/jai.vim" + }, "lazydev.nvim": { "rev": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d", "src": "https://github.com/folke/lazydev.nvim" @@ -20,6 +36,18 @@ "rev": "3923662bf3d6ca49a9503f8d7196ea0450983e6a", "src": "https://github.com/nvim-mini/mini.nvim" }, + "none-ls.nvim": { + "rev": "5abf61927023ea83031753504adb19630ba80eef", + "src": "https://github.com/nvimtools/none-ls.nvim" + }, + "nvim": { + "rev": "ce8d176faa4643e026e597ae3c31db59b63cef09", + "src": "https://github.com/catppuccin/nvim.git" + }, + "nvim-cmp": { + "rev": "d97d85e01339f01b842e6ec1502f639b080cb0fc", + "src": "https://github.com/hrsh7th/nvim-cmp" + }, "nvim-lspconfig": { "rev": "8e2084bf5e40c79c1f42210a6ef96a0a4793a763", "src": "https://github.com/neovim/nvim-lspconfig" @@ -28,6 +56,10 @@ "rev": "539abf6da5ee8702e37b82cc953131dadd570da2", "src": "https://github.com/nvim-treesitter/nvim-treesitter" }, + "presence.nvim": { + "rev": "87c857a56b7703f976d3a5ef15967d80508df6e6", + "src": "https://github.com/andweeb/presence.nvim" + }, "render-markdown.nvim": { "rev": "c7188a8f9d2953696b6303caccbf39c51fa2c1b1", "src": "https://github.com/MeanderingProgrammer/render-markdown.nvim" @@ -36,9 +68,21 @@ "rev": "cf2a288696b03d0934da713d66c6d71557b5c997", "src": "https://github.com/rose-pine/neovim" }, + "teide.nvim": { + "rev": "c9cd84e59c57651be7cc6b0f981011c247b6d233", + "src": "https://github.com/serhez/teide.nvim" + }, "todotxt.nvim": { "rev": "65eb9543046b1db6a0b59edf98fff59fdbc77c01", "src": "https://github.com/phrmendes/todotxt.nvim" + }, + "tokyonight.nvim": { + "rev": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd", + "src": "https://github.com/folke/tokyonight.nvim" + }, + "vim-tmux-navigator": { + "rev": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a", + "src": "https://github.com/christoomey/vim-tmux-navigator" } } } diff --git a/queries/jai/context.scm b/queries/jai/context.scm new file mode 100644 index 0000000..aebefb7 --- /dev/null +++ b/queries/jai/context.scm @@ -0,0 +1,8 @@ +(procedure_declaration) @context +(static_if_statement) @context +(if_statement) @context +(else_clause) @context +(for_statement) @context +(enum_declaration) @context +(struct_declaration) @context +(while_statement) @context
\ No newline at end of file diff --git a/queries/jai/highlights.scm b/queries/jai/highlights.scm new file mode 100644 index 0000000..91b2f19 --- /dev/null +++ b/queries/jai/highlights.scm @@ -0,0 +1,261 @@ +; Includes + +[ + (import) + (load) +] @include + + +; Keywords +[ + ; from modules/Jai_Lexer + "if" + "xx" + + "ifx" + "for" + + "then" + "else" + "null" + "case" + "enum" + "true" + "cast" + + "while" + "break" + "using" + "defer" + "false" + "union" + + "return" + "struct" + "inline" + "remove" + + ; "size_of" + "type_of" + ; "code_of" + ; "context" + + "continue" + "operator" + + ; "type_info" + "no_inline" + "interface" + + "enum_flags" + + ; "is_constant" + + "push_context" + + ; "initializer_of" +] @keyword + +[ + "return" +] @keyword.return + +[ + "if" + "else" + "case" + "break" +] @conditional + +((if_expression + [ + "then" + "ifx" + "else" + ] @conditional.ternary) + (#set! "priority" 105)) + +; Repeats + +[ + "for" + "while" + "continue" +] @repeat + +; Variables + +; (identifier) @variable +name: (identifier) @variable +argument: (identifier) @variable +named_argument: (identifier) @variable +(member_expression (identifier) @variable) +(parenthesized_expression (identifier) @variable) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "context")) + +; Namespaces + +(import (identifier) @namespace) + +; Parameters + +(parameter (identifier) @parameter ":" "="? (identifier)? @constant) + +; (call_expression argument: (identifier) @parameter "=") + +; Functions + +; (procedure_declaration (identifier) @function (procedure (block))) +(procedure_declaration (identifier) @function (block)) + +(call_expression function: (identifier) @function.call) + +; Types + +type: (types) @type +type: (identifier) @type +((types) @type) + +modifier: (identifier) @keyword +keyword: (identifier) @keyword + +((types (identifier) @type.builtin) + (#any-of? @type.builtin + "bool" "int" "string" + "s8" "s16" "s32" "s64" + "u8" "u16" "u32" "u64" + "Type" "Any")) + +(struct_declaration (identifier) @type ":" ":") + +(enum_declaration (identifier) @type ":" ":") + +; (const_declaration (identifier) @type ":" ":" [(array_type) (pointer_type)]) + +; ; I don't like this +; ((identifier) @type +; (#lua-match? @type "^[A-Z][a-zA-Z0-9]*$") +; (#not-has-parent? @type parameter procedure_declaration call_expression)) + +; Fields + +(member_expression "." (identifier) @field) + +(assignment_statement (identifier) @field "="?) +(update_statement (identifier) @field) + +; Constants + +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$") + (#not-has-parent? @constant type parameter)) + +(member_expression . "." (identifier) @constant) + +(enum_field (identifier) @constant) + +; Literals + +(integer) @number +(float) @number + +(string) @string + +;(character) @character + +(string_contents (escape_sequence) @string.escape) + +(boolean) @boolean + +[ + (uninitialized) + (null) +] @constant.builtin + +; Operators + +[ + ":" + "=" + "+" + "-" + "*" + "/" + "%" + ">" + ">=" + "<" + "<=" + "==" + "!=" + "|" + "~" + "&" + "&~" + "<<" + ">>" + "<<<" + ">>>" + "||" + "&&" + "!" + ".." + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "<<<=" + ">>>=" + "||=" + "&&=" +] @operator + +; Punctuation + +[ "{" "}" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ + "`" + "->" + "." + "," + ":" + ";" +] @punctuation.delimiter + +; Comments + +[ + (block_comment) + (comment) +] @spell + +[ + (block_comment) + (comment) +] @comment + +; Errors + +(ERROR) @error + +directive: ("#") @keyword ; #if +type: ("type_of") @type + +(compiler_directive) @keyword +(heredoc_start) @none +(heredoc_end) @none +(heredoc_body) @string +(note) @string diff --git a/queries/jai/indents.scm b/queries/jai/indents.scm new file mode 100644 index 0000000..82b0331 --- /dev/null +++ b/queries/jai/indents.scm @@ -0,0 +1,67 @@ +; Some documentation I found in a random github issue +; @indent.begin ; indent children when matching this node +; @indent.end ; marks the end of indented block +; @indent.align ; behaves like python aligned/hanging indent +; @indent.dedent ; dedent children when matching this node +; @indent.branch ; dedent itself when matching this node +; @indent.ignore ; do not indent in this node +; @indent.auto ; behaves like 'autoindent' buffer option +; @indent.zero ; sets this node at position 0 (no indent) + +; NOTE: these don't work well with Allman style. +; Also; I am really bad at this. There is almost no documentation available and I don't speak lisp or whichever of it's flavors this is. + +; Incomplete + +[ + (block) + (enum_declaration "{") + (struct_or_union_block "{") + (struct_literal "{") + (anonymous_enum_type "{") + (asm_statement "{") + (array_literal "[") + (index_expression "[") + (literal) + (assignment_parameters "(") +] @indent.begin + +((modify_block) @indent.end) +((place_directive) @indent.branch) + +; only indent the first statement after an if +(if_statement_condition_and_consequence + consequence: (_ + ";" @indent.end) @_consequence + (#not-match? @_consequence "\\{") +) @indent.begin + +(else_clause) @indent.branch + +; This is a workaround. I can't get 'else if' indentation to work properly. +(else_clause + consequence: (_) @_consequence + (#match? @_consequence "if") +) @indent.auto + +(if_case_statement) @indent.begin +(switch_case ";") @indent.branch + +((identifier) . (ERROR "(" @indent.begin)) + +(block + "}" @indent.end) + +[ + ")" + "]" + "}" +] @indent.branch @indent.end + +[ + (comment) + (block_comment) + (string) + (ERROR) +] @indent.auto + |
