var start_col = start_idx + 1
if opt.lspOptions.ultisnipsSupport
- call UltiSnips#SnippetsInCurrentScope(1)
- for key in matchfuzzy(g:current_ulti_dict_info->keys(), prefix)
- var item = g:current_ulti_dict_info[key]
- var parts = split(item.location, ':')
- var txt = readfile(parts[0])[str2nr(parts[1]) : str2nr(parts[1]) + 20]
- var restxt = item.description .. "\n\n"
- for line in txt
- if line == ""
- break
- else
- restxt = restxt .. line .. "\n"
- endif
- endfor
- items->add({
- label: key,
- data: {
- entryNames: [key],
- },
- kind: 15,
- documentation: restxt,
- })
+ call UltiSnips#SnippetsInCurrentScope(1)
+ for key in matchfuzzy(g:current_ulti_dict_info->keys(), prefix)
+ var item = g:current_ulti_dict_info[key]
+ var parts = split(item.location, ':')
+ var txt = readfile(parts[0])[str2nr(parts[1]) : str2nr(parts[1]) + 20]
+ var restxt = item.description .. "\n\n"
+ for line in txt
+ if line == ""
+ break
+ else
+ restxt = restxt .. line .. "\n"
+ endif
endfor
+ items->add({
+ label: key,
+ data: {
+ entryNames: [key],
+ },
+ kind: 15,
+ documentation: restxt,
+ })
+ endfor
endif
#writefile([$'chcol = {chcol}, starttext = [{starttext}], prefix = [{prefix}], start_idx = {start_idx}, end_idx = {end_idx}, start_col = {start_col}'], '/tmp/lspcomplete.log', 'a')
if item->has_key('textEdit') && opt.lspOptions.completionMatcher != 'fuzzy'
var start_charcol: number
if prefix != ''
- start_charcol = charidx(starttext, start_idx) + 1
+ start_charcol = charidx(starttext, start_idx) + 1
else
- start_charcol = chcol
+ start_charcol = chcol
endif
var textEdit = item.textEdit
var textEditStartCol = textEdit.range.start.character
if textEditStartCol != start_charcol
- var offset = start_charcol - textEditStartCol - 1
- d.word = textEdit.newText[offset : ]
+ var offset = start_charcol - textEditStartCol - 1
+ d.word = textEdit.newText[offset : ]
else
- d.word = textEdit.newText
+ d.word = textEdit.newText
endif
elseif item->has_key('insertText')
d.word = item.insertText
# plain text completion
if prefix != ''
- # If the completion item text doesn't start with the current (case
- # ignored) keyword prefix, skip it.
- if opt.lspOptions.completionMatcher == 'icase'
- if d.word->tolower()->stridx(prefix) != 0
- continue
- endif
- # If the completion item text doesn't fuzzy match with the current
- # keyword prefix, skip it.
- elseif opt.lspOptions.completionMatcher == 'fuzzy'
- if matchfuzzy([d.word], prefix)->empty()
- continue
- endif
- # If the completion item text doesn't start with the current keyword
- # prefix, skip it.
- else
- if d.word->stridx(prefix) != 0
- continue
- endif
- endif
+ # If the completion item text doesn't start with the current (case
+ # ignored) keyword prefix, skip it.
+ if opt.lspOptions.completionMatcher == 'icase'
+ if d.word->tolower()->stridx(prefix) != 0
+ continue
+ endif
+ # If the completion item text doesn't fuzzy match with the current
+ # keyword prefix, skip it.
+ elseif opt.lspOptions.completionMatcher == 'fuzzy'
+ if matchfuzzy([d.word], prefix)->empty()
+ continue
+ endif
+ # If the completion item text doesn't start with the current keyword
+ # prefix, skip it.
+ else
+ if d.word->stridx(prefix) != 0
+ continue
+ endif
+ endif
endif
endif
d.info = 'Lazy doc'
else
if item->has_key('detail') && item.detail != ''
- # Solve a issue where if a server send a detail field
- # with a "\n", on the menu will be everything joined with
- # a "^@" separating it. (example: clangd)
- d.menu = item.detail->split("\n")[0]
+ # Solve a issue where if a server send a detail field
+ # with a "\n", on the menu will be everything joined with
+ # a "^@" separating it. (example: clangd)
+ d.menu = item.detail->split("\n")[0]
endif
if item->has_key('documentation')
- if item.documentation->type() == v:t_string && item.documentation != ''
- d.info = item.documentation
- elseif item.documentation->type() == v:t_dict
- && item.documentation.value->type() == v:t_string
- d.info = item.documentation.value
- endif
+ if item.documentation->type() == v:t_string && item.documentation != ''
+ d.info = item.documentation
+ elseif item.documentation->type() == v:t_dict
+ && item.documentation.value->type() == v:t_string
+ d.info = item.documentation.value
+ endif
endif
endif
if cItem.documentation->type() == v:t_dict
# MarkupContent
if cItem.documentation.kind == 'plaintext'
- infoText->extend(cItem.documentation.value->split("\n"))
- infoKind = 'text'
+ infoText->extend(cItem.documentation.value->split("\n"))
+ infoKind = 'text'
elseif cItem.documentation.kind == 'markdown'
- infoText->extend(cItem.documentation.value->split("\n"))
- infoKind = 'lspgfm'
+ infoText->extend(cItem.documentation.value->split("\n"))
+ infoKind = 'lspgfm'
else
- util.ErrMsg($'Error: Unsupported documentation type ({cItem.documentation.kind})')
- return
+ util.ErrMsg($'Error: Unsupported documentation type ({cItem.documentation.kind})')
+ return
endif
elseif cItem.documentation->type() == v:t_string
infoText->extend(cItem.documentation->split("\n"))
# process the 'completionItem/resolve' reply from the LSP server
# Result: CompletionItem
export def CompletionResolveReply(lspserver: dict<any>, cItem: any)
- ShowCompletionDocumentation(cItem)
+ ShowCompletionDocumentation(cItem)
enddef
# omni complete handler
var item = v:event.completed_item
if item->has_key('user_data') && !item.user_data->empty()
if !item.user_data->has_key('documentation')
- lspserver.resolveCompletion(item.user_data)
+ lspserver.resolveCompletion(item.user_data)
else
- ShowCompletionDocumentation(item.user_data)
+ ShowCompletionDocumentation(item.user_data)
endif
endif
enddef
endif
acmds->add({bufnr: bnr,
- event: 'CompleteChanged',
- group: 'LSPBufferAutocmds',
- cmd: 'LspSetPopupFileType()'})
+ event: 'CompleteChanged',
+ group: 'LSPBufferAutocmds',
+ cmd: 'LspSetPopupFileType()'})
# Execute LSP server initiated text edits after completion
acmds->add({bufnr: bnr,