programs: integrate nvimpager into man to make text reflow correctly

also get marginally better syntax highlighting! the cursor movements are a little strange, but overall net improvement
This commit is contained in:
2024-12-30 20:25:45 +00:00
parent fee5c7042b
commit 7093385f98
6 changed files with 35 additions and 2 deletions

View File

@@ -46,8 +46,6 @@
## IMPROVEMENTS:
- sane-deadlines: show day of the week for upcoming items
- `man`: reflow text when resized
- most likely solution is to use a HTML pager: <https://unix.stackexchange.com/a/11413>
- curlftpfs: replace with something better
- safer (rust? actively maintained? sandboxable?)
- handles spaces/symbols in filenames

View File

@@ -91,6 +91,7 @@ in
"nmap"
"nmcli"
"nmon"
"nvimpager"
"nvme-cli" # nvme
# "openssl"
"parted"

View File

@@ -133,6 +133,7 @@
./nmcli.nix
./notejot.nix
./ntfy-sh.nix
./nvimpager.nix
./nwg-panel
./objdump.nix
./obsidian.nix

View File

@@ -15,9 +15,11 @@
# - --use-color = enable color instead of just monochrome (highlights search matches)
# SYSTEMD_LESS defaults to FRSXMK
env = rec {
# MANPAGER = "less";
PAGER = "less";
LESS = "--incsearch --LONG-PROMPT --quit-if-one-screen --quit-on-intr --RAW-CONTROL-CHARS --shift=.2 --use-color";
SYSTEMD_LESS = LESS; #< used by journalctl
};
mime.priority = 200; # fallback to more specialized pagers where exists
};
}

View File

@@ -29,3 +29,10 @@ set conceallevel=2
" source: https://www.reddit.com/r/neovim/comments/chlmfk/highlight_trailing_whitespaces_in_neovim/
set list
set listchars=tab:▷\·,trail,extends:◣,precedes:◢,nbsp:○
" when using vim to view manpages
" (`:Man topic` or `MANPAGER='nvim +Man!' man topic` or `vim man://topic`),
" instruct `man` to output unwrapped buffers, and let vim soft-wrap them.
" this allows one to resize the terminal and have the manpage be re-rendered.
" see: <https://github.com/neovim/neovim/issues/11436>
let g:man_hardwrap=0

View File

@@ -0,0 +1,24 @@
{ config, pkgs, ... }:
{
sane.programs.nvimpager = {
packageUnwrapped = (pkgs.nvimpager.override {
neovim = config.sane.programs.neovim.packageUnwrapped;
}).overrideAttrs {
# check phase fails, something to do with me enabling plugins not expected by the tester
doCheck = false;
};
suggestedPrograms = [ "neovim" ];
sandbox.whitelistWayland = true; # for system clipboard integration
env.MANPAGER = "nvimpager";
# env.PAGER = "nvimpager";
# `man 2 select` will have `man` render the manpage to plain text, then pipe it into vim for syntax highlighting.
# force MANWIDTH=999 to make `man` not hard-wrap any lines, and instead let vim soft-wrap lines.
# that allows the document to be responsive to screen-size/windowing changes.
# MANROFFOPT = "-c" improves the indentation, but i'm not totally sure what it actually does.
env.MANWIDTH = "999";
env.MANROFFOPT = "-c";
};
}