-
Notifications
You must be signed in to change notification settings - Fork 5
Install docs on plugin load; partial matching for restrict_sources #8
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
Previously, `ensure_installed` was only supported during `apidocs_open()`. This commit allows the user to define `ensure_installed` in `config = function() ... end` so that language docs are installed immediately when the plugin is loaded
Modified all usages of restrict_sources to consider partial matches. E.g., previously, `restrict_sources={"python"}` would fail to find `python~3.13`, whereas now that will be considered a match. Also added an example remap to the README that shows how this can be used to search the docs for the current file's language automatically.
On fresh installation, `vim.uv.fs_scandir()` will be nil, so `vim.uv.fs_scandir_next()` will fail and the plugin will not successfully load. This commit fixes the issue by returning an empty table if fs is nil
thank you for the PR! it would probably have been better to have two PRs, one for each feature though. When it comes to the partial matching, maybe it could be made more robust to avoid false positives (quite unlikely though), but also to make it more explicit. So if you ask for When it comes to ensure_installed, actually I quite like it as it is, that it installs on first use. I see that lazy=true or something could prevent the installation, but not everyone is using lazy (I'm not for instance). It seems to me installing on first use is better than installing at neovim startup in all cases, because when you set up your config on a new computer, imagine the mess if all plugins start aggressively setting themselves up at startup all at the same time. And especially apidocs, which can freeze neovim for multiple minutes. |
Sorry about that; I can refactor and open separate PRs if you like.
Sure, that'll be super easy to change
Good point - I can refactor it so that it must be explicitly enabled with a boolean field value like
I guess this is just a matter of personal preference. For me, the approach of doing the download and parsing when the plugin is called is counterintuitive, because if I'm calling However I will note that it is not my intention to modify the current behaviour, but rather just to give the user the option of doing it how they like. |
i wouldn't want too much code to be added to the plugin for this install_at_startup idea. maybe this would work, just export the function to install the sources. And then the user can call it in their setup if they like. This would probably mean almost zero change to the plugin (although i'm not sure from the top of my head right now), and would offer the feature. at this point it's probably not worth splitting the PRs unless it's very easy for you. but modifying both features might require some history rewriting acrobatics for you now :) |
I like the idea of exporting the function for the user to call; I'll see about facilitating that. And since these commits are rather simple it won't be too much trouble; I have already split out the partial matching. So, I'll close this and open a new PR with the partial matching and make a subsequent one after with the other changes. |
This plugin contains two commits that add minor enhancements. Both of these changes are non-breaking. If you'd like any alterations feel free to let me know.
Also, note that the majority of line changes to
telescope.lua
in #ca1e5d6 are just whitespace shenanigans. The lines that were actually changed were lines 75-97.Install
ensure_installed
docs on plugin loadPreviously,
ensure_installed
was only checked during the call toapidocs_open()
. Now, if the user sets this value in the plugin config, the docs can be automatically installed as soon as the plugin loads. This is showcased in the added example to the README, which also setslazy = false
so that the plugin always loads as soon as Neovim is opened:Partial matching for
restrict_sources
Added partial string matching for
restrict_sources
. Previously, the exact directory name had to be entered, e.g.python~3.13
rather than justpython
. With the new approach, ifrestrict_sources
contains a valuepython
, any directories starting withpython
will be considered valid. The motivation for this is demonstrated in the README example - we can now automatically restrict the sources for the language of the current file, and we won't have issues if the language docs have the version in their name: