Skip to content

Fix completion offset #22

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions autoload/ddc_vim_lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ function! ddc_vim_lsp#_callback(server, position, id, data) abort
\ 'position': a:position,
\ 'response': a:data['response'],
\ }
let lspitems = lsp#omni#get_vim_completion_items(l:options)['items']
let completionResult = lsp#omni#get_vim_completion_items(l:options)
let startcol = completionResult['startcol']
let lspitems = completionResult['items']

let isIncomplete = (
\ type(a:data['response']['result']) == 4
\ && has_key(a:data['response']['result'], 'isIncomplete')
\ ) ?
\ a:data['response']['result']['isIncomplete'] : v:false

call ddc#callback(a:id, {'items': lspitems, 'isIncomplete': isIncomplete})
call ddc#callback(a:id, {
\ 'items': lspitems,
\ 'isIncomplete': isIncomplete,
\ 'startcol': startcol,
\ 'currentcol': col('.'),
\})
endfunction

function! ddc_vim_lsp#request(server_name, id) abort
Expand Down
9 changes: 8 additions & 1 deletion denops/@ddc-sources/vim-lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ export class Source extends BaseSource<Params> {
args.onCallback(id) as Promise<{
items: DdcItem[];
isIncomplete: boolean;
startcol: number;
currentcol: number;
}>,
args.denops.call("ddc_vim_lsp#request", lspservers[0], id),
]);
return {
items: payload.items,
items: payload.items.map((elem: DdcItem) => {
elem.word = elem.word.slice(
payload.currentcol - payload.startcol,
);
return elem;
}),
isIncomplete: payload.isIncomplete,
};
}
Expand Down