nvim: add config files
This commit is contained in:
85
nvim/lua/plugins/nvim-cmp.lua
Normal file
85
nvim/lua/plugins/nvim-cmp.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
return {
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
dependencies = {
|
||||
'L3MON4D3/LuaSnip',
|
||||
'hrsh7th/cmp-vsnip',
|
||||
'hrsh7th/vim-vsnip',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'onsails/lspkind.nvim',
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help'
|
||||
},
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup {
|
||||
formatting = {
|
||||
fields = { 'kind', 'abbr', 'menu' },
|
||||
format = function(entry, vim_item)
|
||||
local lspkind = require('lspkind')
|
||||
local kind = lspkind.cmp_format({
|
||||
mode = "symbol_text",
|
||||
maxwidth = 50
|
||||
})(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
kind.kind = " " .. (strings[1] or "") .. " "
|
||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = 'neorg' },
|
||||
{ name = 'nvim_lsp_signature_help' }
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
--['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
||||
--['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
||||
["<TAB>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
--elseif has_words_before() then
|
||||
-- cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<S-TAB>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.recently_used,
|
||||
cmp.config.compare.locality,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user