arch/roles/dots/files/home/.emacs.d/lan/python-cf.org
2025-04-26 11:41:01 +06:00

1.6 KiB

python

init

(require 'use-package)

tree-sitter

(add-hook 'python-mode-hook #'tree-sitter-mode +1)
(add-hook 'python-mode-hook #'tree-sitter-hl-mode +1)

LINT

(use-package flycheck
  :ensure t
  :init
  (global-flycheck-mode)
  :config
  (setq-default flycheck-disabled-checkers '(lsp))
  (setq flycheck-python-flake8-executable "flake8")
  (setq flycheck-python-pylint-executable "pylint")
  ;; (flycheck-add-next-checker 'python-flake8 'python-pylint)
  )

приоритетный линтер

(defun my/projectile-set-flycheck-checker ()
  (when (projectile-project-p)
    (setq-local flycheck-checker 'python-pyright)))  ;; замените на нужный

(add-hook 'python-mode-hook #'my/projectile-set-flycheck-checker)
(use-package python
  :hook (python-mode . (lambda ()
                         (flycheck-mode)
                         )))

lsp elpy

;; (use-package elpy
;;   :ensure t
;;   :init
;;   (elpy-enable))
;; (add-hook 'elpy-mode-hook (lambda () (highlight-indentation-mode -1)))

(use-package lsp-mode
  :ensure t
  :hook (python-mode . lsp)
  :commands lsp)

(use-package lsp-pyright
  :ensure t
  :after lsp-mode
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         )))

Cheat sheet

elpy

Search the buffer for a list of definitions of classes and functions. C-c C-o (elpy-occur-definitions)