Additional code completion sources (tabnine)

This commit is contained in:
Yannick Reiß 2024-03-19 07:20:20 +01:00
parent b2a762ab4d
commit ce70d6f9b7
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
4 changed files with 55 additions and 7 deletions

View File

@ -16,10 +16,10 @@ cmp.setup({
}, },
-- Add borders to the windows -- Add borders to the windows
-- window = { window = {
-- completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
-- }, },
-- mapping -- mapping
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
@ -53,7 +53,7 @@ cmp.setup({
{ name = "buffer", keyword_length = 1 }, { name = "buffer", keyword_length = 1 },
{ name = "calc" }, { name = "calc" },
{ name = "lua-latex-symbols", option = { cache = true } }, { name = "lua-latex-symbols", option = { cache = true } },
-- { name = "spell", option = { keep_all_entries = false }, keyword_length = 2 }, { name = "cmp_tabnine", keyword_length = 2 },
}), }),
-- add formatting of the different sources -- add formatting of the different sources
@ -69,6 +69,7 @@ cmp.setup({
lualatexsymbols = "𝕋", lualatexsymbols = "𝕋",
spell = "📚", spell = "📚",
fuzzy_buffer = "📄", fuzzy_buffer = "📄",
cmp_tabnine = "🖳",
} }
item.menu = menu_icon[entry.source.name] item.menu = menu_icon[entry.source.name]
return item return item
@ -91,6 +92,16 @@ cmp.setup.cmdline({ "/", "?" }, {
sources = { sources = {
{ name = "buffer" }, { name = "buffer" },
}, },
formatting = {
fields = { "menu", "abbr", "kind" },
format = function(entry, item)
local menu_icon = {
buffer = "📚",
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
@ -98,8 +109,37 @@ cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "path" }, { name = "path" },
{ name = "cmdline_history", keyword_length = 15 }, { name = "cmdline_history", keyword_length = 8 },
}, { }, {
{ name = "cmdline" }, { name = "cmdline" },
}), }),
formatting = {
fields = { "menu", "abbr", "kind" },
format = function(entry, item)
local menu_icon = {
path = "🌐",
cmdline = "🎛",
cmdline_history = "📰",
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
})
-- Tabnine configuration
local tabnine = require("cmp_tabnine.config")
tabnine:setup({
max_lines = 1000,
max_num_results = 10,
sort = true,
run_on_every_keystroke = true,
snippet_placeholder = "..",
ignored_file_types = {
-- default is not to ignore
-- uncomment to ignore in lua:
-- lua = true
},
show_prediction_strength = true,
min_percent = 40,
}) })

View File

@ -63,4 +63,10 @@ return {
"quangnguyen30192/cmp-nvim-ultisnips", "quangnguyen30192/cmp-nvim-ultisnips",
"mihaifm/bufstop", "mihaifm/bufstop",
"https://git.nickr.eu/yannickreiss/nvim-sourcer.git", "https://git.nickr.eu/yannickreiss/nvim-sourcer.git",
{ "tzachar/cmp-fuzzy-buffer", requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" } },
{
"tzachar/cmp-tabnine",
build = "./install.sh",
dependencies = "hrsh7th/nvim-cmp",
},
} }

View File

@ -44,6 +44,8 @@ function! Build()
endif endif
endfunction endfunction
colorscheme vim-monokai-tasty
nnoremap <C-b> :call Build()<CR> nnoremap <C-b> :call Build()<CR>
nnoremap <M-w> :bdelete<CR> nnoremap <M-w> :bdelete<CR>
nnoremap <C-y> :BufstopFast<CR> nnoremap <C-y> :BufstopFast<CR>

View File

@ -4,7 +4,7 @@ filetype plugin on
syntax on syntax on
" colorscheme vim-monokai-tasty " colorscheme vim-monokai-tasty
colorscheme desert colorscheme slate
" open builtin terminal " open builtin terminal
function OpenTerm() function OpenTerm()