1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat: use nixvim for manpager definition

This commit is contained in:
oddlama 2023-11-05 19:31:15 +01:00
parent cc04e10405
commit c037780743
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
8 changed files with 78 additions and 141 deletions

View file

@ -8,6 +8,14 @@
kanidm-secret-manipulator = prev.callPackage ./kanidm-secret-manipulator.nix {};
segoe-ui-ttf = prev.callPackage ./segoe-ui-ttf.nix {};
zsh-histdb-skim = prev.callPackage ./zsh-skim-histdb.nix {};
neovim-clean = prev.neovim-unwrapped.overrideAttrs (_neovimFinal: neovimPrev: {
nativeBuildInputs = (neovimPrev.nativeBuildInputs or []) ++ [prev.makeWrapper];
postInstall =
(neovimPrev.postInstall or "")
+ ''
wrapProgram $out/bin/nvim --add-flags "--clean"
'';
});
kanidm = prev.kanidm.overrideAttrs (_finalAttrs: _previousAttrs: {
patches = [

View file

@ -0,0 +1,65 @@
{
lib,
pkgs,
...
}: {
home.sessionVariables.MANPAGER = lib.getExe (pkgs.nixvim.makeNixvim {
package = pkgs.neovim-clean;
options = {
buftype = "nowrite";
backup = false;
modeline = false;
shelltemp = false;
swapfile = false;
undofile = false;
writebackup = false;
virtualedit = "all";
splitkeep = "screen";
termguicolors = false;
};
extraConfigLua = ''
vim.opt.shadafile = vim.fn.stdpath "state" .. "/shada/man.shada";
'';
keymaps = [
{
action = "<C-]>";
key = "<CR>";
mode = ["n"];
options = {
silent = true;
desc = "Jump to tag under cursor";
};
}
{
action = ":pop<CR>";
key = "<BS>";
mode = ["n"];
options = {
silent = true;
desc = "Jump to previous tag in stack";
};
}
{
action = ":pop<CR>";
key = "<C-Left>";
mode = ["n"];
options = {
silent = true;
desc = "Jump to previous tag in stack";
};
}
{
action = ":tag<CR>";
key = "<C-Right>";
mode = ["n"];
options = {
silent = true;
desc = "Jump to next tag in stack";
};
}
];
});
}

View file

@ -1,14 +0,0 @@
{pkgs, ...}: let
nvimPager = pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped nvimConfig;
nvimConfig =
pkgs.neovimUtils.makeNeovimConfig {
wrapRc = false;
withPython3 = false;
withRuby = false;
}
// {
wrapperArgs = ["--add-flags" "--clean -u ${./init.lua}"];
};
in {
home.sessionVariables.MANPAGER = "${nvimPager}/bin/nvim '+Man!'";
}

View file

@ -1,17 +0,0 @@
vim.opt.buftype = "nowrite"
vim.opt.backup = false
vim.opt.modeline = false
vim.opt.shelltemp = false
vim.opt.swapfile = false
vim.opt.undofile = false
vim.opt.writebackup = false
vim.opt.shadafile = vim.fn.stdpath "state" .. "/shada/man.shada"
vim.opt.virtualedit = "all"
vim.opt.splitkeep = "screen"
-- Make sure to use ANSI colors
vim.opt.termguicolors = false
vim.keymap.set("n", "<CR>", "<C-]>", { silent = true, desc = "Jump to tag under cursor" })
vim.keymap.set("n", "<BS>", ":pop<CR>", { silent = true, desc = "Jump to previous tag in stack" })
vim.keymap.set("n", "<C-Left>", ":pop<CR>", { silent = true, desc = "Jump to previous tag in stack" })
vim.keymap.set("n", "<C-Right>", ":tag<CR>", { silent = true, desc = "Jump to next tag in stack" })

View file

@ -1,6 +1,4 @@
{
programs.neovim-custom.enable = true;
home.persistence."/state".directories = [
".local/share/nvim"
".local/state/nvim"

View file

@ -2,11 +2,10 @@
imports = [
./uid.nix
./secrets.nix
./neovim.nix
./config/htop.nix
./config/impermanence.nix
./config/manpager
./config/manpager.nix
./config/neovim.nix
./config/shell
./config/utils.nix

View file

@ -1,76 +0,0 @@
{
lib,
config,
pkgs,
...
}: let
inherit
(lib)
concatMapStrings
flip
mkEnableOption
mkIf
mkOption
mkPackageOption
types
;
cfg = config.programs.neovim-custom;
initLuaContent = ''
${cfg.initEarly}
-- Begin plugin configuration
${concatMapStrings (x: "${x.config}\n") (cfg.config.plugins or [])}
-- End plugin configuration
${cfg.init}
'';
nvimConfig =
pkgs.neovimUtils.makeNeovimConfig cfg.config
// {
wrapRc = false;
wrapperArgs = ["--add-flags" "-u ${pkgs.writeText "init.lua" initLuaContent}"];
};
finalPackage =
flip pkgs.wrapNeovimUnstable nvimConfig
(cfg.package.overrideAttrs (_final: prev: {
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
postInstall =
(prev.postInstall or "")
+ ''
wrapProgram $out/bin/nvim --add-flags "--clean"
'';
}));
in {
options.programs.neovim-custom = {
enable = mkEnableOption "Neovim";
package = mkPackageOption pkgs "neovim-unwrapped" {};
config = mkOption {
description = "The neovim configuration to use (passed to makeNeovimConfig and then to wrapNeovimUnstable)";
default = {};
type = types.anything;
};
initEarly = mkOption {
description = "The early init.lua content that will be added before plugin configs.";
default = "";
type = types.lines;
};
init = mkOption {
description = "The init.lua content, added after plugin configs.";
default = "";
type = types.lines;
};
};
config = mkIf cfg.enable {
home = {
# XXX: TODO packages = [finalPackage];
shellAliases.E = "${finalPackage}/bin/nvim";
sessionVariables.EDITOR = "nvim";
shellAliases.vimdiff = "nvim -d";
};
};
}

View file

@ -3,37 +3,8 @@
pkgs,
...
}: {
#programs.neovim-custom = {
# config = {
# withPython3 = false;
# withRuby = false;
# withNodeJs = false;
# #extraPython3Packages = p: [];
# plugins = with pkgs.vimPlugins; [
# {
# plugin = neo-tree-nvim;
# config =
# /*
# lua
# */
# ''
# require("neo-tree").setup {}
# '';
# }
# ];
# };
# init = builtins.readFile ./aaa/init.lua;
#};
home.shellAliases.nixvim = lib.getExe (pkgs.nixvim.makeNixvim {
package = pkgs.neovim-unwrapped.overrideAttrs (_final: prev: {
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
postInstall =
(prev.postInstall or "")
+ ''
wrapProgram $out/bin/nvim --add-flags "--clean"
'';
});
package = pkgs.neovim-clean;
colorschemes = {
catppuccin = {
@ -158,6 +129,9 @@
};
in [(pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped nvimConfig)];
home.sessionVariables.EDITOR = "nvim";
home.shellAliases.vimdiff = "nvim -d";
xdg.configFile = {
"nvim/ftplugin".source = ./ftplugin;
"nvim/init.lua".source = ./init.lua;