fix(nvim): update cmp config
This commit is contained in:
parent
b1d63764c4
commit
865a6aa5c1
1
nvimrc
1
nvimrc
|
@ -266,6 +266,7 @@ runtime macros/matchit.vim
|
||||||
|
|
||||||
" load other plugins:
|
" load other plugins:
|
||||||
packadd! rust.vim " https://github.com/rust-lang/rust.vim.git
|
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! tmux-complete.vim " https://github.com/wellle/tmux-complete.vim.git
|
||||||
packadd! vim-commentary " https://github.com/tpope/vim-commentary.git
|
packadd! vim-commentary " https://github.com/tpope/vim-commentary.git
|
||||||
packadd! vim-rails " https://github.com/tpope/vim-rails.git
|
packadd! vim-rails " https://github.com/tpope/vim-rails.git
|
||||||
|
|
|
@ -3,7 +3,7 @@ local cmp = require("cmp")
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = "menu,menuone,noinsert,noselect",
|
completeopt = "menu,menuone,noselect",
|
||||||
},
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
|
@ -18,10 +18,32 @@ cmp.setup({
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<C-e>"] = cmp.mapping.close(),
|
["<C-e>"] = cmp.mapping.close(),
|
||||||
["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
||||||
["<CR>"] = 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({
|
sources = cmp.config.sources({
|
||||||
{ name = "copilot", keyword_length = 0 },
|
{ name = "copilot", keyword_length = 0 },
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require("nvim-treesitter.configs").setup({
|
require("nvim-treesitter.configs").setup({
|
||||||
|
-- TODO: only install needed
|
||||||
ensure_installed = "all",
|
ensure_installed = "all",
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
Loading…
Reference in New Issue