From a8771d5166be5c5533f839f908d3ab64c8507cf4 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 17 Apr 2025 16:18:37 -0400 Subject: [PATCH] use blink.cmp in neovim_unstable --- .../.config/nvim_unstable/init.lua | 1 + .../.config/nvim_unstable/lazy-lock.json | 4 +- .../nvim_unstable/lsp/rust_analyzer.lua | 5 -- .../nvim_unstable/lua/aleidk/autocmds.lua | 21 ++++++- .../nvim_unstable/lua/aleidk/options.lua | 18 ------ .../lua/aleidk/plugins/completion.lua | 63 +++++++++++++++++++ .../nvim_unstable/lua/aleidk/plugins/init.lua | 1 + .../lua/aleidk/plugins/linters.lua | 4 ++ .../nvim_unstable/lua/aleidk/plugins/mini.lua | 14 ++--- 9 files changed, 95 insertions(+), 36 deletions(-) delete mode 100644 Configs/nvim_unstable/.config/nvim_unstable/lsp/rust_analyzer.lua create mode 100644 Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/completion.lua diff --git a/Configs/nvim_unstable/.config/nvim_unstable/init.lua b/Configs/nvim_unstable/.config/nvim_unstable/init.lua index 329586b..5b8bbcd 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/init.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/init.lua @@ -16,6 +16,7 @@ end vim.opt.rtp:prepend(lazypath) require("aleidk.options") +require("aleidk.autocmds") require("aleidk.keymaps") -- Setup lazy.nvim diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lazy-lock.json b/Configs/nvim_unstable/.config/nvim_unstable/lazy-lock.json index 78fc60e..38cc8e4 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lazy-lock.json +++ b/Configs/nvim_unstable/.config/nvim_unstable/lazy-lock.json @@ -1,4 +1,6 @@ { + "blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" }, + "blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" }, "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "conform.nvim": { "branch": "master", "commit": "6632e7d788a85bf8405ea0c812d343fc308b7b8c" }, @@ -11,7 +13,7 @@ "mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" }, "neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" }, "nvim-lint": { "branch": "master", "commit": "93b8040115c9114dac1047311763bef275e752dc" }, - "nvim-lspconfig": { "branch": "master", "commit": "ff6471d4f837354d8257dfa326b031dd8858b16e" }, + "nvim-lspconfig": { "branch": "master", "commit": "a56f4b9dde5daf3d4c7bb50cf78ab609537f2259" }, "nvim-treesitter": { "branch": "master", "commit": "9be6836ebeb88a536055bf1ce0961eef68da4bc6" }, "nvim-treesitter-context": { "branch": "master", "commit": "93b29a32d5f4be10e39226c6b796f28d68a8b483" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lsp/rust_analyzer.lua b/Configs/nvim_unstable/.config/nvim_unstable/lsp/rust_analyzer.lua deleted file mode 100644 index b2b8a12..0000000 --- a/Configs/nvim_unstable/.config/nvim_unstable/lsp/rust_analyzer.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - cmd = { "rust-analyzer" }, - filetypes = { 'rust' }, - root_markers = { "cargo.toml" }, -} diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/autocmds.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/autocmds.lua index 54e2c9b..9e7e188 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/autocmds.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/autocmds.lua @@ -6,14 +6,29 @@ vim.api.nvim_create_autocmd('LspAttach', { return end + vim.bo[args.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp' + -- Prefer LSP folding if client supports it if client:supports_method('textDocument/foldingRange') then local win = vim.api.nvim_get_current_win() vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()' end - if client:supports_method 'textDocument/completion' then - vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) - end + vim.keymap.set({ "n", "x", "v" }, "la", vim.lsp.buf.code_action, { buffer = args.buf, desc = "Code Action" }) + vim.keymap.set({ "n", "x", "v" }, "ld", vim.diagnostic.open_float, { desc = "Show diagnostic under cursor" }) + vim.keymap.set({ "n", "x", "v" }, "lc", function() + local curpos = vim.fn.getcurpos() + local diagnostics = vim.diagnostic.get(0, { lnum = curpos[2] - 1 }) + + if #diagnostics == 0 then + vim.notify("No diagnostic under cursor") + return + end + + local diagnostic = diagnostics[1] + local msg = string.format("%s [%s]: %s", diagnostic.source, diagnostic.code, diagnostic.message) + vim.fn.setreg("+", msg) + vim.notify("Diagnostic saved to clipboard:\n\n" .. msg) + end, { buffer = args.buf, desc = "Copy diagnostic to clipboard" }) end, }) diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua index 428672e..96f4643 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua @@ -157,22 +157,4 @@ vim.lsp.enable({ vim.diagnostic.config({ virtual_lines = { current_line = true }, - on_attach = function(_, bufnr) - vim.keymap.set({ "n", "x", "v" }, "la", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code Action" }) - vim.keymap.set({ "n", "x", "v" }, "ld", vim.diagnostic.open_float, { desc = "Show diagnostic under cursor" }) - vim.keymap.set({ "n", "x", "v" }, "lc", function() - local curpos = vim.fn.getcurpos() - local diagnostics = vim.diagnostic.get(0, { lnum = curpos[2] - 1 }) - - if #diagnostics == 0 then - vim.notify("No diagnostic under cursor") - return - end - - local diagnostic = diagnostics[1] - local msg = string.format("%s [%s]: %s", diagnostic.source, diagnostic.code, diagnostic.message) - vim.fn.setreg("+", msg) - vim.notify("Diagnostic saved to clipboard:\n\n" .. msg) - end, { buffer = bufnr, desc = "Copy diagnostic to clipboard" }) - end, }) diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/completion.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/completion.lua new file mode 100644 index 0000000..1101f70 --- /dev/null +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/completion.lua @@ -0,0 +1,63 @@ +return { + "saghen/blink.cmp", + lazy = false, + version = "*", + dependencies = { + "neovim/nvim-lspconfig", + "echasnovski/mini.nvim", + "folke/lazydev.nvim", + { "saghen/blink.compat", version = "*", }, + }, + opts = function() + local window_options = { + border = "rounded", + winblend = vim.o.pumblend, + } + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + return { + appearance = { + nerd_font_variant = 'mono' + }, + completion = { + accept = { auto_brackets = { enabled = true }, }, + -- Show documentation when selecting a completion item + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + + -- Display a preview of the selected item on the current line + ghost_text = { enabled = true }, + }, + keymap = { + preset = "enter", + [""] = { 'select_next', 'fallback' }, + [""] = { 'select_prev', 'fallback' }, + [""] = { 'scroll_documentation_up', 'fallback' }, + [""] = { 'scroll_documentation_down', 'fallback' }, + }, + sources = { + providers = { + dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" }, + lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" }, + luasnip = { + name = 'luasnip', + module = 'blink.compat.source', + score_offset = -3, + opts = { + use_show_condition = false, + show_autosnippets = true, + }, + }, + }, + default = { + "lsp", + "path", + "snippets", + "buffer", + "dadbod", + "lazydev", + }, + }, + } + end +} diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/init.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/init.lua index 1f62383..3d74e7f 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/init.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/init.lua @@ -1,4 +1,5 @@ return { + 'neovim/nvim-lspconfig', 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically { "nvim-tree/nvim-web-devicons", lazy = true }, { diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/linters.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/linters.lua index 06aec9f..4e13ecd 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/linters.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/linters.lua @@ -14,6 +14,10 @@ return { NeogitCommitMessage = { "gitlint" }, gitcommit = { "gitlint" }, markdown = { "markdownlint" }, + javascript = { "biomejs" }, + typescript = { "biomejs" }, + javascriptreact = { "biomejs" }, + typescriptreact = { "biomejs" }, } vim.api.nvim_create_autocmd({ "BufWritePost" }, { diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/mini.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/mini.lua index 3cf4c42..bdaace6 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/mini.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/plugins/mini.lua @@ -6,7 +6,9 @@ return { }, config = function() require('mini.icons').setup() - require('mini.bracketed').setup() -- [] movement for various stuff + require('mini.bracketed').setup({ + diagnostic = { options = { severity = vim.diagnostic.severity.ERROR } }, + }) require("mini.ai").setup({}) require('mini.cursorword').setup() -- Highlight word under cursor require('mini.extra').setup() @@ -17,14 +19,9 @@ return { require('mini.splitjoin').setup() require("mini.align").setup({}) require('mini.animate').setup() - require('mini.notify').setup({ - -- Notifications about LSP progress - lsp_progress = { - -- Whether to enable showing - enable = false, - } - }) + require('mini.notify').setup() vim.notify = require('mini.notify').make_notify() + vim.keymap.set('n', 'un', require('mini.notify').show_history, { desc = 'Show notifications', silent = true }) require('mini.statusline').setup({}) require('mini.diff').setup({ view = { style = 'sign' } }) @@ -160,7 +157,6 @@ return { { mode = "n", keys = "l", desc = "+LSP" }, { mode = "n", keys = "r", desc = "+Replace" }, { mode = "n", keys = "u", desc = "+UI & Config" }, - { mode = "n", keys = "un", desc = "+Noice" }, { mode = "n", keys = "w", desc = "+Workspace" }, { mode = "n", keys = "p", desc = "+Run stuff" }, { mode = "n", keys = "z", desc = "+ZK" },