From cae577e428d68cd3547a3ee52462a8b822358d40 Mon Sep 17 00:00:00 2001 From: Adam <56338480+adastx@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:35:29 +0200 Subject: nvim setup snippets, nvim-tree, lualine(tabline) --- .config/nvim/lua/opts.lua | 55 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) (limited to '.config/nvim/lua/opts.lua') diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua index 259f460..126d6c4 100644 --- a/.config/nvim/lua/opts.lua +++ b/.config/nvim/lua/opts.lua @@ -1,19 +1,60 @@ +-- SNIPPETS +local nvim_lsp = require('lspconfig') +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +local servers = { 'omnisharp', 'html', 'sumneko_lua', 'bashls', 'tsserver', 'cssls' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + capabilities = capabilities, + } +end + +vim.o.completeopt = 'menuone,noselect' +local luasnip = require 'luasnip' + -- CMP local cmp = require 'cmp' - cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, mapping = { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ + [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, - }) + }, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') + else + fallback() + end + end, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '') + else + fallback() + end + end, }, sources = { { name = 'nvim_lsp' }, - } + { name = 'luasnip' }, + }, } -- C# @@ -69,4 +110,6 @@ require'nvim-treesitter.configs'.setup { }, } +-- Misc require('kommentary.config').use_extended_mappings() +vim.o.tabline = '%!v:lua.require\'luatab\'.tabline()' -- cgit v1.2.3-70-g09d2