Skip to content

feat: add fuzzy matching for completions - #538

Closed
metif12 wants to merge 4 commits into
vlang:masterfrom
metif12:fuzzy-completion-matching
Closed

metif12 wants to merge 4 commits into
vlang:masterfrom
metif12:fuzzy-completion-matching

Conversation

@metif12

@metif12 metif12 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add fuzzy.v with fuzzy_match and fuzzy_filter functions
  • Integrate fuzzy filtering into completion handler
  • Set is_incomplete=true when fuzzy filtering is active
  • Add word_prefix_at_cursor helper
  • Add 11 tests for fuzzy matching
  • Update README with editor support sections
  • Add TODO.md with improvement plan

Changes

  • fuzzy.v: Fuzzy matching algorithm with scoring (consecutive bonus, word-start bonus)
  • fuzzy_test.v: 11 tests covering exact match, subsequence, case-insensitivity, empty pattern, no-match, consecutive bonus, word-start bonus, filtering, ranking
  • handlers.v: word_prefix_at_cursor method + fuzzy filtering in completion handler
  • README.md: Added Kate, Neovim, Emacs, Helix sections + proper Zed LSP config
  • TODO.md: Improvement plan with 3 phases

Test plan

  • All 11 fuzzy tests pass
  • Project compiles clean (v -check)
  • Verify completion behavior in editor with fuzzy filtering active

…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.
- Add fuzzy.v with fuzzy_match and fuzzy_filter functions
- Integrate fuzzy filtering into completion handler
- Set is_incomplete=true when fuzzy filtering is active
- Add word_prefix_at_cursor helper
- Add 11 tests for fuzzy matching
- Update README with editor support sections
- Add TODO.md with improvement plan
- 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
@metif12

metif12 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #542 (clean fuzzy-only split). Keeping #541 as the postfix vehicle.

@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