diff options
Diffstat (limited to 'home-manager/soispha/config/neovim/nixneovim')
4 files changed, 377 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 + }; +} |