Skip to content

getPreviewer does not work when using lspEngine: 'vim-lsp' #61

@k-86

Description

@k-86

Problems summary

When calling ddc#get_previewer({item}) while configuring lspEngine: 'vim-lsp',
getPreviewer does not work due to timeout.

Expected

It gets additional information for a given completion item.

Environment Information

  • ddc-source-lsp version (SHA1):
    3958289

  • ddc-ui-none version (SHA1):
    1c12bc3

  • ddc.vim version (SHA1):
    4e1ae49

  • denops.vim version (SHA1):
    2a39384

  • vim-lsp version (SHA1):
    f7ccf00

  • vim-lsp-settings version (SHA1):
    54ade15

  • deno version(deno -V output):
    deno 1.43.2

  • OS:
    Ubuntu 22.04.4 LTS in WSL2

  • neovim/Vim :version output:
    NVIM v0.9.5
    Build type: Release
    LuaJIT 2.1.1692716794

    VIM - Vi IMproved 9.1 Included patches: 1-401

    Compiled by asdf
    Huge version without GUI. Features included (+) or not (-):
    +acl +file_in_path +mouse_urxvt -tag_any_white
    +arabic +find_in_path +mouse_xterm -tcl
    +autocmd +float +multi_byte +termguicolors
    +autochdir +folding +multi_lang +terminal
    -autoservername -footer -mzscheme +terminfo
    -balloon_eval +fork() +netbeans_intg +termresponse
    +balloon_eval_term +gettext +num64 +textobjects
    -browse -hangul_input +packages +textprop
    ++builtin_terms +iconv +path_extra +timers
    +byte_offset +insert_expand -perl +title
    +channel +ipv6 +persistent_undo -toolbar
    +cindent +job +popupwin +user_commands
    -clientserver +jumplist +postscript +vartabs
    -clipboard +keymap +printer +vertsplit
    +cmdline_compl +lambda +profile +vim9script
    +cmdline_hist +langmap -python +viminfo
    +cmdline_info +libcall -python3 +virtualedit
    +comments +linebreak +quickfix +visual
    +conceal +lispindent +reltime +visualextra
    +cryptv +listcmds +rightleft +vreplace
    +cscope +localmap -ruby +wildignore
    +cursorbind -lua +scrollbind +wildmenu
    +cursorshape +menu +signs +windows
    +dialog_con +mksession +smartindent +writebackup
    +diff +modify_fname -sodium -X11
    +digraphs +mouse -sound +xattr
    -dnd -mouseshape +spell -xfontset
    -ebcdic +mouse_dec +startuptime -xim
    +emacs_tags +mouse_gpm +statusline -xpm
    +eval -mouse_jsbterm -sun_workshop -xsmp
    +ex_extra +mouse_netterm +syntax -xterm_clipboard
    +extra_search +mouse_sgr +tag_binary -xterm_save
    -farsi -mouse_sysmouse -tag_old_static

Provide a minimal init.vim/vimrc without plugin managers (Required!)

if &compatible
  set nocompatible
endif

filetype on

set rtp+=/path/to/github.com/vim-denops/denops.vim
set rtp+=/path/to/github.com/Shougo/ddc-ui-none
set rtp+=/path/to/github.com/Shougo/ddc.vim
set rtp+=/path/to/github.com/Shougo/ddc-source-lsp
set rtp+=/path/to/github.com/prabirshrestha/vim-lsp
set rtp+=/path/to/github.com/mattn/vim-lsp-settings

call ddc#custom#patch_global('ui', 'none')
call ddc#custom#patch_global('sources', ['lsp'])
call ddc#custom#patch_global('sourceParams', #{
  \   lsp: #{
  \     lspEngine: 'vim-lsp',
  \   },
  \ })
call ddc#enable()

function Test() abort
  let path_to_test_ts = 'file:///path/to/test.ts' " Replace file path

  let lspitem = {
    \ 'label':'at',
    \ 'commitCharacters':['.',',',';'],
    \ 'data':{
    \   'tsc':{
    \     'specifier':path_to_test_ts,
    \     'name':'at',
    \     'position':3,
    \     'useCodeSnippet':v:true,
    \     },
    \   },
    \ 'sortText':'11',
    \ 'kind':2,
    \ }

  let item = {
    \ 'word':'at',
    \ 'menu':'',
    \ 'highlights':[],
    \ 'user_data':{
    \   'clientId':'deno',
    \   'suggestCharacter':3,
    \   'requestCharacter':3,
    \   'offsetEncoding':'utf-16',
    \   'lspitem': json_encode(lspitem),
    \   'lineOnRequest':'[].',
    \   'resolvable':v:true,
    \   },
    \ 'info':'',
    \ '__sourceName':'lsp',
    \ 'kind':'Method',
    \ 'abbr':'at',
    \ 'dup':v:true,
    \ '__dup':'ignore',
    \ }

  let start_time = reltime()
  let res = ddc#get_previewer(item)
  let end_time = reltime()

  echom 'ddc#get_previewer: ' . string(res)
  echom 'Elapsed time: ' . reltimestr(reltime(start_time, end_time))
endfunction

How to reproduce the problem from neovim/Vim startup (Required!)

  1. echo "[]." > test.ts
  2. Replace path_to_test_ts in init.vim/vimrc
  3. (n)vim -u init.vim/vimrc test.ts
  4. install deno lsp if it is not installed (call :LspManageServers)
  5. call Test()

Upload the log messages by :redir and :message (if errored)

ddc#get_previewer: {'kind': 'markdown', 'contents': []}
Elapsed time:   1.106308

Note

Where timeout error occurs is

try {
const response = await request(
denops,
lspEngine,
"completionItem/resolve",
lspItem,
{ client, timeout: 1000, sync: true, bufnr: bufnr },
);
const { result } = u.ensure(
response,
is.ObjectOf({ result: is.ObjectOf({ label: is.String }) }),
);
return result as LSP.CompletionItem;
} catch {
return lspItem;
}

debug code

return result as LSP.CompletionItem;
} catch {
return lspItem;
}

  return result as LSP.CompletionItem;
} catch (e) {
  console.log(e);
  return lspItem;
}

const id = register(
denops,
(res: unknown) => waiter.resolve(res),
{ once: true },
);

const id = register(
    denops,
    (res: unknown) => {
      console.log(res);
      waiter.resolve(res);
    },
    { once: true },
  );

:message

[denops] Error: No response from server deno
[denops]     at request (file:///path/to/github.com/Shougo/ddc-source-lsp/denops/ddc-source-lsp/request.ts:75:15)
[denops]     at eventLoopTick (ext:core/01_core.js:207:9)
[denops]     at async Source.#resolve (file:///path/to/github.com/Shougo/ddc-source-lsp/denops/@ddc-sources/lsp.ts:256:24)
[denops]     at async Source.getPreviewer (file:///path/to/github.com/Shougo/ddc-source-lsp/denops/@ddc-sources/lsp.ts:284:21)
[denops]     at async getPreviewer (file:///path/to/github.com/Shougo/ddc.vim/denops/ddc/ext.ts:218:21)
[denops]     at async Object.getPreviewer (file:///path/to/github.com/Shougo/ddc.vim/denops/ddc/app.ts:142:14)
[denops]     at async Plugin.call (file:///path/to/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:138:12)
[denops]     at async Service.#dispatch (file:///path/to/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:68:12)
[denops]     at async Service.dispatch (file:///path/to/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:73:14)
[denops]     at async Vim.#dispatch (file:///path/to/github.com/vim-denops/denops.vim/denops/@denops-private/host/vim.ts:114:14)
ddc#get_previewer: {'kind': 'markdown', 'contents': []}
Elapsed time:   1.074064
[denops] {"response":{"id":5,"jsonrpc":"2.0","result":{"label":"at","insertText":"at(${1:index})","sortText":"11","kind":2,"insertTextFormat":2,"documentation":{"kind":"markdown","value":"Returns the item located at the specified index.\n\n*@param* - index The zero-based index of the desired code unit. A negative index will count back from the last item."},"detail":"(method) Array<never>.at(index: number): undefined"}},"request":{"id":5,"jsonrpc":"2.0","method":"completionItem/resolve","params":{"label":"at","commitCharacters":[".",",",";"],"data":{"tsc":{"specifier":"file:///path/to/test.ts","name":"at","position":3,"useCodeSnippet":true}},"sortText":"11","kind":2}},"server_name":"deno"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions