Add nvim-cmp basic config
This commit is contained in:
parent
db10325c97
commit
ee4f78902b
2 changed files with 62 additions and 0 deletions
43
lua/custom/completion.lua
Normal file
43
lua/custom/completion.lua
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
-- Set some settings for competion
|
||||||
|
-- For more info type `:help completeopt`
|
||||||
|
-- menu: Show menu when completions available (more than 1)
|
||||||
|
-- menuone: Show menu even when there is only 1 option
|
||||||
|
-- noselect: Force user to select convinient option
|
||||||
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||||
|
|
||||||
|
local lspkind = require "lspkind"
|
||||||
|
|
||||||
|
local kind_formatter = lspkind.cmp_format {
|
||||||
|
mode = "symbol_text",
|
||||||
|
menu = {
|
||||||
|
buffer = "[buf]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
nvim_lua = "[api]",
|
||||||
|
path = "[path]",
|
||||||
|
luasnip = "[snip]",
|
||||||
|
gh_issues = "[issues]",
|
||||||
|
tn = "[TabNine]",
|
||||||
|
eruby = "[erb]",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local cmp = require "cmp"
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
||||||
|
["<C-y>"] = cmp.mapping(
|
||||||
|
cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
{ "i", "c" }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
19
lua/custom/plugins/completion.lua
Normal file
19
lua/custom/plugins/completion.lua
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
return {
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
event = "InsertEnter", -- Only load plugin when in INSERT mode
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-buffer", -- source for text in buffer
|
||||||
|
"hrsh7th/cmp-path", -- source for file system paths
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
-- follow latest release.
|
||||||
|
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||||
|
},
|
||||||
|
"saadparwaiz1/cmp_luasnip", -- for autocompletion
|
||||||
|
"rafamadriz/friendly-snippets", -- useful snippets
|
||||||
|
"onsails/lspkind.nvim", -- vs-code like pictograms
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require "custom/completion"
|
||||||
|
end,
|
||||||
|
}
|
Loading…
Reference in a new issue