aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-04-22 00:20:05 +0800
committerGuangxiong Lin <[email protected]>2022-04-22 00:20:05 +0800
commit811b18bdbd6002f3a8aaa1b85cc25eea70a05934 (patch)
tree8e0e9979b92f10bda30a214024b1b5ff5bba3a0d
parent49aa78b8d2e01b275038eb3869660fde3a077423 (diff)
downloaddotfiles-811b18bdbd6002f3a8aaa1b85cc25eea70a05934.tar.gz
dotfiles-811b18bdbd6002f3a8aaa1b85cc25eea70a05934.tar.bz2
dotfiles-811b18bdbd6002f3a8aaa1b85cc25eea70a05934.zip
Add config of python (emacs)
-rw-r--r--.emacs.d/init.el2
-rw-r--r--.emacs.d/lisp/init-c.el2
-rw-r--r--.emacs.d/lisp/init-eglot.el3
-rw-r--r--.emacs.d/lisp/init-go.el5
-rw-r--r--.emacs.d/lisp/init-python.el20
5 files changed, 30 insertions, 2 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index a0ba982..0dcedfb 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -28,6 +28,8 @@
(require 'init-org)
(require 'init-lang)
(require 'init-go)
+(require 'init-python)
+(require 'init-c)
(require 'init-eglot)
(require 'init-racket)
(require 'init-deft)
diff --git a/.emacs.d/lisp/init-c.el b/.emacs.d/lisp/init-c.el
new file mode 100644
index 0000000..020ca56
--- /dev/null
+++ b/.emacs.d/lisp/init-c.el
@@ -0,0 +1,2 @@
+;; TODO
+(provide 'init-c)
diff --git a/.emacs.d/lisp/init-eglot.el b/.emacs.d/lisp/init-eglot.el
index 5409958..311c5d3 100644
--- a/.emacs.d/lisp/init-eglot.el
+++ b/.emacs.d/lisp/init-eglot.el
@@ -1,3 +1,6 @@
+(when (gx/maybe-require-package 'eglot)
+ (autoload #'eglot-ensure "eglot" nil t))
+
(defun gx/eglot-format-before-save ()
(add-hook 'before-save-hook #'eglot-format nil t))
diff --git a/.emacs.d/lisp/init-go.el b/.emacs.d/lisp/init-go.el
index f0a6b84..3a224fb 100644
--- a/.emacs.d/lisp/init-go.el
+++ b/.emacs.d/lisp/init-go.el
@@ -1,4 +1,5 @@
(when (gx/maybe-require-package 'go-mode)
+ (autoload #'go-mode "go-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode)))
(add-hook 'go-mode-hook (lambda () (setq tab-width 4)))
@@ -6,8 +7,8 @@
(gx/maybe-require-package 'go-dlv)
(when (gx/maybe-require-package 'eglot)
- (add-hook 'go-mode-hook #'eglot-ensure)
(add-hook 'go-mode-hook #'gx/eglot-format-before-save)
- (add-hook 'go-mode-hook #'gx/eglot-code-action-organize-imports-before-save))
+ (add-hook 'go-mode-hook #'gx/eglot-code-action-organize-imports-before-save)
+ (add-hook 'go-mode-hook #'eglot-ensure))
(provide 'init-go)
diff --git a/.emacs.d/lisp/init-python.el b/.emacs.d/lisp/init-python.el
new file mode 100644
index 0000000..646251f
--- /dev/null
+++ b/.emacs.d/lisp/init-python.el
@@ -0,0 +1,20 @@
+(when (gx/maybe-require-package 'eglot)
+ (add-hook 'python-mode-hook #'eglot-ensure))
+
+;; TODO Check if the venv-directory exists.
+;; Raise error message if it doesn't.
+(defun gx/python-load-venv ()
+ ""
+ (setenv "WORKON_HOME" (projectile-project-root))
+ (let* ((project-root (projectile-project-root))
+ (venv-directory "venv"))
+ (setenv "WORKON_HOME" project-root)
+ (pyvenv-workon venv-directory)))
+
+
+(when (gx/maybe-require-package 'pyvenv)
+ (autoload #'pyvenv-activate "pyvenv" nil t)
+ (autoload #'pyvenv-workon "pyvenv" nil t)
+ (add-hook 'python-mode-hook #'gx/python-load-venv))
+
+(provide 'init-python)