Commit Graph

79 Commits

Author SHA1 Message Date
Anmol Sethi
a6917f840d
man.vim: Simplify man#init to reduce load time (#12482)
I removed the SunOS stuff since no one uses SunOS and I've never tested
it on there.

I removed the section_flag init as we can just use -S instead of -s
and -S is used by every implementation as far as I know.

This brings man#init's time from 50-70ms to 15-20ms for me.

Closes #12318
Related #6766
Related #6815
2020-07-21 11:46:42 -04:00
Anmol Sethi
adc3425a37
man.vim: Fix tagfunc to respect b:man_default_sects
Also, kudos to @zsugabubus for fixing a related issue in #12417

This also prevents any sorting of the paths from man. We need to
respect the order we get from it otherwise you end up loading

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man/man1/ls.1

on MacOS instead of /usr/share/man/man1/ls.1
2020-06-13 02:55:40 -04:00
Anmol Sethi
4aaffc5f33
man.vim: Refactor verify_exists to unset $MANSECT as needed
Also cleaned it up a little and made it faster.

Closes #9159 and #9271

Also changes man#extract_sect_and_name_ref to only return a single
section at a time. This fixes a bug in its usage in man#goto_tag
where get_paths would be called with multiple sections and it does
not support that.

I noticed that our tagfunc doesn't obey b:man_default_sects and
I'll fix that next.
2020-06-12 23:44:31 -04:00
Rob Pilling
5e0c435ca1 man.vim: Handle man errors when looking for man-paths
Fallback to simply globbing the tag we're given. This matches the
original behaviour of `man.vim`, prior to c6afad78d3.

fixes #11794
closes #11918
2020-02-29 23:44:43 -08:00
Rob Pilling
4a7d84ae60 man.vim: workaround for 'cscopetag' #11679
The old `:Man` implementation would take either the word under
the cursor, or the argument passed in, and load that as a man page.

Since we now use 'tagfunc' and look for all relevant man-pages, if
your system has several (i.e. same name, different sections), we return
several, giving the user an option.

This works for most tag commands except `:tjump`, which will
fail if there's multiple tags to choose from. This just happens to
be what the cscope code uses (it actually attempts to prompt the
user, but this fails).
2020-01-06 21:57:36 -08:00
Rob Pilling
33beeed4d9 man.vim: Improve ft=man 'iskeyword' #11457
This addresses a minor quality problem with the recent `'tagfunc'`
changes for `man.vim` (see [link]).

Currently, with the cursor on a parenthese, hitting `K` will jump us to
the man page of the next mentioned entry, instead of the one to which
the parenthese (or section number) belongs.

```
pcrepattern(3), terminfo(5), glob(7), regex(7).
       e.g. ^        e.g. ^
```

Adding the parentheses to `'iskeyword'` means we correctly handle these cases too.

[link]: https://github.com/neovim/neovim/pull/11280#discussion_r348342357
2019-11-27 21:01:04 -08:00
Justin M. Keyes
544eeeb0d6
Merge #11451 'man.vim: Fixes' 2019-11-24 17:37:47 -08:00
Anmol Sethi
4ce96e4979
man.vim: Hard wrap by default
Closes #11436
2019-11-24 20:31:46 -05:00
Anmol Sethi
526798a941 man.vim: Ensure 'modifiable' in man#init_pager #11450 2019-11-24 17:30:04 -08:00
Justin M. Keyes
525bb1b55d Merge #11280 "man.vim: implement 'tagfunc'" 2019-11-20 00:31:22 -08:00
Rob Pilling
807e4039cb Sort man pages by relevance during goto_tag() 2019-11-13 22:00:11 +00:00
Rob Pilling
18c5f6ab9f Don't attempt swapfiles for man pages
This is because we now use :tag to open a man page, which attempts
to open a swap file for a path under man://...
2019-11-13 21:57:17 +00:00
Rob Pilling
aeee41192b Remove eventignore - :Man now uses :tag to populate the page 2019-11-13 21:56:28 +00:00
Rob Pilling
c6afad78d3 man.vim: remove push_tag and simplify man#open_page 2019-10-29 18:41:30 +00:00
Joshua Rubin
99aa166cb1 man.vim: never switch to non-man window #11286
In order to find if there was already an open man page, the :Man command
would cycle through each window to see if &ft=='man'. This triggers
autocmds, e.g. BufEnter, unnecessarily and can have unexpected
side-effects.

Change the logic to check each window's ft without switching to it
unless it is actually a man window.

Signed-off-by: Joshua Rubin <me@jawa.dev>
2019-10-25 09:41:22 -07:00
Rob Pilling
0173bdf98b man.vim: parse the section from the tag 2019-10-24 22:15:57 +01:00
Rob Pilling
2f0412e61d man.vim: :Man preserves the tag stack 2019-10-24 22:15:57 +01:00
Rob Pilling
63f0ca3263 man.vim: use 'tagfunc' instead of remapping
man#pop_tag() is also no longer used
2019-10-24 21:15:18 +01:00
Rob Pilling
ed72d9597d man.vim: pull out s:get_paths() 2019-10-24 21:15:16 +01:00
Curtis McEnroe
40f5a6c4da man.vim: g:man_hardwrap #9633
This option allows restoring the behaviour prior to #9023.
Fixes #9583
Closes #9633
2019-02-21 00:06:26 +01:00
Justin M. Keyes
112a5b76e6 man.vim: lowercase title when invoked as $MANPAGER
man#init_pager() guesses the ref by the heading, which is usually
uppercase, so we don't know the correct casing. But lowercase is more
common, so use that for the buffer name instead of uppercase.

ref #9156
2018-10-26 02:50:21 +02:00
Justin M. Keyes
c03a0f5fc8 man.vim: avoid duplicate buffers, E95
Before this commit, man#init_pager() always tries to scrape the manpage
name and set the buffer name. That's much less important than avoiding
duplicate buffers and E95. And it doesn't seem to be necessary, usually.

Steps to reproduce:

    $ export MANPAGER="nvim -c 'set ft=man' -"
    $ man sleep
    :Man sleep

    Error detected while processing function man#init_pager:
    line   15:
    E95: Buffer with this name already exists

    :ls!
    1  h-  "man://SLEEP(1)"               line 4
    2 %a-  "man://sleep(1)"               line 1
2018-10-25 04:09:53 +02:00
Justin M. Keyes
3999aa755e man.vim: set $MANWIDTH=999
On some systems, mandoc disallows $MANWIDTH greater than 1000.
E.g. FreeBSD:
b7d613ae8a/contrib/mandoc/manpath.c (L312)

closes #9065
2018-09-30 18:35:19 +02:00
Justin M. Keyes
a1976c7390 man.vim: Start at the top #9023
fixes #9057
2018-09-27 10:08:31 +02:00
Justin M. Keyes
dc256e376d man.vim: Fix very long justified lines #9023
When nroff justifies a line, it fills the line with whitespace to meet
$MANWIDTH.  With $MANWIDTH=9999, that of course results in nonsense (and
behaves poorly with 'cursorline' option).

To work around that, instead of trying to hard-justify the lines, just
replace the mega-whitespace with a fixed size of 10 spaces.

Perhaps N/Vim needs a "soft justify" feature?
2018-09-21 10:17:37 +02:00
Doron Behar
9081cad514 man.vim: Ignore $MANWIDTH, use soft wrap #9023
fix #9017
close #9023
2018-09-21 10:17:37 +02:00
dm1try
71bb4fd481 man.vim: guard against reload (#8940)
Some plugins attempt to reload autoloaded scripts.
Use a guard to prevent this.

fix #8939
2018-09-01 11:42:43 +02:00
Brayden Banks
9afed40ea6 man.vim: fix for mandoc (#8698)
When giving a section, the first candidate selection was not performed.

followup/fixup #8341
2018-07-08 17:31:10 +02:00
Justin M. Keyes
1cd8517344 man.vim: s:get_path(): trim newline in all cases
ref #8372
2018-05-10 16:03:13 +02:00
Jon Bernard
f1a3075553 man.vim: get() first item if -w returns multiple paths #8372
OpenBSD's man returns all candidates when searching with -w instead of
the first one it finds.  So this patch takes the first one if multiple
entries are found.

closes #8372
closes #8341
2018-05-10 14:42:10 +02:00
Marco Hinz
dbcdd29139
man.vim: use correct offset in presence of modifier commands
The argument expansion for :Man depends on the number of arguments given to it
starting at the command itself. But user completion functions always provide the
entire command-line which can include modifier commands like :tab, :vert, etc.
leading to a wrong number of arguments.

Prune all arguments up to :Man.

Fixes #7872.
2018-01-22 17:05:52 +01:00
Justin M. Keyes
59888b68ab Merge #7623 'man.vim: highlight bold, underlined text' 2018-01-09 10:10:22 +01:00
Anmol Sethi
3eaa9a2579 man.vim: always keep the alternate buffer (#7784)
Closes #7772
2017-12-29 19:00:10 +01:00
Gabriel Holodak
eb44519b5d Address PR comments 2017-12-27 23:28:04 -05:00
Gabriel Holodak
6740c94562 Add support for escape sequences 2017-12-27 23:27:14 -05:00
Gabriel Holodak
c28ce5f619 Switch to processing in Lua 2017-12-27 23:27:14 -05:00
Gabriel Holodak
0446d4d691 Highlight backspaced characters 2017-12-27 23:27:14 -05:00
raichoo
967e892cb6 man.vim: feature-test section (-s) flag #6815
Different implementations of `man` might be using different
flags for sections.
2017-05-26 00:30:40 +02:00
raichoo
3280765f2d man.vim: check for -l flag #6766 2017-05-19 14:02:11 +02:00
Matthew Wynn
e7a4d95a9e man.vim: Fix filename argument in mandoc #6693
Use the -l flag to open a man file.
TODO: Does not work on SunOS.

Fixes #6683
2017-05-08 17:45:06 +02:00
Tommy Allen
bc4a2e1576 help, man.vim: "outline" (TOC) feature #5169 2017-05-01 17:45:54 +02:00
Anmol Sethi
a346cb1d58 man.vim: call s:error in man#read_page (#6362)
The comment is incorrect, s:error does need to be called. I thought the
call was unnecessary because it didn't show any message for me but I had
shortmess+=F which was hiding the message.
2017-03-25 22:43:25 +01:00
Anmol Sethi
c8ee0be745 man.vim: use 'eventignore' instead of :noautocmd #6149
We only need to ignore BufReadCmd (from runtime/plugin/man.vim).

Closes #6144
2017-02-27 18:16:37 +01:00
Anmol Sethi
3d3b1641d0 man.vim: more robust s:verify_exists #6043
Closes #6039

Also: close the window if we could not get the page from man but only if
we opened it ourselves.
2017-02-04 10:02:59 +01:00
Anmol Sethi
39a6f835e7 man.vim: get page after opening split (#6032)
This will ensure that $MANWIDTH is correctly set.
2017-01-31 16:03:45 +01:00
Anmol Sethi
5bcb972a88 man.vim: remove terminal escape characters (#6033)
This will make man.vim work on nixOS.
2017-01-31 16:00:00 +01:00
Marcus Fritzsch
afa7f42f77 man.vim: Avoid empty argument when MANWIDTH is set. (#5882) 2017-01-06 00:20:22 +01:00
Anmol Sethi
f6c4e0961d man.vim: remove newline from man errors (#5852) 2017-01-01 15:09:27 +01:00
Anmol Sethi
c72f4d4d05 man.vim: revert "completion now respects 'wildignorecase'" (#5839)
Instead, a note was added to `:h man.vim` on how 'fileignorecase'
controls the case sensitivity of completion.
2016-12-27 19:01:04 -05:00
ooora
9066e23562 man.vim, provider.vim: Avoid shell syntax. #5734
- Improves compatibility with shell=tcsh.
- man.vim: split read_page into get_page, put_page. Do not split the
  window until we know there is going to be output.
2016-12-27 23:26:06 +01:00