feat(nvim): cmdline completions

This commit is contained in:
u2515h 2024-01-06 22:49:38 +01:00
parent 1fafc88bc7
commit ab37924276
2 changed files with 17 additions and 20 deletions

View File

@ -21,12 +21,8 @@ autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
vim.opt.spell = true vim.opt.spell = true
vim.opt.spelllang = {'en_us'} vim.opt.spelllang = {'en_us'}
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with( vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics,
vim.lsp.diagnostic.on_publish_diagnostics, {virtual_text = true})
{
virtual_text = true,
}
)
-- Completion Plugin Setup -- Completion Plugin Setup
local cmp = require 'cmp' local cmp = require 'cmp'
cmp.setup({ cmp.setup({
@ -56,7 +52,6 @@ cmp.setup({
{name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized {name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
{name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* {name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{name = 'buffer', keyword_length = 2}, -- source current buffer {name = 'buffer', keyword_length = 2}, -- source current buffer
{name = 'vsnip', keyword_length = 2}, -- nvim-cmp source for vim-vsnip
{name = 'calc'}, -- source for math calculation {name = 'calc'}, -- source for math calculation
{ {
name = 'spell', name = 'spell',
@ -64,33 +59,34 @@ cmp.setup({
keep_all_entries = false, keep_all_entries = false,
enable_in_context = function() return true end enable_in_context = function() return true end
} }
}, }, {name = 'conventionalcommits', keyword_length = 1}, {name = 'crates'}
{name = 'conventionalcommits', keyword_length = 1 },
{name = 'crates'},
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered() documentation = cmp.config.window.bordered()
}, },
formatting = { formatting = {
fields = {'menu', 'abbr', 'kind'}, fields = {'menu', 'abbr' --[[ 'kind' ]] },
format = function(entry, item) format = function(entry, item)
local menu_icon = { local menu_icon = {
nvim_lsp = 'λ', nvim_lsp = 'λ',
vsnip = '', vsnip = '',
buffer = 'Ω', buffer = '',
path = '📁', path = '',
spell = '💬', spell = '',
calc = '', calc = '',
crates = '📦', crates = ''
} }
item.menu = menu_icon[entry.source.name] item.menu = menu_icon[entry.source.name]
if entry.source.name == "calc" then item.kind = "Math" end
return item return item
end end
} }
}) })
cmp.setup.cmdline('/', { cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}})
sources = { cmp.setup.cmdline(':', {
{ name = 'buffer' }, mapping = cmp.mapping.preset.cmdline(),
} sources = cmp.config.sources({{name = 'path'}}, {
{name = 'cmdline', option = {ignore_cmds = {'Man', '!'}}}
})
}) })

View File

@ -55,6 +55,7 @@ in
cmp-spell cmp-spell
cmp-conventionalcommits cmp-conventionalcommits
cmp-calc cmp-calc
cmp-cmdline
rustaceanvim rustaceanvim
lsp-inlayhints-nvim # https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7620822 lsp-inlayhints-nvim # https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7620822
plenary-nvim plenary-nvim