Documentation Comment highlighting with TreeSitter

This page summarizes the projects mentioned and recommended in the original post on /r/neovim

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • nvim-treesitter

    Nvim Treesitter configurations and abstraction layer

  • As far as I know there is currently no treesitter parser for Doxygen style comments. There is a language agnostic comment parser that is supported by nvim-treesitter that will highlight things like TODO: and NOTE: in comments. Until this recent commit nvim-treesitter provided a query for this parser that highlighted @ text in comments. It was meant to highlight a reference to a user but it doubled as a doxygen tag highlight for me for a while. I just noticed that this query has been removed and I'm not sure why but you can add it as a custom query in your Neovim config. I have yet to try this so you'll have to refer to the Neovim treesitter docs for where to add the query.

  • DoxyGen-Syntax

    DoxyGen Highlighting on top of c/c++/java

  • Hey folks, I've been trying to get nvim to highlight the documentation in my codebase. In particular I want keywords like the ones below highlighted in a different colour (@brief, etc). I'm aware there is something similar to this in vim here https://github.com/vim-scripts/DoxyGen-Syntax/tree/master, but to my understanding treesitter disables vim syntax matching and highlighting. Anyone know of a solution?

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • tree-sitter-comment

    Tree-sitter grammar for comment tags like TODO, FIXME(user).

  • As far as I know there is currently no treesitter parser for Doxygen style comments. There is a language agnostic comment parser that is supported by nvim-treesitter that will highlight things like TODO: and NOTE: in comments. Until this recent commit nvim-treesitter provided a query for this parser that highlighted @ text in comments. It was meant to highlight a reference to a user but it doubled as a doxygen tag highlight for me for a while. I just noticed that this query has been removed and I'm not sure why but you can add it as a custom query in your Neovim config. I have yet to try this so you'll have to refer to the Neovim treesitter docs for where to add the query.

  • lua-language-server

    A language server that offers Lua language support - programmed in Lua

  • Lastly, neovim now supports semantic token highlighting which uses semantic tokens from LSP servers to provide even better, language specific highlighting. Some LSP servers support semantic tokens for doc comments. The lua language server is a good example. Unfortunately, if you're using a language like C or C++, the language servers do not provide semantic tokens for comments because doxygen style comments are not specific to those languages so you might be out of luck for semantic token highlighting.

  • tree-sitter-jsdoc

    JSDoc grammar for Tree-sitter

  • No perfect answer but hopefully that helps break things down a bit. Maybe a treesitter parser for doxygen comments could be created similar to this one for jsdoc.

  • nvim-config

  • Not sure for Java (that’s Java right?), but for Python I inject rst in docstring comments. See here for my config.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts