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 mode blocking and therefore unusable #159

Open
krux02 opened this issue May 10, 2017 · 20 comments
Open

company mode blocking and therefore unusable #159

krux02 opened this issue May 10, 2017 · 20 comments
Labels

Comments

@krux02
Copy link
Contributor

krux02 commented May 10, 2017

something must be wrong with the company mode integration. Whenever I edit non trivial Nim files, emacs blocks input for several seconds until it continues working. Therefore I am constantly forced to disable company mode for nim files.

@krux02
Copy link
Contributor Author

krux02 commented Jul 14, 2017

Well I had to disabled company mode for nim in general because of the blocking performance issue.

yuutayamada added a commit that referenced this issue Aug 22, 2017
@yuutayamada
Copy link
Contributor

Please update nim-mode. Now it should work (or maybe better than before)

@krux02
Copy link
Contributor Author

krux02 commented Aug 23, 2017

I am testing it right now, I will inform you when about how it works out.

@yuutayamada
Copy link
Contributor

ping @krux02

@yuutayamada
Copy link
Contributor

just FYI, I added log function on latest nim-mode.
you can use it by adding following config:

(let ((level :debug))
  (setq warning-minimum-level     level
        warning-minimum-log-level level))

It may help to distinguish the problem is really auto-completion or not.

@krux02
Copy link
Contributor Author

krux02 commented Oct 23, 2017

Thank you for your information, and I am very happy to see that there is some momentum in nim-mode again. I will check it out.

@cipharius
Copy link
Contributor

Started having this issue as well. company-mode is completely unusable for me in nim-mode. Poked around source, but didn't find what exactly is causing this, but will try some more.

@BontaVlad
Copy link

I to had issues with company-mode. Since this is my first adventure in elisp world take everything with a grain of salt.

If you want to investigate the problem by yourself follow these steps:

Step 1: is to enable logging:
(let ((level :debug)) (setq warning-minimum-level level warning-minimum-log-level level))

Step 2: If you want to debug emacs you can enable toggle-debug-on-quit and when emacs freezes hit C-g multiple times. This will stop the process and spit out a back-trace.

Step 3: Check the nim-log buffer.

Step 4: Add to nimsuggest-options located in nim-vars.el these additional flags --log, --debug. Restart emacs. These aditional flags will make nimssugest log aditional info and create a nimsuggest.log file in the home folder. If you change some elisp files and want to see the changes without restarting emacs run the function eval-buffer on the modified file.

In my case, running nimssugest with the --refresh would make nimsuggest freak out and repeatedly compile my file if it encountered an error, this in turn would trigger the timeout in nimsuggest--call-sync, and also call over and over again (sleep-for 0.01). Getting rid of the --refresh option and setting the time to 5s and the sleep-for to a 0.3 s ameliorates the problem.

For the best nim-mode experience:

  • upgrade emacs to 27.0 for async stuff eg: company and flymake
  • enable nimsuggest-mode so that company-mode will use the company-nimssugest back-end and not company-capf (capf in my case is practically unusable). Use company-diag to find out which back-end is enabled.
  • Set flycheck to use nimsuggest instead of nim, make sure flymake is enabled.

Hope this could prove useful for someone.

@krux02
Copy link
Contributor Author

krux02 commented Mar 23, 2018

@BontaVlad you suggested to use flymake and flycheck. I never used flymake. I don't know what it really is, but I have the impression it tries to do the same thing as flycheck and therefore should not be used at the same time. I guess I am wrong here, so how does flycheck and flymake actually interact with each other?

@BontaVlad
Copy link

@krux02 Yes you are right, that was a bad wording on my part. Flycheck and flymake will step on each others tows. At first I chose flymake(the nim-mode source comments recommends it), while I liked the fast feedback is not as well supported(gui stuff) in spacemacs so I switched back to flycheck. If you stick with flycheck, set the checker to nimsuggest, you already using nimssugest for completion, jump at def etc, so you might as well use it for linting.
In the end nim-mode is quite usable now, completion is fast, linting also, no more big shutters. Only thing left is to automate some init hooks.

@twillis
Copy link

twillis commented Jun 14, 2018

@BontaVlad s comment helped me solve my problem in spacemacs.

when I open a file initially company-diag reports it's using the company-capf backend which is indeed unusable. M-x nimsuggest-mode disables, M-x nimsuggest-mode enables and company-diag reports company-nimsuggest as backend being used and everything is snappy as expected.

So thanks @BontaVlad

@krux02
Copy link
Contributor Author

krux02 commented Jun 14, 2018

@twillis how big are the files you work with? Company mode with nimsuggest-mode works in small files, but as soon as the file as a certain size, it is just unusable to work with.

@twillis
Copy link

twillis commented Jun 15, 2018

@krux02 less than 100 lines, this is just something I found when working through Nim in Action.

@krux02
Copy link
Contributor Author

krux02 commented Jun 15, 2018

@twillis well I have often more than 1000 lines of code. And I can tell you that even with company-mode disabled nim-mode is often blocking my input. I continue to disable more and more features from nim-mode to keep it usable in my project.

@tavurth
Copy link

tavurth commented Aug 11, 2018

In my case, running nimssugest with the --refresh would make nimsuggest freak out and repeatedly compile my file if it encountered an error, this in turn would trigger the timeout in nimsuggest--call-sync, and also call over and over again (sleep-for 0.01). Getting rid of the --refresh option and setting the time to 5s and the sleep-for to a 0.3 s ameliorates the problem.

@BontaVlad Thank you! This resolved the issue for me. it took a long time to track this issue down as this issue was not high on my google ranking.

Perhaps we can remove --refresh from the defaults?

@pigmej
Copy link
Member

pigmej commented Sep 20, 2018

You can set this variable by M-x customize-variable and customize nimsuggest-options

@igna92ts
Copy link

@BontaVlad This happened to me as well, but how do I permanently set it to company-nimsuggest? As it is now I need to disable and re-enable nimsuggest-mode to get it to use company-nimsuggest instead of capf

@yuutayamada
Copy link
Contributor

If you want to avoid capf stuff on nim-capf-setup function, you can configure like this:

(advice-add 'nim-capf-setup :override
            (lambda ()
              (when (bound-and-true-p company-backends)
                (add-to-list 'company-backends 'company-nimsuggest))))

I'm not sure why you need to disable and re-enable nimsuggest-mode though.

@yuutayamada
Copy link
Contributor

yuutayamada commented Nov 14, 2018

@igna92ts are you putting nim-mode configuration before your company-mode's configuration? if so, please move your nim-mode configuration to after company-mode's configuration because the company-backends variable might not exist.
[edit]
sorry I pointed wrong person changed (from @BontaVlad to @igna92ts)
and this is for disable/re-enable problem

@cyruseuros
Copy link

@yuutayamada, I have the same problem as @igna92ts, even though my nim config comes after my company config. Any thoughts as to why? Also worth noting that after I disable and re-enable nimsuggest-mode, company-nimsuggest appears in company-backends, but not in "Used backend:" when running company-diag.

cyruseuros added a commit to cyruseuros/spacemacs that referenced this issue Feb 2, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
cyruseuros added a commit to cyruseuros/spacemacs that referenced this issue Feb 2, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
sdwolfz pushed a commit to syl20bnr/spacemacs that referenced this issue Feb 3, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
billy1kaplan pushed a commit to billy1kaplan/spacemacs that referenced this issue Apr 19, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
@krux02 krux02 added the critical label May 3, 2019
stephanschubert pushed a commit to stephanschubert/spacemacs that referenced this issue Oct 23, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
sei40kr pushed a commit to sei40kr/spacemacs that referenced this issue Nov 11, 2019
As described here: nim-lang/nim-mode#159,
company-capf makes nim-mode unusable. I am replacing it with
company-nimsuggest as it is much more responsive. The reason I elected not to
leave company-capf in as a backup is that it would somehow still make it to the
car of company-backends, regardless of position at assignment, thus becoming the
default completion backend. Given that no functionality is lost this way, and
that nimsuggest is now part of the core nim installation
(https://github.com/nim-lang/nimsuggest), I do not think anything has been
sacrificed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants