From eaf110c96f820e77887db7950de5647ccc38213d Mon Sep 17 00:00:00 2001 From: gwg313 Date: Thu, 26 Sep 2024 11:35:37 -0400 Subject: [PATCH] feat: neovim plugins update --- home-manager/modules/neovim/autocommands.nix | 21 + home-manager/modules/neovim/default.nix | 2 + home-manager/modules/neovim/keymappings.nix | 387 ++++++++++++++ .../modules/neovim/plugins/default.nix | 3 + home-manager/modules/neovim/plugins/lsp.nix | 26 + .../modules/neovim/plugins/luasnip.nix | 41 ++ .../neovim/plugins/mini-indentscope.nix | 37 ++ .../modules/neovim/plugins/mini-surround.nix | 23 + .../modules/neovim/plugins/todo-comments.nix | 50 ++ .../modules/neovim/snippets/tex/greek.lua | 105 ++++ .../modules/neovim/snippets/tex/math.lua | 492 ++++++++++++++++++ .../modules/neovim/snippets/tex/test.tex | 5 + hosts/grymforge/configuration.nix | 9 +- 13 files changed, 1195 insertions(+), 6 deletions(-) create mode 100644 home-manager/modules/neovim/autocommands.nix create mode 100644 home-manager/modules/neovim/keymappings.nix create mode 100644 home-manager/modules/neovim/plugins/luasnip.nix create mode 100644 home-manager/modules/neovim/plugins/mini-indentscope.nix create mode 100644 home-manager/modules/neovim/plugins/mini-surround.nix create mode 100644 home-manager/modules/neovim/snippets/tex/greek.lua create mode 100644 home-manager/modules/neovim/snippets/tex/math.lua create mode 100644 home-manager/modules/neovim/snippets/tex/test.tex diff --git a/home-manager/modules/neovim/autocommands.nix b/home-manager/modules/neovim/autocommands.nix new file mode 100644 index 0000000..562efae --- /dev/null +++ b/home-manager/modules/neovim/autocommands.nix @@ -0,0 +1,21 @@ +{...}: { + programs.nixvim = { + autoCmd = [ + # Remove trailing whitespace on save + { + event = "BufWrite"; + command = "%s/\\s\\+$//e"; + } + + { + event = "FileType"; + pattern = [ + "tex" + "latex" + "markdown" + ]; + command = "setlocal spell spelllang=en_us"; + } + ]; + }; +} diff --git a/home-manager/modules/neovim/default.nix b/home-manager/modules/neovim/default.nix index 23e1334..ffeb224 100644 --- a/home-manager/modules/neovim/default.nix +++ b/home-manager/modules/neovim/default.nix @@ -4,6 +4,8 @@ inputs.nixvim.homeManagerModules.nixvim ./options.nix ./plugins + ./autocommands.nix + ./keymappings.nix ]; programs.nixvim = { enable = true; diff --git a/home-manager/modules/neovim/keymappings.nix b/home-manager/modules/neovim/keymappings.nix new file mode 100644 index 0000000..61fbc3f --- /dev/null +++ b/home-manager/modules/neovim/keymappings.nix @@ -0,0 +1,387 @@ +{ + config, + lib, + ... +}: { + programs.nixvim = { + extraConfigLuaPre = '' + function bool2str(bool) return bool and "on" or "off" end + ''; + + keymaps = let + helpers = config.lib.nixvim; + normal = + lib.mapAttrsToList + ( + key: {action, ...} @ attrs: { + mode = "n"; + inherit action key; + options = attrs.options or {}; + } + ) + { + "" = { + action = ""; + }; + + # Esc to clear search results + "" = { + action = "noh"; + }; + + # Backspace delete in normal + "" = { + action = "x"; + }; + + # fix Y behaviour + "Y" = { + action = "y$"; + }; + + # back and fourth between the two most recent files + "" = { + action = "b#"; + }; + + # navigate to left/right window + "[" = { + action = "h"; + options = { + desc = "Left window"; + }; + }; + "]" = { + action = "l"; + options = { + desc = "Right window"; + }; + }; + "." = { + action = "j"; + options = { + desc = "Up window"; + }; + }; + "," = { + action = "k"; + options = { + desc = "Down window"; + }; + }; + + # navigate quickfix list + "" = { + action = "cnext"; + }; + "" = { + action = "cprev"; + }; + + # resize with arrows + "" = { + action = "resize -2"; + }; + "" = { + action = "resize +2"; + }; + "" = { + action = "vertical resize +2"; + }; + "" = { + action = "vertical resize -2"; + }; + + # move current line up/down + # M = Alt key + "" = { + action = "move-2"; + }; + "" = { + action = "move+"; + }; + + "w" = { + action = "w"; # Action to perform (save the file in this case) + options = { + desc = "Save"; + }; + }; + + "j" = { + action = "v:count == 0 ? 'gj' : 'j'"; + options = { + desc = "Move cursor down"; + expr = true; + }; + }; + "k" = { + action = "v:count == 0 ? 'gk' : 'k'"; + options = { + desc = "Move cursor up"; + expr = true; + }; + }; + "q" = { + action = "confirm q"; + options = { + desc = "Quit"; + }; + }; + "" = { + action = "enew"; + options = { + desc = "New file"; + }; + }; + "W" = { + action = "w!"; + options = { + desc = "Force write"; + }; + }; + "Q" = { + action = "q!"; + options = { + desc = "Force quit"; + }; + }; + "|" = { + action = "vsplit"; + options = { + desc = "Vertical split"; + }; + }; + "\\" = { + action = "split"; + options = { + desc = "Horizontal split"; + }; + }; + + "bC" = { + action = "%bd!"; + options = { + desc = "Close all buffers"; + }; + }; + "b]" = { + action = "bnext"; + options = { + desc = "Next buffer"; + }; + }; + "" = { + action = "bnext"; + options = { + desc = "Next buffer (default)"; + }; + }; + "b[" = { + action = "bprevious"; + options = { + desc = "Previous buffer"; + }; + }; + "" = { + action = "bprevious"; + options = { + desc = "Previous buffer"; + }; + }; + + "ud" = { + action.__raw = '' + function () + vim.b.disable_diagnostics = not vim.b.disable_diagnostics + if vim.b.disable_diagnostics then + vim.diagnostic.disable(0) + else + vim.diagnostic.enable(0) + end + vim.notify(string.format("Buffer Diagnostics %s", bool2str(not vim.b.disable_diagnostics), "info")) + end''; + options = { + desc = "Buffer Diagnostics toggle"; + }; + }; + + "uD" = { + action.__raw = '' + function () + vim.g.disable_diagnostics = not vim.g.disable_diagnostics + if vim.g.disable_diagnostics then + vim.diagnostic.disable() + else + vim.diagnostic.enable() + end + vim.notify(string.format("Global Diagnostics %s", bool2str(not vim.g.disable_diagnostics), "info")) + end''; + options = { + desc = "Global Diagnostics toggle"; + }; + }; + + "uf" = { + action.__raw = '' + function () + -- vim.g.disable_autoformat = not vim.g.disable_autoformat + vim.cmd('FormatToggle!') + vim.notify(string.format("Buffer Autoformatting %s", bool2str(not vim.b[0].disable_autoformat), "info")) + end''; + options = { + desc = "Buffer Autoformatting toggle"; + }; + }; + + "uF" = { + action.__raw = '' + function () + -- vim.g.disable_autoformat = not vim.g.disable_autoformat + vim.cmd('FormatToggle') + vim.notify(string.format("Global Autoformatting %s", bool2str(not vim.g.disable_autoformat), "info")) + end''; + options = { + desc = "Global Autoformatting toggle"; + }; + }; + + "uS" = { + action.__raw = '' + function () + if vim.g.spell_enabled then vim.cmd('setlocal nospell') end + if not vim.g.spell_enabled then vim.cmd('setlocal spell') end + vim.g.spell_enabled = not vim.g.spell_enabled + vim.notify(string.format("Spell %s", bool2str(vim.g.spell_enabled), "info")) + end''; + options = { + desc = "Spell toggle"; + }; + }; + + "uw" = { + action.__raw = '' + function () + vim.wo.wrap = not vim.wo.wrap + vim.notify(string.format("Wrap %s", bool2str(vim.wo.wrap), "info")) + end''; + options = { + desc = "Word Wrap toggle"; + }; + }; + + "uh" = { + action.__raw = '' + function () + local curr_foldcolumn = vim.wo.foldcolumn + if curr_foldcolumn ~= "0" then vim.g.last_active_foldcolumn = curr_foldcolumn end + vim.wo.foldcolumn = curr_foldcolumn == "0" and (vim.g.last_active_foldcolumn or "1") or "0" + vim.notify(string.format("Fold Column %s", bool2str(vim.wo.foldcolumn), "info")) + end''; + options = { + desc = "Fold Column toggle"; + }; + }; + + "uc" = { + action.__raw = '' + function () + vim.g.cmp_enabled = not vim.g.cmp_enabled + vim.notify(string.format("Completions %s", bool2str(vim.g.cmp_enabled), "info")) + end''; + options = { + desc = "Completions toggle"; + }; + }; + }; + visual = + lib.mapAttrsToList + ( + key: {action, ...} @ attrs: { + mode = "v"; + inherit action key; + options = attrs.options or {}; + } + ) + { + # Better indenting + "" = { + action = "" = { + action = ">gv"; + options = { + desc = "Indent line"; + }; + }; + ">" = { + action = ">gv"; + options = { + desc = "Indent line"; + }; + }; + + # Move selected line/block in visual mode + "K" = { + action = "m '<-2gv=gv"; + }; + "J" = { + action = "m '>+1gv=gv"; + }; + + # Backspace delete in visual + "" = { + action = "x"; + }; + }; + insert = + lib.mapAttrsToList + ( + key: {action, ...} @ attrs: { + mode = "i"; + inherit action key; + options = attrs.options or {}; + } + ) + { + # Move selected line/block in insert mode + "" = { + action = "gk"; + }; + "" = { + action = ""; + }; + "" = { + action = ""; + }; + "" = { + action = "gj"; + }; + }; + in + helpers.keymaps.mkKeymaps {options.silent = true;} (normal ++ visual ++ insert); + plugins.which-key.settings.spec = [ + { + __unkeyed = "w"; + icon = ""; + } + { + __unkeyed = "W"; + icon = "󰽃"; + } + { + __unkeyed = "/"; + icon = ""; + } + ]; + }; +} diff --git a/home-manager/modules/neovim/plugins/default.nix b/home-manager/modules/neovim/plugins/default.nix index fcdf8dd..7507753 100644 --- a/home-manager/modules/neovim/plugins/default.nix +++ b/home-manager/modules/neovim/plugins/default.nix @@ -16,9 +16,12 @@ _: { ./illuminate.nix ./lightbulb.nix ./lualine.nix + ./luasnip.nix ./lean.nix ./lsp.nix ./mini-bufremove.nix + ./mini-surround.nix + ./mini-indentscope.nix ./navic.nix ./nix.nix ./noice.nix diff --git a/home-manager/modules/neovim/plugins/lsp.nix b/home-manager/modules/neovim/plugins/lsp.nix index 2d4694a..fc153fa 100644 --- a/home-manager/modules/neovim/plugins/lsp.nix +++ b/home-manager/modules/neovim/plugins/lsp.nix @@ -76,6 +76,32 @@ leanls.enable = true; texlab.enable = true; html.enable = true; + + cmake = { + enable = true; + filetypes = ["cmake"]; + }; + + # ccls = { + # enable = true; + # filetypes = [ + # "c" + # "cpp" + # "objc" + # "objcpp" + # ]; + # + # initOptions.compilationDatabaseDirectory = "build"; + # }; + clangd = { + enable = true; + filetypes = [ + "c" + "cpp" + "objc" + "objcpp" + ]; + }; }; }; which-key.settings.spec = [ diff --git a/home-manager/modules/neovim/plugins/luasnip.nix b/home-manager/modules/neovim/plugins/luasnip.nix new file mode 100644 index 0000000..bc8e4db --- /dev/null +++ b/home-manager/modules/neovim/plugins/luasnip.nix @@ -0,0 +1,41 @@ +{pkgs, ...}: { + programs.nixvim = { + plugins.luasnip = { + enable = true; + settings = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + fromLua = [{paths = [../snippets];}]; + }; + extraFiles = { + "personal/luasnip-helper-funcs.lua".text = '' + local M = {} + + local ls = require("luasnip") + local sn = ls.snippet_node + local i = ls.insert_node + + function M.get_ISO_8601_date() + return os.date("%Y-%m-%d") + end + + function M.get_visual(args, parent) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW)) + else + return sn(nil, i(1, ''')) + end + end + + return M + ''; + }; + }; +} diff --git a/home-manager/modules/neovim/plugins/mini-indentscope.nix b/home-manager/modules/neovim/plugins/mini-indentscope.nix new file mode 100644 index 0000000..6e417f2 --- /dev/null +++ b/home-manager/modules/neovim/plugins/mini-indentscope.nix @@ -0,0 +1,37 @@ +{...}: { + programs.nixvim = { + autoCmd = [ + { + event = ["FileType"]; + pattern = [ + "help" + "alpha" + "dashboard" + "neo-tree" + "Trouble" + "trouble" + "lazy" + "mason" + "notify" + "toggleterm" + "lazyterm" + ]; + callback.__raw = '' + function() + vim.b.miniindentscope_disable = true + end + ''; + } + ]; + + plugins = { + mini = { + enable = true; + + modules = { + indentscope = {}; + }; + }; + }; + }; +} diff --git a/home-manager/modules/neovim/plugins/mini-surround.nix b/home-manager/modules/neovim/plugins/mini-surround.nix new file mode 100644 index 0000000..68e9ad0 --- /dev/null +++ b/home-manager/modules/neovim/plugins/mini-surround.nix @@ -0,0 +1,23 @@ +{...}: { + programs.nixvim = { + plugins = { + mini = { + enable = true; + + modules = { + surround = { + mappings = { + add = "gsa"; # -- Add surrounding in Normal and Visual modes + delete = "gsd"; # -- Delete surrounding + find = "gsf"; # -- Find surrounding (to the right) + find_left = "gsF"; # -- Find surrounding (to the left) + highlight = "gsh"; # -- Highlight surrounding + replace = "gsr"; # -- Replace surrounding + update_n_lines = "gsn"; # -- Update `n_lines` + }; + }; + }; + }; + }; + }; +} diff --git a/home-manager/modules/neovim/plugins/todo-comments.nix b/home-manager/modules/neovim/plugins/todo-comments.nix index c51897b..49d3e16 100644 --- a/home-manager/modules/neovim/plugins/todo-comments.nix +++ b/home-manager/modules/neovim/plugins/todo-comments.nix @@ -9,6 +9,56 @@ keywords = "TODO,FIX,HACK"; }; }; + keywords = { + FIX = { + alt = [ + "FIXME" + "BUG" + "FIXIT" + "ISSUE" + ]; + color = "error"; + icon = " "; + }; + HACK = { + color = "warning"; + icon = " "; + }; + NOTE = { + alt = ["INFO"]; + color = "hint"; + icon = " "; + }; + PERF = { + alt = [ + "OPTIM" + "PERFORMANCE" + "OPTIMIZE" + ]; + icon = " "; + }; + TEST = { + alt = [ + "TESTING" + "PASSED" + "FAILED" + ]; + color = "test"; + icon = "⏲ "; + }; + TODO = { + color = "info"; + icon = " "; + }; + WARN = { + alt = [ + "WARNING" + "XXX" + ]; + color = "warning"; + icon = " "; + }; + }; }; }; } diff --git a/home-manager/modules/neovim/snippets/tex/greek.lua b/home-manager/modules/neovim/snippets/tex/greek.lua new file mode 100644 index 0000000..9acc05f --- /dev/null +++ b/home-manager/modules/neovim/snippets/tex/greek.lua @@ -0,0 +1,105 @@ +-- Return snippet tables +return { + s({ trig = ";a", snippetType = "autosnippet" }, { + t("\\alpha"), + }), + s({ trig = ";b", snippetType = "autosnippet" }, { + t("\\beta"), + }), + s({ trig = ";g", snippetType = "autosnippet" }, { + t("\\gamma"), + }), + s({ trig = ";G", snippetType = "autosnippet" }, { + t("\\Gamma"), + }), + s({ trig = ";d", snippetType = "autosnippet" }, { + t("\\delta"), + }), + s({ trig = ";D", snippetType = "autosnippet" }, { + t("\\Delta"), + }), + s({ trig = ";e", snippetType = "autosnippet" }, { + t("\\epsilon"), + }), + s({ trig = ";ve", snippetType = "autosnippet" }, { + t("\\varepsilon"), + }), + s({ trig = ";z", snippetType = "autosnippet" }, { + t("\\zeta"), + }), + s({ trig = ";h", snippetType = "autosnippet" }, { + t("\\eta"), + }), + s({ trig = ";o", snippetType = "autosnippet" }, { + t("\\theta"), + }), + s({ trig = ";vo", snippetType = "autosnippet" }, { + t("\\vartheta"), + }), + s({ trig = ";O", snippetType = "autosnippet" }, { + t("\\Theta"), + }), + s({ trig = ";k", snippetType = "autosnippet" }, { + t("\\kappa"), + }), + s({ trig = ";l", snippetType = "autosnippet" }, { + t("\\lambda"), + }), + s({ trig = ";L", snippetType = "autosnippet" }, { + t("\\Lambda"), + }), + s({ trig = ";m", snippetType = "autosnippet" }, { + t("\\mu"), + }), + s({ trig = ";n", snippetType = "autosnippet" }, { + t("\\nu"), + }), + s({ trig = ";x", snippetType = "autosnippet" }, { + t("\\xi"), + }), + s({ trig = ";X", snippetType = "autosnippet" }, { + t("\\Xi"), + }), + s({ trig = ";i", snippetType = "autosnippet" }, { + t("\\pi"), + }), + s({ trig = ";I", snippetType = "autosnippet" }, { + t("\\Pi"), + }), + s({ trig = ";r", snippetType = "autosnippet" }, { + t("\\rho"), + }), + s({ trig = ";s", snippetType = "autosnippet" }, { + t("\\sigma"), + }), + s({ trig = ";S", snippetType = "autosnippet" }, { + t("\\Sigma"), + }), + s({ trig = ";t", snippetType = "autosnippet" }, { + t("\\tau"), + }), + s({ trig = ";f", snippetType = "autosnippet" }, { + t("\\phi"), + }), + s({ trig = ";vf", snippetType = "autosnippet" }, { + t("\\varphi"), + }), + s({ trig = ";F", snippetType = "autosnippet" }, { + t("\\Phi"), + }), + s({ trig = ";c", snippetType = "autosnippet" }, { + t("\\chi"), + }), + s({ trig = ";p", snippetType = "autosnippet" }, { + t("\\psi"), + }), + s({ trig = ";P", snippetType = "autosnippet" }, { + t("\\Psi"), + }), + s({ trig = ";w", snippetType = "autosnippet" }, { + t("\\omega"), + }), + s({ trig = ";W", snippetType = "autosnippet" }, { + t("\\Omega"), + }), +} diff --git a/home-manager/modules/neovim/snippets/tex/math.lua b/home-manager/modules/neovim/snippets/tex/math.lua new file mode 100644 index 0000000..3cc37da --- /dev/null +++ b/home-manager/modules/neovim/snippets/tex/math.lua @@ -0,0 +1,492 @@ +local helpers = require("personal.luasnip-helper-funcs") +local get_visual = helpers.get_visual + +-- Math context detection +local tex = {} +tex.in_mathzone = function() + return vim.fn["vimtex#syntax#in_mathzone"]() == 1 +end +tex.in_text = function() + return not tex.in_mathzone() +end + +-- Return snippet tables +return { + -- SUPERSCRIPT + s( + { trig = "([%w%)%]%}])'", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- SUBSCRIPT + s( + { trig = "([%w%)%]%}]);", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- SUBSCRIPT AND SUPERSCRIPT + s( + { trig = "([%w%)%]%}])__", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>^{<>}_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- TEXT SUBSCRIPT + s( + { trig = "sd", snippetType = "autosnippet", wordTrig = false }, + fmta("_{\\mathrm{<>}}", { d(1, get_visual) }), + { condition = tex.in_mathzone } + ), + -- SUPERSCRIPT SHORTCUT + -- Places the first alphanumeric character after the trigger into a superscript. + s( + { trig = '([%w%)%]%}])"([%w])', regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + f(function(_, snip) + return snip.captures[2] + end), + }), + { condition = tex.in_mathzone } + ), + -- SUBSCRIPT SHORTCUT + -- Places the first alphanumeric character after the trigger into a subscript. + s( + { trig = "([%w%)%]%}]):([%w])", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + f(function(_, snip) + return snip.captures[2] + end), + }), + { condition = tex.in_mathzone } + ), + -- EULER'S NUMBER SUPERSCRIPT SHORTCUT + s( + { trig = "([^%a])ee", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>e^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- ZERO SUBSCRIPT SHORTCUT + s( + { trig = "([%a%)%]%}])00", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("0"), + }), + { condition = tex.in_mathzone } + ), + -- MINUS ONE SUPERSCRIPT SHORTCUT + s( + { trig = "([%a%)%]%}])11", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("-1"), + }), + { condition = tex.in_mathzone } + ), + -- J SUBSCRIPT SHORTCUT (since jk triggers snippet jump forward) + s( + { trig = "([%a%)%]%}])JJ", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("j"), + }), + { condition = tex.in_mathzone } + ), + -- PLUS SUPERSCRIPT SHORTCUT + s( + { trig = "([%a%)%]%}])%+%+", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("+"), + }), + { condition = tex.in_mathzone } + ), + -- COMPLEMENT SUPERSCRIPT + s( + { trig = "([%a%)%]%}])CC", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("\\complement"), + }), + { condition = tex.in_mathzone } + ), + -- CONJUGATE (STAR) SUPERSCRIPT SHORTCUT + s( + { trig = "([%a%)%]%}])%*%*", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + t("*"), + }), + { condition = tex.in_mathzone } + ), + -- VECTOR, i.e. \vec + s( + { trig = "([^%a])vv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\vec{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- DEFAULT UNIT VECTOR WITH SUBSCRIPT, i.e. \unitvector_{} + s( + { trig = "([^%a])ue", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\unitvector_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- UNIT VECTOR WITH HAT, i.e. \uvec{} + s( + { trig = "([^%a])uv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\uvec{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- MATRIX, i.e. \vec + s( + { trig = "([^%a])mt", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\mat{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- FRACTION + s( + { trig = "([^%a])ff", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\frac{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- ANGLE + s( + { trig = "([^%a])gg", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>\\ang{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- ABSOLUTE VALUE + s( + { trig = "([^%a])aa", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("<>\\abs{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- SQUARE ROOT + s( + { trig = "([^%\\])sq", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\sqrt{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- BINOMIAL SYMBOL + s( + { trig = "([^%\\])bnn", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\binom{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- LOGARITHM WITH BASE SUBSCRIPT + s( + { trig = "([^%a%\\])ll", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\log_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + }), + { condition = tex.in_mathzone } + ), + -- DERIVATIVE with denominator only + s( + { trig = "([^%a])dV", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\dvOne{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- DERIVATIVE with numerator and denominator + s( + { trig = "([^%a])dvv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\dv{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- DERIVATIVE with numerator, denominator, and higher-order argument + s( + { trig = "([^%a])ddv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\dvN{<>}{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + i(3), + }), + { condition = tex.in_mathzone } + ), + -- PARTIAL DERIVATIVE with denominator only + s( + { trig = "([^%a])pV", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\pdvOne{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- PARTIAL DERIVATIVE with numerator and denominator + s( + { trig = "([^%a])pvv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\pdv{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- PARTIAL DERIVATIVE with numerator, denominator, and higher-order argument + s( + { trig = "([^%a])ppv", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\pdvN{<>}{<>}{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + i(3), + }), + { condition = tex.in_mathzone } + ), + -- SUM with lower limit + s( + { trig = "([^%a])sM", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\sum_{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + }), + { condition = tex.in_mathzone } + ), + -- SUM with upper and lower limit + s( + { trig = "([^%a])smm", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\sum_{<>}^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- INTEGRAL with upper and lower limit + s( + { trig = "([^%a])intt", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\int_{<>}^{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + -- INTEGRAL from positive to negative infinity + s( + { trig = "([^%a])intf", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\int_{\\infty}^{\\infty}", { + f(function(_, snip) + return snip.captures[1] + end), + }), + { condition = tex.in_mathzone } + ), + -- BOXED command + s( + { trig = "([^%a])bb", wordTrig = false, regTrig = true, snippetType = "autosnippet" }, + fmta("<>\\boxed{<>}", { + f(function(_, snip) + return snip.captures[1] + end), + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + -- + -- BEGIN STATIC SNIPPETS + -- + + -- DIFFERENTIAL, i.e. \diff + s({ trig = "df", snippetType = "autosnippet", priority = 2000, snippetType = "autosnippet" }, { + t("\\diff"), + }, { condition = tex.in_mathzone }), + -- BASIC INTEGRAL SYMBOL, i.e. \int + s({ trig = "in1", snippetType = "autosnippet" }, { + t("\\int"), + }, { condition = tex.in_mathzone }), + -- DOUBLE INTEGRAL, i.e. \iint + s({ trig = "in2", snippetType = "autosnippet" }, { + t("\\iint"), + }, { condition = tex.in_mathzone }), + -- TRIPLE INTEGRAL, i.e. \iiint + s({ trig = "in3", snippetType = "autosnippet" }, { + t("\\iiint"), + }, { condition = tex.in_mathzone }), + -- CLOSED SINGLE INTEGRAL, i.e. \oint + s({ trig = "oi1", snippetType = "autosnippet" }, { + t("\\oint"), + }, { condition = tex.in_mathzone }), + -- CLOSED DOUBLE INTEGRAL, i.e. \oiint + s({ trig = "oi2", snippetType = "autosnippet" }, { + t("\\oiint"), + }, { condition = tex.in_mathzone }), + -- GRADIENT OPERATOR, i.e. \grad + s({ trig = "gdd", snippetType = "autosnippet" }, { + t("\\grad "), + }, { condition = tex.in_mathzone }), + -- CURL OPERATOR, i.e. \curl + s({ trig = "cll", snippetType = "autosnippet" }, { + t("\\curl "), + }, { condition = tex.in_mathzone }), + -- DIVERGENCE OPERATOR, i.e. \divergence + s({ trig = "DI", snippetType = "autosnippet" }, { + t("\\div "), + }, { condition = tex.in_mathzone }), + -- LAPLACIAN OPERATOR, i.e. \laplacian + s({ trig = "laa", snippetType = "autosnippet" }, { + t("\\laplacian "), + }, { condition = tex.in_mathzone }), + -- PARALLEL SYMBOL, i.e. \parallel + s({ trig = "||", snippetType = "autosnippet" }, { + t("\\parallel"), + }), + -- CDOTS, i.e. \cdots + s({ trig = "cdd", snippetType = "autosnippet" }, { + t("\\cdots"), + }), + -- LDOTS, i.e. \ldots + s({ trig = "ldd", snippetType = "autosnippet" }, { + t("\\ldots"), + }), + -- EQUIV, i.e. \equiv + s({ trig = "eqq", snippetType = "autosnippet" }, { + t("\\equiv "), + }), + -- SETMINUS, i.e. \setminus + s({ trig = "stm", snippetType = "autosnippet" }, { + t("\\setminus "), + }), + -- SUBSET, i.e. \subset + s({ trig = "sbb", snippetType = "autosnippet" }, { + t("\\subset "), + }), + -- APPROX, i.e. \approx + s({ trig = "px", snippetType = "autosnippet" }, { + t("\\approx "), + }, { condition = tex.in_mathzone }), + -- PROPTO, i.e. \propto + s({ trig = "pt", snippetType = "autosnippet" }, { + t("\\propto "), + }, { condition = tex.in_mathzone }), + -- COLON, i.e. \colon + s({ trig = "::", snippetType = "autosnippet" }, { + t("\\colon "), + }), + -- IMPLIES, i.e. \implies + s({ trig = ">>", snippetType = "autosnippet" }, { + t("\\implies "), + }), + -- DOT PRODUCT, i.e. \cdot + s({ trig = ",.", snippetType = "autosnippet" }, { + t("\\cdot "), + }), + -- CROSS PRODUCT, i.e. \times + s({ trig = "xx", snippetType = "autosnippet" }, { + t("\\times "), + }), +} diff --git a/home-manager/modules/neovim/snippets/tex/test.tex b/home-manager/modules/neovim/snippets/tex/test.tex new file mode 100644 index 0000000..a1a72cb --- /dev/null +++ b/home-manager/modules/neovim/snippets/tex/test.tex @@ -0,0 +1,5 @@ + + +\begin{align*} + +\end{align*} diff --git a/hosts/grymforge/configuration.nix b/hosts/grymforge/configuration.nix index d1e466b..fe24371 100644 --- a/hosts/grymforge/configuration.nix +++ b/hosts/grymforge/configuration.nix @@ -14,19 +14,15 @@ # If you want to use modules your own flake exports (from modules/nixos): # outputs.nixosModules.example ../../common/nixos/common.nix - ../../common/nixos/bluetooth.nix ../../common/nixos/restic.nix - ../../common/nixos/ssh/default.nix ../../common/gui/hyprland.nix ../../common/gui/steam.nix ../../common/gui/thunar.nix ../../common/style/stylix.nix - ../../common/virtualization/podman.nix - ../../common/virtualization/kubernetes.nix - ../../common/virtualization/libvirt.nix - ../../common/nixos/sysctl/default.nix + ../../common/nixos/sysctl ../../common/networking + ../../common/virtualization ./syncthing.nix ./auditd.nix @@ -49,6 +45,7 @@ ssh.enable = true; ssh_guard.enable = true; + nfs.enable = true; # Bootloader. boot = {