diff --git a/users/jrpotter/neovim/config/utf8/snippets.lua b/users/jrpotter/neovim/config/utf8/snippets.lua index 5bfb3e0..a79ff6f 100644 --- a/users/jrpotter/neovim/config/utf8/snippets.lua +++ b/users/jrpotter/neovim/config/utf8/snippets.lua @@ -151,6 +151,10 @@ return { { trig = [[\lr]], wordTrig = false }, t('↔') ), + s( + { trig = [[←r]], wordTrig = false }, + t('↔') + ), s( { trig = [[\r]], wordTrig = false }, t('→') @@ -192,13 +196,17 @@ return { -- Other operators s( - { trig = [[\neg]], wordTrig = false }, + { trig = [[\not]], wordTrig = false }, t('¬') ), s( { trig = [[\and]], wordTrig = false }, t('∧') ), + s( + { trig = [[αnd]], wordTrig = false }, + t('∧') + ), s( { trig = [[\or]], wordTrig = false }, t('∨') @@ -223,10 +231,18 @@ return { { 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('∈') @@ -235,5 +251,8 @@ return { { trig = [[\notin]], wordTrig = false }, t('∉') ), - + s( + { trig = [[¬in]], wordTrig = false }, + t('∉') + ), } diff --git a/users/jrpotter/neovim/config/utils/cmp.lua b/users/jrpotter/neovim/config/utils/cmp.lua index e5e21cf..108b220 100644 --- a/users/jrpotter/neovim/config/utils/cmp.lua +++ b/users/jrpotter/neovim/config/utils/cmp.lua @@ -13,7 +13,7 @@ function M.setup() end, }, sources = { - { name = 'luasnip' }, + { name = 'luasnip', option = { show_autosnippets = true } }, { name = 'nvim_lsp' }, { name = 'buffer', diff --git a/users/jrpotter/neovim/config/utils/luasnip.lua b/users/jrpotter/neovim/config/utils/luasnip.lua index 5b78d1c..1167d31 100644 --- a/users/jrpotter/neovim/config/utils/luasnip.lua +++ b/users/jrpotter/neovim/config/utils/luasnip.lua @@ -75,11 +75,24 @@ function M.setup() end, { silent = true, expr = true, remap = true }) -- Allow aborting the active snippet at any point in time. - vim.keymap.set( - { 'n', 'i', 's' }, - '', - 'LuaSnipUnlinkCurrent' - ) + 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 257b34e..8064047 100644 --- a/users/jrpotter/neovim/config/utils/statusline.lua +++ b/users/jrpotter/neovim/config/utils/statusline.lua @@ -24,4 +24,12 @@ 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/default.nix b/users/jrpotter/neovim/default.nix index 1399a0a..7649994 100644 --- a/users/jrpotter/neovim/default.nix +++ b/users/jrpotter/neovim/default.nix @@ -20,6 +20,7 @@ let lualine_y = { require('utils.statusline').get_active_lsp, require('utils.statusline').get_dap_status, + require('utils.statusline').get_autoexpand_status, }, lualine_z = {'%c:%l:%%%p'}, }, @@ -31,7 +32,9 @@ let plugin = pkgs.vimPlugins.luasnip; config = '' require('utils.luasnip').setup() - require('luasnip').add_snippets('all', require('utf8.snippets')) + require('luasnip').add_snippets('all', require('utf8.snippets'), { + type = "autosnippets", + }) ${config.programs.neovim.nvim-snippets} ''; };