diff --git a/users/modules/config/neovim.nix b/users/modules/config/neovim.nix index 4046d4d..1780571 100644 --- a/users/modules/config/neovim.nix +++ b/users/modules/config/neovim.nix @@ -1,11 +1,5 @@ { - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = true; - }; + programs.neovim-custom.enable = true; home.persistence."/state".directories = [ ".local/share/nvim" diff --git a/users/modules/default.nix b/users/modules/default.nix index 09bc36d..e997e35 100644 --- a/users/modules/default.nix +++ b/users/modules/default.nix @@ -1,5 +1,6 @@ {...}: { imports = [ + ./neovim.nix ./secrets.nix ./uid.nix diff --git a/users/modules/neovim.nix b/users/modules/neovim.nix new file mode 100644 index 0000000..3915e83 --- /dev/null +++ b/users/modules/neovim.nix @@ -0,0 +1,19 @@ +{ + lib, + config, + pkgs, + ... +}: { + options.programs.neovim-custom = { + enable = lib.mkEnableOption "Neovim"; + package = lib.mkPackageOption pkgs "neovim" {}; + }; + + config = lib.mkIf config.programs.neovim-custom.enable { + home = { + # TODO packages = [config.programs.neovim-custom.package]; + sessionVariables.EDITOR = "nvim"; + shellAliases.vimdiff = "nvim -d"; + }; + }; +} diff --git a/users/myuser/graphical/default.nix b/users/myuser/graphical/default.nix index 86f097a..b022605 100644 --- a/users/myuser/graphical/default.nix +++ b/users/myuser/graphical/default.nix @@ -37,6 +37,7 @@ zathura ]; + # TODO kitty terminfo missing with ssh root@localhost # TODO nix repl cltr+del doesnt work # TODO wrap neovim for kitty hist # TODO neovim gitsigns toggle_deleted keybind @@ -59,8 +60,6 @@ # TODO screenshot selection and scan qr and copy clipboard # TODO screenshot selection and ocr and copy clipboard # TODO sway shortcuts - # TODO kitty terminfo missing with ssh root@localhost - # TODO nvim coloscheme missing on reboot.... what state is missing? # TODO VP9 hardware video decoding blocklisted # TODO gpg switch to sk # TODO some font icons not showing neovim because removed from nerdfonts, replace with bertter . diff --git a/users/myuser/neovim/aaa/init.lua b/users/myuser/neovim/aaa/init.lua new file mode 100644 index 0000000..0f36eb2 --- /dev/null +++ b/users/myuser/neovim/aaa/init.lua @@ -0,0 +1,66 @@ +local opt = vim.opt +local g = vim.g + +g.mapleader = "," + +---------------------------------------------------------------------------------------------------- +-- General +---------------------------------------------------------------------------------------------------- + +opt.undolevels = 1000000 -- Set maximum undo levels +opt.undofile = true -- Enable persistent undo which persists undo history across vim sessions +opt.updatetime = 300 -- Save swap file after 300ms +opt.mouse = "a" -- Enable full mouse support + +---------------------------------------------------------------------------------------------------- +-- Editor visuals +---------------------------------------------------------------------------------------------------- + +opt.termguicolors = true -- Enable true color in terminals + +opt.splitkeep = "screen" -- Try not to move text when opening/closing splits +opt.wrap = false -- Do not wrap text longer than the window's width +opt.scrolloff = 2 -- Keep 2 lines above and below the cursor. +opt.sidescrolloff = 2 -- Keep 2 lines left and right of the cursor. + +opt.number = true -- Show line numbers +opt.cursorline = true -- Enable cursorline, colorscheme only shows this in number column +opt.wildmode = { "list", "full" } -- Only complete the longest common prefix and list all results +opt.fillchars = { stlnc = "─" } -- Show separators in inactive window statuslines + +-- FIXME: disabled because this really fucks everything up in the terminal. +opt.title = false -- Sets the window title +--opt.titlestring = "%t%( %M%)%( (%{expand(\"%:~:.:h\")})%) - nvim" -- The format for the window title + +-- Hide line numbers in terminal windows +vim.api.nvim_exec([[au BufEnter term://* setlocal nonumber]], false) + +---------------------------------------------------------------------------------------------------- +-- Editing behavior +---------------------------------------------------------------------------------------------------- + +opt.whichwrap = "" -- Never let the curser switch to the next line when reaching line end +opt.ignorecase = true -- Ignore case in search by default +opt.smartcase = true -- Be case sensitive when an upper-case character is included + +opt.expandtab = false +opt.tabstop = 4 -- Set indentation of tabs to be equal to 4 spaces. +opt.shiftwidth = 4 +opt.softtabstop = 4 +opt.shiftround = true -- Round indentation commands to next multiple of shiftwidth + +opt.formatoptions = "rqj" -- r = insert comment leader when hitting in insert mode +-- q = allow explicit formatting with gq +-- j = remove comment leaders when joining lines if it makes sense + +opt.virtualedit = "all" -- Allow the curser to be positioned on cells that have no actual character; +-- Like moving beyond EOL or on any visual 'space' of a tab character +opt.selection = "old" -- Do not include line ends in past the-line selections +opt.smartindent = true -- Use smart auto indenting for all file types + +opt.timeoutlen = 20 -- Only wait 20 milliseconds for characters to arrive (see :help timeout) +opt.ttimeoutlen = 20 +opt.timeout = false -- Disable timeout, but enable ttimeout (only timeout on keycodes) +opt.ttimeout = true + +opt.grepprg = "rg --vimgrep --smart-case --follow" -- Replace grep with ripgrep diff --git a/users/myuser/neovim/default.nix b/users/myuser/neovim/default.nix index 26830f0..7191878 100644 --- a/users/myuser/neovim/default.nix +++ b/users/myuser/neovim/default.nix @@ -1,16 +1,40 @@ -{pkgs, ...}: { - programs.neovim = { - withPython3 = true; - extraPython3Packages = pyPkgs: with pyPkgs; [openai]; - withNodeJs = true; - }; +{ + config, + pkgs, + ... +}: { + programs.neovim-custom.package = let + nvimConfig = + pkgs.neovimUtils.makeNeovimConfig { + wrapRc = false; + withPython3 = true; + withRuby = true; + withNodeJs = true; + #extraPython3Packages = p: []; + #plugins = [ + # { plugin = pkgs.; config = ''''; optional = false; } + #]; + } + // { + wrapperArgs = ["--add-flags" "--clean -u ${./aaa/init.lua}"]; + }; + in + pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped nvimConfig; + + home.packages = let + nvimConfig = pkgs.neovimUtils.makeNeovimConfig { + wrapRc = false; + withPython3 = true; + withRuby = true; + withNodeJs = true; + extraPython3Packages = p: with p; [openai]; + }; + in [(pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped nvimConfig)]; xdg.configFile = { "nvim/ftplugin".source = ./ftplugin; "nvim/init.lua".source = ./init.lua; "nvim/lua".source = ./lua; }; - - # TODO NO! NO! all of this goes away - home.packages = with pkgs; [gcc shellcheck stylua]; + home.sessionVariables.E = "${config.programs.neovim-custom.package}/bin/nvim"; }