Make nvim-cmp less annoying
This commit is contained in:
parent
37366c5d0c
commit
96372bd1de
1 changed files with 28 additions and 7 deletions
|
@ -112,6 +112,19 @@ require("lazy").setup({
|
|||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
-- https://github.com/hrsh7th/nvim-cmp/wiki/Advanced-techniques#disabling-completion-in-certain-contexts-such-as-comments
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
local context = require 'cmp.config.context'
|
||||
-- keep command mode completion enabled when cursor is in a comment
|
||||
if vim.api.nvim_get_mode().mode == 'c' then
|
||||
return true
|
||||
else
|
||||
return not context.in_treesitter_capture("comment")
|
||||
and not context.in_syntax_group("Comment")
|
||||
end
|
||||
end,
|
||||
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
|
@ -126,13 +139,21 @@ require("lazy").setup({
|
|||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
|
||||
-- don't use up/down arrows. Different from the suggested "merge", this replaces the keymaps completely
|
||||
-- I wouldn't have to have done this if I used HJKL motions when I edit rather than arrow keys
|
||||
mapping = {
|
||||
['<C-j>'] = { i = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), },
|
||||
['<C-k>'] = { i = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), },
|
||||
['<C-n>'] = { i = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), },
|
||||
['<C-p>'] = { i = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), },
|
||||
['<C-y>'] = { i = cmp.mapping.confirm({ select = false }), },
|
||||
['<C-e>'] = { i = cmp.mapping.abort(), },
|
||||
['<C-Space>'] = { i = cmp.mapping.complete(), },
|
||||
['<C-b>'] = { i = cmp.mapping.scroll_docs(-4) },
|
||||
['<C-f>'] = { i = cmp.mapping.scroll_docs(4) },
|
||||
},
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
|
|
Loading…
Reference in a new issue