configured nvim-cmp
This commit is contained in:
parent
07e6061b84
commit
7c2d1a4bfb
|
|
@ -49,18 +49,20 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
event = "InsertEnter",
|
event = { "InsertEnter", "CmdlineEnter", },
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Snippet engine
|
-- Snippet engine
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
|
||||||
|
|
||||||
-- Plugins
|
-- Plugins
|
||||||
"hrsh7th/cmp-buffer", -- indexer
|
"hrsh7th/cmp-buffer", -- indexer
|
||||||
"hrsh7th/cmp-path", -- Autocomplete for filesystem paths
|
"hrsh7th/cmp-path", -- Autocomplete for filesystem paths
|
||||||
"hrsh7th/cmp-cmdline", -- Autocomplete for vims commandline
|
"hrsh7th/cmp-cmdline", -- Autocomplete for vims commandline
|
||||||
"hrsh7th/cmp-nvim-lua", -- Autocomplete for vim options
|
"hrsh7th/cmp-nvim-lua", -- Autocomplete for vim options
|
||||||
|
|
||||||
|
-- Looks
|
||||||
|
"onsails/lspkind.nvim", -- Add symbols for type
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
@ -71,12 +73,63 @@ return {
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
view = {
|
||||||
|
entries = {
|
||||||
|
name = 'custom',
|
||||||
|
selection_order = 'near_cursor'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = require("lspkind").cmp_format({
|
||||||
|
mode = "symbol_text",
|
||||||
|
maxwidth = 50,
|
||||||
|
ellipsis_char = "...",
|
||||||
|
show_labelDetails = true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = "nvim_lsp" },
|
{ name = "nvim_lsp" },
|
||||||
{ name = "luasnip" },
|
{ name = "luasnip" },
|
||||||
{ name = "buffer" },
|
{ name = "buffer" },
|
||||||
{ name = "path" },
|
{ name = "path" },
|
||||||
},
|
},
|
||||||
|
mapping = {
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
if #cmp.get_entries() == 1 then
|
||||||
|
cmp.confirm({ select = true })
|
||||||
|
else
|
||||||
|
cmp.select_next_item()
|
||||||
|
end
|
||||||
|
--[[ Replace with your snippet engine (see above sections on this page)
|
||||||
|
elseif snippy.can_expand_or_advance() then
|
||||||
|
snippy.expand_or_advance()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
if #cmp.get_entries() == 1 then
|
||||||
|
cmp.confirm({ select = true })
|
||||||
|
end]]
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
end
|
||||||
|
end, { "i", "s", "c" }),
|
||||||
|
["<CR>"] = cmp.mapping({
|
||||||
|
i = function(fallback)
|
||||||
|
if cmp.visible() and cmp.get_active_entry() then
|
||||||
|
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
s = cmp.mapping.confirm({ select = true }),
|
||||||
|
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
|
||||||
|
}),
|
||||||
|
},
|
||||||
enabled = function()
|
enabled = function()
|
||||||
local context = require("cmp.config.context")
|
local context = require("cmp.config.context")
|
||||||
-- disable in autocomplete in comments
|
-- disable in autocomplete in comments
|
||||||
|
|
@ -101,5 +154,7 @@ return {
|
||||||
matching = { disallow_symbol_nonprefix_matching = false }
|
matching = { disallow_symbol_nonprefix_matching = false }
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue