-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Syntax highlighting only applied after edit #572
Comments
Does that happen with any file, or only specific ones? Does it happen in a new file where you write 1-2 lines of code (then save, kill the buffer and re-visit)? Does it happen with |
It happens with any file. No difference in behaviour between a small or a large file, or between an existing or a new file. As I mentioned, it does happen without I did just find a difference in behaviour between editing a file inside my project work tree and one outside (even if it's a copy of a file from my project, so it's not about the contents), but only without rainbow identifiers. In that case, when outside my project just moving the cursor (with the mouse or keyboard) is enough to trigger full syntax highlighting. With rainbow identifiers, it requires an actual edit to the file to trigger highlighting.
(In all of these cases I am completely killing emacs between loads) |
Can you try
And evaluate |
Okay, that difference between "inside project" and "outside project" seems to be caused by |
My packages aren't installed in Is there a better way to figure out what's interacting with js2-mode than just adding/removing packages and customizations and seeing what happens? |
Bisecting your init script is the usual approach (e.g. cut it in half, comment out the second part, try reproducing, repeat). You can also visit a |
Thanks. Should we close this then? Or when I track down the interaction do you want to see if it's something that can be addressed on the |
Sure. Or simply knowing about the offending mode should be useful anyway. |
Okay this is getting really weird. The minimal change I have been able to find to my init.el to cure this problem requires three separate edits:
Adding back any one of those bits of configuration independently of the other two is enough to cause the problem. (I'm really confused by the involvement of Going to try from the other end and see how little I have to add to a blank configuration to start seeing it. |
Going minimalist, I can reproduce the problem by having
With this minimal config, But removing just |
Ugh, more weirdness. Removing My normal workflow uses |
I'm guessing your emacsclient workflow connects to the daemon, and said daemon needs to be restarted, for certain changes for your config to be applied? I'm seeing certain weirdness indeed when But r-i-m doesn't seem to integrate with js2-mode's parser, its scopes, etc, so its usefulness seems limited here. |
Yes, but I have been careful to I'm honestly happy to get rid of rainbow-identifiers; I've only ever been middling about whether it's actually helpful. Although it does seem to work fine with other syntax highlighting packages for every other language I use, so it obviously isn't inherently incompatible with any package that does syntax highlighting (I assumed it has some process figured out for the rainbow-identifiers highlighting to be "low-priority" so it can be overridden by whatever else the syntax highlighter wants to do). Unfortunately that still doesn't fix my normal configuration; I still get the problem unless I also add back in the menu bar (that seems absurd) and disable flycheck (definitely not something I want to drop), or else stop using the daemon. I guess I'll remove rainbow-identifiers and go back to bisecting my config to try to find out what is breaking js2's syntax highlighting in conjunction with flycheck (since flycheck alone doesn't seem to). |
Yeah: it is
Good luck! If you find some minimal configuration, maybe I could do something about it. Or it'll be just another mode to disable. |
@ben-cellfield did you ever make any progress with identifying what causes this? (or @dgutov are you aware of any other reports?) I've recently started having the same issue but I can't see what would cause it in my set up. I don't have Weirdly I find that the first JS file I open of a session everything is fine, but subsequent files don't have syntax highlighting applied until I edit them (see below gif). |
Might be some other mode. If you see no errors, what would ultimately help is bisecting your config. But try this first:
and see if that ends up in a backtrace. |
@AlexChesters No, I haven't dug out any more specific information about what's causing this. It's still happening, but it's a lot less annoying since I got rid of rainbow-identifiers. There's no longer a dependency on where my cursor is, so I can just space-backspace wherever it is when the I open the window and it's not highlighted. Interestingly I'm not seeing that same behaviour you are where the first file is okay and subsequent ones are unhighlighted. Both cases are the same for me. |
hey both, apologies for the delay - been quite busy recently. I eventually determined by issue was caused by (use-package eglot
:config
(add-hook 'js2-mode-hook 'eglot-ensure)) |
That's odd: Eglot doesn't seem to be doing anything with font-lock. But if you are using LSP, maybe try |
I'm experiencing this problem on macOS homebrew Emacs 28.1 too with js2 version When upgrading to MELPA version |
When I first open a js file, no highlighting is applied. As soon as I edit a single character, suddenly the highlighting is applied.
This behaviour seems to interact with
rainbow-identifiers-mode
and becomes even worse. The rainbow identifiers highlighting is applied to every word in the file on open, with no javascript syntax highlighting. Editing a single character then applies syntax highlighting (overriding much of the rainbow identifiers highlighting that was applied to keywords, etc), but only to the line with the edit and following lines; unless I scroll to the top of the file and edit something in the first line, I don't get syntax highlighting for the whole file.The text was updated successfully, but these errors were encountered: