From 30e94f86f094c267e1fb516f9a8a9dcfc4d512d2 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sun, 27 Apr 2025 20:57:49 -0700 Subject: [PATCH] Many improvements. --- init.lua | 2 +- lazy-lock.json | 16 +++++++-- lua/config/keys.lua | 57 ++++++++++++++++++++++++++++++++ lua/config/lazy.lua | 5 ++- lua/config/lsp.lua | 75 ++++++++++++++++++++++++++++++++++++++++-- lua/config/opts.lua | 13 ++++++++ lua/plugins/editor.lua | 8 +++++ lua/plugins/git.lua | 22 +++++++++++++ lua/plugins/lsp.lua | 18 ++++++++++ lua/plugins/ui.lua | 38 +++++++++++++++++++++ 10 files changed, 247 insertions(+), 7 deletions(-) create mode 100644 lua/plugins/editor.lua create mode 100644 lua/plugins/git.lua diff --git a/init.lua b/init.lua index 8be279a..31c38f9 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ require("config.lazy") -require("config.opts") require("config.lsp") require("config.keys") +require("config.opts") diff --git a/lazy-lock.json b/lazy-lock.json index 270e70d..dc17480 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,11 +1,21 @@ { + "blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "gitsigns.nvim": { "branch": "main", "commit": "9cd665f46ab7af2e49d140d328b8e72ea1cf511b" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "material.nvim": { "branch": "main", "commit": "96285a62923ea8e38aea7b603099752da2a97e97" }, + "mini.cursorword": { "branch": "main", "commit": "7d1b38a17834acbbc4feff8e42aedc4ed0c6ff06" }, "mini.icons": { "branch": "main", "commit": "910db5df9724d65371182948f921fce23c2c881e" }, - "nord.nvim": { "branch": "main", "commit": "b4863217a6272ecd41862e09fdea0ba7b7e5f8f5" }, - "nvim-lspconfig": { "branch": "master", "commit": "cb33dea610b7eff240985be9f6fe219920e630ef" }, - "nvim-treesitter": { "branch": "master", "commit": "523a9e148919f58eb5a013f76787e57696e00c93" }, + "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, + "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, + "nord.nvim": { "branch": "main", "commit": "1ee184dfd06ffadc19b7afc0ba4c5eca92dd836e" }, + "nui.nvim": { "branch": "main", "commit": "8d5b0b568517935d3c84f257f272ef004d9f5a59" }, + "nvim-lspconfig": { "branch": "master", "commit": "88d0824d85c0f74a012521d25678a5b01c76feb1" }, + "nvim-treesitter": { "branch": "master", "commit": "3b308861a8d7d7bfbe9be51d52e54dcfd9fe3d38" }, + "nvim-web-devicons": { "branch": "master", "commit": "50b5b06bff13a9b4eab946de7c7033649a6618a1" }, + "rustaceanvim": { "branch": "master", "commit": "3a6af933d5870a419ee2be6e1bd397dfe46c96d2" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/config/keys.lua b/lua/config/keys.lua index 79cfea9..bbd9ee8 100644 --- a/lua/config/keys.lua +++ b/lua/config/keys.lua @@ -1,18 +1,75 @@ require("which-key").add({ + { "b", group = "buffer" }, + { "bd", ":bd", name = "delete current" }, + { "c", group = "code" }, + { "ca", vim.lsp.buf.code_action, name = "code action" }, { "cd", vim.diagnostic.open_float, name = "diagnostic" }, { "e", Snacks.explorer.open, name = "explorer" }, { "f", group = "find" }, + { "fb", Snacks.picker.buffers, name = "buffers" }, { "ff", Snacks.picker.files, name = "files" }, + { "fg", Snacks.picker.grep, name = "grep" }, + + { "g", group = "git" }, + { "gb", group = "blame" }, + { "gbf", ":Gitsigns blame", name = "file" }, + { "gbh", ":Gitsigns blame_line", name = "hover" }, + { "gbl", ":Gitsigns toggle_current_line_blame", name = "virtual text" }, + { "gh", group = "hunk" }, + { "ghr", ":Gitsigns reset_hunk", name = "reset hunk" }, + { "ghp", ":Gitsigns preview_hunk", name = "reset hunk" }, + + { "s", group = "search" }, + { "ss", Snacks.picker.lsp_workspace_symbols, name = "symbols" }, + { "sg", Snacks.picker.grep, name = "grep" }, { "u", group = "ui" }, { "ut", Snacks.picker.colorschemes, name = "colorschemes" }, + { + "ul", + function() + local ll = vim.diagnostic.config().virtual_lines + if ll == false then + ll = { current_line = true } + else + ll = false + end + vim.diagnostic.config({ virtual_lines = ll }) + end, + name = "toggle lsp lines", + }, + + { "w", group = "window" }, + { "wh", "h", name = "left" }, + { "wj", "j", name = "down" }, + { "wk", "k", name = "right" }, + { "wl", "l", name = "up" }, + { "wq", ":q", name = "quit" }, { "g", group = "goto" }, { "gd", vim.lsp.buf.definition, name = "definition" }, { "gr", Snacks.picker.lsp_references, nowait = true, name = "references" }, + + { "H", ":bprev", name = "previous buffer" }, + { "L", ":bnext", name = "next buffer" }, + + { + "[h", + function() + require("gitsigns").nav_hunk("prev") + end, + name = "Next Hunk", + }, + { + "]h", + function() + require("gitsigns").nav_hunk("next") + end, + name = "Next Hunk", + }, }) Snacks.toggle.diagnostics():map("ud") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index e2cb418..0f45208 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -31,5 +31,8 @@ require("lazy").setup({ -- colorscheme that will be used when installing plugins. install = {}, -- automatically check for plugin updates - checker = { enabled = true }, + checker = { + enabled = true, + notify = false, + }, }) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index a366fe1..8998092 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -1,5 +1,7 @@ -require("lspconfig").basedpyright.setup({}) -require("lspconfig").ruff.setup({}) +local capabilities = require("blink.cmp").get_lsp_capabilities() + +require("lspconfig").basedpyright.setup({ capabilities = capabilities }) +require("lspconfig").ruff.setup({ capabilities = capabilities }) require("lspconfig").lua_ls.setup({ on_init = function(client) @@ -31,4 +33,73 @@ require("lspconfig").lua_ls.setup({ settings = { Lua = {}, }, + capabilities = capabilities, +}) + +vim.g.rustaceanvim = { + -- Plugin configuration + -- tools = { + -- }, + -- LSP configuration + server = { + -- on_attach = function(client, bufnr) + -- -- you can also put keymaps in here + --end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargoWatch = true, + cargo = { + allFeatures = true, + allTargets = false, + loadOutDirsFromCheck = true, + buildScripts = { + enable = true, + }, + }, + checkOnSave = { + allFeatures = true, + allTargets = false, + }, + diagnostics = { + enable = true, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + files = { + excludeDirs = { + ".direnv", + ".git", + ".github", + ".gitlab", + "bin", + "node_modules", + "target", + "venv", + ".venv", + }, + }, + }, + }, + }, + -- DAP configuration + dap = {}, +} + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("lsp", { clear = true }), + callback = function(args) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({ async = false, id = args.data.client_id }) + end, + }) + end, }) diff --git a/lua/config/opts.lua b/lua/config/opts.lua index 089980e..c5910f8 100644 --- a/lua/config/opts.lua +++ b/lua/config/opts.lua @@ -1,9 +1,22 @@ vim.opt.termguicolors = true vim.cmd("colorscheme tokyonight") +vim.wo.number = true +vim.wo.relativenumber = true + vim.diagnostic.config({ virtual_text = true, virtual_lines = { current_line = true, }, + update_in_insert = true, + signs = true, +}) + +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, }) diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua new file mode 100644 index 0000000..40c34a9 --- /dev/null +++ b/lua/plugins/editor.lua @@ -0,0 +1,8 @@ +return { + { "echasnovski/mini.pairs", event = "BufEnter", version = "*", opts = {} }, + { "echasnovski/mini.cursorword", event = "BufEnter", version = "*", opts = {} }, + { + "folke/trouble.nvim", + opts = {}, + }, +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..ff56f10 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,22 @@ +return { + { + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + signs_staged = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + }, + }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index afd7d48..f012464 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -4,4 +4,22 @@ return { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", }, + { + "mrcjkb/rustaceanvim", + version = "^6", -- Recommended + lazy = false, -- This plugin is already lazy + enabled = true, + }, + { + "saghen/blink.cmp", + version = "1.*", + opts = { + keymap = { + preset = "enter", + }, + sources = { + default = { "lsp", "path", "buffer" }, + }, + }, + }, } diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 54b25dd..c50a7a8 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -13,4 +13,42 @@ return { end end, }, + { + "akinsho/bufferline.nvim", + version = "*", + dependencies = "nvim-tree/nvim-web-devicons", + opts = { + options = { + diagnostics = "nvim_lsp", + show_close_icon = false, + separator_style = "slant", + offsets = { + { + filetype = "snacks_layout_box", + text = "󰙅 File Explorer", + separator = true, + }, + }, + }, + }, + }, + { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + -- "rcarriga/nvim-notify", + }, + opts = { + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + }, + }, + }, }