-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support for semantic syntax highlighting #235
Comments
I was told there's some LSP-relevant discussion in microsoft/language-server-protocol#18. |
I think semantic highlighting is a great idea. In addition to that, the new |
@pfoerster Now that Neovim has support for semantic tokens, I suddenly care about this :) I remember we discussed this previously and agreed that it should be used sparingly -- if my TeX file ends up looking like a clown car crashed into a paint store window, that is... less than helpful. So it should not try to replicate syntax highlighting (that's what tree-sitter-latex is for) but only show things that (only!) texlab knows about. It's also probably better to add these one at a time when someone comes up with a useful idea, instead of trying to COLOR ALL THE THINGS from the get-go. With this in mind, here's some ideas that I think could be useful (to varying degree):
Of these, I could see myself relying on 2 and 3, possibly also 5. And 6 could be very pedagogical ;) The standard token names are a poor fit for this, of course, but the spec allows defining new ones, or texlab could just re-purpose them, similar to what it does with completionItemKinds and symbolKinds. |
(This is as much a feature request both for the server itself and the VSCode extension.)
I'm currently using texlab with a customised syntax highlighting extension for VSCode (https://marketplace.visualstudio.com/items?itemName=vomout.latex-syntax) to have special highlighting for
\todo
and\footnote
. I also miss the texlab extension not giving any specific meaning and colours to\label
,\cite
,\cref
,\eqref
, etc. I'm happy for this to be a separate package—I like how lean the texlab vscode package is very lean whereas my custom (LaTeX-Workshop derived) grammar is ugly and bloated. It nevertheless does the job.However, there appears to be a much better way. While basic TextMate grammars cannot easily tag syntax highlighting scopes with arbitrary function names (this is what my extension pretty much does for specific commands: adds
footnote
ortodo
to the end of the scope name—of the command and its parameters), it seems that language servers can more easily provide rich semantic highlighting information. See https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide and the sample language at https://github.com/Microsoft/vscode-extension-samples/tree/master/semantic-tokens-sample. So I think it would be feasible for the texlab language server to pretty much tag the scope of every command (and its parameters) with the specific name of that command. In that way user customisations could easily highlight specific commands (including highlighting author initial-prefixed custom\XYtodo
with author-specific colours). (Unfortunately, it does not seem possible for extensions to contribute additional syntax highlighting colours: microsoft/vscode#97753.)What do you think?
The text was updated successfully, but these errors were encountered: