-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
docs/automation: include luv meta definitions files #26268
Comments
Thanks for raising this.
Sigh.
Hopefully this will be implemented, then users (or nvim-lspconfig) can point to the metafile URL. Unless this requires vscode? |
Yes. |
I'm vaguely in favor of this, since (Other directly exposed dependencies like |
Even if the "VS Code addon manager" doesn't help us, it seems like the metafiles will be maintained by LuaLS and available via some URL, which we could then consume via |
This is still an unfinished thread in my lua type annotations crusade: luvit/luv#632 |
First of all, this has less thing to do with lsp but is all about documentation and automation, so the title could be changed as I am investigating how we can include luv ( What would be the gold (upstream) "source" for libuv documentation that neovim can pull?We have two choices. (1) https://github.com/luvit/luv/blob/master/docs.md is the docs maintained and kept up-to-date with the actual libuv implementation.
(2) https://github.com/Bilal2453/luvit-meta (maintained by @Bilal2453)
Technical Problems on doc generator on the
|
For the record, there's a variant of these options: We provide the upstream meta file (starting from one of the existing files, edited to suit us), in the hope that once it's there, upstream will maintain it and we can just pull it on any luv bump. |
That might be the easiest thing tbh. |
Hey there, I am happy to help with this! First for the mentioned problems in the approach of using That being said, I probably wouldn't take either of the mentioned approaches, I had to manually add things in/out from annotations because the automatically generated ones from the markdown (which served as the base) were either inconsistent or incomplete for something like this, my real intention behind the luvit-meta project was not to actually provide types or annotations for Luvit and Luv, but to compensate for the lack of documentation and to eventually replace the upstream docs by converting the annotations into something more usable and easy to maintain (something like JSON files / Lua tables). In my opinion, the approach that should be taken is more inline with what @clason suggested, work on luvit/luv#632 upstream, write a machine-readable luv docs, and use that to generate the annotations. |
Hi @Bilal2453, thanks for your feedback and help! I look forward to working with you together to have a improved meta file (either on your repo or potentially contribute to upstream Regarding overload functions --- I think the current style of overload functions are fine; they follow standard LuaCATS annotation style and it's something that neovim's build process can adapt to. Since it seems that you have some preliminary works done towards luvit/luv#632, I'd be happy to involved if there's anything I can help you with. I will also keep you involved once I start to make any further steps (currently it's more like a planning/design phase for me). |
A tiny bit of progress, I will be working on getting something working over at luv-docgen. I am not currently sure if I need help with something coding wise. Will probably need more opinions about the potential problems will be facing, and the Lua table structure of the parser (both described in the repo). I will be posting further updates over at luvit/luv#632, thanks for everyone's help! |
@Bilal2453 Sounds great, I will have a look and give some suggestions. Also take a look at the LPeg grammar neovim uses https://github.com/neovim/neovim/blob/master/src/nvim/generators/luacats_grammar.lua, written by @lewis6991 (#26967). This handles only |
Judging by how it is going, I am slightly doubting if my parser would really be any better for a more general solution (at least outside of my luv definitions). Doing things right (like accounting for invalid inputs, etc) requires a fair bit of time and I am a bit in a rush as I want to finish this in a day or two (hopefully) before I am busy with work, so I am mostly using Lua's string matching with assumption about what the usage of an annotation looks like. For a long term solution why not use the LuaLS parser itself? It will guarantee that your parser is always doing what it is supposed to do, and will be really easy to maintain it for any upstream changes (like adding new annotations, syntax etc), the only disadvantages of that is A) you have to depend on code outside of your repo and B) the parser is meant for LSP, its Lua structure output is very big and complicated (which is the only reason I didn't use it instead). |
LuaLS is not reliable as a dependency, and as a black box unsuitable. |
I meant using the LuaLS parser itself, not the binary of the language server, does that apply to it too? From what I've seen it seems like it would be reliable, for instance, you need this parser directory + utility.lua, and lpeglabel, parsing definitions would then be like: local parser = require('parser')
local state = parser.compile(input, 'Lua', 'Lua 5.4') -- the version shouldn't really matter
parser.luadoc(state) -- parse docs (definitions)
-- now accessible with state.ast.docs/etc Though you need then to convert this structure into something actually usable, accessing the state directly is painful. |
Yeah, the whole project is not reliable (for this purpose). Rolling our own with Lpeg is the right way in my view. |
Good point, it feels like we're kind of reinventing a wheel, but Neovim's LuaLS annotation use is not 100% strictly compliant with the LuaCATS (for historical reasons), which also changes gradually over time. We have some non-standard annotations that LuaLS may parse differently. Another unresolved issue that I know of is: LuaLS/lua-language-server#2333 -- docs for |
Any annotation tag that isn't recognized by the parser is treated as a normal comment, so it should still be possible to handle it in a later step. For that bug and any future ones, I think it would be neat if we fix those upstream (I might look into, doesn't sound terribly hard to support, famous last words), descriptions are the most complicated thing to parse (from my experience at least), especially ones that don't explicitly use Nonetheless, will see what happens with mine and you could decide from there. |
Problem
Currently, there's no luv _meta file for LSP annotations, and the most used lua LSP is planning to drop the builtin luv meta file, which would require users to download a separate luv meta library.
Expected behavior
Have the luv meta-file library built in.
Downside
Adding a large meta library such as luv to the meta files would increase LSP load times.
The text was updated successfully, but these errors were encountered: