summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/completions.lua
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-06-26 19:54:00 +0300
committerKyren223 <ulmliad223@gmail.com>2024-06-26 19:54:00 +0300
commite3896e07385cbc1327dcd23e1e28ca17f710b709 (patch)
tree326a0b88b1d864c991b7e3ab73545e61bca98353 /.config/nvim/lua/plugins/completions.lua
parent1062f6935d84409dc8b2498d4cb38e1e3aee465a (diff)
Accidentally placed the nvim files in the wrong place, fixed now
Diffstat (limited to '.config/nvim/lua/plugins/completions.lua')
-rw-r--r--.config/nvim/lua/plugins/completions.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/completions.lua b/.config/nvim/lua/plugins/completions.lua
new file mode 100644
index 0000000..51b7a78
--- /dev/null
+++ b/.config/nvim/lua/plugins/completions.lua
@@ -0,0 +1,50 @@
+return {
+ {
+ "hrsh7th/cmp-nvim-lsp"
+ },
+ {
+ "L3MON4D3/LuaSnip",
+ dependencies = {
+ "saadparwaiz1/cmp_luasnip",
+ "rafamadriz/friendly-snippets"
+ }
+ },
+ {
+ "hrsh7th/nvim-cmp",
+ opts = function(_, opts)
+ -- Setup options for lazydev.nvim
+ opts.sources = opts.sources or {}
+ table.insert(opts.sources, {
+ name = "lazydev",
+ group_index = 0,
+ })
+ end,
+ config = function()
+ local cmp = require("cmp")
+ require("luasnip.loaders.from_vscode").lazy_load()
+
+ cmp.setup({
+ snippet = {
+ expand = function(args)
+ require("luasnip").lsp_expand(args.body)
+ end
+ },
+ window = {
+ completion = cmp.config.window.bordered(),
+ documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ["<C-b>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-f>"] = cmp.mapping.scroll_docs(4),
+ ["<C-Space>"] = cmp.mapping.complete(),
+ ["<C-e>"] = cmp.mapping.abort(),
+ ["<CR>"] = cmp.mapping.confirm({ select = true}),
+ }),
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ }, { { name = "buffer"} })
+ })
+ end
+ }
+}