Skip to content

Commit

Permalink
fix luasnip
Browse files Browse the repository at this point in the history
  • Loading branch information
myth929 committed Dec 12, 2023
1 parent 1dbf17a commit 33194b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"LuaSnip": { "branch": "master", "commit": "954c81b53989097faaff0fabc11c29575288c3e1" },
"bufferline.nvim": { "branch": "main", "commit": "6ecd37e0fa8b156099daedd2191130e083fb1490" },
"catppuccin": { "branch": "main", "commit": "a2107df4379d66e72a36a89792603151cebec1bf" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
Expand Down
36 changes: 31 additions & 5 deletions lua/pluginsConfig/plugins/auto-completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,51 @@ return {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
'L3MON4D3/LuaSnip',
"saadparwaiz1/cmp_luasnip",
},
},
config = function()
local cmp = require "cmp"
require("cmp").setup {
preselect = cmp.PreselectMode.None,
snippet = { -- snippet 插件设置
snippet = {
expand = function(args)
require("snippet").lsp_expand(args.body)
end,
require 'luasnip'.lsp_expand(args.body)
end
},
mapping = cmp.mapping.preset.insert { -- 快捷键
["<Tab>"] = cmp.mapping.select_next_item(),
["<S-Tab>"] = cmp.mapping.select_prev_item(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("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",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("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",
}),
["<CR>"] = cmp.mapping.confirm(),
},
sources = { -- 补全优先级. LSP 优先级最高, 其次是 buffer 和 path
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
Expand Down
1 change: 1 addition & 0 deletions lua/pluginsConfig/plugins/lint-pretty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ return {
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
vue = { "prettier" },
lua = { "stylua" },
},
format_on_save = {
Expand Down

0 comments on commit 33194b7

Please sign in to comment.