Browse Source

restructured python mode, integrated pet.

master
Marc 2 weeks ago
parent
commit
d7dc9b77d8
1 changed files with 32 additions and 9 deletions
  1. 41
      config.org

41
config.org

@ -1701,6 +1701,9 @@ at least pandas couldnt be resolved in pyright
#+end_src
** LSP-Mode
see https://github.com/emacs-lsp/lsp-pyright
for pything pip install basedpyright
see also https://github.com/DetachHead/basedpyright
#+begin_src emacs-lisp
(defun corfu-lsp-setup ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
@ -1725,9 +1728,11 @@ at least pandas couldnt be resolved in pyright
:after (python lsp-mode)
:custom
(lsp-pyright-multi-root nil)
(lsp-pyright-langserver-command "basedpyright")
:hook
(python-mode-hook . (lambda ()
(require 'lsp-pyright) (lsp))))
(python-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
#+end_src
** flymake
python in venv: pip install pyflake (or ruff?)
@ -1948,13 +1953,10 @@ npm install -g prettier
Preparations:
- create env:
m-x shell
python3 -m venv ./.env
python3 -m venv ./.venv
- Install language server in *each* projects venv
source ./.env/bin/activate
pip install pyright
- in project root:
touch .project.el
echo "((nil . (pyvenv-activate . "/path/to/project/.env")))" >> .dir-locals.el
pip install basedpyright
für andere language servers
https://github.com/emacs-lsp/lsp-mode#install-language-server
@ -1983,7 +1985,7 @@ Preparations:
:hook
(python-mode . pyvenv-mode)
:custom
(pyvenv-default-virtual-env-name ".env")
(pyvenv-default-virtual-env-name ".venv")
(pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))))
@ -1996,10 +1998,31 @@ Preparations:
TODO python mode hook:
- activate venv
- activate eglot with proper ls
- activate tree-sitter?
- have some fallback if activations fail
** python pet
see https://github.com/wyuenho/emacs-pet
It uses pyvenv to activate the venv. Somehow it doesn't do it on its own. Maybe a misunderstanding on my side.
#+begin_src emacs-lisp
(use-package pet
:ensure t
:config
(add-hook 'python-base-mode-hook 'pet-mode -10)
(add-hook 'pet-mode-hook
(lambda ()
(when python-shell-virtualenv-root
(pyvenv-activate python-shell-virtualenv-root))))
(add-hook 'python-mode-hook
(lambda ()
(setq-local python-shell-interpreter (pet-executable-find "python")
python-shell-virtualenv-root (pet-virtualenv-root))
(flymake-mode)
(lsp)
(setq-local dap-python-executable python-shell-interpreter))))
#+end_src
* beancount
** Installation

Loading…
Cancel
Save