diff --git a/config/neovim/config.lua b/config/neovim/config.lua index 7b89c328..6fd9d6ca 100644 --- a/config/neovim/config.lua +++ b/config/neovim/config.lua @@ -16,6 +16,7 @@ do ["cindent"] = true, ["cinkeys"] = "0{,0},0),0],:,!^F,o,O,e", ["completeopt"] = { "menuone", "noselect", "noinsert" }, + ["confirm"] = true, ["cursorline"] = true, ["encoding"] = "utf-8", ["expandtab"] = true, @@ -38,8 +39,10 @@ do ["relativenumber"] = true, ["ruler"] = true, ["scrolloff"] = 10, + ["sessionoptions"] = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" }, ["shiftwidth"] = 4, ["showmode"] = false, + ["showtabline"] = 0, ["signcolumn"] = "yes", ["smartcase"] = true, ["smartindent"] = false, @@ -52,6 +55,8 @@ do ["timeoutlen"] = 50, ["undodir"] = "/home/lab/smchurla/.vim/undo", ["undofile"] = true, + ["undolevels"] = 10000, + ["winblend"] = 30, } for k, v in pairs(nixvim_options) do @@ -103,13 +108,16 @@ require("lazy").setup({ require("nvim-autopairs").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-autopairs", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "autopairs", + ["opts"] = { ["check_ts"] = true }, }, { "bbye", + ["cmd"] = { "Bdelete", "Bwipeout" }, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/vim-bbye", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "bbye", }, { @@ -118,7 +126,8 @@ require("lazy").setup({ require("better_escape").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/better-escape.nvim", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "better-escape", ["opts"] = { ["mapping"] = { "jk" }, ["timeout"] = 200 }, }, @@ -128,8 +137,9 @@ require("lazy").setup({ require("clangd_extensions").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/clangd_extensions.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "clangd-extensions", + ["opts"] = { ["inlay_hints"] = { ["inline"] = false } }, }, { "cmp", @@ -183,7 +193,8 @@ require("lazy").setup({ }, }, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-cmp", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "cmp", ["opts"] = function() local cmp = require("cmp") @@ -243,7 +254,7 @@ require("lazy").setup({ elseif has_words_before() then cmp.complete() else - fallback() + fallback() -- This will call the intellitab binding end end, { "i", "s" }), [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), @@ -257,7 +268,9 @@ require("lazy").setup({ require("colorizer").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-colorizer.lua", - ["lazy"] = false, + ["enabled"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "colorizer", }, { @@ -297,9 +310,17 @@ require("lazy").setup({ require("conform").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/conform.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "conform", ["opts"] = { + ["format_on_save"] = function(bufnr) + -- Disable with a global or buffer-local variable + if vim.g.disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, ["formatters_by_ft"] = { ["c"] = { "clang-format" }, ["cpp"] = { "clang-format" }, @@ -323,18 +344,19 @@ require("lazy").setup({ require("flash").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/flash.nvim", - ["lazy"] = true, + ["lazy"] = false, ["name"] = "flash", }, { "gitmessenger", + ["cmd"] = { "GitMessenger" }, ["config"] = function(_, opts) for k, v in pairs(opts) do vim.g[k] = v end end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/git-messenger.vim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "gitmessenger", ["opts"] = { ["git_messenger_floating_win_opts"] = { ["border"] = "rounded" }, @@ -347,7 +369,8 @@ require("lazy").setup({ require("gitsigns").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/gitsigns.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "gitsigns", ["opts"] = { ["current_line_blame"] = false }, }, @@ -363,7 +386,8 @@ require("lazy").setup({ require("illuminate").configure(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/vim-illuminate", - ["lazy"] = false, + ["event"] = { "BufreadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "illuminate", ["opts"] = { ["filetypesDenylist"] = { @@ -382,7 +406,8 @@ require("lazy").setup({ { "intellitab", ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/intellitab.nvim", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "intellitab", }, { @@ -396,8 +421,17 @@ require("lazy").setup({ }, { "lazygit", + ["cmd"] = { "LazyGit", "LazyGitConfig", "LazyGitCurrentFile", "LazyGitFilter", "LazyGitFilterCurrentFile" }, + ["dependencies"] = { + { + "plenary", + ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/plenary.nvim", + ["lazy"] = true, + ["name"] = "plenary", + }, + }, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/lazygit.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "lazygit", }, { @@ -410,28 +444,29 @@ require("lazy").setup({ end end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-lint", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "lint", ["opts"] = { ["linters_by_ft"] = { - ["c"] = { "clang-tidy" }, + ["c"] = { "clangtidy" }, ["clojure"] = { "clj-kondo" }, - ["cpp"] = { "clang-tidy" }, - ["h"] = { "clang-tidy" }, - ["hpp"] = { "clang-tidy" }, + ["cpp"] = { "clangtidy" }, + ["h"] = { "clangtidy" }, + ["hpp"] = { "clangtidy" }, ["java"] = { "checkstyle" }, ["javascript"] = { "eslint_d" }, ["lua"] = { "luacheck" }, ["markdown"] = { "vale" }, ["nix"] = { "statix" }, ["python"] = { "flake8" }, - ["rust"] = { "clippy" }, ["text"] = { "vale" }, }, }, }, { "lspconfig", + ["cmd"] = { "LspInfo" }, ["config"] = function(_, opts) local __lspOnAttach = function(client, bufnr) end @@ -448,7 +483,38 @@ require("lazy").setup({ } for i, server in ipairs({ - { ["name"] = "clangd" }, + { + ["extraOptions"] = { + ["capabilities"] = { ["offsetEncoding"] = { "utf-16" } }, + ["cmd"] = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + ["init_options"] = { + ["clangdFileStatus"] = true, + ["completeUnimported"] = true, + ["usePlaceholders"] = true, + }, + ["root_dir"] = function(fname) + return require("lspconfig.util").root_pattern( + "Makefile", + "CMakeLists.txt", + ".clang-format", + ".clang-tidy" + )(fname) or require("lspconfig.util").root_pattern( + "compile_commands.json" + )(fname) or require("lspconfig.util").find_git_ancestor( + fname + ) + end, + }, + ["name"] = "clangd", + }, { ["name"] = "clojure_lsp" }, { ["name"] = "cmake" }, { ["name"] = "lua_ls" }, @@ -480,10 +546,17 @@ require("lazy").setup({ ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/neodev.nvim", ["lazy"] = false, ["name"] = "neodev", + ["opts"] = { + ["library"] = { ["enabled"] = true, ["plugins"] = true, ["runtime"] = true, ["types"] = true }, + ["lspconfig"] = true, + ["pathStrict"] = true, + ["setup_jsonls"] = false, + }, }, }, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-lspconfig", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "lspconfig", }, { @@ -532,12 +605,13 @@ require("lazy").setup({ }, { "navbuddy", + ["cmd"] = { "Navbuddy" }, ["config"] = function(_, opts) local actions = require("nvim-navbuddy.actions") -- ? require("nvim-navbuddy").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-navbuddy", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "navbuddy", ["opts"] = { ["lsp"] = { ["auto_attach"] = true }, ["window"] = { ["border"] = "rounded" } }, }, @@ -553,7 +627,7 @@ require("lazy").setup({ }, { "neo-tree", - ["cmd"] = "Neotree", + ["cmd"] = { "Neotree" }, ["config"] = function(_, opts) require("neo-tree").setup(opts) end, @@ -585,15 +659,28 @@ require("lazy").setup({ ["name"] = "neo-tree", ["opts"] = { ["buffers"] = { ["follow_current_file"] = { ["enabled"] = true, ["leave_dirs_open"] = false } }, + ["enable_diagnostics"] = false, + ["enable_git_status"] = true, ["filesystem"] = { ["follow_current_file"] = { ["enabled"] = true, ["leave_dirs_open"] = false } }, + ["open_files_do_not_replace_types"] = { "terminal", "trouble", "qf" }, + ["popup_border_style"] = "rounded", ["use_default_mappings"] = false, ["window"] = { ["mappings"] = { ["/"] = "fuzzy_finder", - [""] = "toggle_node", + [""] = "open", [""] = "cancel", - [""] = "open", ["?"] = "show_help", + ["R"] = "refresh", + ["a"] = "add", + ["c"] = "close_node", + ["d"] = "delete", + ["i"] = "show_file_details", + ["p"] = "paste_from_clipboard", + ["q"] = "close_window", + ["r"] = "rename", + ["x"] = "cut_to_clipboard", + ["y"] = "copy_to_clipboard", }, }, }, @@ -683,7 +770,7 @@ require("lazy").setup({ }, { "telescope", - ["cmd"] = "Telescope", + ["cmd"] = { "Telescope" }, ["config"] = function(_, opts) local telescope = require("telescope") telescope.setup(opts) @@ -747,16 +834,18 @@ require("lazy").setup({ }, }, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/todo-comments.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "todo-comments", }, { "toggleterm", + ["cmd"] = { "ToggleTerm" }, ["config"] = function(_, opts) require("toggleterm").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/toggleterm.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "toggleterm", ["opts"] = { ["auto_scroll"] = true, @@ -775,6 +864,7 @@ require("lazy").setup({ }, { "treesitter", + ["cmd"] = { "TSModuleInfo" }, ["config"] = function(_, opts) -- Fix treesitter grammars/parsers on nix vim.opt.runtimepath:append( @@ -785,7 +875,8 @@ require("lazy").setup({ require("nvim-treesitter.configs").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-treesitter", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "treesitter", ["opts"] = { ["auto_install"] = false, @@ -814,11 +905,12 @@ require("lazy").setup({ }, { "trouble", + ["cmd"] = { "Trouble", "TroubleToggle" }, ["config"] = function(_, opts) require("trouble").setup(opts) end, ["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/trouble.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "trouble", }, { @@ -864,26 +956,99 @@ require("lazy").setup({ -- Set up keybinds {{{ do local __nixvim_binds = { - { ["action"] = "w", ["key"] = "", ["mode"] = "n", ["options"] = { + { + ["action"] = "v:count == 0 ? 'gj' : 'j'", + ["key"] = "j", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor down", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gj' : 'j'", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor down", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gk' : 'k'", + ["key"] = "k", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor up", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gk' : 'k'", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor up", ["expr"] = true }, + }, + { + ["action"] = "vertical resize -2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Decrease window width" }, + }, + { + ["action"] = "vertical resize +2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Increase window width" }, + }, + { + ["action"] = "resize -2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Decrease window height" }, + }, + { + ["action"] = "resize +2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Increase window height" }, + }, + { ["action"] = "m .+1==", ["key"] = "", ["mode"] = "n", ["options"] = { + ["desc"] = "Move line down", + } }, + { + ["action"] = "m .+1==gi", + ["key"] = "", + ["mode"] = "i", + ["options"] = { ["desc"] = "Move line down" }, + }, + { ["action"] = ":m '>+1gv=gv", ["key"] = "", ["mode"] = "v", ["options"] = { + ["desc"] = "Move line down", + } }, + { ["action"] = "m .-2==", ["key"] = "", ["mode"] = "n", ["options"] = { + ["desc"] = "Move line up", + } }, + { + ["action"] = "m .-2==gi", + ["key"] = "", + ["mode"] = "i", + ["options"] = { ["desc"] = "Move line up" }, + }, + { ["action"] = ":m '<-2gv=gv", ["key"] = "", ["mode"] = "v", ["options"] = { + ["desc"] = "Move line up", + } }, + { ["action"] = "w", ["key"] = "", ["mode"] = "n", ["options"] = { ["desc"] = "Save current buffer", } }, - { ["action"] = "wa", ["key"] = "", ["mode"] = "n", ["options"] = { + { ["action"] = "wa", ["key"] = "", ["mode"] = "n", ["options"] = { ["desc"] = "Save all buffers", } }, + { ["action"] = "", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } }, { ["action"] = "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) vim.api.nvim_set_keymap("c", "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) - function _G.get_wildmenu_key(key_wildmenu, key_regular) return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular end +-- Check LSP server config +vim.api.nvim_create_user_command("LspInspect", function() + require("notify")(vim.inspect(vim.lsp.get_active_clients())) +end, { + desc = "Print LSP server configuration", +}) + -- Set up autocommands {{ do local __nixvim_autocommands = { @@ -1227,9 +1445,24 @@ do }, { ["callback"] = function() - require("conform").format() + vim.highlight.on_yank() end, - ["event"] = { "BufWritePre" }, + ["event"] = { "TextYankPost" }, + }, + { + ["callback"] = function() + local current_tab = vim.fn.tabpagenr() + vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) + end, + ["event"] = { "VimResized" }, + }, + { + ["callback"] = function() + vim.opt_local.conceallevel = 0 + end, + ["event"] = "FileType", + ["pattern"] = { "json", "jsonc", "json5" }, }, } diff --git a/config/neovim/config_nix.lua b/config/neovim/config_nix.lua index 5b0f96e4..8c23c7e7 100644 --- a/config/neovim/config_nix.lua +++ b/config/neovim/config_nix.lua @@ -16,6 +16,7 @@ do ["cindent"] = true, ["cinkeys"] = "0{,0},0),0],:,!^F,o,O,e", ["completeopt"] = { "menuone", "noselect", "noinsert" }, + ["confirm"] = true, ["cursorline"] = true, ["encoding"] = "utf-8", ["expandtab"] = true, @@ -38,8 +39,10 @@ do ["relativenumber"] = true, ["ruler"] = true, ["scrolloff"] = 10, + ["sessionoptions"] = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" }, ["shiftwidth"] = 4, ["showmode"] = false, + ["showtabline"] = 0, ["signcolumn"] = "yes", ["smartcase"] = true, ["smartindent"] = false, @@ -52,6 +55,8 @@ do ["timeoutlen"] = 50, ["undodir"] = "/home/christoph/.vim/undo", ["undofile"] = true, + ["undolevels"] = 10000, + ["winblend"] = 30, } for k, v in pairs(nixvim_options) do @@ -103,13 +108,16 @@ require("lazy").setup({ require("nvim-autopairs").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-autopairs", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "autopairs", + ["opts"] = { ["check_ts"] = true }, }, { "bbye", + ["cmd"] = { "Bdelete", "Bwipeout" }, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-bbye", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "bbye", }, { @@ -118,7 +126,8 @@ require("lazy").setup({ require("better_escape").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/better-escape.nvim", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "better-escape", ["opts"] = { ["mapping"] = { "jk" }, ["timeout"] = 200 }, }, @@ -128,8 +137,9 @@ require("lazy").setup({ require("clangd_extensions").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/clangd_extensions.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "clangd-extensions", + ["opts"] = { ["inlay_hints"] = { ["inline"] = false } }, }, { "cmp", @@ -183,7 +193,8 @@ require("lazy").setup({ }, }, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-cmp", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "cmp", ["opts"] = function() local cmp = require("cmp") @@ -243,7 +254,7 @@ require("lazy").setup({ elseif has_words_before() then cmp.complete() else - fallback() + fallback() -- This will call the intellitab binding end end, { "i", "s" }), [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), @@ -257,7 +268,9 @@ require("lazy").setup({ require("colorizer").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-colorizer.lua", - ["lazy"] = false, + ["enabled"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "colorizer", }, { @@ -297,9 +310,17 @@ require("lazy").setup({ require("conform").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/conform.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "conform", ["opts"] = { + ["format_on_save"] = function(bufnr) + -- Disable with a global or buffer-local variable + if vim.g.disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, ["formatters_by_ft"] = { ["c"] = { "clang-format" }, ["cpp"] = { "clang-format" }, @@ -323,18 +344,19 @@ require("lazy").setup({ require("flash").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/flash.nvim", - ["lazy"] = true, + ["lazy"] = false, ["name"] = "flash", }, { "gitmessenger", + ["cmd"] = { "GitMessenger" }, ["config"] = function(_, opts) for k, v in pairs(opts) do vim.g[k] = v end end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/git-messenger.vim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "gitmessenger", ["opts"] = { ["git_messenger_floating_win_opts"] = { ["border"] = "rounded" }, @@ -347,7 +369,8 @@ require("lazy").setup({ require("gitsigns").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/gitsigns.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "gitsigns", ["opts"] = { ["current_line_blame"] = false }, }, @@ -363,7 +386,8 @@ require("lazy").setup({ require("illuminate").configure(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-illuminate", - ["lazy"] = false, + ["event"] = { "BufreadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "illuminate", ["opts"] = { ["filetypesDenylist"] = { @@ -382,7 +406,8 @@ require("lazy").setup({ { "intellitab", ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/intellitab.nvim", - ["lazy"] = false, + ["event"] = { "InsertEnter" }, + ["lazy"] = true, ["name"] = "intellitab", }, { @@ -396,8 +421,17 @@ require("lazy").setup({ }, { "lazygit", + ["cmd"] = { "LazyGit", "LazyGitConfig", "LazyGitCurrentFile", "LazyGitFilter", "LazyGitFilterCurrentFile" }, + ["dependencies"] = { + { + "plenary", + ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/plenary.nvim", + ["lazy"] = true, + ["name"] = "plenary", + }, + }, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/lazygit.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "lazygit", }, { @@ -410,28 +444,29 @@ require("lazy").setup({ end end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-lint", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "lint", ["opts"] = { ["linters_by_ft"] = { - ["c"] = { "clang-tidy" }, + ["c"] = { "clangtidy" }, ["clojure"] = { "clj-kondo" }, - ["cpp"] = { "clang-tidy" }, - ["h"] = { "clang-tidy" }, - ["hpp"] = { "clang-tidy" }, + ["cpp"] = { "clangtidy" }, + ["h"] = { "clangtidy" }, + ["hpp"] = { "clangtidy" }, ["java"] = { "checkstyle" }, ["javascript"] = { "eslint_d" }, ["lua"] = { "luacheck" }, ["markdown"] = { "vale" }, ["nix"] = { "statix" }, ["python"] = { "flake8" }, - ["rust"] = { "clippy" }, ["text"] = { "vale" }, }, }, }, { "lspconfig", + ["cmd"] = { "LspInfo" }, ["config"] = function(_, opts) local __lspOnAttach = function(client, bufnr) end @@ -448,7 +483,38 @@ require("lazy").setup({ } for i, server in ipairs({ - { ["name"] = "clangd" }, + { + ["extraOptions"] = { + ["capabilities"] = { ["offsetEncoding"] = { "utf-16" } }, + ["cmd"] = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + ["init_options"] = { + ["clangdFileStatus"] = true, + ["completeUnimported"] = true, + ["usePlaceholders"] = true, + }, + ["root_dir"] = function(fname) + return require("lspconfig.util").root_pattern( + "Makefile", + "CMakeLists.txt", + ".clang-format", + ".clang-tidy" + )(fname) or require("lspconfig.util").root_pattern( + "compile_commands.json" + )(fname) or require("lspconfig.util").find_git_ancestor( + fname + ) + end, + }, + ["name"] = "clangd", + }, { ["name"] = "clojure_lsp" }, { ["name"] = "cmake" }, { ["name"] = "lua_ls" }, @@ -480,10 +546,17 @@ require("lazy").setup({ ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/neodev.nvim", ["lazy"] = false, ["name"] = "neodev", + ["opts"] = { + ["library"] = { ["enabled"] = true, ["plugins"] = true, ["runtime"] = true, ["types"] = true }, + ["lspconfig"] = true, + ["pathStrict"] = true, + ["setup_jsonls"] = false, + }, }, }, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-lspconfig", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "lspconfig", }, { @@ -532,12 +605,13 @@ require("lazy").setup({ }, { "navbuddy", + ["cmd"] = { "Navbuddy" }, ["config"] = function(_, opts) local actions = require("nvim-navbuddy.actions") -- ? require("nvim-navbuddy").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-navbuddy", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "navbuddy", ["opts"] = { ["lsp"] = { ["auto_attach"] = true }, ["window"] = { ["border"] = "rounded" } }, }, @@ -553,7 +627,7 @@ require("lazy").setup({ }, { "neo-tree", - ["cmd"] = "Neotree", + ["cmd"] = { "Neotree" }, ["config"] = function(_, opts) require("neo-tree").setup(opts) end, @@ -585,15 +659,28 @@ require("lazy").setup({ ["name"] = "neo-tree", ["opts"] = { ["buffers"] = { ["follow_current_file"] = { ["enabled"] = true, ["leave_dirs_open"] = false } }, + ["enable_diagnostics"] = false, + ["enable_git_status"] = true, ["filesystem"] = { ["follow_current_file"] = { ["enabled"] = true, ["leave_dirs_open"] = false } }, + ["open_files_do_not_replace_types"] = { "terminal", "trouble", "qf" }, + ["popup_border_style"] = "rounded", ["use_default_mappings"] = false, ["window"] = { ["mappings"] = { ["/"] = "fuzzy_finder", - [""] = "toggle_node", + [""] = "open", [""] = "cancel", - [""] = "open", ["?"] = "show_help", + ["R"] = "refresh", + ["a"] = "add", + ["c"] = "close_node", + ["d"] = "delete", + ["i"] = "show_file_details", + ["p"] = "paste_from_clipboard", + ["q"] = "close_window", + ["r"] = "rename", + ["x"] = "cut_to_clipboard", + ["y"] = "copy_to_clipboard", }, }, }, @@ -683,7 +770,7 @@ require("lazy").setup({ }, { "telescope", - ["cmd"] = "Telescope", + ["cmd"] = { "Telescope" }, ["config"] = function(_, opts) local telescope = require("telescope") telescope.setup(opts) @@ -747,16 +834,18 @@ require("lazy").setup({ }, }, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/todo-comments.nvim", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "todo-comments", }, { "toggleterm", + ["cmd"] = { "ToggleTerm" }, ["config"] = function(_, opts) require("toggleterm").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/toggleterm.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "toggleterm", ["opts"] = { ["auto_scroll"] = true, @@ -775,6 +864,7 @@ require("lazy").setup({ }, { "treesitter", + ["cmd"] = { "TSModuleInfo" }, ["config"] = function(_, opts) -- Fix treesitter grammars/parsers on nix vim.opt.runtimepath:append( @@ -785,7 +875,8 @@ require("lazy").setup({ require("nvim-treesitter.configs").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-treesitter", - ["lazy"] = false, + ["event"] = { "BufReadPost", "BufNewFile" }, + ["lazy"] = true, ["name"] = "treesitter", ["opts"] = { ["auto_install"] = false, @@ -814,11 +905,12 @@ require("lazy").setup({ }, { "trouble", + ["cmd"] = { "Trouble", "TroubleToggle" }, ["config"] = function(_, opts) require("trouble").setup(opts) end, ["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/trouble.nvim", - ["lazy"] = false, + ["lazy"] = true, ["name"] = "trouble", }, { @@ -864,26 +956,99 @@ require("lazy").setup({ -- Set up keybinds {{{ do local __nixvim_binds = { - { ["action"] = "w", ["key"] = "", ["mode"] = "n", ["options"] = { + { + ["action"] = "v:count == 0 ? 'gj' : 'j'", + ["key"] = "j", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor down", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gj' : 'j'", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor down", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gk' : 'k'", + ["key"] = "k", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor up", ["expr"] = true }, + }, + { + ["action"] = "v:count == 0 ? 'gk' : 'k'", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Move cursor up", ["expr"] = true }, + }, + { + ["action"] = "vertical resize -2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Decrease window width" }, + }, + { + ["action"] = "vertical resize +2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Increase window width" }, + }, + { + ["action"] = "resize -2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Decrease window height" }, + }, + { + ["action"] = "resize +2", + ["key"] = "", + ["mode"] = "n", + ["options"] = { ["desc"] = "Increase window height" }, + }, + { ["action"] = "m .+1==", ["key"] = "", ["mode"] = "n", ["options"] = { + ["desc"] = "Move line down", + } }, + { + ["action"] = "m .+1==gi", + ["key"] = "", + ["mode"] = "i", + ["options"] = { ["desc"] = "Move line down" }, + }, + { ["action"] = ":m '>+1gv=gv", ["key"] = "", ["mode"] = "v", ["options"] = { + ["desc"] = "Move line down", + } }, + { ["action"] = "m .-2==", ["key"] = "", ["mode"] = "n", ["options"] = { + ["desc"] = "Move line up", + } }, + { + ["action"] = "m .-2==gi", + ["key"] = "", + ["mode"] = "i", + ["options"] = { ["desc"] = "Move line up" }, + }, + { ["action"] = ":m '<-2gv=gv", ["key"] = "", ["mode"] = "v", ["options"] = { + ["desc"] = "Move line up", + } }, + { ["action"] = "w", ["key"] = "", ["mode"] = "n", ["options"] = { ["desc"] = "Save current buffer", } }, - { ["action"] = "wa", ["key"] = "", ["mode"] = "n", ["options"] = { + { ["action"] = "wa", ["key"] = "", ["mode"] = "n", ["options"] = { ["desc"] = "Save all buffers", } }, + { ["action"] = "", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } }, { ["action"] = "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) vim.api.nvim_set_keymap("c", "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) - function _G.get_wildmenu_key(key_wildmenu, key_regular) return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular end +-- Check LSP server config +vim.api.nvim_create_user_command("LspInspect", function() + require("notify")(vim.inspect(vim.lsp.get_active_clients())) +end, { + desc = "Print LSP server configuration", +}) + -- Set up autocommands {{ do local __nixvim_autocommands = { @@ -1227,9 +1445,24 @@ do }, { ["callback"] = function() - require("conform").format() + vim.highlight.on_yank() end, - ["event"] = { "BufWritePre" }, + ["event"] = { "TextYankPost" }, + }, + { + ["callback"] = function() + local current_tab = vim.fn.tabpagenr() + vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) + end, + ["event"] = { "VimResized" }, + }, + { + ["callback"] = function() + vim.opt_local.conceallevel = 0 + end, + ["event"] = "FileType", + ["pattern"] = { "json", "jsonc", "json5" }, }, }