-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add autocompletion Neovim configuration
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
return { | ||
"hrsh7th/nvim-cmp", | ||
event = "VimEnter", | ||
dependencies = { | ||
{ | ||
"L3MON4D3/LuaSnip", | ||
build = (function() | ||
return "make install_jsregexp" | ||
end)(), | ||
}, | ||
"saadparwaiz1/cmp_luasnip", | ||
"hrsh7th/cmp-nvim-lsp", | ||
"hrsh7th/cmp-buffer", | ||
"hrsh7th/cmp-path", | ||
}, | ||
config = function() | ||
local cmp = require("cmp") | ||
local luasnip = require("luasnip") | ||
luasnip.config.setup({}) | ||
|
||
cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
vim.snippet.expand(args.body) | ||
end, | ||
}, | ||
completion = { | ||
-- Only manual completions, please | ||
autocomplete = false, | ||
completeopt = "menu,menuone,noinsert", | ||
}, | ||
|
||
mapping = cmp.mapping.preset.insert({ | ||
-- Scroll the documentation window [b]ack / [f]orward | ||
["<C-b>"] = cmp.mapping.scroll_docs(-4), | ||
["<C-f>"] = cmp.mapping.scroll_docs(4), | ||
|
||
-- Trigger a completion from nvim-cmp. | ||
["<C-Space>"] = cmp.mapping.complete({}), | ||
|
||
-- Think of <c-l> as moving to the right of your snippet expansion. | ||
-- So if you have a snippet that's like: | ||
-- function $name($args) | ||
-- $body | ||
-- end | ||
-- | ||
-- <c-l> will move you to the right of each of the expansion locations. | ||
-- <c-h> is similar, except moving you backwards. | ||
["<C-l>"] = cmp.mapping(function() | ||
if luasnip.expand_or_locally_jumpable() then | ||
luasnip.expand_or_jump() | ||
end | ||
end, { "i", "s" }), | ||
["<C-h>"] = cmp.mapping(function() | ||
if luasnip.locally_jumpable(-1) then | ||
luasnip.jump(-1) | ||
end | ||
end, { "i", "s" }), | ||
|
||
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, | ||
-- expansion) see: | ||
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps | ||
}), | ||
sources = { | ||
{ | ||
name = "lazydev", | ||
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it | ||
group_index = 0, | ||
}, | ||
{ name = "nvim_lsp" }, | ||
{ name = "buffer" }, | ||
{ name = "path" }, | ||
}, | ||
}) | ||
end, | ||
} |