Skip to content
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

"company-omnisharp" makes "company-mode" hook slow #491

Open
bezirg opened this issue Aug 26, 2019 · 2 comments
Open

"company-omnisharp" makes "company-mode" hook slow #491

bezirg opened this issue Aug 26, 2019 · 2 comments

Comments

@bezirg
Copy link

bezirg commented Aug 26, 2019

Hello,

When opening other files than .cs, e.g. .el or .ts files, I see that there is a company-omnisharp function called, even if the buffer loaded is not in csharp mode.

This makes the 1st-time-loading of an emacs-lisp file very slow. Trying to profile this with emacs profiler shows:

              - emacs-lisp-mode                                    64  71%
               - run-mode-hooks                                    64  71%
                - apply                                            64  71%
                 - run-hooks                                       64  71%
                  - #<compiled 0x15917b8446e9>                     62  69%
                   - company-mode                                  62  69%
                    - mapc                                         58  65%
                     - company-init-backend                        58  65%
                      + company-omnisharp                          56  62%
                      + company-dabbrev-code                        1   1%
                    + defvar                                        2   2%
                      byte-code                                     1   1%

, which shows that 87% of the time setting up the emacs-lisp-mode was spent on the company-omnisharp function. The impact of this company-omnisharp varies on the file / mode loaded.

Trying to set:

(add-hook 'emacs-lisp-mode-hook (lambda ()
                                  (set (make-local-variable 'company-backends) '(company-capf company-dabbrev-code company-keywords))
                                  (company-mode)
                                  ))

, did not improve loading times and company-omnisharp still ran.

@bezirg
Copy link
Author

bezirg commented Aug 26, 2019

Could this setup (taking from README) be the culprit?

(eval-after-load
 'company
 '(add-to-list 'company-backends 'company-omnisharp))

@razzmatazz
Copy link
Contributor

Hi @bezirg . Sorry for replying this late. I didn't notice this myself since I am using spacemacs where this is taken care for (major-mode based company-backends list). But I found this on stack overflow:

Can you check if making company-backends a local variable for a buffer withmake-local-variable works (in you mode hook) -- and remove global eval-after-load.

I have not tried this solution by myself, but maybe that helps you? And if it does, we can then integrate the fix into README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants