rescript-lang / rescript-lang/vim-rescript
Omni completion for items without documentation
Nobody has claimed this yet.
- Dominant language
- Vim Script
- Stars
- 164
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
Under the hood, rescript-editor-analysis.exe returns null instead of an object/dict when a completion item has no documentation. This results in multiple errors in rescript#Complete.
A minimal example with vim-plug and the latest versions of vim-rescript and rescript (tested in VIM 8.2 and in Neovim 0.6.1):
~/.vimrc or ~/.config/nvim/init.vim:
call plug#begin()
Plug 'rescript-lang/vim-rescript'
call plug#end()
set omnifunc=rescript#Complete
set completeopt+=preview
Example.res:
let myInteger = 1
let myString = "2"
Also needed:
- complete/completion mismatch fix: #56
Make sure the project is built. Type let my as the last line of Example.res and hit <C-x><C-o> in insert mode. You'll get the following errors twice:
Error detected while processing function rescript#Complete:
line 36:
E121: Undefined variable: value
Press ENTER or type command to continue
Error detected while processing function rescript#Complete:
line 38:
E121: Undefined variable: entry
Press ENTER or type command to continue
Error detected while processing function rescript#Complete:
line 38:
E116: Invalid arguments for function add(l:ret, entry)
Press ENTER or type command to continue
After hitting ENTER enough times:
-- Omni completion (^O^N^P) Pattern not found
I think the problem lies here:
item.documentation is null for undocumented matches.
I tried to replace the offending line with the following, and now omni completion works both for built-in items and for undocumented local items (but I'm no expert in vimscript, so this may be a silly way to do it):
if type(item.documentation) == v:t_dict
let l:info = item.documentation.value
else
let l:info = item.detail " or some default value
endif
let entry = { 'word': item.label, 'kind': l:kind, 'info': l:info }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in autoload/rescript.vim around line 369 and build the project before reproducing the completion case from the issue in Vim or Neovim. Check the handling of item.documentation when it is null, with the completion mismatch fix in #56 as context. Done means built-in and undocumented local items complete without the reported errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- vim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100