-
Notifications
You must be signed in to change notification settings - Fork 292
feat(extra): add manpages picker #2212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I like your passion. I won't be afraid to say that we like your passion, though I'll speak from my own perspective. Not only do the man pages themselves feel kind of rough in Neovim, especially with their behavior as described in the Show and Tell discussion, but they are also an OS dependent, so the picker may need to be handled and documented differently. There are also many minor things to think about, such as what to do with hard or soft wrapping, or whether manpages should be opened like |
|
Sorry if I'm being too impatient. I want to free up some mental bandwidth so that I can actually do some work with my editor, instead of working on it - I'm not great at multitasking 😅 But if the project has a more conservative policy, that's obviously fine. Thanks for all the help making the picker better. |
|
Thanks for the PR! All right, I think it might indeed be a reasonable addition to 'mini.extra'. Probably not in its current form, as it still looks a bit complex. In particular, I am not very fond of an additional "scope" option and rather cryptic handling of everything I'd have to investigate about the best approach here.
Thanks for the positive attitude! I'd also like to clarify: speaking on behalf of the MINI team preferably should be reserved for the team itself. Doing otherwise might create unintended impressions. |
The added complexity seemed to me small enough that having it was better than not, but if you disagree I don't mind removing it. Personally I won't be using the option anyway. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, didn't at all mean to make you feel like having to defend yourself. Your contributions to discussions have been very valuable. And you are of course correct that I appreciate seeing people share and/or contribute to MINI. It might be a result of my personal pet peeve about people using too broad "we" when a more narrow "I" is enough.
@Dook97, it is not only about the local options, but overall code. Like having to go the I'll be looking into this myself, as this will also require testing and documentation. So you can "free up some mental bandwidth" :) |
|
FYI the regex is stolen from telescope's implementation.
Much appreciated 😅 |
NameAfter some initial research, I can say that the complexity of the query is justified. However, the query provided by Telescope needs to be reworked, as it does not discard the There are two main man page viewers:
On the other hand, Alacritty exampleFrom Void Linux
Entries are separated by a comma followed by a space There might be errors in the output (Void Linux): In rare cases, strange entries may appear (Void Linux search): PatternMy take on parsing: if not vim.startswith(item, "man: ") then
local names, sects = str:match("^(.-)%s-(%b())%s+%- ")
sects = sects:sub(2, -2)
local name = names:gsub(", .*", "")
local sect = sects:gsub(", .*", ""):gsub("/.*", "")
endWidthSeems like # man-db
MANWIDTH=100 man 1 tmux# mandoc
man -O width=100 1 tmux |
I find it useful. You might not know exactly the manpage you're looking for and the description can contain keywords by which it may be found.
It would be optimal if we could just use the Man plugin instead of running external commands. That's the way telescope does it too, but it seems to clash with something about how mini.pick handles things 🤷 |
Thanks, both of these are helpful. The different format can be addressed on a case-by-case basis. I have a solution that looks reasonable. It should handle commas and needs one character change to handle
It can be made to work with |
I tried it on an online virtual machine. It printed an error and also opened the man page (I think as a fallback). P.S. I don't have man pages with the |
That will be super helpful. Thanks! |
Resolve #2212 Co-authored-by: =?UTF-8?q?Jan=20Dosko=C4=8Dil?= <30779172+Dook97@users.noreply.github.com> Co-authored-by: Drowning Cat <shamal.ma.personal@gmail.com>
|
There should now be @drowning-cat, I am not able to see the comments on f0b5293, but I did manage to read them from e-mail notifications. Both points ( Thank you again for the idea and enthusiasm! |
|
@echasnovski Thank you for your hard work. Small comments:
|
The dependency on
That won't hurt as a backup at least. |
|
On my system at least (Arch linux), the picker ignores manpages stored in ...while It's even weirder, because |
|
Removing |
Also true, but it only works if the sequence doesn't contain any word characters, like
Both There are two issues you should be aware of:
|
|
Also I think it'd be better to include the |
Does applying the following patch fix this? diff --git a/lua/mini/extra.lua b/lua/mini/extra.lua
index ce11c33c..f6de43e4 100644
--- a/lua/mini/extra.lua
+++ b/lua/mini/extra.lua
@@ -1280,7 +1280,7 @@ MiniExtra.pickers.manpages = function(local_opts, opts)
local source = { name = 'Manpages', choose = choose, preview = preview }
opts = vim.tbl_deep_extend('force', { source = source }, opts or {})
- local spawn_opts = { env = { 'MANWIDTH=999' } }
+ local spawn_opts = { env = { 'MANWIDTH=999', 'MANPATH=' .. vim.env.MANPATH } }
return pick.builtin.cli({ command = { 'man', '-k', '.' }, spawn_opts = spawn_opts }, opts)
end
|
|
No, that doesn't seem to help. The manpages are still not visible. |
For now, I would go with what both 'ibhagwan/fzf-lua' and 'folke/snacks.nvim#picker' are using. The Besides, I don't like the "... but ..." part from here:
If it doesn't work, then it doesn't work.
If there is a concise and reliable way to account for this, then this can be discussed. Otherwise let it be (semi)known limitation. |
local is_mandoc = vim.fn.executable("mandoc") == 1
if is_mandoc then
vim.list_extend(show_man_cmd, { "-O", "width=" .. width })
end |
This comment was marked as resolved.
This comment was marked as resolved.
|
|
|
Great! Could you check if the following patch fixes the issue? diff --git a/lua/mini/extra.lua b/lua/mini/extra.lua
index ce11c33c..9fe4958a 100644
--- a/lua/mini/extra.lua
+++ b/lua/mini/extra.lua
@@ -1280,8 +1280,10 @@ MiniExtra.pickers.manpages = function(local_opts, opts)
local source = { name = 'Manpages', choose = choose, preview = preview }
opts = vim.tbl_deep_extend('force', { source = source }, opts or {})
- local spawn_opts = { env = { 'MANWIDTH=999' } }
- return pick.builtin.cli({ command = { 'man', '-k', '.' }, spawn_opts = spawn_opts }, opts)
+ local env = { 'MANWIDTH=999' }
+ table.insert(env, vim.env.PATH ~= nil and ('PATH=' .. vim.env.PATH) or nil)
+ table.insert(env, vim.env.MANPATH ~= nil and ('MANPATH=' .. vim.env.MANPATH) or nil)
+ return pick.builtin.cli({ command = { 'man', '-k', '.' }, spawn_opts = { env = env } }, opts)
end
--- Neovim marks picker |
|
I've always wanted to say this: no blockers from my side. |
@Dook97, does the above patch with both |
|
Yes, that works! |
|
All right. After 8dccba8 I hope it should work as expected on both Linux and MacOS. The polishing of this already took longer than expected. |


Related: #2209 #2208
A manpages picker.
532095391-32866873-d91e-43a7-9aea-8ab6e42721e7.mp4
@echasnovski Submitting as a PR for your consideration whether this is a good
fit for mini.extra. Together with @drowning-cat I think we've made the code
better and more compact. If it is your call that this shouldn't be included
I'll alter the code in #2209 for it to be a custom picker and be done with it −
I've already spent way too much time on this 😅