A VHDL parser for syntax highlighting.
- VHDL-2000
- VHDL-2008
- VHDL-2019
- VHDL Library Files (search for "1076")
- VSCode Modern VHDL
Neovim, using nvim-treesitter and a Catppuccin colour scheme:
This version started off as a fork of alemuller/tree-sitter-vhdl, but ended up as a complete rewrite of the parser and highlighting scripts. It has very little in common with the original.
This parser uses a simplified grammar, because the full formal grammar in the VHDL standard is highly ambiguous without compiling the entire code-base into a symbol table. In many cases, invalid syntax will parse into a valid tree.
For the same reason, there might be cases where valid syntax does not map to a valid tree. In this case, please log a bug report.
In addition, the following features are not implemented, and are considered outside the scope of this project.
- IEEE Property Specification Language
- VHDL Procedural Interface
This parser has not been merged into the official tree-sitter yet, so you need
to perform a manual setup process.
Configure your treesitter.lua
(or equivalent) as follows:
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.vhdl = {
install_info = {
url = "https://github.com/jpt13653903/tree-sitter-vhdl.git",
files = { 'src/parser.c', 'src/scanner.c' },
branch = 'master', -- or 'develop' if you want the latest features
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = 'vhdl',
}
local treesitter = require('nvim-treesitter.configs')
treesitter.setup {
ensure_installed = {
-- Some list of languages...
'vhdl',
-- Some more languages...
},
-- Some other options and configuration...
}
Then copy the contents of the queries/Neovim
folder to your after/queries/vhdl
configuration folder, typically ~/.config/nvim/after/queries/vhdl
on Linux
and ~/AppData/Local/nvim/after/queries/vhdl
on Windows.
Finally, run :TSUpdate
.
Helix still uses a fork of the old unmaintained
alemuller/tree-sitter-vhdl. To manually use this tree-sitter
instead, clone the Helix repo. In languages.toml
replace the line:
source = { git = "https://github.com/teburd/tree-sitter-vhdl", rev = "c57313adee2231100db0a7880033f6865deeadb2" }
with:
source = { git = "https://github.com/jpt13653903/tree-sitter-vhdl", rev = "256ddae0ba5d1a36ef54d59a1bdb6f0360a9c818" }
Adjust the revision git hash if necessary (latest stable is recommended).
Now build Helix from source. You can check if you got the right
tree-sitter source files in the helix/runtime/grammars/sources/vhdl/
directory.
Replace the helix/runtime/queries/vhdl/highlights.scm
file with the
queries/Helix/highlights.scm
from this repo. You can also adjust
the highlights.scm
file to your liking or change the highlighting in your
theme .toml file.
- Follow the instructions here to setup your development environment.
- Run
npm install --save-dev tree-sitter-cli
- Add
node_modules/.bin
to your environment path - Run
tree-sitter generate
- Run
tree-sitter test
Contributions are welcome. Read Contributing.md for more information.