marcoroth/stimulus-lsp

Document / Fix Language and File Naming Constraints

Opened this issue · 6 comments

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.

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 marcoroth/stimulus-parser#9
  2. is tracked in marcoroth/stimulus-parser#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!

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

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

You can review this :) marcoroth/stimulus-parser#47

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

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: marcoroth/stimulus-parser#48

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

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!