rescript-lang / rescript-lang/vim-rescript

Omni completion duplicate prefix

Open
#58 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vim Script
Stars
164
Forks
17
PR merge metrics
No merged PRs in 30d

Description

When I select an entry from the omni completion menu, the existing prefix is duplicated. I'm using the latest vim-rescript and the suggested omni completion configuration (without coc-vim).

The problem can be demonstrated (once issue #56 has been fixed) by first creating an empty .res file, compiling the project, opening the file in VIM or Neovim and then typing out the following:

Js.Un

Hit <C-x><C-o> in insert mode with the cursor at the end of the line. The only match (Undefined) will be selected as expected. Afterwards the buffer will look like this:

Js.UnUndefined

The plugin most probably shouldn't end up duplicating the common prefix.

It looks like VS Code does the right thing by default and "will replace the word until the cursor with the given label or insertText" in cases like this:

https://code.visualstudio.com/api/references/vscode-api#CompletionItem

This might be a bit problematic to fix client side, because it looks like the plugin must know the correct location when the completion function is first called (when findstart is set to 1). Could the bulk of the logic be moved there so that the second invocation would just return the already-populated list?

Or could the analysis binary be amended to include insertText?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the plugin's omni-completion function, especially the findstart=1 path, and reproduce the issue with an empty .res file and the input Js.Un. Compare the completion behavior with the suggested omni configuration and verify that selecting Undefined leaves Js.Undefined rather than duplicating the prefix; the issue also identifies the analysis binary as a possible integration point.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.