Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omni completion for items without documentation #57

Open
rnmmnen opened this issue Feb 9, 2022 · 0 comments
Open

Omni completion for items without documentation #57

rnmmnen opened this issue Feb 9, 2022 · 0 comments

Comments

@rnmmnen
Copy link

rnmmnen commented Feb 9, 2022

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:

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:

let entry = { 'word': item.label, 'kind': l:kind, 'info': item.documentation.value }

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 }
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

No branches or pull requests

1 participant