diff options
author | Adam <adam.moloney.stuck@gmail.com> | 2021-10-22 17:04:46 +0200 |
---|---|---|
committer | adamstuck <adam.moloney.stuck@gmail.com> | 2021-10-22 17:12:31 +0200 |
commit | c5903b603f4163f246d0e7f18d6eb588a8123107 (patch) | |
tree | fede70b2cd2bff28555137ca841f5dcd83a7a440 /.config | |
parent | e752b4f815d519063872296b10a3644a30587541 (diff) |
vim + nvim cleanup, UltiSnip -> LuaSnip
Diffstat (limited to '.config')
-rw-r--r-- | .config/nvim/init.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/after.lua | 6 | ||||
-rw-r--r-- | .config/nvim/lua/binds.lua | 7 | ||||
-rw-r--r-- | .config/nvim/lua/opts.lua | 82 | ||||
-rw-r--r-- | .config/nvim/lua/plugins.lua | 44 | ||||
-rw-r--r-- | .config/nvim/lua/stl.lua | 6 |
6 files changed, 64 insertions, 82 deletions
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', '[', '[<c-g>u', opts) map('i', '!', '!<c-g>u', opts) map('i', '?', '?<c-g>u', opts) -map('v', '<A-j>', ":m '>+1<CR>gv=gv", opts) -map('v', '<A-k>', ":m '<-2<CR>gv=gv", opts) +map('v', 'J', ":m '>+1<CR>gv=gv", opts) +map('v', 'K', ":m '<-2<CR>gv=gv", opts) map('n', '<leader>h', ':wincmd h<CR>', opts) map('n', '<leader>j', ':wincmd j<CR>', opts) map('n', '<leader>k', ':wincmd k<CR>', opts) map('n', '<leader>l', ':wincmd l<CR>', opts) -map('n', '<C-n>', ':NvimTreeToggle<CR>', opts) -map('n', '<leader>n', ':NvimTreeFindFile<CR>', opts) - map('n', '<C-p>', '<cmd>Telescope find_files<cr>', opts) map('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', opts) map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', 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 { ['<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 [[ 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'}, |