tigersoldier / company-lsp

Company completion backend for lsp-mode
GNU General Public License v3.0
251 stars 26 forks source link

jsts-ls completion issue: either nothing, or too much #126

Closed garyo closed 4 years ago

garyo commented 4 years ago

Using jsts-ls with typescript, and latest company-lsp, I get no completions for "d3.sca|" with company-lsp-cache-candidates set to nil. With 'auto I get too many random candidates (not starting with "sca", not even fuzzy-matching "sca"). For instance:

       (use-package company-lsp
         :ensure t
         :config
         (push 'company-lsp company-backends)
         (setq company-lsp-async t
               company-lsp-cache-candidates 'auto
               )
Emacs 27.0.50 (x86_64-w64-mingw32) of 2019-10-10 on TOWER1
Company 0.9.10

company-backends: (company-lsp company-semantic company-dabbrev-code company-dabbrev company-etags company-keywords)

Used backend: company-lsp
Major mode: typescript-mode
Prefix: #("d3.sca" 0 6
  (fontified t))

Completions:
  #("version" 0 7 (lsp-completion-prefix #("d3.sca" 0 6 (fontified t)) lsp-completion-item #s(hash-table size 6 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("uri" "file:///c:/dss/Product/Horizon/WebProjects/horizon-project/horizon/src/components/KeyframeGraph.vue" "position" #s(hash-table size 2 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("line" 93 "character" 17)) "label" "version" "sortText" "00" "kind" 10 "data" #s(hash-table size 3 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("languageId" "typescript" "uri" "file:///c:/dss/Product/Horizon/WebProjects/horizon-project/horizon/src/components/KeyframeGraph.vue" "offset" 2663)))))) " (Property)"

... and 300kB of completions data follows, everything in the d3 lib.

yyoncho commented 4 years ago

probably we should have an entry for that server in company-lsp-filter-candidates

garyo commented 4 years ago

Is there a workaround I could try? Note that the prefix is "d3.sca" but the returned values don't start with "d3." Also, seems like sending 300k of data per keystroke is going to be pretty slow (and indeed, it brings my Emacs to its knees).

yyoncho commented 4 years ago

Is there a workaround I could try? Note that the prefix is "d3.sca" but the returned values don't start with "d3." Also, seems like sending 300k of data per keystroke is going to be pretty slow (and indeed, it brings my Emacs to its

I will investigate that later more closely (I am back from a vacation) but you may try:

(setq company-lsp-filter-candidates
  '((bingo . nil)
    (ccls . nil)
    (clangd . nil)
    (cquery . nil)
    (go-bingo . nil)
    (gopls . nil)
    (javacomp . nil)
    (jdtls . nil)
    (pyls . nil)
    (rls . nil)
    (jsts-ls . t)
    (t . t)))

FTR when using emacs 27 with native parsing with a proper gc-cons-threshold setting emacs is able to handle 300k json per keystrong without a problem.

garyo commented 4 years ago

Setting that value of company-lsp-filter-candidates makes it give the correct completions for me. Thanks!