tigersoldier / company-lsp

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

Completion does not filter (and is very slow) #52

Closed tam5 closed 6 years ago

tam5 commented 6 years ago

Completions do not filter down based on what I type. (for php at least)

It would also seem that they are extremely slow, which I only mention here in case it might be the same issue.

Here is what I am talking about:

lag

My config:

(use-package company
  :ensure t
  :config
  (setq company-dabbrev-downcase nil)
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 1)
  (setq company-tooltip-align-annotations t)
  (add-to-list 'company-backends '(company-capf company-dabbrev))
  (add-hook 'after-init-hook 'global-company-mode))

(use-package lsp-mode
  :ensure t
  :config
  (setq lsp-response-timeout 25))

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :config
  (add-hook 'lsp-mode-hook 'lsp-ui-mode))

(use-package company-lsp
  :ensure t
  :after (lsp-mode company)
  :config
  (push 'company-lsp company-backends))

(use-package php-mode :ensure t)

(use-package lsp-php
  :after (php-mode lsp-mode)
  :ensure t
  :config
  (setq lsp-php-server-install-dir "~/.emacs.d/packages/lsp")
  (add-hook 'php-mode-hook #'lsp-php-enable))

Is there something I am missing?

tigersoldier commented 6 years ago

When trying to complete, can you run M-x company-diag <RET> and paste the result here?

In the config, I suggest:

tam5 commented 6 years ago

@tigersoldier thanks for your response.

By switching company-lsp-cache-candidates from auto to t, i was able to get the filter to work properly almost all of the time, and this works great.

The only issue I have now, is that it seems to take a very long time (3+ seconds) for the completion results to appear. I am fairly certain the php language server itself is not causing the slowness, so is there another setting i might try to achieve better performance?

Here is a paste of company-diag:


Emacs 26.1 (x86_64-apple-darwin17.5.0) of 2018-07-13 on Aris-MBP.nyc.rr.com
Company 0.9.6

company-backends: (company-lsp
 (company-capf company-dabbrev))

Used backend: company-lsp
Major mode: php-mode
Prefix: ("" . t)

Completions: none(error fetching)

There is a message saying error fetching, and the list of completions here is empty. However, the list was populated before i hit M-x. Maybe that is important.

tigersoldier commented 6 years ago

I'm not sure what causes the long latency if it's not from php language server. You can try:

vv111y commented 6 years ago

I am having similar issue (delay) with python, see https://github.com/tigersoldier/company-lsp/issues/54.

@tam5, how did you rule out the language server?

tam5 commented 6 years ago

Hi @vv111y, I know it is not the language server itself, because I can use the same language server with a different frontend and it works fine. For example, if you use VSCode, you can use the same language server, and even open up dev tools and see how quickly it does respond.

So, the issue must lie somewhere in translation from the language server and emacs, but I have not yet figured out where that is. I will look into it further and post my findings here.

tam5 commented 6 years ago

Upon further investigation, it is php-language-server itself that is too slow (2+ seconds for completion requets). I think VsCode might hide this by including other results in the completions.

There is already an issue on the php langauge server side to address this, so I guess that is where further discussion should go.