diff options
| author | Robert Günzler <r@gnzler.io> | 2025-04-30 13:08:09 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2025-04-30 13:08:09 +0200 |
| commit | b73d408fd9e9b1af65ad3efe8b0cc1244ccd71cf (patch) | |
| tree | 9eff3e7b51c08710713c7524f0f4bb0f106fb308 /.vim/lua/internal | |
| parent | c732af3b0b24ea59034233e69144cb9c9fe9d1fc (diff) | |
vim: cmp -> blink
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.vim/lua/internal')
| -rw-r--r-- | .vim/lua/internal/completion.lua | 154 | ||||
| -rw-r--r-- | .vim/lua/internal/plugins/blink.lua | 85 | ||||
| -rw-r--r-- | .vim/lua/internal/plugins/cmp.lua | 31 | ||||
| -rw-r--r-- | .vim/lua/internal/plugins/completion.lua | 60 | ||||
| -rw-r--r-- | .vim/lua/internal/plugins/lsp.lua | 4 |
5 files changed, 119 insertions, 215 deletions
diff --git a/.vim/lua/internal/completion.lua b/.vim/lua/internal/completion.lua deleted file mode 100644 index 552a45e..0000000 --- a/.vim/lua/internal/completion.lua +++ /dev/null @@ -1,154 +0,0 @@ -vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } -vim.opt.shortmess:append('c') -vim.opt.pumheight = 20 -- max height of completion window - --- re-link the highlight group for the 3rd field in the completion popup --- which is populated with the completion source -vim.schedule(function() - local hl = vim.api.nvim_set_hl - - hl(0, 'CmpItemMenu', { link = 'Comment', force = true }) - - hl(0, 'CmpItemAbbrMatch', { bold = true, force = true }) - hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'CmpItemAbbrMatch', force = true }) - - hl(0, 'CmpItemKindVariable', { link = 'Normal', force = true }) - hl(0, 'CmpItemKindInterface', { link = 'CmpItemKindVariable', force = true }) - hl(0, 'CmpItemKindText', { link = 'CmpItemKindVariable', force = true }) - - hl(0, 'CmpItemKindFunction', { link = 'Function', force = true }) - hl(0, 'CmpItemKindMethod', { link = 'CmpItemKindFunction', force = true }) - - hl(0, 'CmpItemKindKeyword', { link = 'Keyword', force = true }) - hl(0, 'CmpItemKindProperty', { link = 'CmpItemKindKeyword', force = true }) - hl(0, 'CmpItemKindUnit', { link = 'CmpItemKindKeyword', force = true }) -end) - -local cmp = require('cmp') - -cmp.setup({ - sources = { - { name = 'nvim_lsp', keyword_length = 1, group_index = 1 }, - { name = 'nvim_lsp_signature_help', keyword_length = 1, group_index = 1 }, - { name = 'luasnip', keyword_length = 2, group_index = 1 }, - -- { name = 'spell' }, - { name = 'async_path', group_index = 2 }, - { name = 'buffer', keyword_length = 3, group_index = 2 }, - }, - - mapping = { - ['<c-n>'] = cmp.mapping( - cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - { 'i', 'c' } - ), - ['<c-p>'] = cmp.mapping( - cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - { 'i', 'c' } - ), - ['<tab>'] = cmp.mapping( - cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - { 'i', 'c' } - ), - }, - - -- enable snippet expansion - snippet = { - expand = function(args) - vim.snippet.expand(args.body) - end, - }, - - experimental = { - ghost_text = false, - native_menu = false, - }, - - window = { - completion = { - scrollbar = true, - -- align 'abbr' with cursor, necessary due to 'kind' appearing first - col_offset = -3, - }, - }, - - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - expandable_indicator = true, - format = function(entry, item) - item.dup = 0 -- dedup items from the same source, first one wins - item.menu = '░ ' .. entry.source.name - return require('lspkind').cmp_format({ - mode = 'symbol', - symbol_map = { - -- - Array = ' ', - Boolean = ' ', - Class = ' ', - Color = ' ', - Constant = ' ', - Constructor = ' ', - Enum = ' ', - EnumMember = ' ', - Event = ' ', - -- Field = ' ', - Field = ' ', - File = ' ', - Folder = ' ', - Function = ' ', - Interface = ' ', - Key = ' ', - Keyword = ' ', - Method = ' ', - Module = ' ', - Namespace = ' ', - Null = ' ', - Object = ' ', - Operator = ' ', - Property = ' ', - Package = ' ', - Reference = ' ', - Snippet = ' ', - Struct = ' ', - Text = ' ', - TypeParameter = ' ', - Unit = ' ', - Value = ' ', - Variable = ' ', - }, - })(entry, item) - end, - }, -}) - -cmp.setup.cmdline({ ':', '/', '?', '@' }, { - sources = { - { name = 'cmdline', group_index = 1 }, - { name = 'cmdline_history', group_index = 1 }, - { name = 'nvim_lsp_document_symbol', keyword_length = 1, group_index = 1 }, - { name = 'async_path', group_index = 1 }, - { name = 'buffer', group_index = 1 }, - }, - - matching = { - disallow_symbol_nonprefix_matching = false, - }, - - view = { - entries = { selection_order = 'near_cursor' }, - }, - - formatting = { - fields = { 'abbr', 'menu' }, - }, -}) - -cmp.setup.cmdline({ '/', '?' }, { - sources = { - { name = 'nvim_lsp_document_symbol', keyword_length = 1, group_index = 1 }, - { name = 'path', max_item_count = 12, group_index = 1 }, - { name = 'buffer', group_index = 2 }, - }, -}) diff --git a/.vim/lua/internal/plugins/blink.lua b/.vim/lua/internal/plugins/blink.lua new file mode 100644 index 0000000..1d0e0ae --- /dev/null +++ b/.vim/lua/internal/plugins/blink.lua @@ -0,0 +1,85 @@ +return { + { + 'saghen/blink.cmp', + version = '1.*', + + lazy = false, + + dependencies = { + { + 'L3MON4D3/LuaSnip', + version = 'v2.*', + build = 'make install_jsregexp', + config = function() + require('internal.snippets') + end, + }, + }, + + init = function() + vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } + vim.opt.shortmess:append('c') + vim.opt.pumheight = 20 -- max height of completion window + + local hl = vim.api.nvim_set_hl + hl(0, 'BlinkCmpSource', { link = 'Comment', force = true }) + hl(0, 'BlinkCmpLabelDescription', { link = 'Comment', force = true }) + end, + + opts = { + -- TODO: + -- 'prefer_rust_with_warning', requires nightly rust, due to: + -- https://github.com/rust-lang/rust/issues/86656 + fuzzy = { implementation = 'lua' }, + + appearance = { + -- fallback to cmp highlight names + use_nvim_cmp_as_default = true, + -- adjusts spacing to ensure icons are aligned + -- nerd_font_variant = 'normal', + }, + + sources = { + providers = { + buffer = { min_keyword_length = 3 }, + snippets = { min_keyword_length = 3 }, + }, + }, + + completion = { + documentation = { auto_show = true }, + menu = { + draw = { + columns = { + { 'kind_icon' }, + { 'label', 'label_description', gap = 1 }, + { 'source_name' }, + }, + }, + }, + }, + + signature = { + enabled = true, + window = { scrollbar = false }, -- BUG: weird artifacts + }, + + keymap = { + ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' }, + ['<C-e>'] = { 'cancel', 'fallback' }, + ['<C-y>'] = { 'select_and_accept' }, + ['<C-p>'] = { 'select_prev', 'fallback' }, + ['<C-n>'] = { 'select_next', 'fallback' }, + ['<C-b>'] = { 'scroll_documentation_up', 'fallback' }, + ['<C-f>'] = { 'scroll_documentation_down', 'fallback' }, + ['<Tab>'] = { 'select_and_accept', 'fallback' }, + ['<C-j>'] = { 'snippet_forward', 'fallback' }, + ['<C-k>'] = { 'snippet_backward', 'fallback' }, + -- ['<C-l>'] = { 'show', 'hide', 'fallback' }, + }, + + snippets = { preset = 'luasnip' }, + }, + opts_extend = { 'sources.default' }, + }, +} diff --git a/.vim/lua/internal/plugins/cmp.lua b/.vim/lua/internal/plugins/cmp.lua new file mode 100644 index 0000000..086e1ac --- /dev/null +++ b/.vim/lua/internal/plugins/cmp.lua @@ -0,0 +1,31 @@ +return { + { + enabled = false, + -- 'hrsh7th/nvim-cmp', + 'iguanacucumber/magazine.nvim', -- perf improvements + name = 'nvim-cmp', + lazy = false, + -- event = {'InsertEnter', 'CmdlineEnter' }, + priority = 100, + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-nvim-lsp', + 'https://codeberg.org/FelipeLema/cmp-async-path', + -- 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-nvim-lsp-signature-help', -- used to provide function signature completion + 'hrsh7th/cmp-cmdline', + 'dmitmel/cmp-cmdline-history', + 'hrsh7th/cmp-nvim-lsp-document-symbol', -- used by cmdline completion + -- 'f3fora/cmp-spell', + + { 'L3MON4D3/LuaSnip', run = 'make install_jsregexp' }, + 'saadparwaiz1/cmp_luasnip', + + 'onsails/lspkind.nvim', + }, + config = function() + require('internal.snippets') + require('internal.completion') + end, + }, +} diff --git a/.vim/lua/internal/plugins/completion.lua b/.vim/lua/internal/plugins/completion.lua deleted file mode 100644 index db96085..0000000 --- a/.vim/lua/internal/plugins/completion.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - { - -- 'hrsh7th/nvim-cmp', - 'iguanacucumber/magazine.nvim', -- perf improvements - name = 'nvim-cmp', - - lazy = false, - -- event = {'InsertEnter', 'CmdlineEnter' }, - priority = 100, - dependencies = { - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-nvim-lsp', - 'https://codeberg.org/FelipeLema/cmp-async-path', - -- 'hrsh7th/cmp-nvim-lua', - 'hrsh7th/cmp-nvim-lsp-signature-help', -- used to provide function signature completion - 'hrsh7th/cmp-cmdline', - 'dmitmel/cmp-cmdline-history', - 'hrsh7th/cmp-nvim-lsp-document-symbol', -- used by cmdline completion - -- 'f3fora/cmp-spell', - - { 'L3MON4D3/LuaSnip', run = 'make install_jsregexp' }, - 'saadparwaiz1/cmp_luasnip', - - 'onsails/lspkind.nvim', - }, - config = function() - require('internal.snippets') - require('internal.completion') - end, - }, - - -- { -- TODO: try when it doesnt require nightly rust, i dont want binary blobs - -- - -- 'saghen/blink.cmp', - -- lazy = false, - -- -- use a release tag to download pre-built binaries - -- -- version = 'v0.*', - -- -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- build = 'cargo build --release', - -- - -- opts = { - -- highlight = { - -- -- sets the fallback highlight groups to nvim-cmp's highlight groups - -- -- useful for when your theme doesn't support blink.cmp - -- -- will be removed in a future release, assuming themes add support - -- use_nvim_cmp_as_default = true, - -- }, - -- - -- -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- -- adjusts spacing to ensure icons are aligned - -- nerd_font_variant = 'normal', - -- - -- -- experimental auto-brackets support - -- -- accept = { auto_brackets = { enabled = true } } - -- - -- -- experimental signature help support - -- -- trigger = { signature_help = { enabled = true } } - -- }, - -- }, -} diff --git a/.vim/lua/internal/plugins/lsp.lua b/.vim/lua/internal/plugins/lsp.lua index d138c6c..e2a5866 100644 --- a/.vim/lua/internal/plugins/lsp.lua +++ b/.vim/lua/internal/plugins/lsp.lua @@ -8,7 +8,9 @@ return { }, config = function() local capabilities = nil - if pcall(require, 'cmp_nvim_lsp') then + if pcall(require, 'blink.cmp') then + capabilities = require('blink.cmp').get_lsp_capabilities() + elseif pcall(require, 'cmp_nvim_lsp') then capabilities = require('cmp_nvim_lsp').default_capabilities() end |