nvim: plugins: Switch to luasnip

This commit is contained in:
Sanchayan Maity 2021-10-18 10:43:20 +05:30
parent 8e1f6a8834
commit bfb4d258b3
3 changed files with 12 additions and 14 deletions

View File

@ -1,5 +1,10 @@
local cmp = require 'cmp' local cmp = require 'cmp'
local lspkind = require 'lspkind' local lspkind = require 'lspkind'
local luasnip = require 'luasnip'
-- https://github.com/hrsh7th/nvim-cmp/issues/180#issuecomment-915405589
luasnip.config.set_config { history = true }
require('luasnip.loaders.from_vscode').load {}
cmp.setup { cmp.setup {
preselect = cmp.PreselectMode.None, preselect = cmp.PreselectMode.None,
@ -14,7 +19,7 @@ cmp.setup {
nvim_lsp = '[Lsp]', nvim_lsp = '[Lsp]',
nvim_lua = '[Lua]', nvim_lua = '[Lua]',
path = '[Path]', path = '[Path]',
vsnip = '[Snippet]', luasnip = '[Snippet]',
})[entry.source.name] })[entry.source.name]
vim_item.kind = lspkind.presets.default[vim_item.kind] vim_item.kind = lspkind.presets.default[vim_item.kind]
return vim_item return vim_item
@ -22,7 +27,7 @@ cmp.setup {
}, },
snippet = { snippet = {
expand = function (args) expand = function (args)
vim.fn["vsnip#anonymous"](args.body) luasnip.lsp_expand(args.body)
end end
}, },
documentation = { documentation = {
@ -42,7 +47,7 @@ cmp.setup {
priority = 100 priority = 100
}, },
{ {
name = 'vsnip', name = 'luasnip',
priority = 80 priority = 80
}, },
{ {

View File

@ -87,12 +87,6 @@ vim.g.vimtex_view_general_options = '--unique \\@pdf\\#src:@tex:@line:@col'
vim.g['sneak#label'] = 1 vim.g['sneak#label'] = 1
vim.g['sneak#s_next'] = 1 vim.g['sneak#s_next'] = 1
vim.g['sneak#use_ic_scs'] = 0 vim.g['sneak#use_ic_scs'] = 0
-- vsnip settings
vim.g.vsnip_filetypes = {
javascriptreact = {'javascript'},
typescript = {'javascript'},
typescriptreact = {'javascript', 'javascriptreact', 'typescript'}
}
-- dirvish -- dirvish
vim.g.dirvish_relative_paths = 1 vim.g.dirvish_relative_paths = 1
-- dispatch -- dispatch

View File

@ -23,9 +23,11 @@ local init = function ()
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-nvim-lua',
'hrsh7th/cmp-buffer', 'hrsh7th/cmp-buffer',
'hrsh7th/cmp-vsnip',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'onsails/lspkind-nvim' 'onsails/lspkind-nvim',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
'rafamadriz/friendly-snippets'
} }
} }
-- Git support -- Git support
@ -122,9 +124,6 @@ local init = function ()
use { use {
'chentau/marks.nvim', 'chentau/marks.nvim',
} }
-- Snippets
use 'hrsh7th/vim-vsnip'
use 'rafamadriz/friendly-snippets'
-- For files with ANSI escape sequences -- For files with ANSI escape sequences
use { use {
'powerman/vim-plugin-AnsiEsc', 'powerman/vim-plugin-AnsiEsc',