From 1aae0aa6ae3b9cf7d94a3bf35131b1c0a3675da1 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Sun, 29 Sep 2024 16:04:55 -0600 Subject: [PATCH] Drop luasnip. --- users/jrpotter/neovim/config/utils/cmp.lua | 11 - .../jrpotter/neovim/config/utils/luasnip.lua | 98 ------- .../neovim/config/utils/statusline.lua | 8 - users/jrpotter/neovim/config/utils/utf8.lua | 258 ------------------ users/jrpotter/neovim/default.nix | 12 - 5 files changed, 387 deletions(-) delete mode 100644 users/jrpotter/neovim/config/utils/luasnip.lua delete mode 100644 users/jrpotter/neovim/config/utils/utf8.lua diff --git a/users/jrpotter/neovim/config/utils/cmp.lua b/users/jrpotter/neovim/config/utils/cmp.lua index d279b96..12a0408 100644 --- a/users/jrpotter/neovim/config/utils/cmp.lua +++ b/users/jrpotter/neovim/config/utils/cmp.lua @@ -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() [""] = 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() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) else fallback() end diff --git a/users/jrpotter/neovim/config/utils/luasnip.lua b/users/jrpotter/neovim/config/utils/luasnip.lua deleted file mode 100644 index 2187198..0000000 --- a/users/jrpotter/neovim/config/utils/luasnip.lua +++ /dev/null @@ -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 = "", - 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" }, "", function() - if luasnip.choice_active() then - return "luasnip-next-choice" - else - return "" - end - end, { silent = true, expr = true, remap = true }) - - vim.keymap.set({ "i", "s" }, "", function() - if luasnip.choice_active() then - return "luasnip-prev-choice" - else - return "" - end - end, { silent = true, expr = true, remap = true }) - - -- Allow aborting the active snippet at any point in time. - vim.keymap.set({ "n", "i", "s" }, "", "LuaSnipUnlinkCurrent") - - -- 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 diff --git a/users/jrpotter/neovim/config/utils/statusline.lua b/users/jrpotter/neovim/config/utils/statusline.lua index 8462af2..9b4b612 100644 --- a/users/jrpotter/neovim/config/utils/statusline.lua +++ b/users/jrpotter/neovim/config/utils/statusline.lua @@ -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 diff --git a/users/jrpotter/neovim/config/utils/utf8.lua b/users/jrpotter/neovim/config/utils/utf8.lua deleted file mode 100644 index 2c0f50e..0000000 --- a/users/jrpotter/neovim/config/utils/utf8.lua +++ /dev/null @@ -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("βˆ‰") - ), -} diff --git a/users/jrpotter/neovim/default.nix b/users/jrpotter/neovim/default.nix index 92e29cc..f9e2c14 100644 --- a/users/jrpotter/neovim/default.nix +++ b/users/jrpotter/neovim/default.nix @@ -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 ];