Skip to content

feat: add postfix completions - #539

Closed
metif12 wants to merge 5 commits into
vlang:masterfrom
metif12:postfix-completions
Closed

metif12 wants to merge 5 commits into
vlang:masterfrom
metif12:postfix-completions

Conversation

@metif12

@metif12 metif12 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add postfix_completions() with .if, .match, .for, .ptr, .unwrap
  • All postfix completions use snippet format (insert_text_format: 2)
  • Hook into indexed_completions general completion path
  • Add 9 tests for postfix completions

Changes

  • handlers.v: postfix_completions() function + integration into indexed_completions
  • postfix_test.v: 9 tests covering count, labels, snippets, kinds, and content

Test plan

  • All 9 postfix tests pass
  • Project compiles clean (v -check)

…iler

Hover, completion, signature help, and go to definition all go through
`v -vls-mode -line-info`, which the V launcher routes to the V1
compatibility compiler. When that compiler is missing, the launcher
refuses with a single line and exits:

    `-vls-mode` requires the compatibility compiler, but no usable V
    0.5.2 fallback was found and make is unavailable. Install make,
    then run `make v1` in `C:\Users\me\v`.

That refusal is not an "unknown option" line, so neither
`compiler_rejects_line_info` nor `compiler_refused_and_stopped`
recognized it. `line_info_mode` stayed `.direct`, so VLS kept spawning
the compiler once per request for an answer that can never arrive, and
every one of those lookups resolved to empty with nothing said about why.

Recognize the refusal, retire the lookups as `.missing` so they are
answered from VLS's own index instead of paying a process launch each,
and tell the user what to install. A launcher that can build the
fallback itself announces "running `make v1` now" and then answers, so
that form is explicitly not a dead end.

The notice needs no "already warned" flag: the caller sets
`line_info_mode` to `.missing` first, and from then on `run_v_line_info`
returns from its early `.missing` check without reaching this point, so
it is sent at most once per session.
vlang/v#29369 (merged as 76d88b9) rewrites the tail of the launcher's refusal:
the sentence after "make is unavailable" is now a platform-specific hint, and
the comma became a period. On Windows the clause reads

    On Windows, install GNU make in MSYS2 (`make` or `mingw32-make`) and put
    its tools, including `sh`, on PATH.

and elsewhere it is still "Install make.".

`compiler_lacks_compatibility_compiler` keys on "requires the compatibility
compiler", which both spellings contain, so detection is unaffected. This test
pinned the old wording verbatim, so it now asserts both: green before the
compiler change and after it, and the coupling is written down instead of being
rediscovered the next time the wording shifts.

Validated against V 0.5.2 76d88b9, the merged compiler: the Windows sample above
is its output verbatim. `interop_test.v` passes; the module suite reports the
same 3 failures with and without this change - `index_test.v`, `handlers_test.v`
and `integration_test.v`, none of them in this file. `integration_test.v` fails
on an empty completion list, which is the symptom of the missing V1 fallback
this refusal describes, and is what vlang/v#29369 and vlang/vscode-vlang#543 are
about.
@metif12
metif12 force-pushed the postfix-completions branch 3 times, most recently from 7802e71 to 227e463 Compare October 7, 2026 05:55
…tics

- Use compile_target as exec_dir and diagnostic_source_dir so the
  compiler checks the correct module directory
- Add base_dir parameter to source_path_from_overlay so relative
  paths resolve against the compile target, not the project root
- Escape backslashes in JSON rootPath for Windows paths
- Fix u64 to int conversion in test file size calculations
When the 'v' on PATH is a forwarding wrapper (v.bat -> v.exe),
find_v_dir returned the wrapper directory, so vlib module lookups
(os, builtin, time, strings) resolved nowhere and indexed member
completions came back empty. Unwrap .bat/.cmd shims to their quoted
executable target in resolve_v_compiler_exe and cover it with tests.
- Add snapshot_test.v with assert_snapshot helper
- Add tests for completion, hover, and definition
- Snapshots stored in testdata/snapshots/
- Set VLS_UPDATE_SNAPSHOTS=1 to regenerate
@metif12
metif12 force-pushed the postfix-completions branch from 227e463 to c8488cc Compare October 7, 2026 08:10
@metif12

metif12 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing as mislabeled: this branch carries interop fixes plus snapshot infra, not postfix. Postfix lives in #541; snapshot infra is re-proposed in #543.

@metif12 metif12 closed this Oct 7, 2026
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.

1 participant