diff options
Diffstat (limited to 'home-manager')
37 files changed, 1878 insertions, 79 deletions
diff --git a/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix b/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix index 761f0c17..0a686190 100644 --- a/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix @@ -1,6 +1,6 @@ {...}: { programs.nixvim = { - clipboard.provides = { + clipboard.providers = { wl-copy.enable = true; }; }; diff --git a/home-manager/soispha/config/neovim/nixvim/default.nix b/home-manager/soispha/config/neovim/nixvim/default.nix index f216fb05..a96bc476 100644 --- a/home-manager/soispha/config/neovim/nixvim/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/default.nix @@ -1,39 +1,26 @@ -{ - pkgs, - ... -}: { +{...}: { imports = [ - ./options - ./mappings - ./colorscheme + ./autocmds ./clipboard + ./mappings + ./options + ./plugins ]; programs.nixvim = { enable = true; - defaultEditor = true; - - # to install plugins just activate their modules - plugins = { - lsp = { - enable = true; - hls.enable = true; - rust-analyzer.enable = true; - }; - treesitter = { - enable = true; - indent = true; - }; - mini = { - enable = true; - ai.enable = true; - jump.enable = true; - }; - }; - # Not all plugins have own modules - # You can add missing plugins here - # `pkgs.vimExtraPlugins` is added by the overlay you added at the beginning - # For a list of available plugins, look here: [available plugins](https://github.com/jooooscha/nixpkgs-vim-extra-plugins/blob/main/plugins.md) - extraPlugins = [pkgs.vimExtraPlugins.nightfox-nvim]; + # source: https://www.patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Neovim + extraConfigLuaPre = '' + --------------------------------------------------------------------------- + -- + -- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ + -- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ + -- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ + -- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ + -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ + -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + -- + --------------------------------------------------------------------------- + ''; }; } diff --git a/home-manager/soispha/config/neovim/nixvim/mappings/default.nix b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix index 237319a0..575ad465 100644 --- a/home-manager/soispha/config/neovim/nixvim/mappings/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix @@ -13,7 +13,7 @@ }; in { insert = - lib.recursiveUpate { + lib.recursiveUpdate { "hh" = { action = '' function() @@ -29,7 +29,7 @@ ''; desc = "completion trigger/ forward in completen menu"; }; - "<S-Tab>" = { + "<C-Space>" = { action = '' function() local cmp = require('cmp'); @@ -78,6 +78,10 @@ desc = "jump to command line"; }; + "\\f" = { + action = "require('lf').start()"; + desc = "open lf in a floating window"; + }; # Splits "<C-t>" = { diff --git a/home-manager/soispha/config/neovim/nixvim/colorscheme/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/colorscheme/default.nix index 9864c5cf..9864c5cf 100644 --- a/home-manager/soispha/config/neovim/nixvim/colorscheme/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/plugins/colorscheme/default.nix diff --git a/home-manager/soispha/config/neovim/nixvim/colorscheme/lua/nightfox.lua b/home-manager/soispha/config/neovim/nixvim/plugins/colorscheme/lua/nightfox.lua index 1ca4f743..b00626a2 100644 --- a/home-manager/soispha/config/neovim/nixvim/colorscheme/lua/nightfox.lua +++ b/home-manager/soispha/config/neovim/nixvim/plugins/colorscheme/lua/nightfox.lua @@ -1,4 +1,3 @@ --- Default options require('nightfox').setup({ options = { -- Compiled file's destination location @@ -49,5 +48,3 @@ require('nightfox').setup({ specs = {}, groups = {}, }) - -vim.cmd.colorscheme("duskfox"); diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/default.nix index 150798c3..0622203e 100644 --- a/home-manager/soispha/config/neovim/nixvim/plugins/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/plugins/default.nix @@ -1,5 +1,14 @@ {...}: { imports = [ - ./treesiter + ./colorscheme + ./lf-nvim + ./lsp + ./lualine + ./luasnip + ./nvim-cmp + ./nvim-lint + ./raw_plugins + ./treesitter + ./vim-tex ]; } diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/default.nix new file mode 100644 index 00000000..a42c6f33 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/default.nix @@ -0,0 +1,8 @@ +{lib, ...}: { + programs.nixvim = { + # TODO package lf-nvim though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/lf-nvim.lua} + ''; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/lua/lf-nvim.lua b/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/lua/lf-nvim.lua new file mode 100644 index 00000000..f6b249ce --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lf-nvim/lua/lf-nvim.lua @@ -0,0 +1,43 @@ +local fn = vim.fn + +-- Defaults +require("lf").setup({ + default_action = "drop", -- default action when `Lf` opens a file + -- TODO document these mappings: + default_actions = { -- default action keybindings + ["<C-t>"] = "tabedit", + ["<C-x>"] = "split", + ["<C-v>"] = "vsplit", + ["<C-o>"] = "tab drop", + }, + + winblend = 10, -- psuedotransparency level + dir = "", -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) + direction = "float", -- window type: float horizontal vertical + border = "rounded", -- border kind: single double shadow curved + height = fn.float2nr(fn.round(0.75 * o.lines)), -- height of the *floating* window + width = fn.float2nr(fn.round(0.75 * o.columns)), -- width of the *floating* window + escape_quit = true, -- map escape to the quit command (so it doesn't go into a meta normal mode) + focus_on_open = true, -- focus the current file when opening Lf (experimental) + mappings = true, -- whether terminal buffer mapping is enabled + tmux = false, -- tmux statusline can be disabled on opening of Lf + default_file_manager = true, -- make lf default file manager + disable_netrw_warning = true, -- don't display a message when opening a directory with `default_file_manager` as true + highlights = { -- highlights passed to toggleterm + Normal = { link = "Normal" }, + NormalFloat = { link = 'Normal' }, + FloatBorder = { guifg = "<VALUE>", guibg = "<VALUE>" }, + }, + + -- Layout configurations + layout_mapping = "<M-u>", -- resize window with this key + views = { -- window dimensions to rotate through + { width = 0.800, height = 0.800 }, + { width = 0.600, height = 0.600 }, + { width = 0.950, height = 0.950 }, + { width = 0.500, height = 0.500, col = 0, row = 0 }, + { width = 0.500, height = 0.500, col = 0, row = 0.5 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0.5 }, + } +}) diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix index 8d5cfaf1..dc8210d1 100644 --- a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix @@ -1,5 +1,10 @@ {...}: { - programs.nixvim.plugins.lsp.servers = { - - }; + imports = [ + ./servers/bashls.nix + ./servers/ltex.nix + ./servers/lua-ls.nix + ./servers/nil_ls.nix + ./servers/rust-analyzer.nix + ./servers/texlab.nix + ]; } diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/bashls.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/bashls.nix new file mode 100644 index 00000000..0577a335 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/bashls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + bashls.enable = true; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/ltex.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/ltex.nix new file mode 100644 index 00000000..9fc42473 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/ltex.nix @@ -0,0 +1,39 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + ltex = let + filetypes = [ + "rust" + "java" + "cpp" + "shell" + "bash" + + "bibtex" + "context" + "context.tex" + "latex" + "tex" + + "html" + "markdown" + "org" + "restructuredtext" + "rsweave" + + "git-commit" + "gitcommit" + ]; + in { + enable = true; + inherit filetypes; + settings = { + enabled = filetypes; + completionEnabled = true; + language = "en-CA"; + additionalRules = { + enablePickyRules = true; + }; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/lua-ls.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/lua-ls.nix new file mode 100644 index 00000000..5a44b500 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/lua-ls.nix @@ -0,0 +1,8 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + lua-ls = { + enable = true; + settings.telemetry.enable = false; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/nil_ls.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/nil_ls.nix new file mode 100644 index 00000000..f0cccbdc --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/nil_ls.nix @@ -0,0 +1,10 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + nil_ls = { + enable = true; + settings = { + formatting.command = ["alejandra"]; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/rust-analyzer.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/rust-analyzer.nix new file mode 100644 index 00000000..943a8c80 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/rust-analyzer.nix @@ -0,0 +1,10 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + rust-analyzer = { + enable = true; + settings = { + typing.autoClosingAngleBrackets.enable = true; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/texlab.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/texlab.nix new file mode 100644 index 00000000..59af8d39 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/servers/texlab.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + texlab = { + enable = true; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix index 0ec255db..2c95b562 100644 --- a/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix @@ -46,29 +46,27 @@ ''; }; in { - options = { - icons_enabled = true; - theme = "nightfox"; - component_separators = { - left = ""; - right = ""; - }; - section_separators = { - left = ""; - right = ""; - }; - disabled_filetypes = { - statusline = []; - winbar = []; - }; - ignore_focus = {}; - always_divide_middle = true; - globalstatus = false; - refresh = { - statusline = 1000; - tabline = 1000; - winbar = 1000; - }; + iconsEnabled = true; + theme = "nightfox"; + componentSeparators = { + left = ""; + right = ""; + }; + sectionSeparators = { + left = ""; + right = ""; + }; + disabledFiletypes = { + statusline = []; + winbar = []; + }; + ignoreFocus = {}; + alwaysDivideMiddle = true; + globalstatus = false; + refresh = { + statusline = 1000; + tabline = 1000; + winbar = 1000; }; sections = { lualine_a = ["mode"]; @@ -85,7 +83,7 @@ lualine_y = ["encoding" "fileformat" get_mixed_indent get_trailing_whitespace]; lualine_z = [get_location_of_file]; }; - inactive_sections = { + inactiveSections = { lualine_a = []; lualine_b = []; lualine_c = ["filename"]; @@ -95,7 +93,7 @@ }; tabline = {}; winbar = {}; - inactive_winbar = {}; + inactiveWinbar = {}; # TODO add all installed and supported extensions here extensions = ["fugitive"]; diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/default.nix new file mode 100644 index 00000000..50a0b94c --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/default.nix @@ -0,0 +1,12 @@ +{lib, ...}: { + programs.nixvim = { + plugins.luasnip = { + enable = true; + }; + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/luasnip.lua} + require("luasnip.loaders.from_lua").load({paths = "${./lua/snippets}"}) + require("luasnip.loaders.from_lua").lazy_load({paths = "${./lua/snippets}"}) + ''; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/luasnip.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/luasnip.lua new file mode 100644 index 00000000..c7707c69 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/luasnip.lua @@ -0,0 +1,9 @@ +require("luasnip").config.set_config({ + -- Enable auto triggered snippets + enable_autosnippets = true, + + -- Use Tab (or some other key if you prefer) to trigger visual selection + store_selection_keys = "<Tab>", +}) + + diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua new file mode 100644 index 00000000..2fecd1e7 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua @@ -0,0 +1,51 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end +local function char_count_same(c1, c2) + local line = vim.api.nvim_get_current_line() + -- '%'-escape chars to force explicit match (gsub accepts patterns). + -- second return value is number of substitutions. + local _, ct1 = string.gsub(line, '%' .. c1, '') + local _, ct2 = string.gsub(line, '%' .. c2, '') + return ct1 == ct2 +end + +local function even_count(c) + local line = vim.api.nvim_get_current_line() + local _, ct = string.gsub(line, c, '') + return ct % 2 == 0 +end + +local function neg(fn, ...) + return not fn(...) +end + +local function part(fn, ...) + local args = { ... } + return function() return fn(unpack(args)) end +end + +-- This makes creation of pair-type snippets easier. +local function pair(pair_begin, pair_end, expand_func, ...) + -- triggerd by opening part of pair, wordTrig=false to trigger anywhere. + -- ... is used to pass any args following the expand_func to it. + return s({ trig = pair_begin, wordTrig = false, snippetType = "autosnippet" }, { + t({ pair_begin }), d(1, get_visual), t({ pair_end }) + }, { + condition = part(expand_func, part(..., pair_begin, pair_end)) + }) +end + +return { + pair("(", ")", neg, char_count_same), + pair("{", "}", neg, char_count_same), + pair("[", "]", neg, char_count_same), + -- pair("<", ">", neg, char_count_same), + pair("'", "'", neg, even_count), + pair('"', '"', neg, even_count), + pair("`", "`", neg, even_count), +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/at.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/at.lua new file mode 100644 index 00000000..8f84fd30 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/at.lua @@ -0,0 +1,28 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1)) + end +end + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +return { + -- HEADER + s({ trig = "tr", regTrig = false, wordTrig = true, snippetType = "autosnippet" }, + fmt( + [[ + <tr> + <td><code>{}</code></td> + <th><code>{}</code></th> + </tr> + ]] , + { + d(1, get_visual), + d(2, get_visual), + } + ), + { condition = line_begin } + ), +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua new file mode 100644 index 00000000..df42314b --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua @@ -0,0 +1,105 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1)) + end +end + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +return + { + -- HEADER + s({trig="h([123456])", regTrig=true, wordTrig=false, snippetType="autosnippet"}, + fmt( + [[ + <h{}>{}</h{}> + ]], + { + f( function(_, snip) return snip.captures[1] end ), + d(1, get_visual), + f( function(_, snip) return snip.captures[1] end ), + } + ), + {condition = line_begin} + ), + -- PARAGRAPH + s({trig="pp", snippetType="autosnippet"}, + fmt( + [[ + <p>{}</p> + ]], + { + d(1, get_visual), + } + ), + {condition = line_begin} + ), + -- UNORDERED LIST + s({trig="itt", snippetType="autosnippet"}, + fmt( + [[ + <ul> + <li>{}</li>{} + </ul> + ]], + { + i(1), + i(0) + } + ), + {condition = line_begin} + ), + -- LIST ITEM + s({trig="ii", snippetType="autosnippet"}, + fmt( + [[ + <li>{}</li> + ]], + { + d(1, get_visual), + } + ), + {condition = line_begin} + ), + -- DOCUMENT TEMPLATE + s({trig="base"}, + fmt( + [[ + <!doctype HTML> + <html lang="en"> + <head> + <meta charset="UTF-8"> + <title>{}</title> + </head> + <body> + {} + </body> + </html> + ]], + { + i(1, "FooBar"), + i(0) + } + ), + {condition = line_begin} + ), + -- ANCHOR TAG + s({trig = "([^%l])aa", regTrig = true, wordTrig = false, snippetType="autosnippet"}, + fmt( + [[ + {}<a href="{}">{}</a> + ]], + { + f( function(_, snip) return snip.captures[1] end ), + i(1), + d(2, get_visual), + } + ) + ), + } + + + + diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/nix/delimiter.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/nix/delimiter.lua new file mode 100644 index 00000000..12e1df42 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/nix/delimiter.lua @@ -0,0 +1,24 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + + +-- Return snippet tables +return +{ + -- LEFT/RIGHT ALL BRACES + s({trig = "cmd;(.*);", regTrig = true, wordTrig = false, snippetType="autosnippet"}, + fmta( + [[<> = builtins.readFile "./cmds/<>.sh";]], + { + f( function(_, snip) return snip.captures[1] end ), + f( function(_, snip) return snip.captures[1] end ), + } + ) + ), +} + diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua new file mode 100644 index 00000000..36cae366 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua @@ -0,0 +1,36 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + +local translation_table = { + ["("] = ")", + ["{"] = "}", + ["["] = "]", +} + +-- 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 +{ + -- LEFT/RIGHT ALL BRACES + s({trig = "([^%a])l([%(%[%{])", regTrig = true, wordTrig = false, snippetType="autosnippet"}, + fmta( + "<>\\left<><>\\right<>", + { + f( function(_, snip) return snip.captures[1] end ), + f( function(_, snip) return snip.captures[2] end ), + d(1, get_visual), + f( function(_, snip) return translation_table[snip.captures[2]] end ), + } + ) + ), +} + diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/environments.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/environments.lua new file mode 100644 index 00000000..e88bc16e --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/environments.lua @@ -0,0 +1,130 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(0, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(0, '')) + end +end + +-- 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 + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +-- Return snippet tables +return { + -- EQUATION +-- s({ trig = "nn", snippetType = "autosnippet" }, +-- fmta( +-- [[ +-- \begin{equation*} +-- <> +-- \end{equation*} +-- ]] , +-- { +-- i(0), +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- SPLIT EQUATION +-- s({ trig = "ss", snippetType = "autosnippet" }, +-- fmta( +-- [[ +-- \begin{equation*} +-- \begin{split} +-- <> +-- \end{split} +-- \end{equation*} +-- ]] , +-- { +-- d(1, get_visual), +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- ALIGN +-- s({ trig = "all", snippetType = "autosnippet" }, +-- fmta( +-- [[ +-- \begin{align*} +-- <> +-- \end{align*} +-- ]] , +-- { +-- i(0), +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- ITEMIZE +-- s({ trig = "itt", snippetType = "autosnippet" }, +-- fmta( +-- [[ +-- \begin{itemize} +-- +-- \item <> +-- +-- \end{itemize} +-- ]] , +-- { +-- i(0), +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- ENUMERATE +-- s({ trig = "enn", snippetType = "autosnippet" }, +-- fmta( +-- [[ +-- \begin{enumerate} +-- +-- \item <> +-- +-- \end{enumerate} +-- ]] , +-- { +-- i(0), +-- } +-- ) +-- ), +-- -- INLINE MATH +-- s({ trig = "([^%l])mm", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, +-- fmta( +-- "<>$<>$", +-- { +-- f(function(_, snip) return snip.captures[1] end), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- INLINE MATH ON NEW LINE +-- s({ trig = "^mm", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, +-- fmta( +-- "$<>$", +-- { +-- i(0), +-- })), +-- -- FIGURE +-- s({ trig = "fig" }, +-- fmta( +-- [[ +-- \begin{figure}[htb!] +-- \centering +-- \includegraphics[width=<>\linewidth]{<>} +-- \caption{<>} +-- \label{fig:<>} +-- \end{figure} +-- ]] , +-- { +-- i(1), +-- i(2), +-- i(3), +-- i(4), +-- } +-- ), +-- { condition = line_begin } +-- ), +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/fonts.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/fonts.lua new file mode 100644 index 00000000..aeddf571 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/fonts.lua @@ -0,0 +1,110 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + +-- A logical OR of `line_begin` and the regTrig '[^%a]trig' +function line_begin_or_non_letter(line_to_cursor, matched_trigger) + local line_begin = line_to_cursor:sub(1, -(#matched_trigger + 1)):match("^%s*$") + local non_letter = line_to_cursor:sub(-(#matched_trigger + 1), -(#matched_trigger + 1)):match("[^%a]") + return line_begin or non_letter +end + +-- 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 + +local line_begin = function(line_to_cursor, matched_trigger) + -- +1 because `string.sub("abcd", 1, -2)` -> abc + return line_to_cursor:sub(1, -(#matched_trigger + 1)):match("^%s*$") +end + +-- Return snippet tables +return + { +-- -- TYPEWRITER i.e. \texttt +-- s({trig = "([^%a])sd", regTrig = true, wordTrig = false, snippetType="autosnippet", priority=2000}, +-- fmta( +-- "<>\\texttt{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ), +-- {condition = tex.in_text} +-- ), +-- -- ITALIC i.e. \textit +-- s({trig = "([^%a])tii", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\textit{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- BOLD i.e. \textbf +-- s({trig = "tbb", snippetType="autosnippet"}, +-- fmta( +-- "\\textbf{<>}", +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- MATH ROMAN i.e. \mathrm +-- s({trig = "([^%a])rmm", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\mathrm{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- MATH CALIGRAPHY i.e. \mathcal +-- s({trig = "([^%a])mcc", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\mathcal{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- MATH BOLDFACE i.e. \mathbf +-- s({trig = "([^%a])mbf", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\mathbf{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- MATH BLACKBOARD i.e. \mathbb +-- s({trig = "([^%a])mbb", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\mathbb{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- REGULAR TEXT i.e. \text (in math environments) +-- s({trig = "([^%a])tee", regTrig = true, wordTrig = false, snippetType="autosnippet"}, +-- fmta( +-- "<>\\text{<>}", +-- { +-- f( function(_, snip) return snip.captures[1] end ), +-- d(1, get_visual), +-- } +-- ), +-- { condition = tex.in_mathzone } +-- ), + } diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua new file mode 100644 index 00000000..419e47ef --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua @@ -0,0 +1,140 @@ +-- 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/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/math.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/math.lua new file mode 100644 index 00000000..e252ad43 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/math.lua @@ -0,0 +1,537 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(0, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(0, '')) + end +end + +-- 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} +-- ), +-- -- 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", 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/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/new.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/new.lua new file mode 100644 index 00000000..0ca73da4 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/new.lua @@ -0,0 +1,51 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end +local function char_count_same(c1, c2) + local line = vim.api.nvim_get_current_line() + -- '%'-escape chars to force explicit match (gsub accepts patterns). + -- second return value is number of substitutions. + local _, ct1 = string.gsub(line, '%' .. c1, '') + local _, ct2 = string.gsub(line, '%' .. c2, '') + return ct1 == ct2 +end + +local function even_count(c) + local line = vim.api.nvim_get_current_line() + local _, ct = string.gsub(line, c, '') + return ct % 2 == 0 +end + +local function neg(fn, ...) + return not fn(...) +end + +local function part(fn, ...) + local args = { ... } + return function() return fn(unpack(args)) end +end + +-- This makes creation of pair-type snippets easier. +local function pair(pair_begin, pair_end, expand_func, ...) + -- triggerd by opening part of pair, wordTrig=false to trigger anywhere. + -- ... is used to pass any args following the expand_func to it. + return s({ trig = pair_begin, wordTrig = false, snippetType = "autosnippet" }, { + t({ pair_begin }), d(1, get_visual), t({ pair_end }) + }, { + condition = part(expand_func, part(..., pair_begin, pair_end)) + }) +end + +return { + pair("(", ")", neg, char_count_same), + pair("{", "}", neg, char_count_same), + pair("[", "]", neg, char_count_same), + pair("<", ">", neg, char_count_same), + pair("'", "'", neg, even_count), + pair('"', '"', neg, even_count), + pair("`", "`", neg, even_count), +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/static.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/static.lua new file mode 100644 index 00000000..b064ce7b --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/static.lua @@ -0,0 +1,94 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +-- Environment/syntax 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 +tex.in_tikz = function() + local is_inside = vim.fn['vimtex#env#is_inside']("tikzpicture") + return (is_inside[1] > 0 and is_inside[2] > 0) +end + +-- Return snippet tables +return + { +-- s({trig="LL", snippetType="autosnippet"}, +-- { +-- t("& "), +-- } +-- ), +-- s({trig="q"}, +-- { +-- t("\\quad "), +-- } +-- ), +-- s({trig="qq", snippetType="autosnippet"}, +-- { +-- t("\\qquad "), +-- } +-- ), +-- s({trig="np"}, +-- { +-- t("\\newpage"), +-- }, +-- {condition = line_begin} +-- ), +-- s({trig="which", snippetType="autosnippet"}, +-- { +-- t("\\text{ for which } "), +-- }, +-- {condition = tex.in_mathzone} +-- ), +-- s({trig="all", snippetType="autosnippet"}, +-- { +-- t("\\text{ for all } "), +-- }, +-- {condition = tex.in_mathzone} +-- ), +-- s({trig="and", snippetType="autosnippet"}, +-- { +-- t("\\quad \\text{and} \\quad"), +-- }, +-- {condition = tex.in_mathzone} +-- ), +-- s({trig="forall", snippetType="autosnippet"}, +-- { +-- t("\\text{ for all } "), +-- }, +-- {condition = tex.in_mathzone} +-- ), +-- s({trig = "toc", snippetType="autosnippet"}, +-- { +-- t("\\tableofcontents"), +-- }, +-- { condition = line_begin } +-- ), + s({trig="inff", snippetType="autosnippet"}, + { + t("\\infty"), + } + ), + s({trig="ii", snippetType="autosnippet"}, + { + t("\\item "), + }, + { condition = line_begin } + ), + s({trig = "--", snippetType="autosnippet"}, + {t('% --------------------------------------------- %')}, + {condition = line_begin} + ), +-- -- HLINE WITH EXTRA VERTICAL SPACE +-- s({trig = "hl"}, +-- {t('\\hline {\\rule{0pt}{2.5ex}} \\hspace{-7pt}')}, +-- {condition = line_begin} +-- ), + } diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/system.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/system.lua new file mode 100644 index 00000000..d551a818 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/system.lua @@ -0,0 +1,168 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +-- 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 + { +-- -- ANNOTATE (custom command for annotating equation derivations) +-- s({trig = "ann", snippetType="autosnippet"}, +-- fmta( +-- [[ +-- \annotate{<>}{<>} +-- ]], +-- { +-- i(1), +-- d(2, get_visual), +-- } +-- ) +-- ), +-- -- REFERENCE +-- s({trig = " RR", snippetType="autosnippet", wordTrig=false}, +-- fmta( +-- [[ +-- ~\ref{<>} +-- ]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- USE A LATEX PACKAGE +-- s({trig = "pack", snippetType="autosnippet"}, +-- fmta( +-- [[ +-- \usepackage{<>} +-- ]], +-- { +-- d(1, get_visual), +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- INPUT a LaTeX file +-- s({trig = "inn", snippetType="autosnippet"}, +-- fmta( +-- [[ +-- \input{<><>} +-- ]], +-- { +-- i(1, "~/dotfiles/config/latex/templates/"), +-- i(2) +-- } +-- ), +-- { condition = line_begin } +-- ), +-- -- LABEL +-- s({trig = "lbl", snippetType="autosnippet"}, +-- fmta( +-- [[ +-- \label{<>} +-- ]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- HPHANTOM +-- s({trig = "hpp", snippetType="autosnippet"}, +-- fmta( +-- [[ +-- \hphantom{<>} +-- ]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- s({trig = "TODOO", snippetType="autosnippet"}, +-- fmta( +-- [[\TODO{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- s({trig="nc"}, +-- fmta( +-- [[\newcommand{<>}{<>}]], +-- { +-- i(1), +-- i(2) +-- } +-- ), +-- {condition = line_begin} +-- ), +-- s({trig="sii", snippetType="autosnippet"}, +-- fmta( +-- [[\si{<>}]], +-- { +-- i(1), +-- } +-- ) +-- ), +-- s({trig="SI", snippetType="autosnippet"}, +-- fmta( +-- [[\SI{<>}{<>}]], +-- { +-- i(1), +-- i(2) +-- } +-- ) +-- ), +-- s({trig="url"}, +-- fmta( +-- [[\url{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- VSPACE +-- s({trig="vs"}, +-- fmta( +-- [[\vspace{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- SECTION +-- s({trig="h1", snippetType="autosnippet"}, +-- fmta( +-- [[\section{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- SUBSECTION +-- s({trig="h2", snippetType="autosnippet"}, +-- fmta( +-- [[\subsection{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), +-- -- SUBSUBSECTION +-- s({trig="h3", snippetType="autosnippet"}, +-- fmta( +-- [[\subsubsection{<>}]], +-- { +-- d(1, get_visual), +-- } +-- ) +-- ), + } diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/tmp.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/tmp.lua new file mode 100644 index 00000000..c0acfb3a --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/tmp.lua @@ -0,0 +1,24 @@ +local get_visual = function(args, parent) + if (#parent.snippet.env.SELECT_RAW > 0) then + return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + else + return sn(nil, i(1, '')) + end +end + +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +return { + -- s({trig="up"}, + -- fmta( + -- [[ + -- \usepackage<>{<>} + -- ]], + -- { + -- -- c(1, {t(""), sn(nil, {t("["), i(1, "options"), t("]")})}), + -- c(1, {sn(nil, {t("["), i(1, "options"), t("]")}), t("")}), + -- i(2, "name"), + -- } + -- ) + -- ), +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/nvim-cmp/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-cmp/default.nix new file mode 100644 index 00000000..d464a305 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-cmp/default.nix @@ -0,0 +1,47 @@ +{...}: { + programs.nixvim.plugins.nvim-cmp = { + /* + TODO; integrate this: + ```lua + enabled = { + function() + -- disable completion in comments + local context = require 'cmp.config.context' + -- keep command mode completion enabled when cursor is in a comment + -- te + if vim.api.nvim_get_mode().mode == 'c' then + return true + else + return not context.in_treesitter_capture("comment") + and not context.in_syntax_group("Comment") + end + end + }, + ``` + */ + enable = true; + + mapping = { + # TODO add support for desc and which key here + "<C-d>" = { + action = "cmp.mapping.scroll_docs(-4)"; + #desc = "Scroll up by four lines"; + }; + "<C-f>" = { + action = "cmp.mapping.scroll_docs(4)"; + #desc = "Scroll down by four lines"; + }; + "<C-Space>" = { + action = "cmp.mapping.complete()"; + #desc = "Confirm snipped"; + }; + }; + + snippet.expand = "luasnip"; + + sources = [ + {name = "nvim_lsp";} + {name = "luasnip";} + ]; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/default.nix new file mode 100644 index 00000000..c55efacc --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/default.nix @@ -0,0 +1,8 @@ +{lib, ...}: { + programs.nixvim = { + # TODO package nvim-lint though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/nvim-lint.lua} + ''; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/lua/nvim-lint.lua b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/lua/nvim-lint.lua new file mode 100644 index 00000000..812d4827 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/nvim-lint/lua/nvim-lint.lua @@ -0,0 +1,20 @@ +require('lint').linters_by_ft = { + -- text + markdown = {}, + -- tex = {'chktex'}, -- maybe add some text linters ? + + -- shell + sh = {'shellcheck',}, + bash = {'shellcheck'}, + zsh = {'shellcheck'}, + dash = {'shellcheck'}, + + yaml = {'yamllint'}, + nix = {'nix', 'statix'}, +} + +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { + callback = function() + require("lint").try_lint() + end, +}) diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/raw_plugins/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/raw_plugins/default.nix new file mode 100644 index 00000000..fdc30d7f --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/raw_plugins/default.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: { + programs.nixvim = { + # Not all plugins have own modules + # You can add missing plugins here + # `pkgs.vimExtraPlugins` is added by the overlay you added at the beginning + # For a list of available plugins, look here: [available plugins](https://github.com/jooooscha/nixpkgs-vim-extra-plugins/blob/main/plugins.md) + extraPlugins = with pkgs.vimExtraPlugins; [ + nightfox-nvim + nvim-lint + lf-nvim + + nvim-toggleterm-lua # required by lf-nvim + ]; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix index 7a8a3a26..4aca6887 100644 --- a/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix +++ b/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix @@ -1,11 +1,18 @@ {...}: { programs.nixvim.plugins.treesitter = { enable = true; - # A list of parser names; or "all" - # ensure_installed = [ "c" "lua" "rust" ]; - ensure_installed = "all"; - # TODO make this work + ensureInstalled = "all"; + indent = true; + + # inject nixvim specific highlighting (eg in extraConfigLua). + nixvimInjections = true; + + # TODO It would we wonderfull, if we could use treesitter in latex + #disabledLanguages = ["latex"]; + + /* + # TODO this is not supported by the nixVim modlue, nixNeovim supports this though .. highlight = { # `false` will disable the whole extension enable = true; @@ -15,20 +22,18 @@ # Set this to `true` if you depend on 'syntax' being enabled (like for indentation). # Using this option may slow down your editor; and you may see some duplicate highlights. # Instead of true it can also be a list of languages - additional_vim_regex_highlighting = [""]; + additionalVimRegexHighlighting = [""]; }; + */ - indent = { - enable = true; - }; - incremental_selection = { + incrementalSelection = { enable = true; keymaps = { # TODO include these - init_selection = "gnn"; # set to `false` to disable one of the mappings - node_incremental = "grn"; - scope_incremental = "grc"; - node_decremental = "grm"; + initSelection = "gnn"; # set to `false` to disable one of the mappings + nodeIncremental = "grn"; + scopeIncremental = "grc"; + nodeDecremental = "grm"; }; }; }; diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/vim-tex/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/vim-tex/default.nix new file mode 100644 index 00000000..39825fd3 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/vim-tex/default.nix @@ -0,0 +1,55 @@ +{...}: { + programs.nixvim = { + options.conceallevel = 0; + + # globals.tex_conceal = "abdmg"; + # globals.tex_flavor = "latex"; + + plugins.vimtex = { + enable = true; + extraConfig = { + view_method = "zathura"; + quickfix_mode = -1; + view_enabled = -1; + tex_conceal = "abdmg"; + tex_flavor = "latex"; + + mappings_disable = { + n = ["tsf" "tsc" "tse" "ts$" "tsd" "tsD"]; + x = ["tsd" "tsD" "tsf"]; + }; + + toc_config = { + name = "TOC"; + layers = ["content" "todo" "include"]; + resize = false; + split_width = 49; + todo_sorted = -1; + show_help = false; + show_numbers = false; + mode = true; + layer_keys = { + content = "C"; + label = "L"; + todo = "j"; + include = "I"; + }; + }; + + compiler_latexmk = { + build_dir = "build"; + callback = false; + continuous = true; + executable = "latexmk"; + hooks = []; + options = [ + "-verbose" + "-file-line-error" + "-synctex=0" + "-interaction=nonstopmode" + ]; + }; + }; + }; + }; +} |