nim-lang / nim-mode

An emacs major mode for the Nim programming language
139 stars 46 forks source link

Enabling company mode: no completions, but freezing for several seconds. #101

Closed krux02 closed 8 years ago

krux02 commented 8 years ago

Company mode is enabled, but I do not get any completions. Instead emacs just freezes now and then for several seconds. Since I am new to emacs, I don't know what information you need in order to find out, what could cause this problem, but I will give you all the information you need, if you tell me what it is you need, and where I cant find it. I will attach my emacs config.

config.el.txt

yuutayamada commented 8 years ago

I think you are missing nim-nimsuggest-path to configure.

Can you specify following configuration? (please fill out the correct path of nimsuggest and put the code top of your configuration)

(setq nim-nimsuggest-path "/home/krux/..../nimsuggest/nimsuggest")

then

open up a nim file without nim's compiler directory (because it doesn't work well) and please try "M-." (meta + dot key) on echo statement. The M-. is binded jump to definition function and I would make sure your emacs is applied nimsuggest's configuration. (In my emacs, I could jump system.nim file)

yuutayamada commented 8 years ago

@krux02 Also you don't need this line (this is to load from another file)

(provide  'init_nim-mode)

and you might don't need following config:

(require 'flycheck-nim-async)
(defconst nimsuggest-vervosity nil)

there are two ways to syntax check in nim files.

  1. flycheck-nim
  2. flycheck-nim-async

first one uses nim check command and second one uses chk option of nimsuggest. I think you already installed flycheck-nim, so you can delete above configuration. (instead, if you want to use flycheck-nim-async, uninstall flycheck-nim)

flycheck-nim-async can check nimscript files as well, but there is a minor bug, so it's hard to recommend which one...

krux02 commented 8 years ago

for some reason (setq nim-nimsuggest-path "/home/...") did not help, but starting emacs from the terminal, instead from Alt+F2 emacs did do a difference. For some reason Alt+F2 started programs do not have the same path variable.

EDIT: I have (setq nim-nimsuggest-path "/home/...") in my .emacs, but if I examine the value of that variable at runtime, it has the value nil. (I used C-h v RET nim-nimsuggest-path)

yuutayamada commented 8 years ago

Sorry for my confusing suggestion. You can use defconst instead of setq to prevent overriding variable or put the configuration after (require 'nim-mode)

krux02 commented 8 years ago

I did put it after (require 'nim-mode) that's the context where it failed.

yuutayamada commented 8 years ago

Is nim-nimsuggest-path still nil in a nim file?

if so, I guess:

  1. maybe old byte-compiled file exists? (*.elc extension)
  2. your emacs isn't loading your configuration?
krux02 commented 8 years ago

nim-nimsuggest-path is not nil in a non-nim file. In a Nim file it is set to nil in nim-suggest.el, as told from C-h v nim-nimsuggest-path. My .emacs get's loaded correctly.

yuutayamada commented 8 years ago

hmm, it's strange... the (require 'nim-mode) loads also nim-suggest.el and once emacs loaded nim-mode by using the require, second time emacs ignores loading the same file. (so I thought putting the (setq nim-nimsuggest-path ...) after (require 'nim-mode) solve your overriding problem)

Have you tried defconst instead of setq?

(just FYI, load function loads if emacs already loads the file, so sometimes it overrides user configuration, though I know you don't use this function)

EDIT: I modified little bit around "I thought ..."

krux02 commented 8 years ago

I would like to mention again, that starting emacs from an environment, where the path is set correctly solves this problem.

No defconst does not solve the problem, and `(require 'nim-suggest) also does not solve the problem.

Flycheck in .emacs warns me with the warning assignment to free variable 'nim-suggest-path'

yuutayamada commented 8 years ago

Flycheck in .emacs warns me with the warning assignment to free variable 'nim-suggest-path'

because it's typo of nim-nimsuggest-path

yuutayamada commented 8 years ago

@krux02 can you close this issue? I think you already solved this issue.