marcoroth / stimulus-lsp

Intelligent Stimulus tooling for Visual Studio Code and Neovim
https://hotwire.io/ecosystem/tooling/stimulus-lsp
MIT License
219 stars 10 forks source link

Document / Fix Language and File Naming Constraints #138

Open CharlieIGG opened 7 months ago

CharlieIGG commented 7 months ago

First of all, thanks for the amazing work you're doing here @marcoroth.

When I started using this extension, I immediately started getting false negatives for stimulus.controller.invalid.

After some digging into the code, and doing some experimentation, I came to the conclusion that this extension currently has a couple of constraints, which don't seem to be documented on the VSCode extension itself:

  1. The extension currently doesn't support Typescript files (they simply don't get recognized?)
  2. The extension expects all controller files to be named ${some_name}_controller (which I guess makes sense, in that it mirrors the Rails conventions).

Going a bit through the code, it seems to me that the main source of these limitations is this line on your Stimulus Parser library.

If my diagnostic here is correct, then I think newcomers would greatly benefit by having these two constraints clearly documented at a top level.

Obviously, it'd be even better if we can get rid of these constraints.

marcoroth commented 7 months ago

Hey @CharlieIGG, thanks for opening this issue!

You are right, the extension is probably too optimistic as-is right now. But both of the constraints you outlined are goals that I want to cover with the LSP.

  1. is tracked in https://github.com/marcoroth/stimulus-parser/issues/9
  2. is tracked in https://github.com/marcoroth/stimulus-parser/issues/29

The TypeScript one turned out harder than expected. I have a WIP version using the actual typescript parser using the Compiler API, but it's not really nice to work with. So I'm a little stuck on that one.

Please let me know if you have any insights or want to help. Thank you!

CharlieIGG commented 7 months ago

Hey @marcoroth I'll try to have a stab at it in the next few days.

marcoroth commented 7 months ago

Awesome @CharlieIGG, let me know if I can assist you in any way or have questions

CharlieIGG commented 7 months ago

You can review this :) https://github.com/marcoroth/stimulus-parser/pull/47

EDIT – Never mind, this is failing during build... need to figure out a fix

CharlieIGG commented 7 months ago

Things are not looking great with acorn-typescript.

TSQuery looks more promising, but having no experience with it, it's taking me a while to figure out. I have a separate PR (WIP) here: https://github.com/marcoroth/stimulus-parser/pull/48

I'll let you know as soon as I have something worth reviewing @marcoroth

marcoroth commented 7 months ago

Hey @CharlieIGG, thanks for giving this a shot. Yeah, I think acorn-typescript looks more promising than it actually is. Also because it's not really feature-complete.

I'm actually surprised that there isn't a nice and easy-to-use TypeScript parser available.

Granted, I didn't know about TSQuery, but this already looks more promising!