From c5903b603f4163f246d0e7f18d6eb588a8123107 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 22 Oct 2021 17:04:46 +0200 Subject: vim + nvim cleanup, UltiSnip -> LuaSnip --- .config/nvim/init.lua | 1 - .config/nvim/lua/after.lua | 6 ---- .config/nvim/lua/binds.lua | 7 ++-- .config/nvim/lua/opts.lua | 82 +++++++++++++++++++++----------------------- .config/nvim/lua/plugins.lua | 44 +++++++++++------------- .config/nvim/lua/stl.lua | 6 ++-- 6 files changed, 64 insertions(+), 82 deletions(-) delete mode 100644 .config/nvim/lua/after.lua (limited to '.config/nvim') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 961f7d2..3bc3238 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -3,4 +3,3 @@ require('opts') require('setup') require('binds') require('stl') -require('after') diff --git a/.config/nvim/lua/after.lua b/.config/nvim/lua/after.lua deleted file mode 100644 index 454acee..0000000 --- a/.config/nvim/lua/after.lua +++ /dev/null @@ -1,6 +0,0 @@ -require'colorizer'.setup { - '*'; - '!vim'; - css = { rgb_fn = true; }; - html = { names = false; } -} diff --git a/.config/nvim/lua/binds.lua b/.config/nvim/lua/binds.lua index 40d9a83..2e6ca70 100644 --- a/.config/nvim/lua/binds.lua +++ b/.config/nvim/lua/binds.lua @@ -17,17 +17,14 @@ map('i', '[', '[u', opts) map('i', '!', '!u', opts) map('i', '?', '?u', opts) -map('v', '', ":m '>+1gv=gv", opts) -map('v', '', ":m '<-2gv=gv", opts) +map('v', 'J', ":m '>+1gv=gv", opts) +map('v', 'K', ":m '<-2gv=gv", opts) map('n', 'h', ':wincmd h', opts) map('n', 'j', ':wincmd j', opts) map('n', 'k', ':wincmd k', opts) map('n', 'l', ':wincmd l', opts) -map('n', '', ':NvimTreeToggle', opts) -map('n', 'n', ':NvimTreeFindFile', opts) - map('n', '', 'Telescope find_files', opts) map('n', 'fg', 'Telescope live_grep', opts) map('n', 'fb', 'Telescope buffers', opts) 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 { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.close(), - -- [''] = cmp.mapping.confirm { - -- behavior = cmp.ConfirmBehavior.Replace, - -- select = true, - -- }, + [''] = cmp.mapping.close(), [""] = cmp.mapping(function(fallback) - if vim.fn["UltiSnips#CanJumpForwards"]() == 1 then - vim.fn.feedkeys(t(":call UltiSnips#JumpForwards()")) + 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" }), + [""] = cmp.mapping(function(fallback) - if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then - return vim.fn.feedkeys(t(":call UltiSnips#JumpBackwards()")) + 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 = [[]], - 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 [[ diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index c1a83c3..4175672 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -5,20 +5,17 @@ require('packer').startup(function() use 'tpope/vim-fugitive' use 'tpope/vim-surround' use 'tpope/vim-repeat' - use 'ThePrimeagen/vim-be-good' + use 'b3nj5m1n/kommentary' + use 'mhinz/vim-startify' use 'neovim/nvim-lspconfig' - use 'hrsh7th/nvim-cmp' use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-path' - use 'kyazdani42/nvim-web-devicons' - use 'norcalli/nvim-colorizer.lua' - use 'b3nj5m1n/kommentary' - use 'mhinz/vim-startify' - use "akinsho/toggleterm.nvim" + use 'hrsh7th/nvim-cmp' use "ray-x/lsp_signature.nvim" - use "lukas-reineke/indent-blankline.nvim" use "windwp/nvim-autopairs" + use "lukas-reineke/indent-blankline.nvim" + use 'kyazdani42/nvim-web-devicons' use { 'nvim-telescope/telescope.nvim', @@ -31,15 +28,22 @@ require('packer').startup(function() } use { - "SirVer/ultisnips", + "L3MON4D3/LuaSnip", requires = { - "honza/vim-snippets", - "quangnguyen30192/cmp-nvim-ultisnips" - }, - config = function() - vim.g.UltiSnipsRemoveSelectModeMappings = 0 - end, + "rafamadriz/friendly-snippets", + "saadparwaiz1/cmp_luasnip" + } } + -- use { + -- "SirVer/ultisnips", + -- requires = { + -- "honza/vim-snippets", + -- "quangnguyen30192/cmp-nvim-ultisnips" + -- }, + -- config = function() + -- vim.g.UltiSnipsRemoveSelectModeMappings = 0 + -- end, + -- } use { 'lewis6991/gitsigns.nvim', @@ -56,16 +60,8 @@ require('packer').startup(function() run = ':TSUpdate' } - use { 'alvarosevilla95/luatab.nvim', requires='kyazdani42/nvim-web-devicons' } - use { - 'hoob3rt/lualine.nvim', + 'nvim-lualine/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } - - use { - 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = function() require'nvim-tree'.setup {} end - } end) diff --git a/.config/nvim/lua/stl.lua b/.config/nvim/lua/stl.lua index 633dcaa..74c2d6f 100644 --- a/.config/nvim/lua/stl.lua +++ b/.config/nvim/lua/stl.lua @@ -2,9 +2,9 @@ require'lualine'.setup { options = { icons_enabled = true, theme = 'gruvbox', - component_separators = {'', ''}, - section_separators = {'', ''}, - disabled_filetypes = {'startify', 'NvimTree', 'toggleterm', 'terminal'} + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {'startify', 'terminal', 'netrw'} }, sections = { lualine_a = {'mode'}, -- cgit v1.2.3-70-g09d2