From 282c1c9db72670719d4d3e7b924d90d14228f06d Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sun, 14 Jul 2024 16:31:42 +0300 Subject: Neovim: snippets now load automatically, changed TODO.md --- .config/nvim/lua/custom/completion.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to '.config/nvim/lua/custom/completion.lua') diff --git a/.config/nvim/lua/custom/completion.lua b/.config/nvim/lua/custom/completion.lua index 85a963f..5cf8c7b 100644 --- a/.config/nvim/lua/custom/completion.lua +++ b/.config/nvim/lua/custom/completion.lua @@ -1,4 +1,7 @@ -require('custom.snippets.lua') +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do + loadfile(ft_path)() +end + local luasnip = require('luasnip') local lspkind = require('lspkind') local cmp = require('cmp') @@ -37,10 +40,10 @@ cmp.setup({ enabled = is_enabled, completion = { completeopt = 'menu,menuone,noinsert' }, sources = cmp.config.sources({ - { name = 'nvim_lsp' }, -- for lsp - { name = 'luasnip' }, -- for snippets + { name = 'nvim_lsp' }, -- for lsp + { name = 'luasnip' }, -- for snippets { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim - { name = 'path' }, -- for filesystem + { name = 'path' }, -- for filesystem }, {}), snippet = { expand = function(args) @@ -73,7 +76,7 @@ cmp.setup({ format = function(entry, vim_item) local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item) local strings = vim.split(kind.kind, '%s', { trimempty = true }) - kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) + kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text) return kind end, -- cgit v1.3.1