diff options
Diffstat (limited to 'hm/soispha/conf/nvim')
57 files changed, 2274 insertions, 0 deletions
diff --git a/hm/soispha/conf/nvim/autocmds/default.nix b/hm/soispha/conf/nvim/autocmds/default.nix new file mode 100644 index 00000000..cb0311fb --- /dev/null +++ b/hm/soispha/conf/nvim/autocmds/default.nix @@ -0,0 +1,99 @@ +{config, ...}: { + programs.nixvim = { + autoGroups = { + cursor_off = {clear = true;}; + colorcolumn_toggle = {clear = true;}; + numbertoggle = {clear = true;}; + coloroverride = {clear = true;}; + highlight_on_yank = {clear = true;}; + }; + autoCmd = [ + { + event = ["TextYankPost"]; + pattern = ["*"]; + callback = { + __raw = '' + function() + vim.highlight.on_yank() + end + ''; + }; + group = "highlight_on_yank"; + description = "Highlight the yanked text"; + } + { + event = ["BufWritePre"]; + pattern = ["*"]; + command = '' + ks | if search("\\s\\+$", 'n') != 0 | :%s/\s\+$// | endif | 's + ''; + description = '' + Remove trailing whitespace on safe + :%s/\s\+$\| \+\ze\t//g >> For trailing spaces and spaces before tabstops + ''; + } + + { + event = ["WinLeave"]; + pattern = ["*"]; + command = "set nocursorline"; # TODO: possible also nocursorcolumn + group = "cursor_off"; + description = "Display cursorline and cursorcolumn ONLY in active window."; + } + { + event = ["WinEnter"]; + pattern = ["*"]; + command = "set cursorline"; # TODO: possible also cursorcolumn + group = "cursor_off"; + description = "Display cursorline and cursorcolumn ONLY in active window."; + } + + { + event = ["InsertEnter"]; + pattern = ["*"]; + command = "set colorcolumn=${config.programs.nixvim.options.colorcolumn}"; + group = "colorcolumn_toggle"; + description = "Only activate the colorcolumn when focused"; + } + { + event = ["BufLeave" "FocusLost" "InsertLeave" "WinLeave"]; + pattern = ["*"]; + command = "set colorcolumn=0"; + group = "colorcolumn_toggle"; + description = "Only activate the colorcolumn when focused"; + } + + { + event = ["BufEnter" "FocusGained" "InsertLeave" "WinEnter"]; + pattern = ["*"]; + command = "if &nu && mode() != \"i\" | set rnu | endif"; + group = "numbertoggle"; + description = "Change line numbers, when not focused"; + } + { + event = ["BufLeave" "FocusLost" "InsertEnter" "WinLeave"]; + pattern = ["*"]; + command = "if &nu | set nornu | endif"; + group = "numbertoggle"; + description = "Change line numbers, when not focused"; + } + + { + # Override LineNr + event = ["ColorScheme"]; + pattern = ["*"]; + command = "highlight LineNr ctermfg=DarkGrey guifg=DarkGrey "; + group = "coloroverride"; + description = "Changes Line number colors"; + } + { + # Override CursorLineNr + event = ["ColorScheme"]; + pattern = ["*"]; + command = "highlight CursorLineNr ctermfg=White guifg=White "; + group = "coloroverride"; + description = "Changes Line number colors"; + } + ]; + }; +} diff --git a/hm/soispha/conf/nvim/clipboard/default.nix b/hm/soispha/conf/nvim/clipboard/default.nix new file mode 100644 index 00000000..0a686190 --- /dev/null +++ b/hm/soispha/conf/nvim/clipboard/default.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim = { + clipboard.providers = { + wl-copy.enable = true; + }; + }; +} diff --git a/hm/soispha/conf/nvim/default.nix b/hm/soispha/conf/nvim/default.nix new file mode 100644 index 00000000..61467618 --- /dev/null +++ b/hm/soispha/conf/nvim/default.nix @@ -0,0 +1,48 @@ +{ + pkgs, + lib, + ... +}: { + imports = [ + ./autocmds + ./clipboard + ./files + ./mappings + ./options + ./plugins + ]; + programs.nixvim = { + enable = true; + + # source: https://www.patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Neovim + extraConfigLuaPre = lib.mkBefore '' + --------------------------------------------------------------------------- + -- + -- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ + -- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ + -- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ + -- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ + -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ + -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + -- + --------------------------------------------------------------------------- + ''; + + extraPackages = with pkgs; [ + /* + These are mostly linters and formatters used for different file types. + Including them here is fine, as they are not necessarily sync able to different people. + */ + # nix + alejandra + statix + + # yaml + yamllint + + # shell + shellcheck + shfmt + ]; + }; +} diff --git a/hm/soispha/conf/nvim/files/default.nix b/hm/soispha/conf/nvim/files/default.nix new file mode 100644 index 00000000..5045eb9f --- /dev/null +++ b/hm/soispha/conf/nvim/files/default.nix @@ -0,0 +1,17 @@ +{ + lib, + pkgs, + ... +}: { + programs.nixvim = { + extraPlugins = [ + pkgs.vimExtraPlugins.gruvbox + ]; + extraFiles = { + path = "ftplugin/tex.lua"; + content = '' + ${lib.strings.fileContents ./ftplugin/tex.lua} + ''; + }; + }; +} diff --git a/hm/soispha/conf/nvim/files/ftplugin/tex.lua b/hm/soispha/conf/nvim/files/ftplugin/tex.lua new file mode 100644 index 00000000..8f39d7bb --- /dev/null +++ b/hm/soispha/conf/nvim/files/ftplugin/tex.lua @@ -0,0 +1,78 @@ +-- local used = false; +-- vim.keymap.set('n', '<leader>t', function() +-- used = not used; +-- if used then +-- require('nvim-treesitter.configs').setup { +-- highlight = { +-- additional_vim_regex_highlighting = { "latex", "markdown" }, +-- }, +-- } +-- else +-- require('nvim-treesitter.configs').setup { +-- highlight = { +-- additional_vim_regex_highlighting = { "" }, +-- }, +-- } +-- end +-- end +-- ); +-- +-- +-- Set non-treesitter colorscheme +require("gruvbox").setup({ + undercurl = true; + underline = true; + bold = true; + italic = { strings = true; comments = true; operators = false; folds = true; }; + strikethrough = true; + invert_selection = false; + invert_signs = false; + invert_tabline = false; + invert_intend_guides = false; + inverse = true; -- invert background for search, diffs, statuslines and errors + contrast = ""; -- can be "hard", "soft" or empty string + palette_overrides = {}; + overrides = {}; + dim_inactive = false; + transparent_mode = false; +}) +vim.cmd("colorscheme gruvbox") + +require("lualine").setup({ options = { theme = "gruvbox"; }; }) + +-- Set tex specific telescope extension +require("telescope").setup({ + extensions = { + bibtex = { + -- Depth for the *.bib file + depth = 1; + -- Path to global bibliographies (placed outside of the project) + global_files = {}; + -- Define the search keys to use in the picker + search_keys = { "author"; "year"; "title"; }; + -- Template for the formatted citation + citation_format = "{{author}} ({{year}}), {{title}}."; + -- Only use initials for the authors first name + citation_trim_firstname = true; + -- Max number of authors to write in the formatted citation + -- following authors will be replaced by "et al." + citation_max_auth = 2; + -- Wrapping in the preview window is disabled by default + wrap = false; + -- Custom format for citation label + custom_formats = { + { id = "tex_autocite"; cite_marker = "\\autocite{%s}"; }; + }; + format = "tex_autocite"; + -- Use context awareness + context = true; + -- Fallback to global/directory .bib files if context not found + -- This setting has no effect if context = false + context_fallback = true; + }; + }; +}) +require("telescope").load_extension("bibtex") +vim.api.nvim_set_keymap("n", "<leader>ib", function() + require("telescope").extensions.bibtex.bibtex() + end, { noremap = true; silent = true; desc = "list bibtex entries in telescope"; }) diff --git a/hm/soispha/conf/nvim/mappings/default.nix b/hm/soispha/conf/nvim/mappings/default.nix new file mode 100644 index 00000000..1d00b0a4 --- /dev/null +++ b/hm/soispha/conf/nvim/mappings/default.nix @@ -0,0 +1,222 @@ +{lib, ...}: { + programs.nixvim = { + globals = { + mapleader = " "; + maplocalleader = " "; + }; + maps = let + normal_and_insert = { + "<Esc>" = { + action = "<cmd>noh<CR><Esc>"; + desc = "Disable the search highlighting and send Escape"; + }; + }; + in { + insert = + lib.recursiveUpdate { + "hh" = { + action = '' + function() + local cmp = require('cmp'); + local luasnip = require('luasnip'); + + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end + ''; + lua = true; + desc = "completion trigger/ forward in completen menu"; + }; + "cc" = { + action = '' + function() + local cmp = require('cmp'); + cmp.confirm() + end + ''; + lua = true; + desc = "confirm the selected item"; + }; + } + normal_and_insert; + normalVisualOp = { + # yank/ cut to the system clipboard + "<leader>y" = { + action = "\"+y"; + desc = "yank to the system clipboard"; + }; + "<leader>Y" = { + action = "\"+Y"; + desc = "yank until the end of the line to the system clipboard"; + }; + + # Unmap some old keys + #"s" = "'<Nop>'"; + #"t" = "'<Nop>'"; + "<Up>" = "<Nop>"; + "<Down>" = "<Nop>"; + "<Left>" = "<Nop>"; + "<Right>" = "<Nop>"; + + # Center the cursor vertically when moving to the next word during a search. + "l" = { + action = "nzzzv"; + desc = "Center the cursor vertically when moving to the next word during a + search."; + }; + "L" = { + action = "Nzzzv"; + desc = "Center the cursor vertically when moving to the next word during a + search."; + }; + # remap the other keys to dvorak + "k" = { + action = "t"; + desc = "go the the right on char"; + }; + "K" = { + action = "T"; + desc = "go to the left on char"; + }; + "j" = { + action = "k"; + desc = "go to the right before the char"; + }; + "J" = { + action = "K"; + desc = "go to the left before the char"; + }; + + # Change Vim-keys + "h" = { + action = "<left>"; + desc = "go left"; + }; + "t" = { + action = "g<down>"; + desc = "go down, with displaylines"; + }; + "n" = { + action = "g<up>"; + desc = "go up, with displaylines"; + }; + "s" = { + action = "<right>"; + desc = "go right"; + }; + + # Move display lines + "0" = { + action = "g0"; + desc = "go to the leftmost character in the screen line"; + }; + "$" = { + action = "g$"; + desc = "go to the rightmost character in the screen line"; + }; + }; + normal = + lib.recursiveUpdate { + "<Tab>" = { + action = ":"; + desc = "jump to command line"; + }; + + "\\f" = { + action = "function() require('lf').start() end"; + lua = true; + desc = "open lf in a floating window"; + }; + + # Splits + "<C-t>" = { + action = "<C-w>p"; + desc = "go to previous split"; + }; + "<C-n>" = { + action = "<C-w>w"; + desc = "go to next split"; + }; + "<leader>-" = { + action = "<C-W>s"; + desc = "New horizontal split"; + }; + "<leader>|" = { + action = "<C-W>v"; + desc = "New vertical split"; + }; + + # Exit insert mode after creating a new line above or below the current line."; + "o" = { + action = "o<Esc>"; + desc = "add new line below"; + }; + "O" = { + action = "O<Esc>"; + desc = "add new line above"; + }; + + "<leader>p" = { + action = "\"_dP"; + desc = "keep the cut thing in the base register"; + }; + + "<leader>d" = { + action = "\"_d"; + desc = "delete without saving to register"; + }; + "dd" = { + action = '' + function() + if vim.api.nvim_get_current_line():match("^%s*$") then + return '"_dd' + else + return "dd" + end + end + ''; + lua = true; + desc = "Pipe all blank line deletions to the blackhole register"; + expr = true; + silent = true; + }; + + "<leader>s" = { + action = ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>"; + desc = "replace for the word under the cursor"; + }; + + "<C-s>" = { + action = "<cmd>mksession! <CR>"; + desc = "overwrite/create a session"; + }; + + "<leader>X" = { + action = "!!$SHELL <CR>"; + desc = "Read the current line and execute that line in your $SHELL. The resulting output will replace the curent line that was being executed."; + }; + } + normal_and_insert; + terminal = { + "<Esc><Esc>" = { + action = "<C-\\><C-n>"; + desc = "Exit terminal mode with <Esc><Esc>"; + }; + }; + visual = { + # move selected lines in visual mode + "T" = { + action = ":m '>+1<CR>gv=gv"; + desc = "move selected lines in visual mode down"; + }; + "N" = { + action = ":m '<-2<CR>gv=gv"; + desc = "move selected lines in visual mode up"; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/options/default.nix b/hm/soispha/conf/nvim/options/default.nix new file mode 100644 index 00000000..879a5cd1 --- /dev/null +++ b/hm/soispha/conf/nvim/options/default.nix @@ -0,0 +1,105 @@ +{nixosConfig, ...}: { + programs.nixvim.options = { + autoindent = true; # copy indent from previous line + cindent = true; # use c like indenting rules + breakindent = true; # continue indent visually + showbreak = "↳ "; # downwards arrow with tip rightwards(U+21B3, UTF-8: E2 86 B3) + breakindentopt = { + shift = 2; # wrapped line's beginning will be shifted by the given number of + }; + + incsearch = true; # show search results while typing + inccommand = "split"; # line preview of :s results + ignorecase = true; # ignore case when searching + smartcase = true; # if a capital letter is used in search, overwrite ignorecase + showmatch = true; # show matching words during a search. + hlsearch = true; # highlight when searching + + confirm = true; # confirm to save changes before closing modified buffer + colorcolumn = "+1"; # show a +1 before the 'textwidth' + completeopt = ["menuone" "noselect"]; # have a better completion experience + + # https://www.compart.com/en/unicode/U+XXXX (unicode character code) + # stylua: ignore + fillchars = { + fold = "·"; # MIDDLE DOT (U+00B7, UTF-8: C2 B7) + horiz = "━"; # BOX DRAWINGS HEAVY HORIZONTAL (U+2501, UTF-8: E2 94 81) + horizdown = "┳"; # BOX DRAWINGS HEAVY DOWN AND HORIZONTAL (U+2533, UTF-8: E2 94 B3) + horizup = "┻"; # BOX DRAWINGS HEAVY UP AND HORIZONTAL (U+253B, UTF-8: E2 94 BB) + vert = "┃"; # BOX DRAWINGS HEAVY VERTICAL (U+2503, UTF-8: E2 94 83) + vertleft = "┫"; # BOX DRAWINGS HEAVY VERTICAL AND LEFT (U+252B, UTF-8: E2 94 AB) + vertright = "┣"; # BOX DRAWINGS HEAVY VERTICAL AND RIGHT (U+2523, UTF-8: E2 94 A3) + verthoriz = "╋"; # BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL (U+254B, UTF-8: E2 95 8B) + }; + listchars = builtins.concatStringsSep "," [ + "nbsp:⦸" # CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8) + "tab:▷┅" # WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) + "extends:»" # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB) + "precedes:«" # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB) + "trail:•" # BULLET (U+2022, UTF-8: E2 80 A2) + ]; + + # shell-like autocomplete to unambiguous portions + wildmode = builtins.concatStringsSep "," [ + "longest" + "list" + "full" + ]; + + grepformat = "%f:%l:%c:%m"; # the default format for rg in vimgrep mode + grepprg = "rg --vimgrep"; # use rg as grep implementation in `:grep` + + hidden = true; # allows you to hide buffers with unsaved changes without being prompted + + laststatus = 3; # use global statusline # TODO: + + list = true; # show whitespace + + mouse = ""; # disables the mouse + + number = true; # line numbers + relativenumber = true; # relative line numbers + + # vim.opt.shada:append {'%'}; -- store buffers in the shada file and reopen them if nvim has been started without file name argument + + shell = nixosConfig.users.users.soispha.shell.pname; # try to use default shell for the default user as a shell for ":!" + + spell = true; # activate spell checking + spelllang = "en_us,de_de"; # set spell languages + spelloptions = "camel"; # CamelCase check if both camel and case are correct words + + syntax = "ON"; # use syntax highlighting and let nvim figure out which + + shiftwidth = 0; # use tabstop setting as shiftwidth + tabstop = 4; # use 4 spaces in place of a tab + expandtab = true; # expand tabs to spaces + + showtabline = 2; # always show the tabline + + timeoutlen = 500; # wait 500 msec for the next char in an input sequence + ttyfast = true; # let vim know that I am using a fast term + + undofile = true; # use a undofile, to save the undos + undolevels = 10000; # keep nearly all undo things stored + + virtualedit = "block"; # allow the cursor to move beyond actual character in visual block mode + + textwidth = 120; # automatically hard wrap at 120 columns by default + + foldmethod = "marker"; # use markers to specify folds + + termguicolors = true; + cursorline = true; + # vim.opt.cursorcolumn = true; + + scrolloff = 999; # try to keep at least 999 lines above and below the cursor (this effectively keeps the screen centered) + + linebreak = true; # break to long lines, but do only break them at [[::space::]] + + showcmd = true; # show partial command, being typed + showmode = true; # show the mode (Visual, Insert, Command) + + wildmenu = true; # shell completion + wildignore = "*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx"; # ignore binary files + }; +} diff --git a/hm/soispha/conf/nvim/plugins/colorscheme/default.nix b/hm/soispha/conf/nvim/plugins/colorscheme/default.nix new file mode 100644 index 00000000..21069752 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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 = "duskfox"; + extraPlugins = [ + pkgs.vimExtraPlugins.nightfox-nvim + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/colorscheme/lua/mk_todos_readable.lua b/hm/soispha/conf/nvim/plugins/colorscheme/lua/mk_todos_readable.lua new file mode 100644 index 00000000..0145ec19 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/colorscheme/lua/mk_todos_readable.lua @@ -0,0 +1,5 @@ +local opts = { bg = "NONE"; fg = "fg"; } +vim.api.nvim_set_hl(0, "@text.danger", opts) +vim.api.nvim_set_hl(0, "@text.note", opts) +vim.api.nvim_set_hl(0, "@text.todo", opts) +vim.api.nvim_set_hl(0, "@text.warning", opts) diff --git a/hm/soispha/conf/nvim/plugins/colorscheme/lua/nightfox.lua b/hm/soispha/conf/nvim/plugins/colorscheme/lua/nightfox.lua new file mode 100644 index 00000000..025eb133 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/default.nix b/hm/soispha/conf/nvim/plugins/default.nix new file mode 100644 index 00000000..796ae3f2 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/default.nix @@ -0,0 +1,23 @@ +{...}: { + imports = [ + #./lsp-progress-nvim + ./colorscheme + ./femaco + ./goto-preview + ./harpoon + ./leap + ./lf-nvim + ./lsp + ./lspkind + ./lualine + ./luasnip + ./nvim-cmp + ./nvim-lint + ./raw_plugins + ./telescope + ./todo-comments + ./treesitter + ./vim-tex + ./which-key + ]; +} diff --git a/hm/soispha/conf/nvim/plugins/femaco/default.nix b/hm/soispha/conf/nvim/plugins/femaco/default.nix new file mode 100644 index 00000000..6d7ec16a --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/femaco/default.nix @@ -0,0 +1,24 @@ +{ + pkgs, + lib, + ... +}: { + programs.nixvim = { + # TODO: package femaco though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/femaco.lua} + ''; + extraPlugins = [ + pkgs.vimPlugins.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/plugins/femaco/lua/femaco.lua b/hm/soispha/conf/nvim/plugins/femaco/lua/femaco.lua new file mode 100644 index 00000000..12171793 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/femaco/lua/femaco.lua @@ -0,0 +1,49 @@ +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/plugins/goto-preview/default.nix b/hm/soispha/conf/nvim/plugins/goto-preview/default.nix new file mode 100644 index 00000000..740bb04c --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/goto-preview/lua/goto-preview.lua b/hm/soispha/conf/nvim/plugins/goto-preview/lua/goto-preview.lua new file mode 100644 index 00000000..cde50d3e --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/harpoon/default.nix b/hm/soispha/conf/nvim/plugins/harpoon/default.nix new file mode 100644 index 00000000..ecd1d6cb --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/leap/default.nix b/hm/soispha/conf/nvim/plugins/leap/default.nix new file mode 100644 index 00000000..bffdf33c --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lf-nvim/default.nix b/hm/soispha/conf/nvim/plugins/lf-nvim/default.nix new file mode 100644 index 00000000..c562f400 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lf-nvim/lua/lf-nvim.lua b/hm/soispha/conf/nvim/plugins/lf-nvim/lua/lf-nvim.lua new file mode 100644 index 00000000..8a0cf817 --- /dev/null +++ b/hm/soispha/conf/nvim/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: 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/plugins/lsp-progress-nvim/default.nix b/hm/soispha/conf/nvim/plugins/lsp-progress-nvim/default.nix new file mode 100644 index 00000000..6602ceb6 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua b/hm/soispha/conf/nvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua new file mode 100644 index 00000000..4273085c --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lsp/default.nix b/hm/soispha/conf/nvim/plugins/lsp/default.nix new file mode 100644 index 00000000..b7c1e174 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lsp/keymaps/default.nix b/hm/soispha/conf/nvim/plugins/lsp/keymaps/default.nix new file mode 100644 index 00000000..4017521d --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lsp/servers/default.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/default.nix new file mode 100644 index 00000000..8ffac2e1 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lsp/servers/servers/bashls.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/bashls.nix new file mode 100644 index 00000000..0577a335 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/bashls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + bashls.enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/lsp/servers/servers/ccls.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/ccls.nix new file mode 100644 index 00000000..0698bcce --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/ccls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + ccls.enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/lsp/servers/servers/ltex.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/ltex.nix new file mode 100644 index 00000000..0d039f82 --- /dev/null +++ b/hm/soispha/conf/nvim/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 = false; + language = "en-CA"; + additionalRules = { + enablePickyRules = true; + }; + }; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/lsp/servers/servers/lua-ls.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/lua-ls.nix new file mode 100644 index 00000000..5a44b500 --- /dev/null +++ b/hm/soispha/conf/nvim/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/hm/soispha/conf/nvim/plugins/lsp/servers/servers/nil_ls.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/nil_ls.nix new file mode 100644 index 00000000..f0cccbdc --- /dev/null +++ b/hm/soispha/conf/nvim/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/hm/soispha/conf/nvim/plugins/lsp/servers/servers/rust-analyzer.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/rust-analyzer.nix new file mode 100644 index 00000000..943a8c80 --- /dev/null +++ b/hm/soispha/conf/nvim/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/hm/soispha/conf/nvim/plugins/lsp/servers/servers/texlab.nix b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/texlab.nix new file mode 100644 index 00000000..59af8d39 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/lsp/servers/servers/texlab.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + texlab = { + enable = true; + }; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/lspkind/default.nix b/hm/soispha/conf/nvim/plugins/lspkind/default.nix new file mode 100644 index 00000000..ed7d411b --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/lualine/default.nix b/hm/soispha/conf/nvim/plugins/lualine/default.nix new file mode 100644 index 00000000..0b789558 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/luasnip/default.nix b/hm/soispha/conf/nvim/plugins/luasnip/default.nix new file mode 100644 index 00000000..50a0b94c --- /dev/null +++ b/hm/soispha/conf/nvim/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/hm/soispha/conf/nvim/plugins/luasnip/lua/luasnip.lua b/hm/soispha/conf/nvim/plugins/luasnip/lua/luasnip.lua new file mode 100644 index 00000000..0a603692 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/luasnip/lua/snippets/all.lua b/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/all.lua new file mode 100644 index 00000000..5ce91a87 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/all.lua @@ -0,0 +1,60 @@ +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 + +local maybe = { pair = nil; } +if vim.bo.filetype == "tex" then + maybe.pair = pair("<", ">", neg, char_count_same) +end + +local output_table = { + 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); +} +output_table[#output_table + 1] = maybe.pair + +return output_table diff --git a/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/html/html.lua b/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/html/html.lua new file mode 100644 index 00000000..c467dd68 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/luasnip/lua/snippets/tex/delimiter.lua b/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/tex/delimiter.lua new file mode 100644 index 00000000..e50898fc --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/luasnip/lua/snippets/tex/greek.lua b/hm/soispha/conf/nvim/plugins/luasnip/lua/snippets/tex/greek.lua new file mode 100644 index 00000000..19989093 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/nvim-cmp/default.nix b/hm/soispha/conf/nvim/plugins/nvim-cmp/default.nix new file mode 100644 index 00000000..2fd35272 --- /dev/null +++ b/hm/soispha/conf/nvim/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"; + }; + "HH" = { + action = "cmp.mapping.complete()"; + #desc = "Confirm snipped"; + }; + }; + + snippet.expand = "luasnip"; + + sources = [ + {name = "nvim_lsp";} + {name = "luasnip";} + ]; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/nvim-lint/default.nix b/hm/soispha/conf/nvim/plugins/nvim-lint/default.nix new file mode 100644 index 00000000..c583ebf6 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/nvim-lint/lua/nvim-lint.lua b/hm/soispha/conf/nvim/plugins/nvim-lint/lua/nvim-lint.lua new file mode 100644 index 00000000..582da638 --- /dev/null +++ b/hm/soispha/conf/nvim/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/hm/soispha/conf/nvim/plugins/raw_plugins/default.nix b/hm/soispha/conf/nvim/plugins/raw_plugins/default.nix new file mode 100644 index 00000000..941cb7cb --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/default.nix b/hm/soispha/conf/nvim/plugins/telescope/default.nix new file mode 100644 index 00000000..b5054ed0 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/telescope/default.nix @@ -0,0 +1,10 @@ +{...}: { + imports = [ + ./defaults + ./keymaps + ./extensions + ]; + programs.nixvim.plugins.telescope = { + enable = true; + }; +} diff --git a/hm/soispha/conf/nvim/plugins/telescope/defaults/default.nix b/hm/soispha/conf/nvim/plugins/telescope/defaults/default.nix new file mode 100644 index 00000000..1d88aad8 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/bibtex/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/bibtex/default.nix new file mode 100644 index 00000000..12c9736c --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/default.nix new file mode 100644 index 00000000..0b1e033a --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/telescope/extensions/default.nix @@ -0,0 +1,9 @@ +{...}: { + imports = [ + ./bibtex + ./frecency + ./fzy-native + ./rooter + ./symbols + ]; +} diff --git a/hm/soispha/conf/nvim/plugins/telescope/extensions/frecency/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/frecency/default.nix new file mode 100644 index 00000000..4a4c22be --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/fzy-native/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/fzy-native/default.nix new file mode 100644 index 00000000..ce0bdccc --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/rooter/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/rooter/default.nix new file mode 100644 index 00000000..779448cc --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/rooter/lua/rooter.lua b/hm/soispha/conf/nvim/plugins/telescope/extensions/rooter/lua/rooter.lua new file mode 100644 index 00000000..eaf68ecf --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/telescope/extensions/symbols/default.nix b/hm/soispha/conf/nvim/plugins/telescope/extensions/symbols/default.nix new file mode 100644 index 00000000..1a679776 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/telescope/extensions/symbols/default.nix @@ -0,0 +1,51 @@ +{pkgs, ...}: { + programs.nixvim = { + extraPlugins = [ + # Source of symbols for telescope symbols + pkgs.vimExtraPlugins.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/plugins/telescope/keymaps/default.nix b/hm/soispha/conf/nvim/plugins/telescope/keymaps/default.nix new file mode 100644 index 00000000..f0745f73 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/todo-comments/default.nix b/hm/soispha/conf/nvim/plugins/todo-comments/default.nix new file mode 100644 index 00000000..9ed6cc87 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/treesitter/default.nix b/hm/soispha/conf/nvim/plugins/treesitter/default.nix new file mode 100644 index 00000000..9d30d6b9 --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/vim-tex/default.nix b/hm/soispha/conf/nvim/plugins/vim-tex/default.nix new file mode 100644 index 00000000..9b5cea5e --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/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/plugins/which-key/default.nix b/hm/soispha/conf/nvim/plugins/which-key/default.nix new file mode 100644 index 00000000..be63f7ac --- /dev/null +++ b/hm/soispha/conf/nvim/plugins/which-key/default.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.which-key = { + enable = true; + }; +} |