Drop luasnip.
parent
975c01e546
commit
1aae0aa6ae
|
@ -2,18 +2,11 @@ local M = {}
|
|||
|
||||
local cmp = require("cmp")
|
||||
local cmp_buffer = require("cmp_buffer")
|
||||
local luasnip = require("luasnip")
|
||||
local types = require("cmp.types")
|
||||
|
||||
function M.setup()
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "luasnip", option = { show_autosnippets = true } },
|
||||
{ name = "nvim_lsp" },
|
||||
{
|
||||
name = "buffer",
|
||||
|
@ -70,8 +63,6 @@ function M.setup()
|
|||
["<c-n>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
@ -80,8 +71,6 @@ function M.setup()
|
|||
["<c-p>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -24,12 +24,4 @@ function M.get_dap_status()
|
|||
end
|
||||
end
|
||||
|
||||
function M.get_autoexpand_status()
|
||||
if require('luasnip').expand_auto_on then
|
||||
return "🟢 auto"
|
||||
else
|
||||
return "🔴 auto"
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -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("∉")
|
||||
),
|
||||
}
|
|
@ -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 = {
|
||||
plugin = pkgs.vimPlugins.nvim-cmp;
|
||||
config = ''
|
||||
|
@ -129,7 +119,6 @@ in
|
|||
} else p) [
|
||||
colorscheme # Is always first.
|
||||
lualine
|
||||
luasnip
|
||||
nvim-cmp
|
||||
nvim-dap
|
||||
nvim-lspconfig
|
||||
|
@ -137,7 +126,6 @@ in
|
|||
nvim-treesitter
|
||||
pkgs.vimPlugins.cmp-buffer
|
||||
pkgs.vimPlugins.cmp-nvim-lsp
|
||||
pkgs.vimPlugins.cmp_luasnip
|
||||
pkgs.vimPlugins.nvim-web-devicons
|
||||
pkgs.vimPlugins.vim-prettier
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue