Inspecting 12345 embedded code snippet gives the following highlight groups:
Erlang:
- @attribute.erlang links to Macro priority: 100 language: erlang
- @string.erlang links to String priority: 100 language: erlang
Elixir:
- @constant.elixir links to Constant priority: 100 language: elixir
- @comment.documentation.elixir links to Documentation priority: 100 language: elixir
- @constant.elixir links to Constant priority: 100 language: elixir
- @string.elixir links to String priority: 100 language: elixir
- @comment.documentation.elixir links to Documentation priority: 100 language: elixir
- @spell.markdown links to @spell priority: 100 language: markdown
- @markup.raw.markdown_inline links to Special priority: 100 language: markdown_inline
- @nospell.markdown_inline links to @nospell priority: 100 language: markdown_inline
Erlang moduledoc is highlighted as a plain Macro / String which has two consequences:
Spell checking is not enabled as it doesn’t link to @spell.
No syntax highlighting for the embedded code - everything is highlighted as a plain flat string.
Writing Erlang documentation under such restrictions is not easy.
I am using neovim with elp Version: 1.1.0+build-2025-11-04 installed with Mason more or less as described in the elp documentation. Additionally I am installing Erlang treesitter (it doesn’t help much in this case):
Thanks @belltoy.
Adding after/queries/erlang/highlights.scm has no effect in my case.
After adding queries/erlang/highlights.scm, the module documentation highlight groups change to:
- @doc.markdown.erlang links to @doc priority: 100 language: erlang
- @comment.erlang links to Comment priority: 100 language: erlang
Documentation is highlighted as a @doc, but it still lacks spell checking and embedded code highlighting. Additionally, the highlighting of standard Erlang comments (% comment) becomes corrupted.
I don’t use triple quoted documentation strings anymore - I solved problem by placing documentation in external markdown files. The advantages are that the code is no longer polluted with tons of annoying inline documentation, can use robust linting/formatting/viewing/… markdown utilities and can share md docs with Elixir if necessary.
That should give you markdown highlight in your -moduledoc and -doc strings.
For the spell check in the doc string, it is the query in markdown highlights.scm, there should be a (inline) @spell query in your ~/.local/share/nvim/site/markdown/highlights.scm. So as long as the above injections query matches, the markdown highlight and the spell check should work for you.