Skip to content
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

man_pages to support listing man pages for word under cursor #3278

Closed
dsirov opened this issue Sep 4, 2024 · 3 comments · May be fixed by #3274
Closed

man_pages to support listing man pages for word under cursor #3278

dsirov opened this issue Sep 4, 2024 · 3 comments · May be fixed by #3274
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@dsirov
Copy link

dsirov commented Sep 4, 2024

:Telsecope man_pages currently lists all man pages (from ALL or specific sections).

It would be nice if there was an option for a programmer to list all relevant man pages for the (API) word under cursor in the source code.

For example, for open(...), the list will be:

  • open (3pm)
  • open (2)

Proposal: add a boolean option cword, that if true, would only show man pages for words under cursor.
:Telescope man_pages cword=true

@dsirov dsirov added the enhancement Enhancement to performance, inner workings or existent features label Sep 4, 2024
@jamestrew
Copy link
Contributor

would something like this suffice?

require('telescope.builtin').man_pages({ sections = { 'ALL' }, default_text = vim.fn.expand('<cword>') })

@dsirov
Copy link
Author

dsirov commented Oct 30, 2024

@jamestrew, this will show too many entries as it will:

  1. Search man pages that contain the word under cursor
  2. Use fuzzy search and pull man pages with the word under cursor as abbreviation
  3. Possibly search the word under cursor inside the man page description

For example, for open(...) the list will be 939 entries long and will include, for example:

  • EVP_OpenInit (3ossl) - EVP envelope decryption
  • OPENSSL_sk_new_reserve (3ossl) - stack container
  • etc...

Using the proposed approach, there is no clutter and the only additional input required from the user (if at all) is to choose the correct section for the exact man page as word under cursor.

For open, the list will be only:

  • open (3pm)
  • open (2)

@Conni2461
Copy link
Member

Conni2461 commented Oct 30, 2024

there is nothing to do here, this is currently already possible. and the current solution is much more flexible rather than only an explicit cword option because it allows you to define how you want to execute the apropos call.

Otherwise we would need to add even more options for regex, exact, full word matching etc ... You can use the following keymap if you are on an linux based system. I dont know if it also works on darwin/feebsd or if you have to slightly modify that command. You can test that with your cli

vim.keymap.set("n", "<leader>om", function()
  require("telescope.builtin").man_pages({
    sections = { "ALL" },
    man_cmd = { "apropos", "-r", "^" .. vim.fn.expand('<cword>') .. "$" }
  })
end, { noremap = true })

image

@Conni2461 Conni2461 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants