This change adds editor completion for the special keywords BLOCK_LIST and ADDR_LIST and tweaks comment formatting to ensure a space after a single # when appropriate.
The primary user-visible outcomes:
LSP completion behavior for symbol-list keywords
Typing a prefix like BLOCK_L now offers the BLOCK_LIST keyword as an incomplete completion item that triggers further suggestions (it uses editor.action.triggerSuggest).
Once the full keyword is present in the typed word position, the completion replaces the keyword with a complete list of quoted names (block templates for BLOCK_LIST, addresses for ADDR_LIST).
Each returned item uses filter_text prefixed with the keyword (e.g. BLOCK_LIST"steady_rest") so suggesting the keyword remains visible while additional typing narrows the list.
The completion ignores occurrences that are variables (e.g. $BLOCK_LIST) or other word contexts (e.g. MY_BLOCK_LIST or plain steady).
Implementation is concentrated in a new helper _symbol_list_completion(...) and integration points in on_completion and _on_completion in server/src/lsp_server.py. The file imports line_prefix_at_position and uses a small regex to detect the word before the cursor.
Comment formatting
NxFormatter.format_comment (in server/src/tools/formatter.py) now inserts a single space after a # for comments like #Comment → # Comment, while leaving #, ##... separators, #! shebang-like comments, and comments that already start with whitespace unchanged. Inline comments after code (set x 1 ;#inline) are likewise formatted to ;# inline.
Files touched (high-level):
server/src/lsp_server.py: add _symbol_list_completion, integrate with completion flow, and merge symbol-list items when suggestions are re-requested.
server/src/tools/formatter.py: add format_comment to NxFormatter.
Tests: added/updated tests under server/tests/python_tests/:
test_def_symbols.py: new tests for BLOCK_LIST/ADDR_LIST completion behavior.
test_formatter.py: renamed from test_format_uplevel.py and extended with test_comment_gets_space_after_hash.
Testing
No test execution results were provided.
Recommended checks for reviewers:
Run the unit tests in server/tests/python_tests/ (e.g. pytest server/tests/python_tests/ -k def_symbols and -k formatter) to exercise the new tests locally.
In an editor connected to the LSP server, verify these interactive scenarios:
Type BLOCK_L and confirm the completion list shows BLOCK_LIST as an incomplete item and that selecting or continuing typing triggers the full list.
Type BLOCK_LIST (or ADDR_LIST) in a call site and confirm the completions are the quoted names (e.g. "steady_rest", "SPOS") and that the replacement inserts quotes.
Confirm comments like #Comment become # Comment and that ## heading, #\tTabbed, #, and #!something remain unchanged.
Compatibility / Risk notes
This is a localized change to LSP completion and formatter behavior. There are no changed on-disk formats or configuration flags introduced by the diff.
The completion logic depends on LSP_SERVER.block_template_items() and LSP_SERVER.address_items() to return the available names; reviewers should confirm these functions behave as expected in the running environment.
If you want I can point to the specific changed blocks in lsp_server.py and formatter.py for a targeted review of the new helpers and their interaction with existing completion ranking logic.
This change adds editor completion for the special keywords `BLOCK_LIST` and `ADDR_LIST` and tweaks comment formatting to ensure a space after a single `#` when appropriate.
The primary user-visible outcomes:
- LSP completion behavior for symbol-list keywords
- Typing a prefix like `BLOCK_L` now offers the `BLOCK_LIST` keyword as an incomplete completion item that triggers further suggestions (it uses `editor.action.triggerSuggest`).
- Once the full keyword is present in the typed word position, the completion replaces the keyword with a complete list of quoted names (block templates for `BLOCK_LIST`, addresses for `ADDR_LIST`).
- Each returned item uses `filter_text` prefixed with the keyword (e.g. `BLOCK_LIST"steady_rest"`) so suggesting the keyword remains visible while additional typing narrows the list.
- The completion ignores occurrences that are variables (e.g. `$BLOCK_LIST`) or other word contexts (e.g. `MY_BLOCK_LIST` or plain `steady`).
- Implementation is concentrated in a new helper `_symbol_list_completion(...)` and integration points in `on_completion` and `_on_completion` in `server/src/lsp_server.py`. The file imports `line_prefix_at_position` and uses a small regex to detect the word before the cursor.
- Comment formatting
- `NxFormatter.format_comment` (in `server/src/tools/formatter.py`) now inserts a single space after a `#` for comments like `#Comment` → `# Comment`, while leaving `#`, `##...` separators, `#!` shebang-like comments, and comments that already start with whitespace unchanged. Inline comments after code (`set x 1 ;#inline`) are likewise formatted to `;# inline`.
Files touched (high-level):
- `server/src/lsp_server.py`: add `_symbol_list_completion`, integrate with completion flow, and merge symbol-list items when suggestions are re-requested.
- `server/src/tools/formatter.py`: add `format_comment` to `NxFormatter`.
- Tests: added/updated tests under `server/tests/python_tests/`:
- `test_def_symbols.py`: new tests for `BLOCK_LIST`/`ADDR_LIST` completion behavior.
- `test_formatter.py`: renamed from `test_format_uplevel.py` and extended with `test_comment_gets_space_after_hash`.
Testing
No test execution results were provided.
Recommended checks for reviewers:
- Run the unit tests in `server/tests/python_tests/` (e.g. `pytest server/tests/python_tests/ -k def_symbols` and `-k formatter`) to exercise the new tests locally.
- In an editor connected to the LSP server, verify these interactive scenarios:
1. Type `BLOCK_L` and confirm the completion list shows `BLOCK_LIST` as an incomplete item and that selecting or continuing typing triggers the full list.
2. Type `BLOCK_LIST` (or `ADDR_LIST`) in a call site and confirm the completions are the quoted names (e.g. `"steady_rest"`, `"SPOS"`) and that the replacement inserts quotes.
3. Confirm comments like `#Comment` become `# Comment` and that `## heading`, `#\tTabbed`, `#`, and `#!something` remain unchanged.
Compatibility / Risk notes
- This is a localized change to LSP completion and formatter behavior. There are no changed on-disk formats or configuration flags introduced by the diff.
- The completion logic depends on `LSP_SERVER.block_template_items()` and `LSP_SERVER.address_items()` to return the available names; reviewers should confirm these functions behave as expected in the running environment.
If you want I can point to the specific changed blocks in `lsp_server.py` and `formatter.py` for a targeted review of the new helpers and their interaction with existing completion ranking logic.
Christoph
added 1 commit 2026-09-24 12:27:51 +00:00
Add keyword-driven completions for BLOCK_LIST and ADDR_LIST in the LSP server.
- While typing a prefix of these keywords the server returns the keyword(s)
as incomplete snippet suggestions that trigger a re-request.
- Once the keyword is typed the server replaces it with a full list of the
corresponding loaded block templates or addresses (quoted), and sets each
item's filter_text to include the keyword so further typing narrows results.
- Integrate this flow into on_completion and factor the symbol-list logic
into a helper that returns either incomplete keyword suggestions or the
completed symbol list.
Also implement NxFormatter.format_comment to ensure a single space after a
leading '#' for comments that don't already start with whitespace, while
leaving sequences of '#' (separators), shebangs, and already-spaced comments
unchanged. This affects both standalone and inline comments.
Add/rename tests to cover the new completions and comment-spacing behavior.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This change adds editor completion for the special keywords
BLOCK_LISTandADDR_LISTand tweaks comment formatting to ensure a space after a single#when appropriate.The primary user-visible outcomes:
LSP completion behavior for symbol-list keywords
BLOCK_Lnow offers theBLOCK_LISTkeyword as an incomplete completion item that triggers further suggestions (it useseditor.action.triggerSuggest).BLOCK_LIST, addresses forADDR_LIST).filter_textprefixed with the keyword (e.g.BLOCK_LIST"steady_rest") so suggesting the keyword remains visible while additional typing narrows the list.$BLOCK_LIST) or other word contexts (e.g.MY_BLOCK_LISTor plainsteady)._symbol_list_completion(...)and integration points inon_completionand_on_completioninserver/src/lsp_server.py. The file importsline_prefix_at_positionand uses a small regex to detect the word before the cursor.Comment formatting
NxFormatter.format_comment(inserver/src/tools/formatter.py) now inserts a single space after a#for comments like#Comment→# Comment, while leaving#,##...separators,#!shebang-like comments, and comments that already start with whitespace unchanged. Inline comments after code (set x 1 ;#inline) are likewise formatted to;# inline.Files touched (high-level):
server/src/lsp_server.py: add_symbol_list_completion, integrate with completion flow, and merge symbol-list items when suggestions are re-requested.server/src/tools/formatter.py: addformat_commenttoNxFormatter.server/tests/python_tests/:test_def_symbols.py: new tests forBLOCK_LIST/ADDR_LISTcompletion behavior.test_formatter.py: renamed fromtest_format_uplevel.pyand extended withtest_comment_gets_space_after_hash.Testing
No test execution results were provided.
Recommended checks for reviewers:
server/tests/python_tests/(e.g.pytest server/tests/python_tests/ -k def_symbolsand-k formatter) to exercise the new tests locally.BLOCK_Land confirm the completion list showsBLOCK_LISTas an incomplete item and that selecting or continuing typing triggers the full list.BLOCK_LIST(orADDR_LIST) in a call site and confirm the completions are the quoted names (e.g."steady_rest","SPOS") and that the replacement inserts quotes.#Commentbecome# Commentand that## heading,#\tTabbed,#, and#!somethingremain unchanged.Compatibility / Risk notes
LSP_SERVER.block_template_items()andLSP_SERVER.address_items()to return the available names; reviewers should confirm these functions behave as expected in the running environment.If you want I can point to the specific changed blocks in
lsp_server.pyandformatter.pyfor a targeted review of the new helpers and their interaction with existing completion ranking logic.