stimulus-lsp icon indicating copy to clipboard operation
stimulus-lsp copied to clipboard

Document / Fix Language and File Naming Constraints

Open CharlieIGG opened this issue 2 years ago • 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.

CharlieIGG avatar Jan 23 '24 14:01 CharlieIGG

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!

marcoroth avatar Jan 29 '24 23:01 marcoroth

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

CharlieIGG avatar Feb 04 '24 20:02 CharlieIGG

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

marcoroth avatar Feb 05 '24 17:02 marcoroth

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 avatar Feb 05 '24 18:02 CharlieIGG

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

CharlieIGG avatar Feb 06 '24 21:02 CharlieIGG

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!

marcoroth avatar Feb 06 '24 21:02 marcoroth