diff options
author | Adam <56338480+adastx@users.noreply.github.com> | 2021-10-08 22:14:57 +0200 |
---|---|---|
committer | Adam <56338480+adastx@users.noreply.github.com> | 2021-10-08 22:14:57 +0200 |
commit | 7df52095b08341146f7eee633363faa74a639b13 (patch) | |
tree | 1cab13c2ef5ae301ec5460eb2e2089ad0b71cff2 /.config/nvim/lua | |
parent | beb0f05bb24305d81018f84cfec02d73cccc447c (diff) |
Vim disabled swapfiles, working snippets
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/opts.lua | 43 | ||||
-rw-r--r-- | .config/nvim/lua/plugins.lua | 21 | ||||
-rw-r--r-- | .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 { ['<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 { 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), '') + ["<Tab>"] = cmp.mapping(function(fallback) + if vim.fn.complete_info()["selected"] == -1 and vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then + vim.fn.feedkeys(t("<C-R>=UltiSnips#ExpandSnippet()<CR>")) + elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then + vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpForwards()<CR>")) + elseif vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t("<C-n>"), "n") 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), '') + 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>")) + elseif vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t("<C-p>"), "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,14 +19,25 @@ 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 = { 'nvim-lua/plenary.nvim' 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') |