diff options
| author | Robert Günzler <r@gnzler.io> | 2022-04-04 12:00:29 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-04-04 12:00:29 +0200 |
| commit | 06a1cd6ede3ee876c4b1206769985b79e3559c5d (patch) | |
| tree | 3319602c85184c56410ab0da4f0114cfb905aafd /.vim/lua/plugins.lua | |
| parent | adad823f99bea2a20bae2efbd92e5cd5bae8eb8b (diff) | |
vim: use luasnip
Diffstat (limited to '.vim/lua/plugins.lua')
| -rw-r--r-- | .vim/lua/plugins.lua | 157 |
1 files changed, 139 insertions, 18 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index bef00cc..49748e8 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -364,15 +364,19 @@ return require('packer').startup({function() use {'hrsh7th/nvim-cmp', -- {{{ requires = { 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-nvim-lsp', - -- 3rd party - 'dcampos/cmp-snippy', + 'hrsh7th/cmp-nvim-lsp-document-symbol', + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'saadparwaiz1/cmp_luasnip', 'f3fora/cmp-spell', + 'onsails/lspkind-nvim', }, config = function() local cmp = require('cmp') + local luasnip = require('luasnip') cmp.setup { completion = { -- autocomplete = { cmp.TriggerEvent.TextChanged } @@ -383,46 +387,163 @@ return require('packer').startup({function() border = { '', '', '', ' ', '', '', '', ' ' }, }, mapping = { - ['<cr>'] = cmp.mapping.confirm(), + ['<cr>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm({ select = true }) + elseif luasnip.expandable() then + luasnip.expand() + else + fallback() + end + end), ['<c-space>'] = cmp.mapping.complete(), - ['<c-e>'] = cmp.mapping.close(), + ['<c-e>'] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + ['<c-n>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's'}), + ['<c-p>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's'}), + ['<tab>'] = cmp.mapping({ + i = function(fallback) + if cmp.visible() then + cmp.confirm({ select = true }) + elseif luasnip.expandable() then + luasnip.expand() + else + fallback() + end + end, + s = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + c = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + }), + ['<s-tab>'] = cmp.mapping({ + s = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, + c = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, + }), }, snippet = { expand = function(args) - require('snippy').expand_snippet(args.body) + require('luasnip').lsp_expand(args.body) end, }, - sources = { + sources = cmp.config.sources({ { name = 'nvim_lsp' }, - { name = 'snippy' }, + { name = 'nvim_lsp_signature_help' }, + { name = 'luasnip' }, { name = 'nvim_lua' }, + }, { { name = 'neorg' }, { name = 'orgmode' }, { name = 'spell', keyword_length = 3, max_item_count = 10 }, { name = 'path' }, { name = 'buffer', keyword_length = 3 }, - }, + }), formatting = { format = require('lspkind').cmp_format { with_text = false, menu = { - nvim_lsp = '[lsp]', - snippy = '[snip]', - nvim_lua = '[nvim]', - orgmode = '[org]', - spell = '[spell]', - path = '[path]', - buffer = '[buf]', + nvim_lsp = '[LSP]', + luasnip = '[SNIP]', + nvim_lua = '[NVIM]', + orgmode = '[ORG]', + spell = '[SPELL]', + path = '[PATH]', + buffer = '[BUF]', } } }, - experimental = { - native_menu = false, - -- ghost_text = { hl_group = 'Comment' } + } + cmp.setup.cmdline('/', { + sources = cmp.config.sources({ + { name = 'nvim_lsp_document_symbol' } + }, { + { name = 'buffer' } + }) + }) + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + + require('lspkind').init { + symbol_map = { + Text = '', + Method = '', + Function = '', + Constructor = '', + Field = '', + Variable = '', + Class = '', + Interface = '', + Module = '', + Property = '', + Unit = '', + Value = '', + Enum = '', + Keyword = '', + Snippet = '', + Color = '', + File = '', + Reference = '', + Folder = '', + EnumMember = '', + Constant = '', + Struct = 'פּ', + Event = '', + Operator = '', + TypeParameter = '', } } end} -- }}} + use {'L3MON4D3/LuaSnip', -- {{{ + config = function() + require('snips') + end} -- }}} + use {'nvim-telescope/telescope.nvim', --- {{{ requires = { 'nvim-lua/popup.nvim', |