Skip to main content

Tree-Sitter parser for Ada

The grammar is adapted from the work done by Stephen Leak for the Emacs ada-mode. It was translated (partially for now) to tree-sitter syntax, and slightly changed to reduce some conflicts. Tree-sitter doesn't need a full syntax tree, so we can take some shortcuts in the grammar.

Installation

You will need neovim at least version 8.0 (not tested with earlier version).

Installation is very manual at this stage, until we can integrate this package inside nvim-treesitter itself. At the moment, assuming you are using lua configuration and Packer for your package management:

-- file: ~/.config/nvim/init.lua

--  Merge this with any existing Packer configuration you might already
--  have. This loads packer itself, then loads the new `ada.nvim` package.
require('packer').startup(function(use)
    use(require('mytreesitter.nvim'))
end)

Then create a new file to setup treesitter (or merge with an existing configuration of course).

--  file: ~/.config/nvim/mytreesitter.nvim

return {
   'nvim-treesitter/nvim-treesitter',
   requires = {
      'nvim-treesitter/nvim-treesitter-textobjects'
   },
   run=function()
      require('nvim-treesitter.install').update({ with_sync = true })
   end,
   config=function()

      --  Add support for our Ada parser

      local parsers = require "nvim-treesitter.parsers"
      local parser_config = parsers.get_parser_configs()
      parser_config.ada = {
         install_info = {
            url = "https://github.com/briot/tree-sitter-ada",
            files = {"src/parser.c"},
            generate_requires_npm = false,
            requires_generate_from_grammar = false,
         },
         filetype = "ada",
       }
   end,
}

Finally, we need to install the Ada parser with:

   :PackerSync                          " to install treesitter itself
   :TSInstall ada                       " to install Ada support

However, the above part only installs the parser itself (to generate a syntax tree from your source files). We now need to install queries, i.e. pattern matching against that tree to provide various capabilities like syntax highlighting, folding, indentation, smart textobject selection,...

For this, and until we can merge with nvim-treesitter itself, you will have to clone this github repository, then copy the queries/ directory to

  ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/

Usage

Syntax highlighting

The above default configuration will replace the default regular expressions-based syntax highlighting in vim. Instead, the highlighting is based on the tree build every time you type something.

The default highlighting looks pretty much like the one from the standard Ada mode. However, the tree-based approach potentially opens the door for smart highlighting, like "Use a different background color for a subprogram specification", "show constant definitions in blue" or other high-level approaches.

WIP: document how users can do this in their own configuration files.
The current approach is to modify queries/highlights.scm

Potentially (though it seems to be disabled in neovim at the moment), the highlighting can also get smarter. Going back to the "show constants in blue" example above, the queries/locals.scm file adds a simple approach so that references to those constants can point to the definition, and therefore use the same blue highlighting.

Because neovim also has support for language servers (LSP), it is likely better to rely on the language server here.

Block folding

If you press za now, this will toggle the folding of the "current block". This is defined in queries/folds.scm, and currently knows about package specifications, package bodies, subprograms bodies, if statements and loops. Other semantic blocks could be added.

Smart Selection

The file queries/textobjects.scm defines a function textobjects, so that you can now use commands like

  • vaf (v)isually select (a) (f)unction or subprogram
  • vif (v)isually select (i)nside a (f)unction or subprogram
  • vai (v)isually select (a) (i)f statement (or loop)
  • vii (v)isually select (i)nside an (i)f statement (or loop)

Development

Execute the following commands:

   npm install
   npm run test

Documentation

The grammar itself is fully described in the file grammar.js. When it processes it, TreeSitter generates src/grammar.json, which can be converted to a EBNF format via https://github.com/mingodad/plgh/blob/main/json2ebnf.js and rendered into a diagram on https://www.bottlecaps.de/rr/ui if you prefer graphical visualization (you can also copy-paste from issue #1 a pre-processed version of grammar.json).

Metadata

Release files for tree-sitter-ada 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-ada 0.9.2
File Size Uploaded Provenance Actions
tree_sitter_ada-0.9.2.tar.gz 143.4 kB Without provenance Details for tree_sitter_ada-0.9.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-ada 0.9.2
File Actions
tree_sitter_ada-0.9.2-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for tree_sitter_ada-0.9.2-cp310-abi3-win_arm64.whl
tree_sitter_ada-0.9.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_ada-0.9.2-cp310-abi3-win_amd64.whl
tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl
tree_sitter_ada-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for tree_sitter_ada-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_ada-0.9.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_ada-0.9.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_ada-0.9.2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_ada-0.9.2-cp310-abi3-macosx_11_0_arm64.whl
tree_sitter_ada-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details for tree_sitter_ada-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl

Total release size: 754.9 kB

Release files / tree_sitter_ada-0.9.2.tar.gz

Download URL tree_sitter_ada-0.9.2.tar.gz
Size 143.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6ee97e7581382332a14c731930312c9ef37afcf89116bba8ab0069825d426945
BLAKE2b-256 checksum
How to use checksums
14fc53f5f015aec2de2fbb879a8920ab4dbead59d710b828b23c78519c5ffdc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-win_arm64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-win_arm64.whl
Size 66.0 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
ba877bcd90e7c322933825e1259d366336d85e232b008df1fa39e570ed9f8080
BLAKE2b-256 checksum
How to use checksums
0b206da938c6ae7b9be869cd4737a67739d1cfde75bfbaab2e684bd267387eb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-win_amd64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-win_amd64.whl
Size 66.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a8efede7f55776d82f4ecfd1c3d5e169c1a416614d4e3e932f9a4f95327e9861
BLAKE2b-256 checksum
How to use checksums
5d580ef3d66015ab3a2e7cc7d292e847805a27337a6a4aebfa54e98402bcbad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl
Size 86.5 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
34cf12dc6aea59220b3868c0a76e65a97f7a83c1971756472d821ea59d366a82
BLAKE2b-256 checksum
How to use checksums
a7f817c1e4a06fac5bc0add8cac666079528f14a99c60c621e4b5e305d46b048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl
Size 88.0 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
487ef3cde309cec20b7300865ba23043d032a102b53533bea49db68d4fc2709d
BLAKE2b-256 checksum
How to use checksums
8a2b89ec17a694f8bbe3c2f735b41e10f978a697c60230ddc034e2d6a8f27351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 88.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
04754e9e8dc4030881e64bb1a6537a8271bf1b18ab8b13d8aa3a0d872f05f5a4
BLAKE2b-256 checksum
How to use checksums
6a334ca68809ccc03cc5ab069cd494c9bf32d22f6112fe8ada787eb7991f7c28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 87.2 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
948cfcc0f2955986cf214eef30055133b28ab3e30bc816da3d986259a272c7c4
BLAKE2b-256 checksum
How to use checksums
645845cf139933dbe780813a5d689acf4ca0936c1102ce955563d0773389b555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-macosx_11_0_arm64.whl
Size 65.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d6cd930963e1a94655bf8ccf2b84c7dc6cb42e54d598d9a9f0dcb030142a90bc
BLAKE2b-256 checksum
How to use checksums
5bef2fd59817830634af99d74db231b23ab84b73d17eda64442e2b9d55be7ffc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_ada-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_ada-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl
Size 63.2 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fe02449d1b78d05356967489d9e0582d02aeda18227d8c1b17e0faf0733c6288
BLAKE2b-256 checksum
How to use checksums
1afbe88ebf82dee23fb19dc52dddb9e14ac23c1e34a91b0ea6ee3cd96a73af43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tree-sitter-ada 0.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page