Open krux02 opened 7 years ago
Well I had to disabled company mode for nim in general because of the blocking performance issue.
Please update nim-mode. Now it should work (or maybe better than before)
I am testing it right now, I will inform you when about how it works out.
ping @krux02
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.
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.
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.
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:
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.
@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?
@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.
@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
@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.
@krux02 less than 100 lines, this is just something I found when working through Nim in Action.
@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.
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?
You can set this variable by M-x customize-variable
and customize nimsuggest-options
@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
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.
@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
@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
.
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.