Include code completion and snippets
This commit is contained in:
parent
05874830dd
commit
25a1a4d16e
3 changed files with 107 additions and 37 deletions
45
.config/nvim/lua/plugins/completions.lua
Normal file
45
.config/nvim/lua/plugins/completions.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp
|
||||
"rafamadriz/friendly-snippets", -- Collection of snippets
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
config = function()
|
||||
require("luasnip.loaders.from_vscode").lazy_load() -- Load snippets from friendly-snippets
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-PageUp>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-PageDown>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
--{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue