CppCXY / EmmyLuaAnalyzer

a new EmmyLua Language Server
MIT License
39 stars 6 forks source link

Possible improvements to analyzer #11

Closed notpeter closed 1 month ago

notpeter commented 2 months ago

I gave the new EmmyLuaAnalyzer a whirl and here's some things I found:

Bugs

Settings

Future suggested capabilities


Steps to reproduce:

  1. Create a folder with an .emmyrc.json:
    {
    "workspace": {
        "preloadFileSize": 5120000,
        "library": [
            "../playdate-luacats"
        ]
    }
    }
  2. Checkout https://github.com/notpeter/playdate-luacats/
  3. Profit?
CppCXY commented 2 months ago

good work, but there are some things that are not as you said. Emmylua does not define syntax highlighting, but instead uses the default highlighting of VScode, which is maintained by Sumneko. The reason you didn't see it is because it was overwritten by your other plugins

notpeter commented 2 months ago

Good work yourself! It's impressive to see this coming together. Sorry to do such a big dump all at once. I totally understand if some of these are by-design or out-of-scope, but I just wanted to share initial feedback of what I saw using the new LS for a couple hours.

All the screenshots only have the EmmyLua and EmmyLuaCodeStyle extensions installed (I uninstalled Sumneko), but I had wrongly assumed that EmmyLuaVscode and EmmyLuaAnylzer were providing syntax highlighting and grammar definitions (via DocumentSemanticTokensProvider or your own Grammar) but you are correct, this is just the default TextMate syntax highlighting, currently maintained by Sumneko.

Took me a minute to find it, but the main VSCode repo has vscode/extensions/lua which points to the LuaLS/lua.tmbundle repo that I didn't know existed. Thanks for pointing me in the direction of this. I'll see if I can take a crack at a PR there which does some basic syntax highlighting of annotations (/me casually dusts off oniguruma regex syntax manual)

Otherwise, enjoy your holiday. Excellent stuff.

CppCXY commented 2 months ago

By default, the highlighting in VSCode is like this, I don't know why it's not rendered on your computer: image

You've asked many questions, and it's hard for me to respond to each one individually. I've turned some tasks into issues and responded within them. For other task questions, I'll give a general response:

  1. Type checking is not currently implemented because type inference is not yet perfect. Also, many linters take time to develop (sumneko lua has been accumulating for several years, and many people submit PRs, I'm basically doing it alone, so it will be slower in terms of time).
  2. The alias issue is how emmylua supported it in the past, but I've tried to be as compatible as possible with both syntaxes.
  3. Regarding the compatibility with .luarc.json, I initially planned to directly use .luarc.json, but I found that many configurations are meaningless to my language service. So, I adopted a form that is basically consistent with it, but to avoid confusion, I didn't directly use .luarc.json, but used .emmyrc.json instead.
notpeter commented 1 month ago

Sounds great! I understand if there's certainly a difference in feature set vs LuaLS, but I'm very excited for there to be multiple players in the Lua Language Server space. Your .NET code is definitely more accessible than LuaLS's mix of Lua and C++ spread across nearly a dozen repos. I'm going to go ahead and close this issue, I created it mostly to document my first couple hours evaluating it and I thought you would appreciate the feedback.

Excited to see how things progress. In particular, hopefully you can get cross platform builds that don't require the CLR going as that will certainly ease adoption. I think this is part of the success of LuaLS -- it does not need to depend / interop with your target lua environment, everything is batteries-included when you add the extension.

Anyways, impressive work and I hope the feedback was useful.

CppCXY commented 1 month ago

Because it uses a lot of reflection libraries, it's currently not AOT-compilable. dotnet projects can be compiled in a self-contained manner, but the result of the compilation is to package the entire dotnet runtime, which will cause the package size to increase significantly, roughly from 6mb to 70mb. This is also not conducive to distribution. Initially, this project was written in Rust, and used a lot of libraries and ideas from rust-analyzer. However, at that time, Rust's debugging tools were too poor. After a few years, I see that C# has become very popular now, and various debugging tools are very complete. So I rewrote the project in C#.

notpeter commented 1 month ago

Gotcha. 70mb is a little chunky, but I don't think it's out of line. Looking at my language servers:

Server Size
lua-language-server 21MB
yaml-language-server 29MB
pyright 29MB
gopls 31MB
typescript-language-server 35MB
rust-analyzer 39MB
vscode-css-language-server 94MB
vscode-eslint 108MB

I'm not super familiar with the modern .NET ecosystem, but if it's possible (even if it includes the whole runtime) I'd suggest building a fat executable. Developers on MacOS/Linux are unlikely to have a prexisting runtime installed and it's not immediately clear that what is needed is the runtime (scroll down and look in the right-hand column, 72MB) and not the SDK (front and center, 600MB) so bundling 70MB is not only convenient, it may be more space efficient in the end.

You could support an alternate install methods (e.g. homebrew formula, chocolatey, etc) that automatically install the CLR as dependency but if you're targeting the widest possible audience I wouldn't worry about another 70MB.