diff options
author | Soispha <soispha@vhack.eu> | 2023-08-03 21:34:16 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-19 17:34:47 +0200 |
commit | be1cc38bdb83e6716b08d24cc1201fffc6649311 (patch) | |
tree | c3691569e0e8858b672b501096b6cb5edd39daf6 /home-manager | |
parent | Feat(treewide): Import nixVim (diff) | |
download | nixos-config-be1cc38bdb83e6716b08d24cc1201fffc6649311.tar.gz nixos-config-be1cc38bdb83e6716b08d24cc1201fffc6649311.zip |
Feat(hm/conf/nvim): Add basic nix config [REBASE TARGET]
Diffstat (limited to '')
17 files changed, 1079 insertions, 0 deletions
diff --git a/home-manager/soispha/config/neovim/nixneovim/default.nix b/home-manager/soispha/config/neovim/nixneovim/default.nix new file mode 100644 index 00000000..bd10b36d --- /dev/null +++ b/home-manager/soispha/config/neovim/nixneovim/default.nix @@ -0,0 +1,42 @@ +{ + lib, + pkgs, + ... +}: { + imports = [ + ./options + ./mappings + ]; + # TODO package nightfox though a module + programs.nixneovim = { + enable = true; + defaultEditor = true; + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/nightfox.lua} + ''; + + # to install plugins just activate their modules + plugins = { + lsp = { + enable = true; + hls.enable = true; + rust-analyzer.enable = true; + }; + treesitter = { + enable = true; + indent = true; + }; + mini = { + enable = true; + ai.enable = true; + jump.enable = true; + }; + }; + + # Not all plugins have own modules + # You can add missing plugins here + # `pkgs.vimExtraPlugins` is added by the overlay you added at the beginning + # For a list of available plugins, look here: [available plugins](https://github.com/jooooscha/nixpkgs-vim-extra-plugins/blob/main/plugins.md) + extraPlugins = [pkgs.vimExtraPlugins.nightfox-nvim]; + }; +} diff --git a/home-manager/soispha/config/neovim/nixneovim/lua/nightfox.lua b/home-manager/soispha/config/neovim/nixneovim/lua/nightfox.lua new file mode 100644 index 00000000..1ca4f743 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixneovim/lua/nightfox.lua @@ -0,0 +1,53 @@ +-- Default options +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 = {}, +}) + +vim.cmd.colorscheme("duskfox"); diff --git a/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix b/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix new file mode 100644 index 00000000..8b38a1d0 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix @@ -0,0 +1,177 @@ +{lib, ...}: { + programs.nixneovim = { + globals = { + mapleader = " "; + maplocalleader = " "; + }; + mapping = let + normal_and_insert = { + "<Esc>" = { + action = "'<cmd>noh<CR><Esc>'"; + desc = "Disable the search highlighting and send Escape"; + }; + }; + in { + insert = + lib.recursiveUpate { + "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 + ''; + desc = "completion trigger/ forward in completen menu"; + }; + "<S-Tab>" = { + action = '' + function() + local cmp = require('cmp'); + cmp.confirm() + end + ''; + desc = "confirm the selected item"; + }; + } + normal_and_insert; + normalVisualOp = { + # yank/ cut to the system clipboard + "<leader>y" = "'\"+y'"; + "<leader>Y" = "'\"+Y'"; + + # Unmap some old keys + #"s" = "'<Nop>'"; + #"t" = "'<Nop>'"; + "<Up>" = "'<Nop>'"; + "<Down>" = "'<Nop>'"; + "<Left>" = "'<Nop>'"; + "<Right>" = "'<Nop>'"; + + # remap dvorak + "l" = "n"; + "L" = "N"; + "k" = "t"; + "K" = "T"; + "j" = "k"; + "J" = "K"; + + # Change Vim-keys + "h" = "<left>"; + "t" = "g<down>"; + "n" = "g<up>"; + "s" = "<right>"; + + # Move display lines + "0" = "g0"; + "$" = "g$"; + }; + normal = + lib.recursiveUpdate { + "<Tab>" = { + action = "':'"; + desc = "jump to command line"; + }; + + "N" = { + action = "vim.diagnostic.goto_prev()"; + desc = "go to previous diagnostic message"; + }; + "T" = { + action = "vim.diagnostic.goto_next()"; + desc = "go to next diagnostic message"; + }; + "<leader>e" = { + action = "vim.diagnostic.open_float()"; + desc = "open float for the symbol"; + }; + "<leader>q" = { + action = "vim.diagnostic.setloclist()"; + desc = "add buffer diagnostic to the location list (quick-fix)"; + }; + + # 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" = "'o<Esc>'"; + "O" = "'O<Esc>'"; + + # Center the cursor vertically when moving to the next word during a search. + "n" = "'nzzzv'"; + #"N" = "'Nzzzv'"; + + "<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 + ''; + 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 = "to 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" = "':m '>+1<CR>gv=gv'"; + "N" = "':m '<-2<CR>gv=gv'"; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixneovim/options/default.nix b/home-manager/soispha/config/neovim/nixneovim/options/default.nix new file mode 100644 index 00000000..9fbfb06d --- /dev/null +++ b/home-manager/soispha/config/neovim/nixneovim/options/default.nix @@ -0,0 +1,105 @@ +{nixosConfig, ...}: { + programs.nixneovim.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 = + "" + + "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 = [ + "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 = 1000; # 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/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix b/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix new file mode 100644 index 00000000..d736443e --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix @@ -0,0 +1,67 @@ +{...}: { + programs.nixvim = { + autoGroups = { + cursor_off = {clear = true;}; + numbertoggle = {clear = true;}; + }; + autoCmd = [ + { + event = ["BufWritePre"]; + pattern = ["*"]; + command = '' + ks | if search("\\s\\+$", 'n') != 0 :%s/\s\+//g 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 = ["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 fucused"; + } + + { + # 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/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix b/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix new file mode 100644 index 00000000..761f0c17 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/clipboard/default.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim = { + clipboard.provides = { + wl-copy.enable = true; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/colorscheme/default.nix b/home-manager/soispha/config/neovim/nixvim/colorscheme/default.nix new file mode 100644 index 00000000..9864c5cf --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/colorscheme/default.nix @@ -0,0 +1,9 @@ +{lib, ...}: { + programs.nixvim = { + # TODO package nightfox though a module + extraConfigLuaPost = '' + ${lib.strings.fileContents ./lua/nightfox.lua} + ''; + colorscheme = "duskfox"; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/colorscheme/lua/nightfox.lua b/home-manager/soispha/config/neovim/nixvim/colorscheme/lua/nightfox.lua new file mode 100644 index 00000000..1ca4f743 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/colorscheme/lua/nightfox.lua @@ -0,0 +1,53 @@ +-- Default options +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 = {}, +}) + +vim.cmd.colorscheme("duskfox"); diff --git a/home-manager/soispha/config/neovim/nixvim/default.nix b/home-manager/soispha/config/neovim/nixvim/default.nix new file mode 100644 index 00000000..f216fb05 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/default.nix @@ -0,0 +1,39 @@ +{ + pkgs, + ... +}: { + imports = [ + ./options + ./mappings + ./colorscheme + ./clipboard + ]; + programs.nixvim = { + enable = true; + defaultEditor = true; + + # to install plugins just activate their modules + plugins = { + lsp = { + enable = true; + hls.enable = true; + rust-analyzer.enable = true; + }; + treesitter = { + enable = true; + indent = true; + }; + mini = { + enable = true; + ai.enable = true; + jump.enable = true; + }; + }; + + # Not all plugins have own modules + # You can add missing plugins here + # `pkgs.vimExtraPlugins` is added by the overlay you added at the beginning + # For a list of available plugins, look here: [available plugins](https://github.com/jooooscha/nixpkgs-vim-extra-plugins/blob/main/plugins.md) + extraPlugins = [pkgs.vimExtraPlugins.nightfox-nvim]; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/mappings/default.nix b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix new file mode 100644 index 00000000..237319a0 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/mappings/default.nix @@ -0,0 +1,161 @@ +{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.recursiveUpate { + "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 + ''; + desc = "completion trigger/ forward in completen menu"; + }; + "<S-Tab>" = { + action = '' + function() + local cmp = require('cmp'); + cmp.confirm() + end + ''; + desc = "confirm the selected item"; + }; + } + normal_and_insert; + normalVisualOp = { + # yank/ cut to the system clipboard + "<leader>y" = "'\"+y'"; + "<leader>Y" = "'\"+Y'"; + + # Unmap some old keys + #"s" = "'<Nop>'"; + #"t" = "'<Nop>'"; + "<Up>" = "'<Nop>'"; + "<Down>" = "'<Nop>'"; + "<Left>" = "'<Nop>'"; + "<Right>" = "'<Nop>'"; + + # remap dvorak + "l" = "n"; + "L" = "N"; + "k" = "t"; + "K" = "T"; + "j" = "k"; + "J" = "K"; + + # Change Vim-keys + "h" = "<left>"; + "t" = "g<down>"; + "n" = "g<up>"; + "s" = "<right>"; + + # Move display lines + "0" = "g0"; + "$" = "g$"; + }; + normal = + lib.recursiveUpdate { + "<Tab>" = { + action = "':'"; + desc = "jump to command line"; + }; + + + # 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" = "'o<Esc>'"; + "O" = "'O<Esc>'"; + + # Center the cursor vertically when moving to the next word during a search. + "n" = "'nzzzv'"; + #"N" = "'Nzzzv'"; + + "<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 + ''; + 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 = "to 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" = "':m '>+1<CR>gv=gv'"; + "N" = "':m '<-2<CR>gv=gv'"; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/options/default.nix b/home-manager/soispha/config/neovim/nixvim/options/default.nix new file mode 100644 index 00000000..82d81172 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/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 = + "" + + "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 = [ + "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 = 1000; # 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/home-manager/soispha/config/neovim/nixvim/plugins/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/default.nix new file mode 100644 index 00000000..150798c3 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./treesiter + ]; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/default.nix new file mode 100644 index 00000000..8fd09e3d --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/default.nix @@ -0,0 +1,33 @@ +{...}: { + 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 + # '' + ; + # TODO only for cmp_nvim_lsp + capabilities = '' + capabilities = require('cmp_nvim_lsp').default_capabilities(); + ''; + 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/home-manager/soispha/config/neovim/nixvim/plugins/lsp/keymaps/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/keymaps/default.nix new file mode 100644 index 00000000..b11492b4 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/keymaps/default.nix @@ -0,0 +1,80 @@ +{...}: { + 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>q" = { + action = "setloclist"; + desc = "add buffer diagnostic to the location list (quick-fix)"; + }; + }; + lspBuf = { + "<space>gD" = { + action = "declaration"; + desc = "[G]o to [d]eclaration"; + }; + "<space>gd" = { + action = "definition"; + desc = "[G]o to [d]efinition"; + }; + "<space>hi" = { + action = "hover"; + desc = "Display [h]over [i]nformation"; + }; + "<space>gi" = { + action = "implementation"; + desc = "[G]o to the [i]mplementations"; + }; + "<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>wl" = { + action = '' + function() + print(vim.inspect(list_workspace_folders())) + end + ''; + desc = "[W]orkspace folders [l]ist"; + }; + "<space>gtd" = { + action = "type_definition"; + desc = "[G]o to the [t]ype [d]efinition under the cursor"; + }; + "<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"; + }; + "<space>gr" = { + action = "references"; + desc = "[G]o to all [r]eferences to the symbol"; + }; + "<space>f" = { + action = "function() vim.lsp.buf.format { async = true } end"; + desc = "[F]ormat the current buffer (asynchronously)"; + }; + }; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix new file mode 100644 index 00000000..8d5cfaf1 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp/servers/default.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix new file mode 100644 index 00000000..0ec255db --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lualine/default.nix @@ -0,0 +1,103 @@ +{...}: { + programs.nixvim.plugins.lualine = let + get_location_of_file = { + __raw = '' + function get_location_of_file() + 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 = '' + 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 { + options = { + icons_enabled = true; + theme = "nightfox"; + component_separators = { + left = ""; + right = ""; + }; + section_separators = { + left = ""; + right = ""; + }; + disabled_filetypes = { + statusline = []; + winbar = []; + }; + ignore_focus = {}; + always_divide_middle = true; + globalstatus = false; + refresh = { + statusline = 1000; + tabline = 1000; + winbar = 1000; + }; + }; + sections = { + lualine_a = ["mode"]; + lualine_b = [ + { + name = "FugitiveHead"; + icon = ""; + } + "diff" + "diagnostics" + ]; + lualine_c = ["filename"]; + lualine_x = ["searchcount" "filetype"]; + lualine_y = ["encoding" "fileformat" get_mixed_indent get_trailing_whitespace]; + lualine_z = [get_location_of_file]; + }; + inactive_sections = { + lualine_a = []; + lualine_b = []; + lualine_c = ["filename"]; + lualine_x = [get_location_of_file]; + lualine_y = []; + lualine_z = []; + }; + tabline = {}; + winbar = {}; + inactive_winbar = {}; + + # TODO add all installed and supported extensions here + extensions = ["fugitive"]; + }; +} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix b/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix new file mode 100644 index 00000000..7a8a3a26 --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/plugins/treesitter/default.nix @@ -0,0 +1,35 @@ +{...}: { + programs.nixvim.plugins.treesitter = { + enable = true; + # A list of parser names; or "all" + # ensure_installed = [ "c" "lua" "rust" ]; + ensure_installed = "all"; + + # TODO make this work + 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 + additional_vim_regex_highlighting = [""]; + }; + + indent = { + enable = true; + }; + incremental_selection = { + enable = true; + keymaps = { + # TODO include these + init_selection = "gnn"; # set to `false` to disable one of the mappings + node_incremental = "grn"; + scope_incremental = "grc"; + node_decremental = "grm"; + }; + }; + }; +} |