Add python LSP configuration

main
Sergio Alvariño 3 years ago
parent 440c95d37e
commit 192dfc7fab

@ -828,6 +828,62 @@ References:
#+end_src
** Python
We do need a Python language server installed in the developing enviroment (=pip install python-lsp-server[all]=)
- https://www.mattduck.com/lsp-python-getting-started.html
- https://www.mortens.dev/blog/emacs-and-the-language-server-protocol/index.html
- https://www.reddit.com/r/emacs/comments/ijmgtx/tip_how_to_use_a_stable_and_fast_environment_to/g3kmc7o/
*** Use latest python
Not needed if you have the right settings on your active python with =pyenv=
#+begin_src emacs-lisp
; (setq python-shell-interpreter "/usr/bin/python3.8")
; (setq py-python-command "/usr/bin/python3.8") ; maybe not needed
; (setq python-python-command "/usr/bin/python3.8") ; maybe not needed
#+end_src
*** Configure python mode
#+begin_src emacs-lisp
(use-package python-mode
:hook (python-mode . lsp-deferred)
;; :custom
;; (dap-python-debugger 'debugpy)
;;
;;;;; NOTE: Set these if Python 3 is called "python3" on your system!
;;;; (python-shell-interpreter "python3")
;;;; (dap-python-executable "python3")
:config
;; (require 'dap-python)
)
#+end_src
*** pyenv
Estoy cambiando de virtualenv a pyenv
Usamos =pyenv= para gestionar los /virtualenv/
- https://github.com/aiguofer/pyenv.el
- https://github.com/pythonic-emacs/pyenv-mode
- https://www.reddit.com/r/emacs/comments/ijmgtx/tip_how_to_use_a_stable_and_fast_environment_to/
#+begin_src emacs-lisp
(use-package pyenv-mode
:after python
:init
(add-to-list 'exec-path "~/.pyenv/shims")
(add-to-list 'exec-path "~/.pyenv/bin")
(setenv "WORKON_HOME" "~/.pyenv/versions/")
(defun projectile-pyenv-mode-set ()
"Set pyenv version matching project name."
(let ((project (projectile-project-name)))
(if (member project (pyenv-mode-versions))
(pyenv-mode-set project)
(pyenv-mode-unset))))
:config
(pyenv-mode)
:hook ((python-mode . pyenv-mode)
(projectile-switch-project . projectile-pyenv-mode-set)
)
:bind
("C-x p e" . pyenv-activate-current-project))
#+end_src
* next
#+begin_src emacs-lisp

Loading…
Cancel
Save