nsf / gocode

An autocompletion daemon for the Go programming language
MIT License
5.01k stars 656 forks source link

emacs company-go: Incorrect GOPATH when using emacs server mode #412

Open XANi opened 7 years ago

XANi commented 7 years ago

Currently the GOPATH used is from starting emacs daemon which means that if daemon was started before setting GOPATH (say in autostart or started by Alt+F2, or application's menu).

It also makes not see any changes in GOPATH when using emacs via emacsclient altho that is a smaller problem.

I do not know if there is even an option to extract environmental variables from emacsclient invocation but there should be an config option to set if it does not exist, or override GOPATH

marcelino-m commented 7 years ago

For set correct env in emacs, I recomend to use the package exec-path-from-shell Here my config

(use-package exec-path-from-shell
  :ensure t
  :defer  2
  :config
  (dolist (var '("GOPATH"  "NVM_BIN"))
    (add-to-list 'exec-path-from-shell-variables var))
  (exec-path-from-shell-initialize))

Set in this form gocode work nice! with emacs in normal and server mode (I use emacs in server mode), I hope this response has not been too late Cheers!