From 7df52095b08341146f7eee633363faa74a639b13 Mon Sep 17 00:00:00 2001 From: Adam <56338480+adastx@users.noreply.github.com> Date: Fri, 8 Oct 2021 22:14:57 +0200 Subject: Vim disabled swapfiles, working snippets --- .config/nvim/lua/opts.lua | 43 ++++++++++++++++++++++++++----------------- .config/nvim/lua/plugins.lua | 21 +++++++++++++++------ .config/nvim/lua/setup.lua | 1 + 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua index 126d6c4..ecae0af 100644 --- a/.config/nvim/lua/opts.lua +++ b/.config/nvim/lua/opts.lua @@ -1,4 +1,3 @@ --- SNIPPETS local nvim_lsp = require('lspconfig') local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) @@ -11,14 +10,23 @@ for _, lsp in ipairs(servers) do end vim.o.completeopt = 'menuone,noselect' -local luasnip = require 'luasnip' -- CMP local cmp = require 'cmp' + +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil +end + cmp.setup { snippet = { expand = function(args) - require('luasnip').lsp_expand(args.body) + vim.fn["UltiSnips#Anon"](args.body) end, }, mapping = { @@ -26,34 +34,35 @@ cmp.setup { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = 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), '') + [""] = cmp.mapping(function(fallback) + if vim.fn.complete_info()["selected"] == -1 and vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then + vim.fn.feedkeys(t("=UltiSnips#ExpandSnippet()")) + elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then + vim.fn.feedkeys(t(":call UltiSnips#JumpForwards()")) + elseif vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(""), "n") 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), '') + end, { "i", "s", }), + [""] = cmp.mapping(function(fallback) + if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then + return vim.fn.feedkeys(t(":call UltiSnips#JumpBackwards()")) + elseif vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(""), "n") else fallback() end - end, + end, { "i", "s", }), }, sources = { + { name = 'ultisnips' }, { name = 'nvim_lsp' }, - { name = 'luasnip' }, }, } diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index ebcee68..3ae9343 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -11,8 +11,6 @@ require('packer').startup(function() use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-path' - use 'saadparwaiz1/cmp_luasnip' - use 'L3MON4D3/LuaSnip' use 'kyazdani42/nvim-web-devicons' use 'norcalli/nvim-colorizer.lua' use 'b3nj5m1n/kommentary' @@ -21,13 +19,24 @@ require('packer').startup(function() use { 'nvim-telescope/telescope.nvim', requires = { - {'nvim-lua/popup.nvim'}, - {'nvim-lua/plenary.nvim'}, - {'nvim-telescope/telescope-fzy-native.nvim'}, - {'BurntSushi/ripgrep'} + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-fzy-native.nvim', + 'BurntSushi/ripgrep' } } + use { + "SirVer/ultisnips", + requires = { + "honza/vim-snippets", + "quangnguyen30192/cmp-nvim-ultisnips" + }, + config = function() + vim.g.UltiSnipsRemoveSelectModeMappings = 0 + end, + } + use { 'lewis6991/gitsigns.nvim', requires = { diff --git a/.config/nvim/lua/setup.lua b/.config/nvim/lua/setup.lua index 9c4d737..fe585be 100644 --- a/.config/nvim/lua/setup.lua +++ b/.config/nvim/lua/setup.lua @@ -25,6 +25,7 @@ set.timeout = false set.ttimeoutlen = 200 set.wrap = false set.fcs = 'eob: ' +set.swapfile = false vim.cmd('colorscheme codedark') vim.cmd('highlight CursorLineNr cterm=bold ctermfg=Yellow ctermbg=none') -- cgit v1.2.3-70-g09d2