From 1761d659c74aee2c21ffea3f31700d2713875a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kmie=C4=87?= Date: Wed, 4 Mar 2026 10:32:14 +0100 Subject: [PATCH] Nvim: sync with coder setup --- .config/nvim/lua/plugins/fold.lua | 3 +- .config/nvim/lua/plugins/garbage-day.lua | 3 +- .config/nvim/lua/plugins/join.lua | 1 - .config/nvim/lua/plugins/line.lua | 2 +- .config/nvim/lua/plugins/lspconfig.lua | 17 +- .config/nvim/lua/plugins/null.lua | 41 ++-- .config/nvim/lua/plugins/oil.lua | 13 +- .config/nvim/lua/plugins/telescope.lua | 1 + .config/nvim/lua/plugins/treesitter.lua | 281 ++++++++++++++++++++++- 9 files changed, 337 insertions(+), 25 deletions(-) diff --git a/.config/nvim/lua/plugins/fold.lua b/.config/nvim/lua/plugins/fold.lua index e8a428a..85d486b 100644 --- a/.config/nvim/lua/plugins/fold.lua +++ b/.config/nvim/lua/plugins/fold.lua @@ -79,6 +79,7 @@ return require("ufo").setup({ fold_virt_text_handler = handler }) - end + end, + enabled = false } } diff --git a/.config/nvim/lua/plugins/garbage-day.lua b/.config/nvim/lua/plugins/garbage-day.lua index 9fd4a64..9536d92 100644 --- a/.config/nvim/lua/plugins/garbage-day.lua +++ b/.config/nvim/lua/plugins/garbage-day.lua @@ -3,5 +3,6 @@ return { event = "VeryLazy", opts = { wakeup_delay = 5000 - } + }, + enabled = false } diff --git a/.config/nvim/lua/plugins/join.lua b/.config/nvim/lua/plugins/join.lua index 645383e..7097fca 100644 --- a/.config/nvim/lua/plugins/join.lua +++ b/.config/nvim/lua/plugins/join.lua @@ -12,6 +12,5 @@ return { require('treesj').toggle({ split = { recursive = true } }) end) end, - -- it is loading very long or is it treesitter? enabled = true } diff --git a/.config/nvim/lua/plugins/line.lua b/.config/nvim/lua/plugins/line.lua index f986df4..353d5c3 100644 --- a/.config/nvim/lua/plugins/line.lua +++ b/.config/nvim/lua/plugins/line.lua @@ -381,5 +381,5 @@ return { } }) end, - enabled = false + enabled = true } diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 010d634..727186f 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -130,7 +130,7 @@ return { vim.lsp.config('clangd_extensions', { cmd = { - "/workspace/WayveCode/bzl-build/WayveCode/external/llvm_toolchain_llvm/bin/clangd", + "/workspace/WayveCode/tools/clangd", "--background-index", "-j=32", "--header-insertion=never"}, @@ -186,6 +186,21 @@ return { settings = {}, }) + vim.lsp.config('bzl', { + cmd = { 'bzl', 'lsp', 'serve' }, + filetypes = { 'bzl' }, + -- https://docs.bazel.build/versions/5.4.1/build-ref.html#workspace + root_markers = { 'WORKSPACE', 'WORKSPACE.bazel' }, + }) + + vim.lsp.config('rust_analyzer', { + cmd = { 'rust_analyzer'}, + filetypes = { "rust" }, + single_file_support = true, + settings = {}, + }) + vim.lsp.enable('rust_analyzer') + -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { "cmake", "rust_analyzer", "bashls", "marksman", "bzl" } diff --git a/.config/nvim/lua/plugins/null.lua b/.config/nvim/lua/plugins/null.lua index 9de1566..6e69636 100644 --- a/.config/nvim/lua/plugins/null.lua +++ b/.config/nvim/lua/plugins/null.lua @@ -1,20 +1,35 @@ return { 'nvimtools/none-ls.nvim', + dependencies = { + "CKolkey/ts-node-action", + }, config = function() - local none_ls = require("null-ls") - none_ls.setup({ + local null_ls = require("null-ls") + null_ls.setup({ sources = { - none_ls.builtins.code_actions.gitsigns, - none_ls.builtins.diagnostics.gitlint, - none_ls.builtins.diagnostics.cmake_lint, - none_ls.builtins.diagnostics.codespell, - none_ls.builtins.diagnostics.fish, - none_ls.builtins.diagnostics.mypy, - --none_ls.builtins.diagnostics.mlint, - find it - --none_ls.builtins.diagnostics.commitlint, - written in npm - --none_ls.builtins.diagnostics.checkmake, - written in go - none_ls.builtins.hover.dictionary, - none_ls.builtins.formatting.black}, + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.code_actions.gitrebase, + null_ls.builtins.code_actions.textlint, + null_ls.builtins.code_actions.ts_node_action, + null_ls.builtins.diagnostics.alex, + null_ls.builtins.diagnostics.buf, + null_ls.builtins.diagnostics.buildifier, + null_ls.builtins.diagnostics.gitleaks, + null_ls.builtins.diagnostics.gitlint, + null_ls.builtins.diagnostics.cmake_lint, + null_ls.builtins.diagnostics.codespell, + null_ls.builtins.diagnostics.commitlint, + null_ls.builtins.diagnostics.cppcheck, + null_ls.builtins.diagnostics.fish, + null_ls.builtins.diagnostics.mypy, + null_ls.builtins.diagnostics.protolint, + --null_ls.builtins.diagnostics.mlint, - find it + --null_ls.builtins.diagnostics.commitlint, - written in npm + --null_ls.builtins.diagnostics.checkmake, - written in go + null_ls.builtins.hover.dictionary, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.buf, + null_ls.builtins.formatting.buildifier}, }) end } diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua index cbb9751..a57aab5 100644 --- a/.config/nvim/lua/plugins/oil.lua +++ b/.config/nvim/lua/plugins/oil.lua @@ -2,12 +2,19 @@ return {{ 'stevearc/oil.nvim', opts = { delete_to_trash = true, - + columns = { + "icon", + "permissions", + "size", + "mtime" + }, + skip_confirmation_for_simple_edits = true, }, - vim.keymap.set("n", "tt", "Oil", { desc = "Open parent directory" }) + --vim.keymap.set("n", "tt", "Oil", { desc = "Open parent directory" }) + vim.keymap.set("n", "-", function() require("oil").open(nil, {preview = {vertical = True}}) end, { desc = "Open parent directory" }) }, { 'mong8se/buffish.nvim', - vim.keymap.set("n", "tb", function() require('buffish').open() end, { desc = "Open buffers list" }) + vim.keymap.set("n", "+", function() require('buffish').open() end, { desc = "Open buffers list" }) }, { "benomahony/oil-git.nvim", dependencies = { "stevearc/oil.nvim" }, diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index ac9eba0..c1582a2 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -66,6 +66,7 @@ return { "to_camel_case", "to_title_case", "to_path_case", + "to_pascal_case", } }) require('telescope').load_extension('undo') diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index 677c93f..d71c4f1 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,6 +1,58 @@ return { 'nvim-treesitter/nvim-treesitter', + -- dependencies = { + -- 'mizlan/iswap.nvim', + -- 'romgrk/nvim-treesitter-context', + -- --"nvim-treesitter/nvim-treesitter-textobjects", + -- --"nvim-treesitter/playground", + -- }, + -- build = ':TSUpdate', + -- opts = function() + -- -- Tree-sitter configuration + -- + -- local ts = require'nvim-treesitter' + -- + -- ts.setup { + -- ignore_install = {'javascript'}, + -- sync_install = true, + -- auto_install = true, + -- ensure_installed = {}, + -- modules = {}, + -- highlight = { + -- enable = true, + -- -- disable = function(lang, buf) + -- -- local max_filesize = 100 * 1024 -- 100 KB + -- -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + -- -- if ok and stats and stats.size > max_filesize then + -- -- return true + -- -- end + -- -- end, + -- additional_vim_regex_highlighting = false, + -- }, + -- indent = { + -- enable = true, + -- }, + -- incremental_selection = { + -- enable = false, + -- keymaps = { + -- init_selection = "ti", + -- node_incremental = "ti", + -- scope_incremental = "ts", + -- node_decremental = "td", + -- }, + -- }, + -- matchup = { + -- enable = true, + -- -- disable = { "c", "ruby" }, + -- }, + -- } + -- vim.opt.foldmethod = "manual" + -- vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" + -- vim.opt.foldlevelstart = 99 + -- vim.opt.foldminlines = 50 + -- end dependencies = { +<<<<<<< HEAD 'mizlan/iswap.nvim', 'romgrk/nvim-treesitter-context', --"nvim-treesitter/nvim-treesitter-textobjects", @@ -83,11 +135,232 @@ return { matchup = { enable = true, -- disable = { "c", "ruby" }, +||||||| parent of e4b1315 (Nvim: sync with coder setup) + 'mizlan/iswap.nvim', + 'romgrk/nvim-treesitter-context', + --"nvim-treesitter/nvim-treesitter-textobjects", + --"nvim-treesitter/playground", + }, + build = ':TSUpdate', + opts = function() + -- Tree-sitter configuration + + local ts = require'nvim-treesitter.configs' + + ts.setup { + ignore_install = {'javascript'}, + sync_install = true, + auto_install = true, + ensure_installed = { + "arduino", + "awk", + "bash", + "bibtex", + "bitbake", + "c", + "cmake", + --"comment", + "cpp", + "csv", + "devicetree", + "diff", + "fish", + "gitattributes", + "gitcommit", + "gitignore", + "git_config", + "git_rebase", + "html", + "vimdoc", + "http", + "ini", + "jq", + "json", + "latex", + "lua", + "make", + "markdown", + "markdown_inline", + "matlab", + "ninja", + "proto", + "python", + "regex", + "rust", + "toml", + "vim", + "yaml", }, + modules = {}, + highlight = { + enable = true, + -- disable = function(lang, buf) + -- local max_filesize = 100 * 1024 -- 100 KB + -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + -- if ok and stats and stats.size > max_filesize then + -- return true + -- end + -- end, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = false, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "ti", + node_incremental = "ti", + scope_incremental = "ts", + node_decremental = "td", + }, + }, + matchup = { + enable = true, + -- disable = { "c", "ruby" }, +======= + { + 'nvim-treesitter/nvim-treesitter-context', + opts = { + max_lines = 4, + multiline_threshold = 2, +>>>>>>> e4b1315 (Nvim: sync with coder setup) + }, + }, + { + 'mizlan/iswap.nvim', + enabled = false, } - vim.opt.foldmethod = "manual" - vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" - vim.opt.foldlevelstart = 99 - vim.opt.foldminlines = 50 + }, + lazy = false, + branch = 'main', + --build = ':TSUpdate', + config = function() + local ts = require('nvim-treesitter') + + -- State tracking for async parser loading + local parsers_loaded = {} + local parsers_pending = {} + local parsers_failed = {} + + local ns = vim.api.nvim_create_namespace('treesitter.async') + + -- Helper to start highlighting and indentation + local function start(buf, lang) + local ok = pcall(vim.treesitter.start, buf, lang) + if ok then + -- vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + return ok + end + + -- Install core parsers after lazy.nvim finishes loading all plugins + vim.api.nvim_create_autocmd('User', { + pattern = 'LazyDone', + once = true, + callback = function() + ts.install({ + "arduino", + "awk", + "bash", + "bibtex", + "bitbake", + "c", + "cmake", + --"comment", + "cpp", + "csv", + "devicetree", + "diff", + "fish", + "gitattributes", + "gitcommit", + "gitignore", + "git_config", + "git_rebase", + "html", + "vimdoc", + "http", + "ini", + "jq", + "json", + --"latex", + "lua", + "make", + "markdown", + "markdown_inline", + "matlab", + "ninja", + "proto", + "python", + "regex", + "rust", + "toml", + "vim", + "yaml", + }, { + max_jobs = 8, + }) + end, + }) + + -- Decoration provider for async parser loading + vim.api.nvim_set_decoration_provider(ns, { + on_start = vim.schedule_wrap(function() + if #parsers_pending == 0 then + return false + end + for _, data in ipairs(parsers_pending) do + if vim.api.nvim_buf_is_valid(data.buf) then + if start(data.buf, data.lang) then + parsers_loaded[data.lang] = true + else + parsers_failed[data.lang] = true + end + end + end + parsers_pending = {} + end), + }) + + local group = vim.api.nvim_create_augroup('TreesitterSetup', { clear = true }) + + local ignore_filetypes = { + 'checkhealth', + 'lazy', + 'mason', + 'snacks_dashboard', + 'snacks_notif', + 'snacks_win', + } + + -- Auto-install parsers and enable highlighting on FileType + vim.api.nvim_create_autocmd('FileType', { + group = group, + desc = 'Enable treesitter highlighting and indentation (non-blocking)', + callback = function(event) + if vim.tbl_contains(ignore_filetypes, event.match) then + return + end + + local lang = vim.treesitter.language.get_lang(event.match) or event.match + local buf = event.buf + + if parsers_failed[lang] then + return + end + + if parsers_loaded[lang] then + -- Parser already loaded, start immediately (fast path) + start(buf, lang) + else + -- Queue for async loading + table.insert(parsers_pending, { buf = buf, lang = lang }) + end + + -- Auto-install missing parsers (async, no-op if already installed) + ts.install({ lang }) + end, + }) end }