fix(nvim): update cmp config

This commit is contained in:
Rob Watson 2023-09-22 14:26:13 +02:00
parent b1d63764c4
commit 865a6aa5c1
3 changed files with 26 additions and 2 deletions

1
nvimrc
View File

@ -266,6 +266,7 @@ runtime macros/matchit.vim
" load other plugins:
packadd! rust.vim " https://github.com/rust-lang/rust.vim.git
" TODO: replace with nvim_cmp:
packadd! tmux-complete.vim " https://github.com/wellle/tmux-complete.vim.git
packadd! vim-commentary " https://github.com/tpope/vim-commentary.git
packadd! vim-rails " https://github.com/tpope/vim-rails.git

View File

@ -3,7 +3,7 @@ local cmp = require("cmp")
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert,noselect",
completeopt = "menu,menuone,noselect",
},
snippet = {
expand = function(args)
@ -18,10 +18,32 @@ cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
["<CR>"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#super-tab-like-mapping
["<C-Space>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<Tab>"] = function(fallback)
if not cmp.select_next_item() then
if vim.bo.buftype ~= "prompt" and has_words_before() then
cmp.complete()
else
fallback()
end
end
end,
["<S-Tab>"] = function(fallback)
if not cmp.select_prev_item() then
if vim.bo.buftype ~= "prompt" and has_words_before() then
cmp.complete()
else
fallback()
end
end
end,
}),
sources = cmp.config.sources({
{ name = "copilot", keyword_length = 0 },

View File

@ -1,4 +1,5 @@
require("nvim-treesitter.configs").setup({
-- TODO: only install needed
ensure_installed = "all",
highlight = {
enable = true,