diff options
author | Soispha <soispha@vhack.eu> | 2023-08-29 21:33:43 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-29 21:33:43 +0200 |
commit | 3925f6ee04f09d7d09b7aff018812670a0e89492 (patch) | |
tree | 12642e7332ebb53153bef1bf5d5f811e3f19884b /hm/soispha/conf/nvim/plgs | |
parent | Feat(hm/conf/nvim/plgs/debugprint): Init (diff) | |
download | nixos-config-3925f6ee04f09d7d09b7aff018812670a0e89492.zip |
Refactor(hm/conf/nvim/plugins): Rename to `plgs` to safe commit msg space
Diffstat (limited to 'hm/soispha/conf/nvim/plgs')
56 files changed, 2052 insertions, 0 deletions
diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/default.nix b/hm/soispha/conf/nvim/plgs/colorscheme/default.nix new file mode 100644 index 00000000..c5b3db66 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/colorscheme/default.nix @@ -0,0 +1,17 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package nightfox though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/nightfox.lua} + ${lib.strings.fileContents ./lua/mk_todos_readable.lua} + ''; + colorscheme = "carbonfox"; + extraPlugins = [ + pkgs.vimExtraPlugins.nightfox-nvim + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua new file mode 100644 index 00000000..ee28151c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua @@ -0,0 +1,17 @@ +local opts = { bg = "NONE"; bold = true; } + + +---@param hl_group string: The name of the hl group +---@param extra_opts table: Extra options to pass to nvim_set_hl +local set_hl = function(hl_group, extra_opts) + local local_opts = vim.deepcopy(opts); + for k, v in ipairs(extra_opts) do + local_opts[k] = v; + end + vim.api.nvim_set_hl(0, hl_group, local_opts) +end + +set_hl("@text.danger", { fg = "red"; }) +set_hl("@text.note", { fg = "blue"; }) +set_hl("@text.todo", { fg = "green"; }) +set_hl("@text.warning", { fg = "yellow"; }) diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua new file mode 100644 index 00000000..025eb133 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua @@ -0,0 +1,44 @@ +require("nightfox").setup({ + options = { + -- Compiled file's destination location + compile_path = vim.fn.stdpath("cache") .. "/nightfox"; + compile_file_suffix = "_compiled"; -- Compiled file suffix + transparent = true; -- Disable setting background + terminal_colors = true; -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` + dim_inactive = true; -- Non focused panes set to alternative background + module_default = true; -- Default enable value for modules + colorblind = { + enable = true; -- Enable colorblind support + simulate_only = false; -- Only show simulated colorblind colors and not diff shifted + severity = { + protan = 0.3; -- Severity [0,1] for protan (red) + deutan = 0.9; -- Severity [0,1] for deutan (green) + tritan = 0; -- Severity [0,1] for tritan (blue) + }; + }; + styles = { -- Style to be applied to different syntax groups + comments = "italic"; -- Value is any valid attr-list value `:help attr-list` + conditionals = "NONE"; + constants = "NONE"; + functions = "bold"; + keywords = "bold"; + numbers = "NONE"; + operators = "NONE"; + strings = "NONE"; + types = "NONE"; + variables = "NONE"; + }; + inverse = { -- Inverse highlight for different types + match_paren = false; + visual = false; + search = false; + }; + modules = { -- List of various plugins and additional options + diagnostic = { enable = true; background = false; }; + native_lsp = { enable = true; background = false; }; + }; + }; + palettes = {}; + specs = {}; + groups = {}; +}) diff --git a/hm/soispha/conf/nvim/plgs/comment-nvim/default.nix b/hm/soispha/conf/nvim/plgs/comment-nvim/default.nix new file mode 100644 index 00000000..cf99d3d5 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/comment-nvim/default.nix @@ -0,0 +1,36 @@ +{...}: { + programs.nixvim = { + plugins.comment-nvim = { + enable = true; + padding = true; + sticky = true; + mappings = { + basic = false; + extended = false; + extra = false; + }; + }; + maps = { + visual = { + "gcc" = { + action = "<Plug>(comment_toggle_linewise_visual)"; + desc = "toggle the current line in a linewise comment"; + }; + "gbc" = { + action = "<Plug>(comment_toggle_blockwise_visual)"; + desc = "toggle the current line in a blockwise comment"; + }; + }; + normal = { + "gcc" = { + action = "<Plug>(comment_toggle_linewise_current)"; + desc = "toggle the current line in a linewise comment"; + }; + "gbc" = { + action = "<Plug>(comment_toggle_blockwise_current)"; + desc = "toggle the current line in a blockwise comment"; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/debugprint/default.nix b/hm/soispha/conf/nvim/plgs/debugprint/default.nix new file mode 100644 index 00000000..522965ac --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/debugprint/default.nix @@ -0,0 +1,77 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package debugprint though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/debugprint.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.debugprint-nvim + ]; + + maps = let + visualNormal = { + "g?v" = { + action = '' + function() + return require('debugprint').debugprint({variable = true;}); + end + ''; + lua = true; + expr = true; + desc = '' + 'variable' debug line below the current line + ''; + }; + "g?V" = { + action = '' + function() + return require('debugprint').debugprint({above = true; variable = true;}) ; + end + ''; + lua = true; + expr = true; + desc = '' + 'variable' debug line above the current line + ''; + }; + }; + in { + normal = + { + "g?p" = { + action = '' + function() + return require('debugprint').debugprint(); + end + ''; + lua = true; + expr = true; + desc = '' + 'plain' debug line below the current line + ''; + }; + "g?P" = { + action = '' + function() + return require('debugprint').debugprint({above = true;}); + end + ''; + lua = true; + expr = true; + desc = '' + 'plain' debug line above the current line + ''; + }; + } + // visualNormal; + visual = + { + } + // visualNormal; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua new file mode 100644 index 00000000..2ea38df4 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua @@ -0,0 +1,4 @@ +require("debugprint").setup({ + create_keymaps = false; +}) + diff --git a/hm/soispha/conf/nvim/plgs/default.nix b/hm/soispha/conf/nvim/plgs/default.nix new file mode 100644 index 00000000..60855ba3 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/default.nix @@ -0,0 +1,27 @@ +{...}: { + imports = [ + ./colorscheme + ./comment-nvim + ./debugprint + ./femaco + ./goto-preview + ./harpoon + ./leap + ./lf-nvim + ./lsp + #./lsp-progress-nvim + ./lspkind + ./ltex_extra + ./lualine + ./luasnip + ./neorg + ./nvim-cmp + ./nvim-lint + ./raw_plugins + ./telescope + ./todo-comments + ./treesitter + ./vim-tex + ./which-key + ]; +} diff --git a/hm/soispha/conf/nvim/plgs/femaco/default.nix b/hm/soispha/conf/nvim/plgs/femaco/default.nix new file mode 100644 index 00000000..570ff297 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/femaco/default.nix @@ -0,0 +1,24 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package femaco through a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/femaco.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.nvim-FeMaco-lua + ]; + maps = { + normal = { + "<leader>cc" = { + action = "require('femaco.edit').edit_code_block"; + lua = true; + desc = "edit a [c]ode blo[c]k with femaco"; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua new file mode 100644 index 00000000..10064b5e --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua @@ -0,0 +1,50 @@ +local clip_val = require('femaco.utils').clip_val +require("femaco").setup({ + -- should prepare a new buffer and return the winid + -- by default opens a floating window + -- provide a different callback to change this behaviour + -- @param opts: the return value from float_opts + prepare_buffer = function(opts) + local buf = vim.api.nvim_create_buf(false, false) + return vim.api.nvim_open_win(buf, true, opts) + end; + -- should return options passed to nvim_open_win + -- @param code_block: data about the code-block with the keys + -- * range + -- * lines + -- * lang + float_opts = function(code_block) + return { + relative = "cursor"; + width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10); -- TODO: how to offset sign column etc? + height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6); + anchor = "NW"; + row = 0; + col = 0; + style = "minimal"; + border = "rounded"; + zindex = 1; + } + end; + -- return filetype to use for a given lang + -- lang can be nil + ft_from_lang = function(lang) + return lang + end; + -- what to do after opening the float + post_open_float = function(winnr) + vim.wo.signcolumn = "no" + end; + -- create the path to a temporary file + create_tmp_filepath = function(filetype) + return os.tmpname() + end; + -- if a newline should always be used, useful for multiline injections + -- which separators needs to be on separate lines such as markdown, neorg etc + -- @param base_filetype: The filetype which FeMaco is called from, not the + -- filetype of the injected language (this is the current buffer so you can + -- get it from vim.bo.filetyp). + ensure_newline = function(base_filetype) + return false + end; +}) diff --git a/hm/soispha/conf/nvim/plgs/goto-preview/default.nix b/hm/soispha/conf/nvim/plgs/goto-preview/default.nix new file mode 100644 index 00000000..740bb04c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/goto-preview/default.nix @@ -0,0 +1,42 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package goto-preview though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/goto-preview.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.goto-preview + ]; + maps.normal = { + "<space>gd" = { + action = "require('goto-preview').goto_preview_definition"; + lua = true; + desc = "[G]oto [D]efinition"; + }; + "<space>gtd" = { + action = "require('goto-preview').goto_preview_type_definition"; + lua = true; + desc = "[G]oto the [t]ype [D]efinition"; + }; + "<space>gi" = { + action = "require('goto-preview').goto_preview_implementation"; + lua = true; + desc = "[G]oto [I]mplementations"; + }; + "<space>gr" = { + action = "require('goto-preview').goto_preview_references"; + lua = true; + desc = "[G]o to all [R]eferences of the symbol"; + }; + "\\<space>" = { + action = "require('goto-preview').close_all_win"; + lua = true; + desc = "close all preview windows"; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua new file mode 100644 index 00000000..cde50d3e --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua @@ -0,0 +1,21 @@ +require("goto-preview").setup({ + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = { "↖"; "─"; "┐"; "│"; "┘"; "─"; "└"; "│"; }; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + post_close_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = {}; -- require("telescope.themes").get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true; -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe"; -- the bufhidden option to set on the floating window. See :h bufhidden + stack_floating_preview_windows = true; -- Whether to nest floating windows + preview_window_title = { enable = true; position = "left"; }; -- Whether to set the preview window title as the filename +}) diff --git a/hm/soispha/conf/nvim/plgs/harpoon/default.nix b/hm/soispha/conf/nvim/plgs/harpoon/default.nix new file mode 100644 index 00000000..ecd1d6cb --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/harpoon/default.nix @@ -0,0 +1,95 @@ +{...}: let + numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"]; + mkNumberedCommand = { + command_template, + prefix, + number, + desc_template, + }: { + name = "${prefix}${number}"; + value = { + action = '' + function() + ${command_template number} + end + ''; + lua = true; + desc = "${desc_template number}"; + }; + }; + mkGotoTerminalCommand = number: let + desc_template = number: "Goto terminal number ${number}"; + command_template = number: ''require("harpoon.term").gotoTerminal(${number})''; + prefix = "gt"; + in + mkNumberedCommand {inherit desc_template command_template prefix number;}; + mkGotoFileCommand = number: let + desc_template = number: "Goto Buffer number ${number}"; + command_template = number: ''require("harpoon.ui").nav_file(${number})''; + prefix = "gf"; + in + mkNumberedCommand {inherit desc_template command_template prefix number;}; + + gotoTerminalMappings = builtins.listToAttrs (builtins.map mkGotoTerminalCommand numbers); + gotoFileMappings = builtins.listToAttrs (builtins.map mkGotoFileCommand numbers); +in { + programs.nixvim = { + plugins.harpoon = { + enable = true; + # menu.width = "vim.api.nvim_win_get_width(0) - 4"; # TODO: integrate that + keymaps = { + tmuxGotoTerminal = null; # TODO: + }; + }; + maps.normalVisualOp = + { + "-" = { + action = '' + function() + require("harpoon.ui").nav_next() + end + ''; + lua = true; + desc = "go to the next marked file"; + }; + "_" = { + action = '' + function() + require("harpoon.ui").nav_prev() + end + ''; + lua = true; + desc = "go to the previous marked file"; + }; + "<leader><leader>" = { + action = '' + function() + require("harpoon.mark").add_file() + end + ''; + lua = true; + desc = "add a mark to the open file in harpoon."; + }; + "gqc" = { + action = '' + function() + require("harpoon.cmd-ui").toggle_quick_menu() + end + ''; + lua = true; + desc = "toggle the harpoon command quick menu to see all commands."; + }; + "<leader>q" = { + action = '' + function() + require("harpoon.ui").toggle_quick_menu() + end + ''; + lua = true; + desc = "toggle the harpoon normal quick menu to see all marks."; + }; + } + // gotoFileMappings + // gotoTerminalMappings; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/leap/default.nix b/hm/soispha/conf/nvim/plgs/leap/default.nix new file mode 100644 index 00000000..bffdf33c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/leap/default.nix @@ -0,0 +1,58 @@ +{...}: { + programs.nixvim = { + plugins.leap = { + enable = true; + addDefaultMappings = false; # They don't work with dvorak. + safeLabels = [ + "f" + "j" + "k" + "l" + "/" + "z" + "S" + "F" + "J" + "K" + "L" + "H" + "W" + "E" + "M" + "B" + "U" + "X" + "?" + "Z" + ]; + }; + maps = { + normalVisualOp = { + "m" = { + action = "<Plug>(leap-forward-to)"; + desc = "leap forward to"; + }; + "M" = { + action = "<Plug>(leap-backward-to)"; + desc = "leap backward to"; + }; + "gs" = { + action = "<Plug>(leap-from-window)"; + desc = "leap to enterable windows"; + }; + }; + visual = { + /* + "x" = { + action = "<Plug>(leap-forward-till)"; + desc = "leap forward till"; + }; + "X" = { + action = "<Plug>(leap-backward-till)"; + desc = "leap backward till"; + }; + */ + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lf-nvim/default.nix b/hm/soispha/conf/nvim/plgs/lf-nvim/default.nix new file mode 100644 index 00000000..c562f400 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lf-nvim/default.nix @@ -0,0 +1,18 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package lf-nvim though a module + # FIXME: change the nvim path, when I change the path with lf + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/lf-nvim.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.lf-nvim + + pkgs.vimExtraPlugins.nvim-toggleterm-lua # required by lf-nvim + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua b/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua new file mode 100644 index 00000000..8a0cf817 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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: what do these mappings do? + 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 * vim.o.lines)); -- height of the *floating* window + width = fn.float2nr(fn.round(0.75 * vim.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 = "#cdcbe0"; guibg = "#191726"; }; + }; + + -- 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/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/default.nix b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/default.nix new file mode 100644 index 00000000..6602ceb6 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/default.nix @@ -0,0 +1,50 @@ +{ + lib, + pkgs, + ... +}: { + programs.nixvim = { + # TODO: package lsp-progress-nvim though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/lsp-progress-nvim.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.lsp-progress-nvim + ]; + + # Status line setup + autoGroups.lsp_refresh.clear = true; + autoCmd = [ + { + event = ["User LspProgressStatusUpdated"]; + pattern = ["*"]; + callback = + /* + lua + */ + { + __raw = '' + require("lualine").refresh + ''; + }; + group = "lsp_refresh"; + description = "Refresh the statusbar when the lsp status was updated."; + } + ]; + plugins.lualine = let + get_lsp_progress = { + __raw = + /* + lua + */ + '' + require('lsp-progress').progress + ''; + }; + in { + sections = { + lualine_c = [{name = get_lsp_progress;}]; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua new file mode 100644 index 00000000..4273085c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua @@ -0,0 +1,150 @@ +--- @type table<string, any> +require("lsp-progress").setup({ + -- Spinning icons. + -- + --- @type string[] + spinner = { "⣾"; "⣽"; "⣻"; "⢿"; "⡿"; "⣟"; "⣯"; "⣷"; }; + + -- Spinning update time in milliseconds. + -- + --- @type integer + spin_update_time = 200; + + -- Last message cached decay time in milliseconds. + -- + -- Message could be really fast(appear and disappear in an + -- instant) that user cannot even see it, thus we cache the last message + -- for a while for user view. + -- + --- @type integer + decay = 700; + + -- User event name. + -- + --- @type string + event = "LspProgressStatusUpdated"; + + -- Event update time limit in milliseconds. + -- + -- Sometimes progress handler could emit many events in an instant, while + -- refreshing statusline cause too heavy synchronized IO, so we limit the + -- event rate to reduce this cost. + -- + --- @type integer + event_update_time_limit = 100; + + -- Max progress string length, by default -1 is unlimited. + -- + --- @type integer + max_size = -1; + + -- Regular internal update time. + -- + -- Emit user event to update the lsp progress status, even there's no new + -- message. + -- + --- @type integer + regular_internal_update_time = 500; + + -- Disable emitting events on specific mode/filetype. + -- User events would interrupt insert mode, thus break which-key like plugins behaviour. + -- See: + -- * https://github.com/linrongbin16/lsp-progress.nvim/issues/50 + -- * https://neovim.io/doc/user/builtin.html#mode() + -- + --- @type table[] + disable_events_opts = { { mode = "i"; filetype = "TelescopePrompt"; }; }; + + -- Format series message. + -- + -- By default it looks like: `formatting isort (100%) - done`. + -- + --- @param title string|nil + --- Message title. + --- @param message string|nil + --- Message body. + --- @param percentage number|nil + --- Progress in percentage numbers: 0-100. + --- @param done boolean + --- Indicate whether this series is the last one in progress. + --- @return string|nil messages + --- The returned value will be passed to function `client_format` as + --- one of the `series_messages` array, or ignored if return nil. + series_format = function(title, message, percentage, done) + local builder = {} + local has_title = false + local has_message = false + if title and title ~= "" then + table.insert(builder, title) + has_title = true + end + if message and message ~= "" then + table.insert(builder, message) + has_message = true + end + if percentage and (has_title or has_message) then + table.insert(builder, string.format("(%.0f%%%%)", percentage)) + end + if done and (has_title or has_message) then + table.insert(builder, "- done") + end + return table.concat(builder, " ") + end; + + -- Format client message. + -- + -- By default it looks like: + -- `[null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)`. + -- + --- @param client_name string + --- Client name. + --- @param spinner string + --- Spinner icon. + --- @param series_messages string[]|table[] + --- Messages array. + --- @return string|nil messages + --- The returned value will be passed to function `format` as one of the + --- `client_messages` array, or ignored if return nil. + client_format = function(client_name, spinner, series_messages) + return #series_messages > 0 + and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) + or nil + end; + + -- Format (final) message. + -- + -- By default it looks like: + -- ` LSP [null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)` + -- + --- @param client_messages string[]|table[] + --- Client messages array. + --- @return nil|string message + --- The returned value will be returned from `progress` API. + format = function(client_messages) + local sign = " LSP" -- nf-fa-gear \uf013 + return #client_messages > 0 and (sign .. " " .. table.concat(client_messages, " ")) or sign + end; + + -- Enable debug. + -- + --- @type boolean + debug = false; + + -- Print log to console(command line). + -- + --- @type boolean + console_log = false; + + -- Print log to file. + -- + --- @type boolean + file_log = true; + + -- Log file to write, work with `file_log=true`. + -- + -- For Windows: `$env:USERPROFILE\AppData\Local\nvim-data\lsp-progress.log`. + -- For *NIX: `~/.local/share/nvim/lsp-progress.log`. + -- + --- @type string + file_log_name = "lsp-progress.log"; +}) diff --git a/hm/soispha/conf/nvim/plgs/lsp/default.nix b/hm/soispha/conf/nvim/plgs/lsp/default.nix new file mode 100644 index 00000000..b7c1e174 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/default.nix @@ -0,0 +1,29 @@ +{...}: { + imports = [ + ./keymaps + ./servers + ]; + programs.nixvim.plugins.lsp = { + enable = true; + onAttach = + "" + # + '' + # function(client, bufnr) + # -- Enable completion triggered by <c-x><c-o> + # -- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + # end + # '' + ; + preConfig = '' + vim.diagnostic.config({ + underline = true, + -- virtual_text = true, + virtual_text = { + source = "always", -- Or "if_many" + }, + update_in_insert = true, + severity_sort = true, + }, nil); + ''; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/keymaps/default.nix b/hm/soispha/conf/nvim/plgs/lsp/keymaps/default.nix new file mode 100644 index 00000000..4017521d --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/keymaps/default.nix @@ -0,0 +1,72 @@ +{...}: { + programs.nixvim = { + plugins.lsp.keymaps = { + diagnostic = { + "N" = { + action = "goto_prev"; + desc = "go to previous diagnostic message"; + }; + "T" = { + action = "goto_next"; + desc = "go to next diagnostic message"; + }; + "<space>e" = { + action = "open_float"; + desc = "open float for the symbol"; + }; + "<space>gq" = { + action = "setloclist"; + desc = "add buffer diagnostic to the location list (quick-fix)"; + }; + }; + lspBuf = { + "<space>gD" = { + action = "declaration"; + desc = "[G]o to [d]eclaration"; + }; + "<space>hi" = { + action = "hover"; + desc = "Display [h]over [i]nformation"; + }; + "<space>sh" = { + action = "signature_help"; + desc = "Display [s]ignature [h]elp"; + }; + "<space>wa" = { + action = "add_workspace_folder"; + desc = "[W]orkspace folder [a]dd"; + }; + "<space>wr" = { + action = "remove_workspace_folder"; + desc = "[W]orkspace folder [r]emove"; + }; + "<space>rn" = { + action = "rename"; + desc = "[R]e[n]ame the item under the cursor"; + }; + "<space>ca" = { + action = "code_action"; + desc = "Open the [c]ode [a]ction menu"; + }; + }; + }; + maps = { + normal = { + "<space>f" = { + action = "function() vim.lsp.buf.format { async = true } end"; + lua = true; + desc = "[F]ormat the current buffer (asynchronously)"; + }; + "<space>wl" = { + action = '' + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + ''; + lua = true; + desc = "[W]orkspace folders [l]ist"; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/servers/default.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/default.nix new file mode 100644 index 00000000..8ffac2e1 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/servers/default.nix @@ -0,0 +1,11 @@ +{...}: { + imports = [ + ./servers/bashls.nix + ./servers/ltex.nix + ./servers/lua-ls.nix + ./servers/nil_ls.nix + ./servers/rust-analyzer.nix + ./servers/texlab.nix + ./servers/ccls.nix + ]; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/servers/servers/bashls.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/bashls.nix new file mode 100644 index 00000000..0577a335 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/bashls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + bashls.enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/servers/servers/ccls.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/ccls.nix new file mode 100644 index 00000000..0698bcce --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/ccls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + ccls.enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/servers/servers/ltex.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/ltex.nix new file mode 100644 index 00000000..0d039f82 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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 = false; + language = "en-CA"; + additionalRules = { + enablePickyRules = true; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lsp/servers/servers/lua-ls.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/lua-ls.nix new file mode 100644 index 00000000..5a44b500 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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/hm/soispha/conf/nvim/plgs/lsp/servers/servers/nil_ls.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/nil_ls.nix new file mode 100644 index 00000000..f0cccbdc --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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/hm/soispha/conf/nvim/plgs/lsp/servers/servers/rust-analyzer.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/rust-analyzer.nix new file mode 100644 index 00000000..943a8c80 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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/hm/soispha/conf/nvim/plgs/lsp/servers/servers/texlab.nix b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/texlab.nix new file mode 100644 index 00000000..59af8d39 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lsp/servers/servers/texlab.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + texlab = { + enable = true; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/lspkind/default.nix b/hm/soispha/conf/nvim/plgs/lspkind/default.nix new file mode 100644 index 00000000..ed7d411b --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lspkind/default.nix @@ -0,0 +1,6 @@ +{...}: { + programs.nixvim.plugins.lspkind = { + enable = true; + preset = "default"; # "codicons" is only for a font patched with vscode-codeicons. + }; +} diff --git a/hm/soispha/conf/nvim/plgs/ltex_extra/default.nix b/hm/soispha/conf/nvim/plgs/ltex_extra/default.nix new file mode 100644 index 00000000..3d1c60fc --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/ltex_extra/default.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: { + programs.nixvim = { + # TODO: package ltex_extra though a module + extraPlugins = [ + pkgs.vimExtraPlugins.ltex-extra-nvim + ]; + plugins.lsp.servers.ltex.onAttach.function = builtins.readFile ./lua/ltex_extra.lua; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua new file mode 100644 index 00000000..9bcfd33c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua @@ -0,0 +1,16 @@ +require("ltex_extra").setup({ + -- table <string> : languages for witch dictionaries will be loaded, e.g. { "es-AR", "en-US" } + -- https://valentjn.github.io/ltex/supported-languages.html#natural-languages + load_langs = {"en-CA", "de-DE"}; -- en-US as default + -- boolean : whether to load dictionaries on startup + init_check = true; + -- string : relative or absolute path to store dictionaries + -- e.g. subfolder in the project root or the current working directory: ".ltex" + -- e.g. shared files for all projects: vim.fn.expand("~") .. "/.local/share/ltex" + path = vim.fn.expand("~") .. "/.local/state/nvim/ltex"; -- project root or current working directory + -- string : "none", "trace", "debug", "info", "warn", "error", "fatal" + log_level = "warn"; + -- table : configurations of the ltex language server. + -- Only if you are calling the server from ltex_extra + server_opts = nil; +}) diff --git a/hm/soispha/conf/nvim/plgs/lualine/default.nix b/hm/soispha/conf/nvim/plgs/lualine/default.nix new file mode 100644 index 00000000..0b789558 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/lualine/default.nix @@ -0,0 +1,114 @@ +{...}: { + programs.nixvim.plugins.lualine = let + get_location_of_file = { + __raw = '' + function() + local file_lines = vim.fn.line('$'); + local file_current_cursor_positon = vim.fn.getcurpos(); + return file_current_cursor_positon[3] .. ":" .. file_current_cursor_positon[2] .. "/" .. file_lines + end + ''; + }; + + get_trailing_whitespace = { + __raw = '' + function() + local space = vim.fn.search([[\s\+$]], 'nwc') + return space ~= 0 and "TW:" .. space or "" + end + ''; + }; + get_mixed_indent = { + __raw = + /* + lua + */ + '' + function() + local space_pat = [[\v^ +]] + local tab_pat = [[\v^\t+]] + local space_indent = vim.fn.search(space_pat, 'nwc') + local tab_indent = vim.fn.search(tab_pat, 'nwc') + local mixed = (space_indent > 0 and tab_indent > 0) + local mixed_same_line + if not mixed then + mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc') + mixed = mixed_same_line > 0 + end + if not mixed then return "" end + if mixed_same_line ~= nil and mixed_same_line > 0 then + return 'MI:' .. mixed_same_line + end + local space_indent_cnt = vim.fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total + local tab_indent_cnt = vim.fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total + if space_indent_cnt > tab_indent_cnt then + return 'MI:' .. tab_indent + else + return 'MI:' .. space_indent + end + end + ''; + }; + in { + enable = true; + 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"]; + lualine_b = [ + { + name = "FugitiveHead"; + icon = ""; + } + "diff" + "diagnostics" + ]; + lualine_c = ["filename"]; + lualine_x = ["searchcount" "filetype"]; + lualine_y = [ + "encoding" + "fileformat" + {name = get_mixed_indent;} + {name = get_trailing_whitespace;} + ]; + lualine_z = [{name = get_location_of_file;}]; + }; + inactiveSections = { + lualine_a = []; + lualine_b = []; + lualine_c = ["filename"]; + lualine_x = [{name = get_location_of_file;}]; + lualine_y = []; + lualine_z = []; + }; + tabline = {}; + winbar = {}; + inactiveWinbar = {}; + + # TODO: add all installed and supported extensions here + extensions = [ + "toggleterm" + #"fugitive" # TODO: maybe add this? + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/luasnip/default.nix b/hm/soispha/conf/nvim/plgs/luasnip/default.nix new file mode 100644 index 00000000..130fafee --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/default.nix @@ -0,0 +1,20 @@ +{ + lib, + pkgs, + ... +}: { + 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}"}); + ''; + extraPlugins = [ + # needed for the todo-comments snippets + pkgs.vimPlugins.comment-nvim + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua new file mode 100644 index 00000000..0a603692 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua @@ -0,0 +1,7 @@ +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/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua new file mode 100644 index 00000000..ba8816aa --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua @@ -0,0 +1,185 @@ +local ls = require("luasnip"); +-- auto_pairs {{{ +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 + +-- This makes creation of pair-type snippets easier. +local function pair(pair_begin, pair_end, file_types, condition_function) + -- FIXME(@Soispha): This only works if file_types == nil, otherwise the snippet does not expand. + -- It would be nice, if it would support both an empty array (`{}`) and nil <2023-08-27> + -- file_types = file_types or {}; + + return s( + { trig = pair_begin; wordTrig = false; snippetType = "autosnippet"; }, + { t({ pair_begin; }); d(1, get_visual); t({ pair_end; }); }, + { + condition = function() + local filetype_check = true; + if file_types ~= nil then + filetype_check = file_types[vim.bo.filetype] or false; + end; + return (not condition_function(pair_begin, pair_end)) and filetype_check + end; + } + ) +end + +local auto_pairs = { + pair("(", ")", nil, char_count_same); + pair("{", "}", nil, char_count_same); + pair("[", "]", nil, char_count_same); + pair("<", ">", { ["rust"] = true; ["tex"] = true; }, char_count_same); + pair("'", "'", nil, even_count); + pair('"', '"', nil, even_count); + pair("`", "`", nil, even_count); +} + +ls.add_snippets("all", auto_pairs, { type = "snippets"; key = "auto_pairs"; }) +-- }}} + +-- todo_comments {{{ +local calculate_comment_string = require("Comment.ft").calculate +local utils = require("Comment.utils") + +--- Get the comment string {beg,end} table +---@param ctype integer 1 for `line`-comment and 2 for `block`-comment +---@return table comment_strings {begcstring, endcstring} +local get_cstring = function(ctype) + -- use the `Comments.nvim` API to fetch the comment string for the region (eq. '--%s' or '--[[%s]]' for `lua`) + local cstring = calculate_comment_string{ ctype = ctype; range = utils.get_region(); } or vim.bo.commentstring + -- as we want only the strings themselves and not strings ready for using `format` we want to split the left and right side + local left, right = utils.unwrap_cstr(cstring) + -- create a `{left, right}` table for it + return { left; right; } +end +_G.luasnip = {} +_G.luasnip.vars = { + username = "@Soispha"; + email = "soispha@vhack.eu"; +} + + +--- Options for marks to be used in a TODO comment +---@return table,table: The first table contains a node for the date, the second for the signature +local marks = { + signature = function() + return t("(" .. _G.luasnip.vars.username .. ")"), t("") + end; + date_signature = function() + return t("<" .. os.date"%Y-%m-%d" .. ">"), t("(" .. _G.luasnip.vars.username .. ")") + end; + date = function() + return t("<" .. os.date"%Y-%m-%d" .. ">"), t("") + end; + empty = function() + return t(""), t("") + end; +} + +---@param alias string +---@param opts table +---@param mark_function function: This function should return two nodes +---@return table: Returns the comment node +local todo_snippet_nodes = function(alias, opts, mark_function) + local date_node, signature_node = mark_function(); + -- format them into the actual snippet + local comment_node = fmta("<> <><>: <> <> <>", { + f(function() + return get_cstring(opts.ctype)[1] -- get <comment-string[1]> + end); + t(alias); -- [name-of-comment] + signature_node; + i(0); -- {comment-text} + date_node; + f(function() + return get_cstring(opts.ctype)[2] -- get <comment-string[2]> + end); + }) + return comment_node +end + +--- Generate a TODO comment snippet with an automatic description and docstring +---@param context table merged with the generated context table `trig` must be specified +---@param alias string of aliases for the todo comment (ex.: {FIX, ISSUE, FIXIT, BUG}) +---@param opts table merged with the snippet opts table +---@param mark_function function: The function used to get the marks +local todo_snippet = function(context, alias, opts, mark_function) + opts = opts or {} + context = context or {} + if not context.trig then + return error("context doesn't include a `trig` key which is mandatory", 2) -- all we need from the context is the trigger + end + opts.ctype = opts.ctype or + 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined + local alias_string = alias -- `choice_node` documentation + context.name = context.name or + (alias_string .. " comment") -- generate the `name` of the snippet if not defined + context.dscr = context.dscr or + (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined + context.docstring = context.docstring or + (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined + local comment_node = todo_snippet_nodes(alias, opts, mark_function) + return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters +end + +---@param context table: The luasnip context +---@param opts table: The luasnip opts table, needs to have a ctype set +---@param aliases string: All aliases for a name +---@param marks table: Possible marks to account in snipped generation +---@return table: All possible snippets build from the marks +local process_marks = function(context, aliases, opts, marks) + local output = {}; + for mark_name, mark_function in pairs(marks) do + local contex_trig_local = context.trig; + context.trig = context.trig .. "-" .. mark_name; + output[#output + 1] = todo_snippet(context, aliases, opts, mark_function); + context.trig = contex_trig_local; + end + return output; +end + +local todo_snippet_specs = { + { { trig = "todo"; }; { "TODO"; }; { ctype = 1; }; }; + { { trig = "fix"; }; { "FIXME"; "ISSUE"; }; { ctype = 1; }; }; + { { trig = "hack"; }; { "HACK"; }; { ctype = 1; }; }; + { { trig = "warn"; }; { "WARNING"; }; { ctype = 1; }; }; + { { trig = "perf"; }; { "PERFORMANCE"; "OPTIMIZE"; }; { ctype = 1; }; }; + { { trig = "note"; }; { "NOTE"; "INFO"; }; { ctype = 1; }; }; + + -- NOTE: Block commented todo-comments + { { trig = "todob"; }; { "TODO"; }; { ctype = 2; }; }; + { { trig = "fixb"; }; { "FIXME"; "ISSUE"; }; { ctype = 2; }; }; + { { trig = "hackb"; }; { "HACK"; }; { ctype = 2; }; }; + { { trig = "warnb"; }; { "WARNING"; }; { ctype = 2; }; }; + { { trig = "perfb"; }; { "PERF"; "PERFORMANCE"; "OPTIM"; "OPTIMIZE"; }; { ctype = 2; }; }; + { { trig = "noteb"; }; { "NOTE"; "INFO"; }; { ctype = 2; }; }; +} + +local todo_comment_snippets = {} +for _, v in ipairs(todo_snippet_specs) do + local snippets = process_marks(v[1], v[2][1], v[3], marks) + for _, value in pairs(snippets) do table.insert(todo_comment_snippets, value) end +end + +ls.add_snippets("all", todo_comment_snippets, { type = "snippets"; key = "todo_comments"; }) + +-- }}} diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua new file mode 100644 index 00000000..c467dd68 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua @@ -0,0 +1,108 @@ +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/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua new file mode 100644 index 00000000..e50898fc --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua @@ -0,0 +1,34 @@ +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 = { ["("] = ")"; ["{"] = "}"; ["["] = "]"; } + +-- 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/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua new file mode 100644 index 00000000..19989093 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua @@ -0,0 +1,37 @@ +-- 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/hm/soispha/conf/nvim/plgs/neorg/default.nix b/hm/soispha/conf/nvim/plgs/neorg/default.nix new file mode 100644 index 00000000..2014af9f --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/neorg/default.nix @@ -0,0 +1,55 @@ +{...}: { + programs.nixvim.plugins.neorg = { + enable = true; + lazyLoading = true; + + modules = { + "core.defaults" = { + __empty = null; + }; + "core.esupports.metagen".config = { + type = "auto"; + }; + "core.journal".config = { + workspace = "journal"; + }; + "core.keybinds".config = { + hook = { + __raw = '' + function(keybinds) + -- remap the looking glas to the same key, femaco is also mapped to. + keybinds.remap_event("norg", "n", "<space>cc", "core.looking-glass.magnify-code-block") + + keybinds.remap_event("norg", "n", "<C-s>", "core.integrations.telescope.find_linkable") + keybinds.remap_event("norg", "i", "<C-i>", "core.integrations.telescope.insert_link") + end, + ''; + }; + }; + "core.completion".config = { + engine = "nvim-cmp"; + }; + "core.concealer".config = { + __empty = null; + }; + "core.dirman".config = { + workspaces = { + general = "~/repos/notes/general"; + journal = "~/repos/notes/journal"; + }; + }; + "core.export".config = { + __empty = null; + }; + "core.integrations.telescope".config = { + __empty = null; + }; + + # TODO: Add this when the nvim version in nixpkgs is >= 0.10 <2023-08-29> + # + # "core.ui.calendar".config = { + # __empty = null; + # }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/nvim-cmp/default.nix b/hm/soispha/conf/nvim/plgs/nvim-cmp/default.nix new file mode 100644 index 00000000..ceb09182 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/nvim-cmp/default.nix @@ -0,0 +1,54 @@ +{config, ...}: { + programs.nixvim.plugins.nvim-cmp = let + neorg_source = + if config.programs.nixvim.plugins.neorg.modules."core.completion".config.engine == "nvim-cmp" + then [{name = "neorg";}] + else []; + in { + /* + 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"; + }; + "HH" = { + action = "cmp.mapping.complete()"; + #desc = "Confirm snipped"; + }; + }; + + snippet.expand = "luasnip"; + + sources = + [ + {name = "nvim_lsp";} + {name = "luasnip";} + ] + ++ neorg_source; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/nvim-lint/default.nix b/hm/soispha/conf/nvim/plgs/nvim-lint/default.nix new file mode 100644 index 00000000..c583ebf6 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/nvim-lint/default.nix @@ -0,0 +1,15 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package nvim-lint though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/nvim-lint.lua} + ''; + extraPlugins = [ + pkgs.vimExtraPlugins.nvim-lint + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua b/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua new file mode 100644 index 00000000..582da638 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/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/hm/soispha/conf/nvim/plgs/raw_plugins/default.nix b/hm/soispha/conf/nvim/plgs/raw_plugins/default.nix new file mode 100644 index 00000000..941cb7cb --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/raw_plugins/default.nix @@ -0,0 +1,11 @@ +{...}: { + 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: + # https://github.com/jooooscha/nixpkgs-vim-extra-plugins/blob/main/plugins.md + extraPlugins = [ + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/default.nix b/hm/soispha/conf/nvim/plgs/telescope/default.nix new file mode 100644 index 00000000..b5054ed0 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/default.nix @@ -0,0 +1,10 @@ +{...}: { + imports = [ + ./defaults + ./keymaps + ./extensions + ]; + programs.nixvim.plugins.telescope = { + enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/defaults/default.nix b/hm/soispha/conf/nvim/plgs/telescope/defaults/default.nix new file mode 100644 index 00000000..1d88aad8 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/defaults/default.nix @@ -0,0 +1,30 @@ +{...}: { + programs.nixvim.plugins.telescope.defaults = { + mappings = let + insert_and_normal_mappings = { + # map actions.which_key to <c-h> (default: <c-/>) + # actions.which_key shows the mappings for your picker, + # e.g. git_{create, delete, ...}_branch for the git_branches picker + "<C-h>" = "which_key"; + }; + in { + i = + insert_and_normal_mappings; + n = + { + "t" = "move_selection_next"; + "n" = "move_selection_previous"; + "<Space>" = "toggle_all"; + + "<C-d>" = "preview_scrolling_up"; + "<C-u>" = "preview_scrolling_down"; + "<Left>" = "preview_scrolling_left"; + "<Right>" = "preview_scrolling_right"; + + "<Esc>" = "close"; + "q" = "close"; + } + // insert_and_normal_mappings; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/bibtex/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/bibtex/default.nix new file mode 100644 index 00000000..12c9736c --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/bibtex/default.nix @@ -0,0 +1,13 @@ +{pkgs, ...}: { + # WARNING: This is only activated in tex files via the ftplugin. + programs.nixvim = { + extraPlugins = [ + pkgs.vimExtraPlugins.telescope-bibtex-nvim + ]; + maps.normal = { + "<space>ib" = { + desc = "[i]nsert a [b]atex citation"; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/default.nix new file mode 100644 index 00000000..0b1e033a --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/default.nix @@ -0,0 +1,9 @@ +{...}: { + imports = [ + ./bibtex + ./frecency + ./fzy-native + ./rooter + ./symbols + ]; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/frecency/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/frecency/default.nix new file mode 100644 index 00000000..4a4c22be --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/frecency/default.nix @@ -0,0 +1,22 @@ +{...}: { + programs.nixvim = { + maps = { + normal = { + "gff" = { + action = "function() require('telescope').extensions.frecency.frecency() end"; + lua = true; + desc = "activate the frecency file selection"; + }; + }; + }; + plugins.telescope = { + extensions.frecency = { + enable = true; + showUnindexed = true; + showScores = true; + # TODO: add this: + #db_safe_mode = true; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/fzy-native/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/fzy-native/default.nix new file mode 100644 index 00000000..ce0bdccc --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/fzy-native/default.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.telescope.extensions.fzy-native = { + enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/default.nix new file mode 100644 index 00000000..779448cc --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/default.nix @@ -0,0 +1,7 @@ +{lib, ...}: { + programs.nixvim = { + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/rooter.lua} + ''; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua new file mode 100644 index 00000000..eaf68ecf --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua @@ -0,0 +1,84 @@ +-- Taken from: https://github.com/desdic/telescope-rooter.nvim/blob/69423216c75a5f1f1477bbf8faf6b0dc8af04099/lua/telescope/_extensions/rooter.lua +local has_telescope, telescope = pcall(require, "telescope") +if not has_telescope then + error("This extension requires telescope.nvim") + return +end + +local has_plenary, plenary = pcall(require, "plenary") +if not has_plenary then + error("This extension requires plenary") + return +end + +local log = plenary.log.new({ plugin = "telescope_rooter"; level = "info"; }) + +-- TODO: expose this function +local toggle = function(_) + vim.g["Telescope#rooter#enabled"] = not vim.g["Telescope#rooter#enabled"] + print("Telescope#rooter#enabled=" .. vim.inspect(vim.g["Telescope#rooter#enabled"])) +end + +local config = { patterns = { ".git"; }; enable = true; debug = false; } + +-- default enabled +vim.g["Telescope#rooter#enabled"] = vim.F.if_nil(config.enable, true) + +-- redefine log if debug enabled +if vim.F.if_nil(config.debug, false) then + log = plenary.log.new({ plugin = "telescope_rooter"; level = "debug"; }) +end + +local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true; }) + +vim.api.nvim_create_autocmd({ "DirChangedPre"; }, { + callback = function() + if vim.g["Telescope#rooter#enabled"] ~= true then + return + end + + if vim.g["Telescope#rooter#oldpwd"] == nil then + vim.g["Telescope#rooter#oldpwd"] = vim.loop.cwd() + log.debug("before " .. vim.inspect(vim.loop.cwd())) + end + end; + group = group; +}) + +vim.api.nvim_create_autocmd({ "BufEnter"; "BufWinEnter"; }, { + callback = function() + if vim.g["Telescope#rooter#enabled"] ~= true then + return + end + + vim.schedule(function() + if vim.bo.filetype == "TelescopePrompt" then + local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true; })[1]) + if rootdir ~= nil then + vim.api.nvim_set_current_dir(rootdir) + log.debug("changing dir to " .. rootdir) + end + end + end) + end; + group = group; +}) + +vim.api.nvim_create_autocmd({ "BufWinLeave"; }, { + callback = function() + if vim.g["Telescope#rooter#enabled"] ~= true then + return + end + + vim.schedule(function() + if vim.bo.filetype ~= "TelescopePrompt" then + if vim.g["Telescope#rooter#oldpwd"] ~= nil then + log.debug("restoring " .. vim.g["Telescope#rooter#oldpwd"]) + vim.api.nvim_set_current_dir(vim.g["Telescope#rooter#oldpwd"]) + vim.g["Telescope#rooter#oldpwd"] = nil + end + end + end) + end; + group = group; +}) diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/symbols/default.nix b/hm/soispha/conf/nvim/plgs/telescope/extensions/symbols/default.nix new file mode 100644 index 00000000..fe38f8c1 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/symbols/default.nix @@ -0,0 +1,51 @@ +{pkgs, ...}: { + programs.nixvim = { + extraPlugins = [ + # Source of symbols for telescope symbols + pkgs.vimPlugins.telescope-symbols-nvim + ]; + maps = { + normal = { + "<space>il" = { + action = '' + function() + require('telescope.builtin').symbols{ sources = { + 'latex' + }} + end + ''; + lua = true; + desc = "[i]nsert a [l]atex symbol"; + }; + "<space>ie" = { + action = '' + function() + require('telescope.builtin').symbols{ sources = { + 'emoji', + }} + end + ''; + lua = true; + desc = "[i]nsert a [e]moji"; + }; + "<space>is" = { + action = '' + function() + require('telescope.builtin').symbols{ sources = { + 'emoji', + 'gitmoji', + 'julia', + 'kaomoji', + 'latex', + 'math', + 'nerd', + }} + end + ''; + lua = true; + desc = "[i]nsert a [s]ymbol (like emojis)"; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/telescope/keymaps/default.nix b/hm/soispha/conf/nvim/plgs/telescope/keymaps/default.nix new file mode 100644 index 00000000..f0745f73 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/telescope/keymaps/default.nix @@ -0,0 +1,8 @@ +{...}: { + programs.nixvim.plugins.telescope.keymaps = { + "<space>rg" = { + action = "live_grep"; + desc = "[rg] in a live session"; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/todo-comments/default.nix b/hm/soispha/conf/nvim/plgs/todo-comments/default.nix new file mode 100644 index 00000000..35f4b283 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/todo-comments/default.nix @@ -0,0 +1,49 @@ +{...}: { + programs.nixvim.plugins.todo-comments = { + enable = true; + guiStyle = { + fg = "BOLD"; + bg = "NONE"; + }; + highlight = { + keyword = "wide_fg"; + }; + keywords = { + /* + # Defaults: + FIX = { + icon = " "; # Icon used for the sign, and in search results. + color = "error"; # Can be a hex color, or a named color. + alt = ["FIXME" "BUG" "FIXIT" "ISSUE"]; # A set of other keywords that all map to this FIX keywords. + }; + TODO = { + icon = " "; + color = "info"; + }; + HACK = { + icon = " "; + color = "warning"; + }; + WARN = { + icon = " "; + color = "warning"; + alt = ["WARNING" "XXX"]; + }; + PERF = { + icon = " "; + alt = ["OPTIM" "PERFORMANCE" "OPTIMIZE"]; + }; + NOTE = { + icon = " "; + color = "hint"; + alt = ["INFO"]; + }; + TEST = { + icon = "⏲ "; + color = "test"; + alt = ["TESTING" "PASSED" "FAILED"]; + }; + */ + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/treesitter/default.nix b/hm/soispha/conf/nvim/plgs/treesitter/default.nix new file mode 100644 index 00000000..9d30d6b9 --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/treesitter/default.nix @@ -0,0 +1,40 @@ +{...}: { + programs.nixvim.plugins.treesitter = { + enable = true; + + 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; + disable = ["latex"]; + + # Setting this to true will run `:h syntax` and tree-sitter at the same time. + # 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 + additionalVimRegexHighlighting = [""]; + }; + */ + + incrementalSelection = { + enable = true; + keymaps = { + # TODO: include these + initSelection = "gnn"; # set to `false` to disable one of the mappings + nodeIncremental = "grn"; + scopeIncremental = "grc"; + nodeDecremental = "grm"; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/vim-tex/default.nix b/hm/soispha/conf/nvim/plgs/vim-tex/default.nix new file mode 100644 index 00000000..9b5cea5e --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/vim-tex/default.nix @@ -0,0 +1,59 @@ +{...}: { + 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"; + + # Useful if treesitter is the highlighter + #syntax_enabled = 0; + #syntax_conceal_disable = 1; + + 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" + ]; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plgs/which-key/default.nix b/hm/soispha/conf/nvim/plgs/which-key/default.nix new file mode 100644 index 00000000..be63f7ac --- /dev/null +++ b/hm/soispha/conf/nvim/plgs/which-key/default.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.which-key = { + enable = true; + }; +} |