Shougo / ddc-source-lsp

lsp source for ddc.vim
Other
66 stars 20 forks source link

Use external modules #13

Closed haruyama closed 2 years ago

haruyama commented 2 years ago

I am not sure what the policy is on using external modules and entryName handling, so I make a Draft PR.

Use the GatherCandidatesArguments from ddc.vim 2e4bf03

This resolves TS2416 [ERROR]: Property 'gatherCandidates' in type 'Source' is not assignable to the same property in base type 'BaseSource'. error.

% deno run denops/ddc-sources/nvimlsp.ts
Check file:///home/haruyama/work/Vim/ddc-nvim-lsp/denops/ddc-sources/nvimlsp.ts
error: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag?
    await Deno.utime(dest, statInfo.atime, statInfo.mtime);
               ~~~~~
    at https://deno.land/std@0.104.0/fs/copy.ts:96:16

(snip)

TS2416 [ERROR]: Property 'gatherCandidates' in type 'Source' is not assignable to the same property in base type 'BaseSource'.
  Type '(args: { denops: Denops; context: Context; sourceParams: Record<string, Params>; completeStr: string; }) => Promise<Candidate[]>' is not assignable to type '({}: GatherCandidatesArguments) => Promise<Candidate[]>'.
    Types of parameters 'args' and '__0' are incompatible.
      Type 'GatherCandidatesArguments' is not assignable to type '{ denops: Denops; context: Context; sourceParams: Record<string, Params>; completeStr: string; }'.
        Types of property 'sourceParams' are incompatible.
          Type 'Record<string, unknown>' is not assignable to type 'Record<string, Params>'.
            Index signatures are incompatible.
              Type 'unknown' is not assignable to type 'Params'.
  async gatherCandidates(args: {
        ~~~~~~~~~~~~~~~~
    at file:///home/haruyama/work/Vim/ddc-nvim-lsp/denops/ddc-sources/nvimlsp.ts:57:9

Found 7 errors.

Use the CompletionItem from vscode_languageserver_types 98372d6

This resolves some (no-explicit-any) problems from deno lint.

I did not know how to handle entryName, and I did not find entryName in Language Server Protocol Specification. If entryName handling is needed, we cannot use vscode_languageserver_types as is.

Use the equal from equal for checking the objects are equal c2d73fd

From https://basarat.gitbook.io/typescript/recap/equality#structural-equality

If you want to compare two objects for structural equality ==/=== are not sufficient. e.g.

textEdit.range.{start,end} are Position, so I think we should not use ==/===.

Shougo commented 2 years ago

I am not sure what the policy is on using external modules and entryName handling, so I make a Draft PR.

I think it seems good.

Shougo commented 2 years ago

I will merge it later.

Shougo commented 2 years ago

Merged.