Skip to content

Commit

Permalink
Fix snippet bug caused by latest upstream version of nvim, from nvim-…
Browse files Browse the repository at this point in the history
…snippets back to luasnip.
  • Loading branch information
songliyu committed Aug 25, 2024
1 parent 22e093c commit f7e3597
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 76 deletions.
3 changes: 3 additions & 0 deletions lazy-lock-nvim_lsp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"LuaSnip": { "branch": "master", "commit": "7ad2eaeaca56d6ed63acacbfc114b99f1f67b982" },
"aerial.nvim": { "branch": "master", "commit": "4e77964569ef47a70f9bb76c668dcfea2d089d5a" },
"bufdelete.nvim": { "branch": "master", "commit": "576a142108117f9326365bf4f7c494619aed55fe" },
"bufferline.nvim": { "branch": "main", "commit": "99337f63f0a3c3ab9519f3d1da7618ca4f91cffe" },
Expand All @@ -9,6 +10,7 @@
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-tabnine": { "branch": "main", "commit": "d52aae40ee86b62960c31a003352ddfc9e31c8d2" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "9a06e83527407a7600a2fe4e0d10adf432b6215e" },
"copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" },
"csv.vim": { "branch": "master", "commit": "4d5255829afe3b6badb0c8a040116704c0d3213c" },
Expand Down Expand Up @@ -38,6 +40,7 @@
"mini.pairs": { "branch": "main", "commit": "927d19cbdd0e752ab1c7eed87072e71d2cd6ff51" },
"neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" },
"nvim-FeMaco.lua": { "branch": "main", "commit": "96bbf843595dbe865838b3f2484b73557f34700c" },
"nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" },
"nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" },
"nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
"nvim-colorizer.lua": { "branch": "master", "commit": "08bd34bf0ed79723f62764c7f9ca70516d461d0d" },
Expand Down
152 changes: 76 additions & 76 deletions lua/ysl/lsp/nvim_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,65 +212,65 @@ return {
})
end
},
-- {
-- 'L3MON4D3/LuaSnip', -- Snippets plugin
-- build = 'make install_jsregexp',
-- lazy = true,
-- config = function ()
-- require('luasnip.loaders.from_vscode').lazy_load({ paths = {
-- U.CUSTOM_SNIPPETS_PATH,
-- U.path({vim.fn.stdpath('data'), 'lazy', 'friendly-snippets'}),
-- U.path({vim.fn.stdpath('data'), 'lazy', 'cython-snips'}),
-- }})
-- local luasnip = require('luasnip')
-- -- Stop snippets when you leave to normal mode
-- vim.api.nvim_create_autocmd('ModeChanged', {
-- callback = function()
-- if ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i')
-- and luasnip.session.current_nodes[vim.api.nvim_get_current_buf()]
-- and not luasnip.session.jump_active
-- then
-- luasnip.unlink_current()
-- end
-- end
-- })
-- end
-- },
{
'garymjr/nvim-snippets',
dependencies = {
'rafamadriz/friendly-snippets',
},
keys = {
{
'<TAB>',
function()
return vim.snippet.active({ direction = 1 }) and '<cmd>lua vim.snippet.jump(1)<cr>' or '<TAB>'
end,
expr = true,
silent = true,
mode = { 'i', 's' },
},
{
'<S-TAB>',
function()
return vim.snippet.active({ direction = -1 }) and '<cmd>lua vim.snippet.jump(-1)<cr>' or '<S-TAB>'
end,
expr = true,
silent = true,
mode = { 'i', 's' },
},
},
config = function()
require('snippets').setup({
friendly_snippets = true,
search_paths = {
U.CUSTOM_SNIPPETS_PATH,
U.path({vim.fn.stdpath('data'), 'lazy', 'cython-snips'}),
}
'L3MON4D3/LuaSnip', -- Snippets plugin
build = 'make install_jsregexp',
lazy = true,
config = function ()
require('luasnip.loaders.from_vscode').lazy_load({ paths = {
U.CUSTOM_SNIPPETS_PATH,
U.path({vim.fn.stdpath('data'), 'lazy', 'friendly-snippets'}),
U.path({vim.fn.stdpath('data'), 'lazy', 'cython-snips'}),
}})
local luasnip = require('luasnip')
-- Stop snippets when you leave to normal mode
vim.api.nvim_create_autocmd('ModeChanged', {
callback = function()
if ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i')
and luasnip.session.current_nodes[vim.api.nvim_get_current_buf()]
and not luasnip.session.jump_active
then
luasnip.unlink_current()
end
end
})
end
},
-- {
-- 'garymjr/nvim-snippets',
-- dependencies = {
-- 'rafamadriz/friendly-snippets',
-- },
-- keys = {
-- {
-- '<TAB>',
-- function()
-- return vim.snippet.active({ direction = 1 }) and '<cmd>lua vim.snippet.jump(1)<cr>' or '<TAB>'
-- end,
-- expr = true,
-- silent = true,
-- mode = { 'i', 's' },
-- },
-- {
-- '<S-TAB>',
-- function()
-- return vim.snippet.active({ direction = -1 }) and '<cmd>lua vim.snippet.jump(-1)<cr>' or '<S-TAB>'
-- end,
-- expr = true,
-- silent = true,
-- mode = { 'i', 's' },
-- },
-- },
-- config = function()
-- require('snippets').setup({
-- friendly_snippets = true,
-- search_paths = {
-- U.CUSTOM_SNIPPETS_PATH,
-- U.path({vim.fn.stdpath('data'), 'lazy', 'cython-snips'}),
-- }
-- })
-- end
-- },
{
-- 'ysl2/nvim-cmp', -- Autocompletion plugin
'hrsh7th/nvim-cmp', -- Autocompletion plugin
Expand All @@ -279,9 +279,9 @@ return {
'hrsh7th/cmp-nvim-lsp', -- LSP source for nvim-cmp
'hrsh7th/cmp-buffer',
'https://codeberg.org/FelipeLema/cmp-async-path',
-- 'L3MON4D3/LuaSnip', -- Snippets plugin
'L3MON4D3/LuaSnip', -- Snippets plugin
'garymjr/nvim-snippets',
-- 'saadparwaiz1/cmp_luasnip', -- Snippets source for nvim-cmp
'saadparwaiz1/cmp_luasnip', -- Snippets source for nvim-cmp
{
'tzachar/cmp-tabnine',
build = (vim.fn.has('win32') == 1) and 'powershell ./install.ps1' or './install.sh',
Expand All @@ -295,14 +295,14 @@ return {
config = function ()
-- Set up nvim-cmp.
local cmp = require('cmp')
-- local luasnip = require('luasnip')
local luasnip = require('luasnip')
cmp.setup({
completion = { completeopt = 'menu,menuone,noinsert' },
snippet = {
expand = function(args)
-- luasnip.lsp_expand(args.body) -- For `luasnip` users.
-- vim.snippet.active()
vim.snippet.expand(args.body)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
-- vim.snippet.active() -- No need to add this at all, whether or not `luasnip` or `nvim-snippets` users.
-- vim.snippet.expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
Expand All @@ -325,24 +325,24 @@ return {
-- fallback()
-- end
-- end, { 'i', 's' }),
-- ['<C-j>'] = cmp.mapping(function(fallback)
-- if luasnip.expand_or_jumpable() then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), "")
-- else
-- fallback()
-- end
-- end, { 'i', 's' }),
-- ['<C-k>'] = cmp.mapping(function(fallback)
-- if luasnip.jumpable(-1) then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), "")
-- else
-- fallback()
-- end
-- end, { 'i', 's' }),
['<C-j>'] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), "")
else
fallback()
end
end, { 'i', 's' }),
['<C-k>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), "")
else
fallback()
end
end, { 'i', 's' }),
}),
sources = cmp.config.sources({
{ name = 'cmp_tabnine' },
-- { name = 'luasnip' },
{ name = 'luasnip' },
{ name = 'snippets' },
{ name = 'lazydev' },
{ name = 'nvim_lua' },
Expand Down

0 comments on commit f7e3597

Please sign in to comment.