diff options
| author | Matt Turner <mattst88@gmail.com> | 2025-08-10 15:12:07 -0400 |
|---|---|---|
| committer | Matt Turner <mattst88@gmail.com> | 2025-10-11 15:37:07 -0400 |
| commit | 2bbc63355df0f8b9fe6e95505f56ad42c172c776 (patch) | |
| tree | a85f8460995da3aa9d9f08fbb61187615bfc73ef | |
| parent | 97fba5998db163ec1efcd07671c3b98645e6dde9 (diff) | |
nvim: Redo
26 files changed, 684 insertions, 474 deletions
diff --git a/nvim/.config/nvim/after/ftplugin/lua.lua b/nvim/.config/nvim/after/ftplugin/lua.lua deleted file mode 100644 index cbbe688..0000000 --- a/nvim/.config/nvim/after/ftplugin/lua.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.expandtab = true -vim.opt_local.softtabstop = 2 -vim.opt_local.shiftwidth = 2 diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 8181403..1a6f8cf 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,42 +1,17 @@ -vim.g.loaded_ruby_provider = 0 -vim.g.loaded_node_provider = 0 -vim.g.loaded_perl_provider = 0 -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - -- bootstrap lazy.nvim - -- stylua: ignore - vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", - lazypath }) -end -vim.opt.rtp:prepend(vim.env.LAZY or lazypath) +vim.g.mapleader = "," +vim.g.maplocalleader = "\\" -require("lazy").setup({ - spec = { - { import = "plugins" }, - }, - defaults = { - -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. - -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. - lazy = false, - version = "*", -- try installing the latest stable version for plugins that support semver - }, - install = { colorscheme = { "tokyonight", "habamax" } }, - performance = { - rtp = { - -- disable some rtp plugins - disabled_plugins = { - "gzip", - -- "matchit", - -- "matchparen", - -- "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, -}) +-- Folke's Lazy plugin management +require("config.lazy") -require('options') +-- All LSP related configurations +require("config.lsp") + +-- Not currently using linting, just LSP +-- require("config.linter") + +-- Random +require("config.misc") + +vim.cmd[[colorscheme adwaita]] diff --git a/nvim/.config/nvim/lsp/README.md b/nvim/.config/nvim/lsp/README.md new file mode 100644 index 0000000..b0dc51b --- /dev/null +++ b/nvim/.config/nvim/lsp/README.md @@ -0,0 +1,12 @@ +All default language servers should be defined in this file. + +You can find the official description of these properties in the documentation, +in [vim.lsp.Config](https://neovim.io/doc/user/lsp.html#vim.lsp.Config). And +the full list of options is in +[vim.lsp.ClientConfig](https://neovim.io/doc/user/lsp.html#vim.lsp.ClientConfig). + +The LSPs are themselves managed by Mason +https://mason-registry.dev/registry/list + +Good reference can be found with nvim-lspconfig: +https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/configs diff --git a/nvim/.config/nvim/lsp/android_cpp.lua b/nvim/.config/nvim/lsp/android_cpp.lua new file mode 100644 index 0000000..12f9906 --- /dev/null +++ b/nvim/.config/nvim/lsp/android_cpp.lua @@ -0,0 +1,10 @@ +return { + cmd = {'android_clangd.sh', 'local' }, + filetypes = {'c', 'cpp'}, + root_dir = function(bufnr, cb) + -- Only return this if the files are there + if vim.fs.root(bufnr, {'Android.bp', 'compile_commands.json'}) then + cb(vim.fs.root(bufnr, {'compile_commands.json'})) + end + end, +} diff --git a/nvim/.config/nvim/lsp/bashls.lua b/nvim/.config/nvim/lsp/bashls.lua new file mode 100644 index 0000000..187e303 --- /dev/null +++ b/nvim/.config/nvim/lsp/bashls.lua @@ -0,0 +1,4 @@ +return { + cmd = {'bash-language-server', 'start'}, + filetypes = {'bash', 'sh'}, +} diff --git a/nvim/.config/nvim/lsp/clangd.lua b/nvim/.config/nvim/lsp/clangd.lua new file mode 100644 index 0000000..b315114 --- /dev/null +++ b/nvim/.config/nvim/lsp/clangd.lua @@ -0,0 +1,5 @@ +return { + cmd = { 'clangd' }, + filetypes = { 'c', 'cpp' }, + root_markers = {'.clangd', '.clang-tidy', '.clang-format', 'compile_commands.json', 'compile_flags.txt', 'configure.ac'}, +} diff --git a/nvim/.config/nvim/lsp/gopls.lua b/nvim/.config/nvim/lsp/gopls.lua new file mode 100644 index 0000000..b0db098 --- /dev/null +++ b/nvim/.config/nvim/lsp/gopls.lua @@ -0,0 +1,17 @@ +---@type vim.lsp.Config +return { + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_markers = { "go.mod", "go.sum", "go.work" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + undeclarednames = true, + }, + staticcheck = true, + usePlaceholders = true, + }, + }, +} diff --git a/nvim/.config/nvim/lsp/json.lua b/nvim/.config/nvim/lsp/json.lua new file mode 100644 index 0000000..5d4c8a7 --- /dev/null +++ b/nvim/.config/nvim/lsp/json.lua @@ -0,0 +1,4 @@ +return { + cmd = { 'vscode-json-language-server', '--stdio' }, + filetypes = { 'json', 'jsonc' }, +} diff --git a/nvim/.config/nvim/lsp/luals.lua b/nvim/.config/nvim/lsp/luals.lua new file mode 100644 index 0000000..745f38a --- /dev/null +++ b/nvim/.config/nvim/lsp/luals.lua @@ -0,0 +1,5 @@ +return { + cmd = {'lua-language-server'}, + filetypes = {'lua'}, + root_markers = {'.luarc.json', '.luarc.jsonc'}, +} diff --git a/nvim/.config/nvim/lsp/markdown.lua b/nvim/.config/nvim/lsp/markdown.lua new file mode 100644 index 0000000..4b9b6f1 --- /dev/null +++ b/nvim/.config/nvim/lsp/markdown.lua @@ -0,0 +1,4 @@ +return { + cmd = { 'marksman', 'server' }, + filetypes = { ' markdown' }, +} diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..3d5fe94 --- /dev/null +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,44 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "adwaita" } }, + -- automatically check for plugin updates + checker = { enabled = true, notify = false }, + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/nvim/.config/nvim/lua/config/linter.lua b/nvim/.config/nvim/lua/config/linter.lua new file mode 100644 index 0000000..4fc36c4 --- /dev/null +++ b/nvim/.config/nvim/lua/config/linter.lua @@ -0,0 +1,15 @@ +-- The file types are configered in the plugin setup (https://github.com/mfussenegger/nvim-lint) +-- Currently this is part of a Mason dependency but it doesn't have to be. + +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + + -- try_lint without arguments runs the linters defined in `linters_by_ft` + -- for the current filetype + require("lint").try_lint() + + -- You can call `try_lint` with a linter name or a list of names to always + -- run specific linters, independent of the `linters_by_ft` configuration + -- require("lint").try_lint("cspell") + end, +}) diff --git a/nvim/.config/nvim/lua/config/lsp.lua b/nvim/.config/nvim/lua/config/lsp.lua new file mode 100644 index 0000000..625f6f2 --- /dev/null +++ b/nvim/.config/nvim/lua/config/lsp.lua @@ -0,0 +1,120 @@ +vim.lsp.enable('clangd') +vim.lsp.enable('gopls') +vim.lsp.enable("markdown") +vim.lsp.enable("luals") + + +-- Copied from https://github.com/konradmalik/neovim-flake/blob/a63dd89c67bab313dc39046de582699a99385e8e/config/nvim/lua/pde/lsp/commands.lua#L10C1-L40C4 +-- This function allows specifying the server id, but I do not ever want that. +---@param filter vim.lsp.get_clients.Filter? +local function restart_servers(filter) + local clients = vim.lsp.get_clients(filter) + ---@type table<integer, {[1]: vim.lsp.Client, [2]: integer[]}> + local detach_clients = {} + for _, client in ipairs(clients) do + detach_clients[client.id] = { client, vim.lsp.get_buffers_by_client_id(client.id) } + client:stop() + end + + local timer = assert(vim.uv.new_timer(), "cannot create timer") + timer:start( + 500, + 100, + vim.schedule_wrap(function() + for old_client_id, tuple in pairs(detach_clients) do + local client = tuple[1] + local attached_buffers = tuple[2] + if client:is_stopped() then + for _, buf in ipairs(attached_buffers) do + vim.lsp.start(client.config, { bufnr = buf }) + end + detach_clients[old_client_id] = nil + end + end + + if next(detach_clients) == nil and not timer:is_closing() then timer:close() end + end) + ) +end + +-- Stop the language server. Issuing :e after this will restart it +vim.api.nvim_create_user_command('LspStop', function(args) + vim.lsp.stop_client(vim.lsp.get_clients()) +end, { + desc = "Stop the LSP server for all clients", + nargs = 0, +}) +-- +-- Stop the language server. Issuing :e after this will restart it +vim.api.nvim_create_user_command('LspRestart', function(args) + restart_servers() +end, { + desc = "Restart the LSP server for all clients", + nargs = 0, +}) +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +-- +-- This is mostly derived from nvim-lsp even though we're not using that plugin. +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(args) + -- Simple helper for mappings + local function lsp_map(mode, l, r, opts) + opts = opts or {} + opts.buffer = args.buf + vim.keymap.set(mode, l, r, opts) + end + + + -- Buffer local mappings. + -- These are an unpleasant mix of ctags/global + vscode + -- See `:help vim.lsp.*` for documentation on any of the below functions + lsp_map('n', 'gD', vim.lsp.buf.declaration) + lsp_map('n', 'gd', vim.lsp.buf.definition) + lsp_map('n', 'K', vim.lsp.buf.hover) + lsp_map('n', 'gi', vim.lsp.buf.implementation) + lsp_map('n', '<C-k>', vim.lsp.buf.signature_help) + lsp_map('n', '<c-\\>c', vim.lsp.buf.incoming_calls) + lsp_map({'n', 'v'}, '<Leader>ca', vim.lsp.buf.code_action) + lsp_map('n', '<Leader>rn', vim.lsp.buf.rename) + lsp_map('n', '<c-\\>g', vim.lsp.buf.references) + + -- Format the whole file using LSP + lsp_map("n", "<Leader>f", function() + vim.lsp.buf.format({ async = true }) + end) + + -- Format the visual selection + -- This doesn't seem to work for all servers + lsp_map("v", "<leader>vf", function() + vim.lsp.buf.format({ + async = true, + ["start"] = vim.api.nvim_buf_get_mark(0, "<"), + ["end"] = vim.api.nvim_buf_get_mark(0, ">"), + }) + end) + + local client = vim.lsp.get_client_by_id(args.data.client_id) + -- + -- Enable inlay hints by default + if client and client:supports_method("textDocument/inlayHint") then + vim.lsp.inlay_hint.enable(true, { bufnr = args.buf }) + end + + -- Toggle inlay hints + lsp_map("n", "<leader>it", function() + local inlay = not vim.lsp.inlay_hint.is_enabled() + vim.lsp.inlay_hint.enable(inlay, {}) + end) + + --[[ + -- Neovim as of .11 supports native completions. Blink.cmp still offers performance, and other advantages however, so don't use those. + -- Currently using blink.cmp for completions + if client:supports_method('textDocument/completion') then + vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true}) + end + --]] + + end, +}) diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/config/misc.lua index 681fa71..01bd519 100644 --- a/nvim/.config/nvim/lua/options.lua +++ b/nvim/.config/nvim/lua/config/misc.lua @@ -1,3 +1,11 @@ +-- Make the clipboard automatically copy bidirectional +vim.opt.clipboard:append({'unnamedplus'}) + +-- Disable providers I never use and cause warnings in checkhealth +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 +vim.g.loaded_ruby_provider = 0 + -- show line numbers vim.opt.number = true vim.opt.relativenumber = true @@ -30,30 +38,6 @@ vim.keymap.set('n', '<Leader>E', vim.diagnostic.setloclist) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) --- Use LspAttach autocommand to only map the following keys --- after the language server attaches to the current buffer -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - -- Enable completion triggered by <c-x><c-o> - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local options = { buffer = ev.buf } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, options) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, options) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, options) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, options) - vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, options) - vim.keymap.set('n', '<c-\\>c', vim.lsp.buf.incoming_calls, options) - vim.keymap.set({'n', 'v'}, '<Leader>ca', vim.lsp.buf.code_action, options) - vim.keymap.set('n', '<Leader>rn', vim.lsp.buf.rename, options) - vim.keymap.set('n', '<c-\\>g', vim.lsp.buf.references, options) - vim.keymap.set('n', '<space>f', function () - vim.lsp.buf.format{ async = true } - end, options) - end, -}) - vim.o.termguicolors = true + +vim.g.table_mode_corner = "|" diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 632b246..af89115 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,66 +1,71 @@ -vim.g.table_mode_corner = "|" - --- Put simply configured plugins here. return { - { "fladson/vim-kitty", ft = "kitty" }, - { "lukas-reineke/indent-blankline.nvim", version = "v3.6.3", main = "ibl", opts = {} }, - { - "Mofiqul/adwaita.nvim", - lazy = false, - priority = 1000, - config = function() - vim.g.adwaita_darker = true - vim.cmd("colorscheme adwaita") - end - }, - { "norcalli/nvim-terminal.lua", opts = {} }, - "dhruvasagar/vim-table-mode", - { - "ibhagwan/fzf-lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, - }, - { - "kylechui/nvim-surround", - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end - }, - "tpope/vim-eunuch", - "vim-scripts/git_patch_tags.vim", - { - "nvim-lualine/lualine.nvim", - dependencies = { - "nvim-tree/nvim-web-devicons" - }, - }, - { - 'numToStr/Comment.nvim', - opts = { - -- add any options here - }, - lazy = false, - }, - { - "windwp/nvim-autopairs", - event = "InsertEnter", - config = true - }, - { - "rktjmp/paperplanes.nvim", - opts = { - register = "+", - provider = "sprunge.us", - provider_options = { insecure = true, }, - notifier = vim.notify or print, - }, - }, - { - "j-hui/fidget.nvim", - tag = "legacy", - event = "LspAttach", - opts = {}, - }, + { "fladson/vim-kitty", ft = "kitty" }, + { "lukas-reineke/indent-blankline.nvim", version = "v3.9.0", main = "ibl", opts = {} }, + + -- Justification: Adwaita is my system theme + { + "Mofiqul/adwaita.nvim", + lazy = false, + priority = 1000, + config = function() + vim.g.adwaita_darker = true + vim.cmd("colorscheme adwaita") + end + }, + { "norcalli/nvim-terminal.lua", opts = {} }, + { + "kylechui/nvim-surround", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end + }, + "tpope/vim-eunuch", + "vim-scripts/git_patch_tags.vim", + 'numToStr/Comment.nvim', + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true + }, + { + "rktjmp/paperplanes.nvim", + opts = { + register = "+", + provider = "0x0.st", + provider_options = {}, + notifier = vim.notify or print, + }, + }, + + -- Justification: I like being able to `:e foobar.c:854` + { "lewis6991/fileline.nvim" }, + + -- Justification: clangd extensions are fun + { "p00f/clangd_extensions.nvim" }, + + -- Justification: Markdown previewing + { + "euclio/vim-markdown-composer", + build = "cargo build --release", + }, + + -- Justification: Nice to have + { + "ibhagwan/fzf-lua", + dependencies = { "echasnovski/mini.icons" }, + opts = { + fzf_bin = 'sk', + file_icon_padding = '', + } + + }, + -- Justification: Better Rust LSP experience + { + 'mrcjkb/rustaceanvim', + version = '^6', -- Recommended + lazy = false, -- This plugin is already lazy + } } diff --git a/nvim/.config/nvim/lua/plugins/bigfile.lua b/nvim/.config/nvim/lua/plugins/bigfile.lua new file mode 100644 index 0000000..bb2e965 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/bigfile.lua @@ -0,0 +1,20 @@ +-- Motivation: Make nvim faster when working on large files +return { + "LunarVim/bigfile.nvim", + config = function() + require("bigfile").setup({ + filesize = 10, -- Size in MiB + pattern = { "*" }, + features = { -- features to disable for big files + "indent_blankline", + "illuminate", + "lsp", + "treesitter", + "syntax", + "matchparen", + "vimopts", + "filetype", + } + }) + end +} diff --git a/nvim/.config/nvim/lua/plugins/ccls.lua b/nvim/.config/nvim/lua/plugins/ccls.lua deleted file mode 100644 index 1ae961c..0000000 --- a/nvim/.config/nvim/lua/plugins/ccls.lua +++ /dev/null @@ -1,24 +0,0 @@ -local M = { - "ranjithshegde/ccls.nvim", - dependencies = { "neovim/nvim-lspconfig" }, -} - -M.config = function() - local ccls = require("ccls") - ccls.setup({ - lsp = { - -- check :help vim.lsp.start for config options - server = { - name = "ccls", --String name - cmd = {"/usr/bin/ccls"}, -- point to your binary, has to be a table - args = {--[[Any args table]] }, - offset_encoding = "utf-32", -- default value set by plugin - root_dir = vim.fs.dirname(vim.fs.find({ "compile_commands.json", ".git" }, { upward = true })[1]), -- or some other function that returns a string - --on_attach = your_func, - --capabilites = your_table/func - }, - }, - }) -end - -return M diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua deleted file mode 100644 index 01fc0d8..0000000 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ /dev/null @@ -1,65 +0,0 @@ -local M = { - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "saadparwaiz1/cmp_luasnip", - { - "L3MON4D3/LuaSnip", - tag = "v2.1.1", - }, - }, -} - -M.config = function() - local cmp = require("cmp") - vim.opt.completeopt = { "menu", "menuone", "noselect" } - - cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) -- For `luasnip` users. - end, - }, - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - ["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - ["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - ["<C-d>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-e>"] = cmp.mapping.abort(), - ["<CR>"] = cmp.mapping.confirm({}), - ["<S-CR>"] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "luasnip" }, -- For luasnip users. - -- { name = "orgmode" }, - }, { - { name = "buffer" }, - { name = "path" }, - }), - }) - - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), - }) -end - -return M diff --git a/nvim/.config/nvim/lua/plugins/completions.lua b/nvim/.config/nvim/lua/plugins/completions.lua new file mode 100644 index 0000000..344e5f5 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/completions.lua @@ -0,0 +1,87 @@ +-- Justification: I want code completion +--local M = { +return { + "saghen/blink.cmp", + event = { "InsertEnter" }, + -- Completions can be nice even when not attached to an LSP. If LSP only completions are wanted though + --event = { "LspAttach" }, + version = "v1.*", + dependencies = { + { + "echasnovski/mini.snippets", + version = false, + + config = function() + local gen_loader = require("mini.snippets").gen_loader + require("mini.snippets").setup({ + snippets = { + -- Load custom file with global snippets first (adjust for Windows) + gen_loader.from_file("~/.config/nvim/snippets/global.json"), + + -- Load snippets based on current language by reading files from + -- "snippets/" subdirectories from 'runtimepath' directories. + gen_loader.from_lang(), + }, + }) + end, + }, + "rafamadriz/friendly-snippets", + }, + opts = { + keymap = { preset = "enter" }, + snippets = { preset = "mini_snippets" }, + fuzzy = { + implementation = "prefer_rust_with_warning" + }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + completion = { + -- Some LSPs do brackets themsevles + accept = { auto_brackets = { enabled = false } }, + documentation = { auto_show = false, }, + ghost_text = { enabled = true }, + menu = { + -- Use mini.icons https://github.com/Saghen/blink.cmp/discussions/458 + draw = { + components = { + kind_icon = { + text = function(ctx) + local kind_icon, _, _ = require('mini.icons').get('lsp', + ctx.kind) + return kind_icon + end, + -- (optional) use highlights from mini.icons + highlight = function(ctx) + local _, hl, _ = require('mini.icons').get('lsp', + ctx.kind) + return hl + end, + }, + kind = { + -- (optional) use highlights from mini.icons + highlight = function(ctx) + local _, hl, _ = require('mini.icons').get('lsp', + ctx.kind) + return hl + end, + } + } + }, + }, + + }, + }, + opts_extend = { "sources.default" }, + +} + +--[[ +return { + 'echasnovski/mini.completion', + version = false, + event = { "InsertEnter" }, + config = function() + require("mini.completion").setup() + end, +--]] diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua deleted file mode 100644 index dfd6e63..0000000 --- a/nvim/.config/nvim/lua/plugins/git.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - { - "tpope/vim-fugitive", - cmd = "Git", - } -} diff --git a/nvim/.config/nvim/lua/plugins/mason-lsp.lua b/nvim/.config/nvim/lua/plugins/mason-lsp.lua deleted file mode 100644 index 75537c0..0000000 --- a/nvim/.config/nvim/lua/plugins/mason-lsp.lua +++ /dev/null @@ -1,65 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - name = "lspconfig", - lazy = false, - dependencies = { - { "williamboman/mason-lspconfig.nvim", name = "mason-lspconfig" }, - { "williamboman/mason.nvim", name = "mason" }, - }, - config = function() - local lspconfig = require("lspconfig") - local mason = require("mason") - local mason_lspconfig = require("mason-lspconfig") - local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) - local servers = { "lua_ls", "marksman", "pylsp" } --- local options = { noremap = true, silent = true } - - mason.setup({}) - - mason_lspconfig.setup({ ensure_installed = servers }) - - mason_lspconfig.setup_handlers({ - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ["lua_ls"] = function() - lspconfig.lua_ls.setup { - settings = { - Lua = { - runtime = { version = 'LuaJIT', }, - diagnostics = { - globals = { - 'vim', - 'require', - }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { enable = false }, - }, - }, - } - end, - ["pylsp"] = function() - lspconfig.pylsp.setup { - settings = { - pylsp = { - plugins = { - pycodestyle = { - ignore = {'W391'}, - maxLineLength = 100, - } - }, - }, - }, - } - end - }) - end - }, -} diff --git a/nvim/.config/nvim/lua/plugins/mason.lua b/nvim/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..221114f --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/mason.lua @@ -0,0 +1,70 @@ +-- Justification: Mason makes it easy to manage language servers, formatters +-- and linters. This helps keep consistent configuration accross deployments. +-- +-- Language server implementation is handle in lsp/ - formatters and linters +-- are done here. + +local M = { + "williamboman/mason.nvim", + dependencies = { + { "mfussenegger/nvim-lint", lazy = true }, + { "mhartington/formatter.nvim", lazy = true }, + }, + + opts = { + ensure_installed = { + "bash-language-server", + "clang-format", + "clangd", + "json-lsp", + "lua-language-server", + "marksman", + "selene", + "shellcheck", + "shfmt", + "stylua", + }, + }, +} + +M.config = function() + require("formatter").setup({ + -- Helpers for opt in formatters + -- local util = require "formatter.util" + + filetype = { + json = { + require("formatter.filetypes.json").jq, + }, + bp = { + function() + return { + exe = "bpfmt", + args = { + "-o", + }, + stdin = true, + } + end + }, + }, + + -- No matter the formatter, get rid of trailing whitespace + ["*"] = { + require("formatter.filetypes.any").remove_trailing_whitespace, + } + }) + + --[[ + We rely on Language servers for formatting and linting when possible. + require("lint").linters_by_ft = { + bash = { "bash" }, + cpp = { "clang-tidy" }, + markdown = { "vale" }, + lua = { "selene" }, + } + --]] + require("mason").setup() +end + +return { M } diff --git a/nvim/.config/nvim/lua/plugins/mini.lua b/nvim/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..345c854 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,93 @@ +-- Justification: Statusline which needs icons +-- indentscope: Visualize the code block +-- trailspace: Highlight trailing whitespace +return { + { + { + "echasnovski/mini.icons", + version = false, + config = function() + require("mini.icons").setup() + end, + }, + { + "echasnovski/mini-git", + version = false, + main = 'mini.git', + config = function(_, opts) + -- Less nice version of integrated blame + local align_blame = function(au_data) + if au_data.data.git_subcommand ~= 'blame' then return end + + local win_src = au_data.data.win_source + + vim.wo.wrap = false + vim.fn.winrestview({ topline = vim.fn.line('w0', win_src) }) + vim.api.nvim_win_set_cursor(0, { vim.fn.line('.', win_src), 0 }) + + vim.wo[win_src].scrollbind, vim.wo.scrollbind = true, true + end + + local au_opts = { pattern = 'MiniGitCommandSplit', callback = align_blame } + + vim.api.nvim_create_autocmd('User', au_opts) + + require('mini.git').setup(opts) + end, + keys = { + { '<leader>gb', '<cmd>vert Git blame -- %<cr>', desc = '[G]it [B]lame in a split' }, + { '<leader>gc', '<cmd>Git commit<cr>', desc = '[G]it [C]ommit' }, + { '<leader>gC', '<cmd>Git commit --amend<cr>', desc = '[G]it [C]ommit (Amend)' }, + { '<leader>gl', '<cmd>Git log --oneline<cr>', desc = '[G]it [L]og' }, + { '<leader>gl', '<cmd>Git log --oneline --follow -- %<cr>', desc = '[G]it [L]og Buffer' }, + { '<leader>gs', '<cmd>lua MiniGit.show_at_cursor()<cr>', mode = 'n', desc = '[G]it [S]how' }, + { '<leader>gs', '<cmd>lua MiniGit.show_at_cursor()<cr>', mode = 'x', desc = '[G]it [S]how' }, + { '<leader>gr', '<cmd>lua MiniGit.show_range_history()<cr>', mode = 'n', desc = '[G]it [R]ange history' }, + { '<leader>gr', '<cmd>lua MiniGit.show_rangehistory()<cr>', mode = 'x', desc = '[G]it [R]ange history' }, + { '<leader>ga', '<cmd>Git add -- %<cr>', desc = '[G]it [A]dd' }, + }, + }, + { + 'echasnovski/mini.diff', + version = false, + config = true, + keys = { + { '<leader>go', '<cmd>lua MiniDiff.toggle_overlay()<cr>' }, + }, + }, + { + "echasnovski/mini.statusline", + version = false, + config = function() + require("mini.git").setup() + local statusline = require("mini.statusline") + statusline.setup { + use_icons = vim.g.have_nerd_font + } + end, + }, + { + "echasnovski/mini.trailspace", + version = false, + config = function() + require("mini.trailspace").setup() + end, + }, + { + "echasnovski/mini.indentscope", + version = false, + config = function() + require("mini.indentscope").setup({ + delay = 0, + }) + end, + }, + { + "echasnovski/mini.notify", + version = false, + config = function() + require("mini.notify").setup() + end, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua deleted file mode 100644 index cf3f151..0000000 --- a/nvim/.config/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,137 +0,0 @@ -return { - { - "nvim-telescope/telescope.nvim", - lazy = true, - dependencies = { - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }, - "nvim-tree/nvim-web-devicons", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-symbols.nvim", - }, - cmd = "Telescope", - keys = { - { "gr", function() require('telescope.builtin').lsp_references() end }, - { "<leader>fr", function() require('telescope.builtin').lsp_references() end }, - { "<leader>ff", "<cmd>Telescope find_files<cr>" }, - { "<leader>fo", "<cmd>Telescope oldfiles<cr>" }, - { "<leader>fg", "<cmd>Telescope live_grep<cr>" }, - { "<leader>fb", "<cmd>Telescope buffers<cr>" }, - { "<leader>fh", "<cmd>Telescope help_tags<cr>" }, - { "<leader>fs", "<cmd>Telescope grep_string<cr>" }, - }, - config = function() - local always_ignore_these = { - "yarn.lock", -- nodejs - "package%-lock.json", -- nodejs - "node_modules/.*", -- nodejs - "vendor/*", -- golang - "%.git/.*", - "%.png", - "%.jpeg", - "%.jpg", - "%.ico", - "%.webp", - "%.avif", - "%.heic", - "%.mp3", - "%.mp4", - "%.mkv", - "%.mov", - "%.wav", - "%.flv", - "%.avi", - "%.webm", - "%.db", - } - - require("telescope").setup({ - defaults = { - mappings = { - i = { - -- don't go into normal mode, just close - ["<Esc>"] = require("telescope.actions").close, - -- scroll the list with <c-j> and <c-k> - ["<C-j>"] = require("telescope.actions").move_selection_next, - ["<C-k>"] = require("telescope.actions").move_selection_previous, - -- move the preview window up and down - ["<C-u>"] = require("telescope.actions").preview_scrolling_up, - ["<C-d>"] = require("telescope.actions").preview_scrolling_down, - }, - }, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--trim", - }, - layout_strategy = "flex", - layout_config = { - prompt_position = "top", - horizontal = { - mirror = true, - preview_cutoff = 100, - preview_width = 0.5, - }, - vertical = { - mirror = true, - preview_cutoff = 0.4, - }, - flex = { - flip_columns = 110, - }, - height = 0.94, - width = 0.86, - }, - prompt_prefix = " ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = always_ignore_these, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - winblend = 0, - border = {}, - borderchars = { - "─", - "│", - "─", - "│", - "╭", - "╮", - "╯", - "╰", - }, - color_devicons = true, - use_less = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - }, - pickers = { - find_files = { - find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }, - hidden = true, - }, - }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - }, - }) - end - }, -} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua index c1b9cf2..1fbb3e7 100644 --- a/nvim/.config/nvim/lua/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -1,47 +1,46 @@ +-- Justification: Neovim automatically integrates treesitter. To avoid errors +-- and manual language installations, this plugin. + +-- Without this, treesitter file types need to manually installed and updated. return { - { - "nvim-treesitter/nvim-treesitter", - build = function() - pcall(require("nvim-treesitter.install").update({ with_sync = true })) - end, - event = "BufReadPost", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - opts = { - highlight = { enable = true }, - indent = { enable = true }, - context_commentstring = { enable = true, enable_autocmd = false }, - ensure_installed = { - "bash", - "c", - "cmake", - "cpp", - "dockerfile", - "git_config", - "gitattributes", - "gitcommit", - "gitignore", - "go", - "ini", - "javascript", - "jsdoc", - "json", - "json5", - "lua", - "make", - "markdown", - "meson", - "ninja", - "python", - "rust", - "toml", - "vim", - "yaml", - }, - }, - config = function(plugin, opts) - require("nvim-treesitter.configs").setup(opts) - end, - }, + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + + build = function() + require("nvim-treesitter.install").update({ with_sync = true })() + end, + run = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + event = "BufReadPost", + opts = { + highlight = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + ensure_installed = { + "bash", + "c", + "cmake", + "cpp", + "git_config", + "gitattributes", + "gitcommit", + "gitignore", + "ini", + "json5", + "lua", + "make", + "markdown", + "meson", + "ninja", + "python", + "rust", + "toml", + "vim", + "yaml", + }, + }, } diff --git a/nvim/.config/nvim/lua/plugins/trouble.lua b/nvim/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..fc29597 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,37 @@ +return { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "<leader>xx", + "<cmd>Trouble diagnostics toggle<cr>", + desc = "Diagnostics (Trouble)", + }, + { + "<leader>xX", + "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "<leader>cs", + "<cmd>Trouble symbols toggle focus=false<cr>", + desc = "Symbols (Trouble)", + }, + { + "<leader>cl", + "<cmd>Trouble lsp toggle focus=false win.position=right<cr>", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "<leader>xL", + "<cmd>Trouble loclist toggle<cr>", + desc = "Location List (Trouble)", + }, + { + "<leader>xQ", + "<cmd>Trouble qflist toggle<cr>", + desc = "Quickfix List (Trouble)", + }, + }, +} |
