Moduledoc attribute elp tree-sitter highlights - are there any options that could fix/improve -moduledoc highlighting / spell checking?

Define Erlang -moduledoc:

-moduledoc "Test: `12345`".

Similarly define Elixir @moduledoc:

  @moduledoc "Test: `12345`"

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:

  1. Spell checking is not enabled as it doesn’t link to @spell.
  2. 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):

require("nvim-treesitter.configs").setup({
	ensure_installed = {
		"erlang"
...

Are there any options available that could fix/improve -moduledoc highlighting / spell checking?

Try the following query in your after/queries/erlang/highlights.scm:

(wild_attribute
  name: (attr_name
          name: (atom) @_doc)
  value: [
          (string) @doc.markdown @comment
          (paren_expr expr: (string) @doc.markdown @comment)
         ]
    (#any-of? @_doc "moduledoc" "doc")
    (#set! "priority" 100))

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.

Sorry, I forgot the injections.scm:

(wild_attribute
  name: (attr_name
          name: (atom) @_doc)
          value: (string) @injection.content
            (#any-of? @_doc "moduledoc" "doc")
            (#match? @injection.content "^\"\"\"")
            (#offset! @injection.content 0 3 0 -3)
            (#set! "priority" 105)
            (#set! injection.language "markdown"))

(wild_attribute
  name: (attr_name
          name: (atom) @_doc)
          value: (paren_expr
                   expr: (string) @injection.content)
            (#any-of? @_doc "moduledoc" "doc")
            (#match? @injection.content "^\"\"\"")
            (#offset! @injection.content 0 3 0 -3)
            (#set! "priority" 105)
            (#set! injection.language "markdown"))

(wild_attribute
  name: (attr_name
          name: (atom) @_doc)
          value: (string) @injection.content
            (#any-of? @_doc "moduledoc" "doc")
            (#match? @injection.content "^\"[^\"]")
            (#offset! @injection.content 0 1 0 -1)
            (#set! "priority" 105)
            (#set! injection.language "markdown"))

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.