From 58ceb817bb6ba195d1189160878f318f3bcda0ef Mon Sep 17 00:00:00 2001 From: triethyl Date: Sat, 16 Aug 2025 20:20:21 -0400 Subject: neovim: restarted config --- pkgs/old-custom-neovim/config/lua/completion.lua | 98 ++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 pkgs/old-custom-neovim/config/lua/completion.lua (limited to 'pkgs/old-custom-neovim/config/lua/completion.lua') diff --git a/pkgs/old-custom-neovim/config/lua/completion.lua b/pkgs/old-custom-neovim/config/lua/completion.lua new file mode 100644 index 0000000..1ba2a91 --- /dev/null +++ b/pkgs/old-custom-neovim/config/lua/completion.lua @@ -0,0 +1,98 @@ +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} + +require('luasnip.loaders.from_vscode').lazy_load() + +local cmp = require('cmp') +local luasnip = require('luasnip') + +local select_opts = {behavior = cmp.SelectBehavior.Select} + +cmp.setup({ + enabled = function() -- Disable in certain circumstances + local disabled = false + disabled = disabled or (vim.api.nvim_get_option_value('buftype', { buf = 0 }) == 'prompt') -- While in prompts. + disabled = disabled or (vim.fn.reg_recording() ~= '') + disabled = disabled or (vim.fn.reg_executing() ~= '') + disabled = disabled or require('cmp.config.context').in_treesitter_capture('comment') -- While in comments. + return not disabled + end, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = { + {name = 'path'}, + {name = 'nvim_lsp', keyword_length = 1}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, + window = { + documentation = cmp.config.window.bordered() + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon = { + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + + item.menu = menu_icon[entry.source.name] + return item + end, + }, + mapping = { + -- [''] = cmp.mapping.select_prev_item(select_opts), + -- [''] = cmp.mapping.select_next_item(select_opts), + + [''] = cmp.mapping.select_prev_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + [''] = cmp.mapping.abort(), + -- [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({select = true}), + [''] = cmp.mapping.confirm({select = false}), + + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + local col = vim.fn.col('.') - 1 + + if cmp.visible() then + cmp.select_next_item(select_opts) + elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + fallback() + else + -- cmp.complete() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item(select_opts) + else + fallback() + end + end, {'i', 's'}), + }, +}) -- cgit v1.2.3