Add FORMAT_LIST completion and format preview for Tcl files #70

Merged
Christoph merged 1 commit from format-list into main 2026-10-13 13:50:25 +00:00
Owner

Summary

This change introduces a FORMAT_LIST completion keyword for Tcl files and adds hover/markdown previews for FORMAT declarations. Typing or selecting FORMAT_LIST lists all FORMAT names from loaded .def documents; the completion detail shows the unquoted FORMAT specification and the source filename, and resolving a selected item produces a Markdown description with example values.

Key changes

  • Completion

    • Adds FORMAT_LIST to SYMBOL_LIST_KEYWORDS so the keyword appears alongside BLOCK_LIST and ADDR_LIST.
    • Adds TclLanguageServer.format_items() which returns completion items for FORMAT declarations. Each item:
      • uses the declaration name as label, CompletionItemKind.TypeParameter as kind,
      • sets detail to the unquoted FORMAT specification plus the .def filename (see unquote usage),
      • sets data to { "def": [FORMAT, declaration.name] } so the item can be resolved to its definition.
    • While typing the keyword the server still re-requests completions so the full list appears for FORMAT_LIST (in addition to BLOCK_LIST/ADDR_LIST).
    • Selecting a format inserts the format name quoted (tests expect "Tcode" and an edit range).
  • Completion resolve / hover

    • on_completion_resolve now recognizes FORMAT items (based on the FORMAT tag) and calls def_format_markdown(...) to build a Markdown description with example values, instead of the block/address hover.
    • A thin wrapper def_format_markdown was added in tools/def_navigation.py that delegates to the existing _format_markdown implementation.
  • Tests and docs

    • Added tests in server/tests/python_tests/test_def_symbols.py:
      • test_format_list_shows_all_formats_with_preview verifies listing, details, insertion edit, and resolved markdown content.
      • test_format_list_prefix_offers_keyword verifies the FORMAT_LIST keyword appears while typing a prefix.
    • Updated README.md and CHANGELOG.md to document FORMAT_LIST.

Files touched (high-level)

  • Server behavior and wiring: server/src/lsp_server.py, server/src/lsp_tclserver.py
  • Navigation/markdown: server/src/tools/def_navigation.py
  • Tests: server/tests/python_tests/test_def_symbols.py
  • Documentation: README.md, CHANGELOG.md

Testing

No test execution results were provided.

Recommended checks for reviewers:

  1. Run the new unit tests:
    • pytest -q server/tests/python_tests/test_def_symbols.py::test_format_list_shows_all_formats_with_preview
  2. Start the LSP and open a Tcl file with a PSC service.def in the workspace, then:
    • Type FORMAT_LIST (or a prefix like FORM) and confirm the completion shows format names.
    • Select a format and confirm the inserted text is quoted and that completing the item provides a markdown preview with example values.

Notes for reviewer

  • No configuration or migration steps are required; this only adds a new completion keyword and the associated hover/preview behavior.
  • The change reuses existing format-preview logic (_format_markdown) and only adds a small wrapper and completion plumbing.
  • If you want focused verification beyond the unit tests, inspect TclLanguageServer.format_items() for how detail is constructed and on_completion_resolve for the FORMAT dispatch.
Summary This change introduces a `FORMAT_LIST` completion keyword for Tcl files and adds hover/markdown previews for FORMAT declarations. Typing or selecting `FORMAT_LIST` lists all FORMAT names from loaded .def documents; the completion detail shows the unquoted FORMAT specification and the source filename, and resolving a selected item produces a Markdown description with example values. Key changes - Completion - Adds `FORMAT_LIST` to `SYMBOL_LIST_KEYWORDS` so the keyword appears alongside `BLOCK_LIST` and `ADDR_LIST`. - Adds `TclLanguageServer.format_items()` which returns completion items for FORMAT declarations. Each item: - uses the declaration name as `label`, `CompletionItemKind.TypeParameter` as `kind`, - sets `detail` to the unquoted `FORMAT` specification plus the `.def` filename (see `unquote` usage), - sets `data` to `{ "def": [FORMAT, declaration.name] }` so the item can be resolved to its definition. - While typing the keyword the server still re-requests completions so the full list appears for `FORMAT_LIST` (in addition to `BLOCK_LIST`/`ADDR_LIST`). - Selecting a format inserts the format name quoted (tests expect `"Tcode"` and an edit range). - Completion resolve / hover - `on_completion_resolve` now recognizes FORMAT items (based on the `FORMAT` tag) and calls `def_format_markdown(...)` to build a Markdown description with example values, instead of the block/address hover. - A thin wrapper `def_format_markdown` was added in `tools/def_navigation.py` that delegates to the existing `_format_markdown` implementation. - Tests and docs - Added tests in `server/tests/python_tests/test_def_symbols.py`: - `test_format_list_shows_all_formats_with_preview` verifies listing, details, insertion edit, and resolved markdown content. - `test_format_list_prefix_offers_keyword` verifies the `FORMAT_LIST` keyword appears while typing a prefix. - Updated `README.md` and `CHANGELOG.md` to document `FORMAT_LIST`. Files touched (high-level) - Server behavior and wiring: `server/src/lsp_server.py`, `server/src/lsp_tclserver.py` - Navigation/markdown: `server/src/tools/def_navigation.py` - Tests: `server/tests/python_tests/test_def_symbols.py` - Documentation: `README.md`, `CHANGELOG.md` Testing No test execution results were provided. Recommended checks for reviewers: 1. Run the new unit tests: - pytest -q server/tests/python_tests/test_def_symbols.py::test_format_list_shows_all_formats_with_preview 2. Start the LSP and open a Tcl file with a PSC `service.def` in the workspace, then: - Type `FORMAT_LIST` (or a prefix like `FORM`) and confirm the completion shows format names. - Select a format and confirm the inserted text is quoted and that completing the item provides a markdown preview with example values. Notes for reviewer - No configuration or migration steps are required; this only adds a new completion keyword and the associated hover/preview behavior. - The change reuses existing format-preview logic (`_format_markdown`) and only adds a small wrapper and completion plumbing. - If you want focused verification beyond the unit tests, inspect `TclLanguageServer.format_items()` for how `detail` is constructed and `on_completion_resolve` for the FORMAT dispatch.
feat(completion): add FORMAT_LIST keyword for Tcl files
All checks were successful
Tests / python (pull_request) Successful in 30s
Tests / node (pull_request) Successful in 58s
8923d1c871
FORMAT_LIST lists all FORMAT declarations of the loaded PSC .def files,
like BLOCK_LIST and ADDR_LIST. Each item shows the format specification;
the resolved item shows example values as in the .def format hover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Christoph/nx_post_support!70
No description provided.