Fixed bug so hy command work when hy is installed on a virtualenv
Hy is typically installed on a python virtual environment, not globally. When that is the case, init-hy-mode doesn't set any leader keys for hy since it can't find the hy executable on the path. When a virtual environment is activated, init-hy-mode is run again to see if it can find a hy executable and setup the leader keys for hy.
This commit is contained in:
parent
01de4d8b0e
commit
5a7019427e
|
@ -129,23 +129,26 @@
|
||||||
:init
|
:init
|
||||||
(spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc)))
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc)))
|
||||||
|
|
||||||
|
(defun python/find-hy-executable ()
|
||||||
|
(setq-local hy-executable (or (spacemacs/pyenv-executable-find "hy") "hy"))
|
||||||
|
(setq-local hy-mode-inferior-lisp-command (concat hy-executable " --spy")))
|
||||||
|
|
||||||
(defun python/init-hy-mode ()
|
(defun python/init-hy-mode ()
|
||||||
(use-package hy-mode
|
(use-package hy-mode
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
(let ((hy-path (executable-find "hy")))
|
(add-hook 'hy-mode-hook 'python/find-hy-executable)
|
||||||
(when hy-path
|
(add-hook 'pyvenv-post-activate-hooks 'python/find-hy-executable)
|
||||||
(setq hy-mode-inferior-lisp-command (concat hy-path " --spy"))
|
(spacemacs/set-leader-keys-for-major-mode 'hy-mode
|
||||||
(spacemacs/set-leader-keys-for-major-mode 'hy-mode
|
"si" 'inferior-lisp
|
||||||
"si" 'inferior-lisp
|
"sb" 'lisp-load-file
|
||||||
"sb" 'lisp-load-file
|
"sB" 'switch-to-lisp
|
||||||
"sB" 'switch-to-lisp
|
"se" 'lisp-eval-last-sexp
|
||||||
"se" 'lisp-eval-last-sexp
|
"sf" 'lisp-eval-defun
|
||||||
"sf" 'lisp-eval-defun
|
"sF" 'lisp-eval-defun-and-go
|
||||||
"sF" 'lisp-eval-defun-and-go
|
"sr" 'lisp-eval-region
|
||||||
"sr" 'lisp-eval-region
|
"sR" 'lisp-eval-region-and-go))))
|
||||||
"sR" 'lisp-eval-region-and-go))))))
|
|
||||||
|
|
||||||
(defun python/init-live-py-mode ()
|
(defun python/init-live-py-mode ()
|
||||||
(use-package live-py-mode
|
(use-package live-py-mode
|
||||||
|
|
Loading…
Reference in a new issue