summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/opts.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/opts.lua')
-rw-r--r--.config/nvim/lua/opts.lua55
1 files changed, 49 insertions, 6 deletions
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 = {
- ['<Tab>'] = cmp.mapping.select_next_item(),
- ['<S-Tab>'] = cmp.mapping.select_prev_item(),
+ ['<C-n>'] = cmp.mapping.select_next_item(),
+ ['<C-p>'] = cmp.mapping.select_prev_item(),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-d>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
- ['<CR>'] = cmp.mapping.confirm({
+ ['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
- })
+ },
+ ['<Tab>'] = function(fallback)
+ if vim.fn.pumvisible() == 1 then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
+ elseif luasnip.expand_or_jumpable() then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
+ else
+ fallback()
+ end
+ end,
+ ['<S-Tab>'] = function(fallback)
+ if vim.fn.pumvisible() == 1 then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
+ elseif luasnip.jumpable(-1) then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>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()'