Skip to content
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

Add vhdl language support #5826

Merged
merged 4 commits into from Mar 25, 2023
Merged

Conversation

teburd
Copy link
Contributor

@teburd teburd commented Feb 4, 2023

The vhdl tree sitter grammar is great but the queries primarily focus on error highlights. This adds some highlights for keywords and such.

It also adds support for vhdl_ls as a language server.

@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. A-language-support Area: Support for programming/text languages labels Feb 4, 2023
@teburd teburd changed the title Adds vhdl highlighting queries vhdl language support Feb 4, 2023
@teburd
Copy link
Contributor Author

teburd commented Feb 5, 2023

I'm far from a tree-sitter query expert but I've done my best here, most keywords/operators/etc are highlighted for me, with vhdl_ls I get nice linter checks showing up.

It's a reasonable experience, not quite on par with emacs or even vscode quite yet (vscode uses a textmate syntax highlighter which just seems to work better than my hacky treesitter queries)

I'm very open to suggestions on improving the highlights querying. The original author added a large number of error queries to annotate erroneous code which probably is best left for the language server to be frank. So it might be worth ripping out that stuff, and having a helix specific highlights.scm? Thoughts?

@the-mikedavis
Copy link
Member

Yeah I think we should rip out the error.* patterns, those seem out-of-place to me for syntax highlighting. We try to stick to the scopes documented here: https://docs.helix-editor.com/master/themes.html#syntax-highlighting and I don't think it makes sense to add a bunch under the error tree.

@teburd
Copy link
Contributor Author

teburd commented Feb 7, 2023

So I'm finding that a lot of things just aren't in the grammar and thus don't get highlighted, things I'd really like to highlight.

std_logic/std_logic_vector are defined as part of the std_logic_1164 library that comes with vhdl, these aren't in the grammar.

They are effectively builtin types though for how widely they are used.

Can tree-sitter somehow highlight types/functions if a library is imported somehow? the textmate vhdl highlighter seemed to do something like that.

@kraigher
Copy link

kraigher commented Feb 7, 2023

Regarding highlighting it is part of the LSP spec and probably something vhdl_ls could do without much effort.

@teburd
Copy link
Contributor Author

teburd commented Feb 7, 2023

Regarding highlighting it is part of the LSP spec and probably something vhdl_ls could do without much effort.

This would make more sense for vhdl probably than most, is that something helix would be open to enabling/allowing? @the-mikedavis ?

@pascalkuthe
Copy link
Member

pascalkuthe commented Feb 7, 2023

Tree-sitter will always remain the primary mechanism for syntax highlighting as it is used for a lot of other functionality in helix like motions.

LSP syntax highlights also produce a lot of overhead and there is hesitancy about supporting it #5589 (comment). The feature would also be challenging to add into the architecture of helix and no one is working on it so I don't expect this to be available anytime soon.

If it's supported it would only augment tree sitter not replace it: #814 (comment)

I am not as much of an expert on tree-sitter queries as @the-mikedavis but adding special captures for certain commonly used types should be possible regardless.

Simple highlight query file with keywords and builtin types
matching. Many VHDL types however are defined in std libraries
which do not currently get matched on.

This is because the grammar doesn't consider them builtin types.
Points at my fork of the vhdl treesitter grammar for highlights for now,
original author seems inactive.

Points at vhdl_ls as a (rust!) vhdl language server.
@teburd
Copy link
Contributor Author

teburd commented Mar 25, 2023

@the-mikedavis @archseer been awhile since this was posted. I understand the project has a lot of churn but it would be nice to at least have the startings of vhdl support

@the-mikedavis the-mikedavis changed the title vhdl language support Add vhdl language support Mar 25, 2023
@the-mikedavis the-mikedavis merged commit 685ae23 into helix-editor:master Mar 25, 2023
6 checks passed
@the-mikedavis
Copy link
Member

Could you add some info on vhdl_ls to the language server wiki? https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers

Looks like they suggest installing from the GitHub releases artifacts https://github.com/VHDL-LS/rust_hdl

Triton171 pushed a commit to Triton171/helix that referenced this pull request Jun 18, 2023
Simple highlight query file with keywords and builtin types
matching. Many VHDL types however are defined in std libraries
which do not currently get matched on.

This is because the grammar doesn't consider them builtin types.
wes-adams pushed a commit to wes-adams/helix that referenced this pull request Jul 4, 2023
Simple highlight query file with keywords and builtin types
matching. Many VHDL types however are defined in std libraries
which do not currently get matched on.

This is because the grammar doesn't consider them builtin types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants