summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/opts.lua
diff options
context:
space:
mode:
authorAdam <adam.moloney.stuck@gmail.com>2021-10-22 17:04:46 +0200
committeradamstuck <adam.moloney.stuck@gmail.com>2021-10-22 17:12:31 +0200
commitc5903b603f4163f246d0e7f18d6eb588a8123107 (patch)
treefede70b2cd2bff28555137ca841f5dcd83a7a440 /.config/nvim/lua/opts.lua
parente752b4f815d519063872296b10a3644a30587541 (diff)
vim + nvim cleanup, UltiSnip -> LuaSnip
Diffstat (limited to '.config/nvim/lua/opts.lua')
-rw-r--r--.config/nvim/lua/opts.lua82
1 files changed, 39 insertions, 43 deletions
diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua
index 56f066a..70b255c 100644
--- a/.config/nvim/lua/opts.lua
+++ b/.config/nvim/lua/opts.lua
@@ -1,27 +1,18 @@
-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,
- }
+-- CMP
+local has_words_before = function()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
+local luasnip = require("luasnip")
+local cmp = require("cmp")
+require("luasnip/loaders/from_vscode").lazy_load()
vim.o.completeopt = 'menuone,noselect'
--- CMP
-local cmp = require 'cmp'
-
-local t = function(str)
- return vim.api.nvim_replace_termcodes(str, true, true, true)
-end
-
cmp.setup {
snippet = {
expand = function(args)
- vim.fn["UltiSnips#Anon"](args.body)
+ require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
@@ -29,29 +20,33 @@ cmp.setup {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
- ['<C-e>'] = cmp.mapping.close(),
- -- ['<CR>'] = cmp.mapping.confirm {
- -- behavior = cmp.ConfirmBehavior.Replace,
- -- select = true,
- -- },
+ ['<C-c>'] = cmp.mapping.close(),
["<Tab>"] = cmp.mapping(function(fallback)
- if vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
- vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpForwards()<CR>"))
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif luasnip.expand_or_jumpable() then
+ luasnip.expand_or_jump()
+ elseif has_words_before() then
+ cmp.complete()
else
fallback()
end
- end, { "i", "s", }),
+ end, { "i", "s" }),
+
["<S-Tab>"] = cmp.mapping(function(fallback)
- if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then
- return vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpBackwards()<CR>"))
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif luasnip.jumpable(-1) then
+ luasnip.jump(-1)
else
fallback()
end
- end, { "i", "s", }),
+ end, { "i", "s" }),
},
sources = {
{ name = 'nvim_lsp' },
- { name = 'ultisnips' },
+ { name = 'luasnip' },
+ -- { name = 'buffer' }
},
}
vim.cmd('autocmd FileType markdown lua require("cmp").setup.buffer { enabled = false }')
@@ -68,6 +63,18 @@ require("nvim-autopairs.completion.cmp").setup {
},
}
+-- LSPCONFIG
+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
+
-- C#
local pid = vim.fn.getpid()
@@ -117,7 +124,7 @@ require'lspconfig'.bashls.setup{}
-- Misc
require'lsp_signature'.setup {
- hint_enable = false,
+ floating_window = false
}
require'nvim-treesitter.configs'.setup {
@@ -126,26 +133,15 @@ require'nvim-treesitter.configs'.setup {
},
}
-require("toggleterm").setup{
- size = 15,
- open_mapping = [[<c-\>]],
- hide_numbers = true,
- persist_size = true,
- direction = 'horizontal',
- close_on_exit = true,
-}
-
-require('kommentary.config').use_extended_mappings()
require('kommentary.config').configure_language("default", {
prefer_single_line_comments = true,
})
-vim.o.tabline = '%!v:lua.require\'luatab\'.tabline()'
require("indent_blankline").setup {
char = "¦",
show_trailing_blankline_indent = false,
- buftype_exclude = {"startify", "NvimTree", "help", "toggleterm", "terminal"},
- filetype_exclude = {"startify", "NvimTree", "help", "toggleterm", "terminal"},
+ buftype_exclude = {"startify", "help", "terminal"},
+ filetype_exclude = {"startify", "help", "terminal"},
}
vim.cmd [[