Skip to content

Fix Marksman: remap heading symbol kind from String to Namespace#1098

Open
EarthmanWeb wants to merge 2 commits intooraios:mainfrom
EarthmanWeb:fix/markdown-heading-symbol
Open

Fix Marksman: remap heading symbol kind from String to Namespace#1098
EarthmanWeb wants to merge 2 commits intooraios:mainfrom
EarthmanWeb:fix/markdown-heading-symbol

Conversation

@EarthmanWeb
Copy link

Problem

Marksman LSP returns all markdown headings (h1–h6) with
SymbolKind.String (value 15). Serena uses symbol kind values to
classify symbols as "high-level" (classes, functions, namespaces) or
"low-level" (variables, strings, constants) for filtering purposes.
SymbolKind.String (15) falls in the low-level range, so all
markdown headings are silently filtered out of symbol overviews
.

This means get_symbols_overview() on a Markdown file returns nothing,
and find_symbol cannot locate any headings by name.

Fix

Added a request_document_symbols() override in marksman.py that
post-processes the symbol tree and remaps any symbol with
SymbolKind.StringSymbolKind.Namespace (3).

Namespace is semantically appropriate for headings — they are named
sections that contain other content — and places them in the
high-level category so they appear in overviews and are findable.

The remapping is applied recursively to handle nested headings (h2
inside h1, etc.).

Example

Before:

get_symbols_overview("README.md")
# → {} (all headings filtered out — SymbolKind.String treated as low-level)

After:

get_symbols_overview("README.md")
# → {"Introduction": [...], "Installation": [...], "Usage": [...]}

Marksman returns all headings (h1-h6) with SymbolKind.String (15), which
causes them to be treated as low-level symbols and filtered out of
get_symbols_overview results.

Override request_document_symbols in Marksman to remap SymbolKind.String
to SymbolKind.Namespace, which is semantically appropriate for headings
(named sections containing other content) and ensures they appear in
symbol overviews.
@opcode81
Copy link
Contributor

This sounds good. However, do you know which other types of symbols the LS assigns the String type to?
If it's only headings, then it's fine, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants