Drop luasnip.

main
Joshua Potter 2024-09-29 16:04:55 -06:00
parent 975c01e546
commit 1aae0aa6ae
5 changed files with 0 additions and 387 deletions

View File

@ -2,18 +2,11 @@ local M = {}
local cmp = require("cmp") local cmp = require("cmp")
local cmp_buffer = require("cmp_buffer") local cmp_buffer = require("cmp_buffer")
local luasnip = require("luasnip")
local types = require("cmp.types") local types = require("cmp.types")
function M.setup() function M.setup()
cmp.setup { cmp.setup {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = { sources = {
{ name = "luasnip", option = { show_autosnippets = true } },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ {
name = "buffer", name = "buffer",
@ -70,8 +63,6 @@ function M.setup()
["<c-n>"] = cmp.mapping(function(fallback) ["<c-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else else
fallback() fallback()
end end
@ -80,8 +71,6 @@ function M.setup()
["<c-p>"] = cmp.mapping(function(fallback) ["<c-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else else
fallback() fallback()
end end

View File

@ -1,98 +0,0 @@
local M = {}
local luasnip = require("luasnip")
local types = require("luasnip.util.types")
function M.visual_isn(pos)
local d = luasnip.dynamic_node
local i = luasnip.insert_node
local isn = luasnip.indent_snippet_node
local sn = luasnip.snippet_node
return isn(pos, d(1, function(_, parent)
local res, env = {}, parent.snippet.env
for _, ele in ipairs(env.LS_SELECT_DEDENT or {}) do
table.insert(res, ele)
end
return sn(nil, i(1, res))
end), "$PARENT_INDENT\t")
end
function M.choice_index(choice_node)
for i, c in ipairs(choice_node.choices) do
if c == choice_node.active_choice then
return i
end
end
return 1
end
function M.setup()
luasnip.config.setup {
region_check_events = "InsertEnter",
delete_check_events = "InsertLeave",
store_selection_keys = "<tab>",
enable_autosnippets = true,
ext_opts = {
[types.snippet] = {
active = {
virt_text = { { "", "DiagnosticWarn" } },
},
},
[types.insertNode] = {
passive = {
hl_group = "DiagnosticVirtualTextWarn",
},
},
[types.choiceNode] = {
active = {
hl_group = "DiagnosticVirtualTextHint",
virt_text = { { "", "DiagnosticHint" } },
},
},
},
}
-- Track where we are expanding the snippet.
luasnip.env_namespace("INFO", {
init = function(info) return { POS = info.pos } end,
})
vim.keymap.set({ "i", "s" }, "<c-e>", function()
if luasnip.choice_active() then
return "<Plug>luasnip-next-choice"
else
return "<c-e>"
end
end, { silent = true, expr = true, remap = true })
vim.keymap.set({ "i", "s" }, "<c-y>", function()
if luasnip.choice_active() then
return "<Plug>luasnip-prev-choice"
else
return "<c-y>"
end
end, { silent = true, expr = true, remap = true })
-- Allow aborting the active snippet at any point in time.
vim.keymap.set({ "n", "i", "s" }, "<c-l>", "<cmd>LuaSnipUnlinkCurrent<cr>")
-- Allow toggling autoexpansion on and off. This is more or less the intended
-- approach: https://github.com/L3MON4D3/LuaSnip/issues/832#issuecomment-1474993417
luasnip.expand_auto_on = true
local expand_auto = luasnip.expand_auto
local toggle_expand_auto = function()
if luasnip.expand_auto_on then
luasnip.expand_auto = function() end
else
luasnip.expand_auto = expand_auto
end
luasnip.expand_auto_on = not luasnip.expand_auto_on
end
toggle_expand_auto()
vim.keymap.set({ "n", "i", "s" }, "", toggle_expand_auto)
end
return M

View File

@ -24,12 +24,4 @@ function M.get_dap_status()
end end
end end
function M.get_autoexpand_status()
if require('luasnip').expand_auto_on then
return "🟢 auto"
else
return "🔴 auto"
end
end
return M return M

View File

@ -1,258 +0,0 @@
local ls = require('luasnip')
local s = ls.snippet
local t = ls.text_node
return {
-- Superscripts
s(
{ trig = [[\^+]], wordTrig = false },
t("")
),
s(
{ trig = [[\^-]], wordTrig = false },
t("")
),
s(
{ trig = [[\^0]], wordTrig = false },
t("")
),
s(
{ trig = [[\^1]], wordTrig = false },
t("¹")
),
s(
{ trig = [[\^2]], wordTrig = false },
t("²")
),
s(
{ trig = [[\^3]], wordTrig = false },
t("³")
),
s(
{ trig = [[\^4]], wordTrig = false },
t("")
),
s(
{ trig = [[\^5]], wordTrig = false },
t("")
),
s(
{ trig = [[\^6]], wordTrig = false },
t("")
),
s(
{ trig = [[\^7]], wordTrig = false },
t("")
),
s(
{ trig = [[\^8]], wordTrig = false },
t("")
),
s(
{ trig = [[\^9]], wordTrig = false },
t("")
),
-- Subscripts
s(
{ trig = [[\_+]], wordTrig = false },
t("")
),
s(
{ trig = [[\_-]], wordTrig = false },
t("")
),
s(
{ trig = [[\_0]], wordTrig = false },
t("")
),
s(
{ trig = [[\_1]], wordTrig = false },
t("")
),
s(
{ trig = [[\_2]], wordTrig = false },
t("")
),
s(
{ trig = [[\_3]], wordTrig = false },
t("")
),
s(
{ trig = [[\_4]], wordTrig = false },
t("")
),
s(
{ trig = [[\_5]], wordTrig = false },
t("")
),
s(
{ trig = [[\_6]], wordTrig = false },
t("")
),
s(
{ trig = [[\_7]], wordTrig = false },
t("")
),
s(
{ trig = [[\_8]], wordTrig = false },
t("")
),
s(
{ trig = [[\_9]], wordTrig = false },
t("")
),
s(
{ trig = [[\_a]], wordTrig = false },
t("")
),
s(
{ trig = [[\_i]], wordTrig = false },
t("")
),
s(
{ trig = [[\_j]], wordTrig = false },
t("")
),
s(
{ trig = [[\_k]], wordTrig = false },
t("")
),
s(
{ trig = [[\_m]], wordTrig = false },
t("")
),
s(
{ trig = [[\_n]], wordTrig = false },
t("")
),
-- Lists
s(
{ trig = [[\.]], wordTrig = false },
t("·")
),
s(
{ trig = [[\circ]], wordTrig = false },
t("")
),
-- Arrows
s(
{ trig = [[\d]], wordTrig = false },
t("")
),
s(
{ trig = [[\l]], wordTrig = false },
t("")
),
s(
{ trig = [[\lr]], wordTrig = false },
t("")
),
s(
{ trig = [[←r]], wordTrig = false },
t("")
),
s(
{ trig = [[\r]], wordTrig = false },
t("")
),
s(
{ trig = [[\u]], wordTrig = false },
t("")
),
-- Greek letters
s(
{ trig = [[\a]], wordTrig = false },
t("α")
),
s(
{ trig = [[\b]], wordTrig = false },
t("β")
),
s(
{ trig = [[\g]], wordTrig = false },
t("γ")
),
s(
{ trig = [[\e]], wordTrig = false },
t("ε")
),
s(
{ trig = [[\pi]], wordTrig = false },
t("π")
),
s(
{ trig = [[\s]], wordTrig = false },
t("σ")
),
s(
{ trig = [[\z]], wordTrig = false },
t("ζ")
),
-- Other operators
s(
{ trig = [[\not]], wordTrig = false },
t("¬")
),
s(
{ trig = [[\and]], wordTrig = false },
t("")
),
s(
{ trig = [[αnd]], wordTrig = false },
t('')
),
s(
{ trig = [[\or]], wordTrig = false },
t("")
),
s(
{ trig = [[\iff]], wordTrig = false },
t("")
),
s(
{ trig = [[\imp]], wordTrig = false },
t("")
),
s(
{ trig = [[\cap]], wordTrig = false },
t("")
),
s(
{ trig = [[\cup]], wordTrig = false },
t("")
),
s(
{ trig = [[\leq]], wordTrig = false },
t("")
),
s(
{ trig = [[←eq]], wordTrig = false },
t("")
),
s(
{ trig = [[\geq]], wordTrig = false },
t("")
),
s(
{ trig = [[γeq]], wordTrig = false },
t("")
),
s(
{ trig = [[\in]], wordTrig = false },
t("")
),
s(
{ trig = [[\notin]], wordTrig = false },
t("")
),
s(
{ trig = [[¬in]], wordTrig = false },
t("")
),
}

View File

@ -28,16 +28,6 @@ let
''; '';
}; };
luasnip = {
plugin = pkgs.vimPlugins.luasnip;
config = ''
require("utils.luasnip").setup()
require("luasnip").add_snippets("all", require("utils.utf8"), {
type = "autosnippets",
})
'';
};
nvim-cmp = { nvim-cmp = {
plugin = pkgs.vimPlugins.nvim-cmp; plugin = pkgs.vimPlugins.nvim-cmp;
config = '' config = ''
@ -129,7 +119,6 @@ in
} else p) [ } else p) [
colorscheme # Is always first. colorscheme # Is always first.
lualine lualine
luasnip
nvim-cmp nvim-cmp
nvim-dap nvim-dap
nvim-lspconfig nvim-lspconfig
@ -137,7 +126,6 @@ in
nvim-treesitter nvim-treesitter
pkgs.vimPlugins.cmp-buffer pkgs.vimPlugins.cmp-buffer
pkgs.vimPlugins.cmp-nvim-lsp pkgs.vimPlugins.cmp-nvim-lsp
pkgs.vimPlugins.cmp_luasnip
pkgs.vimPlugins.nvim-web-devicons pkgs.vimPlugins.nvim-web-devicons
pkgs.vimPlugins.vim-prettier pkgs.vimPlugins.vim-prettier
]; ];