-
-
Notifications
You must be signed in to change notification settings - Fork 850
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
indents(ecma): use @auto
for comments
#2545
Conversation
Hey @theHamsta, do you have a GIF/screenshot showing that it is working? Because it is still broken for me with this PR. Here's what I did:
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} with Plug 'theHamsta/nvim-treesitter', {'branch': 'ecma-auto-comment', 'do': ':TSUpdate'}
Edit: you made a push right after I dropped this comment. Let me check the changes done in force push ( 54e4530) and let me get back to you... |
12a1f27
to
54e4530
Compare
It is not working for me with 54e4530 JS file: TS file: TSX file: As you can see, all three have different behavior, TSX being closest to stock Vim one (Vim also automatically joins comment's end string — |
It's working for me and it's also working in the tests. Did you restart? It will not work when starting a comment with fun fact: tsx is the only of the filetypes that wouldn't automatically set |
Just to clarify — you're meaning to say that text shouldn't be written on the line where starting comment string is
I did restart. I'll try to remove everything and check again |
Me and the tests have the behavior of your TSX in JS and TS. The indents are almost the same for all three languages. There has to be some difference in the Vimscript filetype configuration. |
@theHamsta I just tried with basically removing everything (here's the dotfile I used for that matter) and I can still see the same issue. |
But you're not using our indent module in your config nvim-treesitter/scripts/minimal_init.lua Line 12 in 2298a75
syntax it's possible that we break one of the traditional indent methods
|
Yes, this is the issue I was speaking of before. At the moment when we have just |
Oh okay. Weird that it only occurs in
Totally on you if you want to merge the PR and close the issue or to give another stab fixing it. Thanks for your efforts! |
d83c94c
to
70d3f50
Compare
@ajitid can you check again? The behavior for unfinished The behavior for all three filetypes is the same (see tests) |
No idea why tests are failing without error. Seems similar to #2291 |
Here's what I got (all of these GIFs are of a VS Code's multiline comment: vs this PRs multiline comment: vs what stock Vim gives us: Stock Vim behaves in an odd fashion, so let's keep it aside for now. But this PR has different indent behavior when a comment is made at the first column vs when it is done at an indent. Here's VSCode's JSDoc comment: To me VSCode's behavior seem to be the most appropriate here. Apologies I'm not the best person to verify validity of the tests written. |
Hmm, apparently it depends on the context on how the I find your GIFs super unhelpful. It's difficult to understand at what moment something should behave differently. It's usually better to have plain text with a marker where something should be inserted and what the result after indentation will be. Plus I can copy+paste your complete failure case to make it a test. |
2b62f5a
to
933c84c
Compare
Noted. Will use text from now on. |
@ajitid I didn't mean in any way to criticize you. I'm very glad that you discovered that bug also in the "fixes". We can just save us some round-trips when it's clear what we mean. Best to communicate is failing example or even better a test for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: fix regex
933c84c
to
9785da3
Compare
I just tested this branch and it still seems broken to me. If the comment isn't closed, the next line does not get indented correctly. /** <- hit [ENTER] here
* If the comment is closed, the next line gets indented correctly. /** <- hit [ENTER] here
*
*/ |
I ran into this, switched to @theHamsta 's fork and it resolved the issues for me. I know it's nearly a thousand commits behind master now; what's the status here? Anything I can do to help? Any chance of a merge? At worst, I might see about rebasing the fork on top of master for my own use. |
9785da3
to
1463000
Compare
1463000
to
e829455
Compare
I don't remember whether this was an improvement or regression. Since the tests pass I guess it's ok? Can other JS please comment? I can maybe give it a try to solve the remaining issues that we still had here. |
I'm not sure - the comment indentation has been wrong since I started using this, so it might be an improvement. Compared to how C-style block comment indentation is handled w/o treesitter, it's a regression. |
I think we should merge. It is the same how comments are currently handled in C/C++ and Java. Though Go still uses the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from that one thing.
;; Probably, also a comment but unfinished | ||
((ERROR) @auto (#lua-match? @auto "/%*")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this unnecessary when (ERROR) @auto
already exists above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @theHamsta this would be really nice to merge :)
Needs to be adapted to the new upstream format, if still desired. |
|
Fixes #2544
@ajitid