From 192dfc7fabfcb2adb68df6389379a366fd8ff2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Alvari=C3=B1o?= Date: Mon, 21 Mar 2022 22:05:11 +0100 Subject: [PATCH] Add python LSP configuration --- myconfig.org | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/myconfig.org b/myconfig.org index 1eda0bb..684737c 100644 --- a/myconfig.org +++ b/myconfig.org @@ -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