From 605dcbfe543fc9f4dc3c236a67fe370c4c01447f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 20 Feb 2019 12:25:30 -0500 Subject: Set man_hard_wrap in nvim Vendoring man.vim until is merged and appears in a release. --- home/.config/nvim/autoload/man.vim | 22 +++++++++++++++++----- home/.config/nvim/init.vim | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'home') diff --git a/home/.config/nvim/autoload/man.vim b/home/.config/nvim/autoload/man.vim index 7385862c..c6f49339 100644 --- a/home/.config/nvim/autoload/man.vim +++ b/home/.config/nvim/autoload/man.vim @@ -149,8 +149,13 @@ function! s:system(cmd, ...) abort endfunction function! s:get_page(path) abort - " Respect $MANWIDTH or default to window width. - let manwidth = empty($MANWIDTH) ? winwidth(0) : $MANWIDTH + " Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065). + " We use soft wrap: ftplugin/man.vim sets wrap/breakindent/…. + let manwidth = 999 + if exists('g:man_hard_wrap') + " Respect $MANWIDTH or default to window width. + let manwidth = empty($MANWIDTH) ? winwidth(0) : $MANWIDTH + endif " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. @@ -166,6 +171,11 @@ function! s:put_page(page) abort while getline(1) =~# '^\s*$' silent keepjumps 1delete _ endwhile + " XXX: nroff justifies text by filling it with whitespace. That interacts + " badly with our use of $MANWIDTH=999. Hack around this by using a fixed + " size for those whitespace regions. + silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g + 1 lua require("man").highlight_man_page() setlocal filetype=man endfunction @@ -386,15 +396,17 @@ function! man#init_pager() abort keepjumps 1 endif lua require("man").highlight_man_page() - " This is not perfect. See `man glDrawArraysInstanced`. Since the title is - " all caps it is impossible to tell what the original capitilization was. + " Guess the ref from the heading (which is usually uppercase, so we cannot + " know the correct casing, cf. `man glDrawArraysInstanced`). let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') try let b:man_sect = man#extract_sect_and_name_ref(ref)[0] catch let b:man_sect = '' endtry - execute 'silent file man://'.fnameescape(ref) + if -1 == match(bufname('%'), 'man:\/\/') " Avoid duplicate buffers, E95. + execute 'silent file man://'.tolower(fnameescape(ref)) + endif endfunction call s:init() diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim index 0f0e7cb3..0eeae165 100644 --- a/home/.config/nvim/init.vim +++ b/home/.config/nvim/init.vim @@ -14,6 +14,7 @@ set foldmethod=syntax foldlevel=99 foldopen-=block let asmsyntax = "nasm" let c_syntax_for_h = 1 let is_posix = 1 +let man_hard_wrap = 1 set title laststatus=1 set scrolloff=1 -- cgit 1.4.1