Move python-check-command and python-flymake-command setting to hooks
Set variables locally depending on what programs are available. Mostly helpful for checking if mypy is installed in given environment (since it's not globally), or for available programs on remote host
This commit is contained in:
parent
4828d8e671
commit
c962bb3f93
29
init.el
29
init.el
|
@ -867,21 +867,17 @@
|
||||||
("C-c c a" . eglot-code-actions)
|
("C-c c a" . eglot-code-actions)
|
||||||
("C-c c r" . eglot-rename))
|
("C-c c r" . eglot-rename))
|
||||||
:hook ((eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)))
|
:hook ((eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)))
|
||||||
(nix-mode . (lambda () (if (and (project-current nil)
|
(nix-mode . (lambda () (if (and (project-current nil) (executable-find "nil" t))
|
||||||
(executable-find "nil" t))
|
|
||||||
(eglot-ensure))))
|
(eglot-ensure))))
|
||||||
(python-base-mode . (lambda () (if (and (project-current nil)
|
(python-base-mode . (lambda () (if (and (project-current nil)
|
||||||
(or (executable-find "pyright" t)
|
(or (executable-find "pyright" t)
|
||||||
(executable-find "pylsp" t)))
|
(executable-find "pylsp" t)))
|
||||||
(eglot-ensure))))
|
(eglot-ensure))))
|
||||||
(lua-mode . (lambda () (if (and (project-current nil)
|
(lua-mode . (lambda () (if (and (project-current nil) (executable-find "lua-language-server" t))
|
||||||
(executable-find "lua-language-server" t))
|
|
||||||
(eglot-ensure))))
|
(eglot-ensure))))
|
||||||
((rust-ts-mode rust-mode) . (lambda () (if (and (project-current nil)
|
((rust-ts-mode rust-mode) . (lambda () (if (and (project-current nil) (executable-find "rust-analyzer" t))
|
||||||
(executable-find "rust-analyzer" t))
|
|
||||||
(eglot-ensure))))
|
(eglot-ensure))))
|
||||||
((js-base-mode typescript-ts-base-mode) . (lambda () (if (and (project-current nil)
|
((js-base-mode typescript-ts-base-mode) . (lambda () (if (and (project-current nil) (executable-find "typescript-language-server" t))
|
||||||
(executable-find "typescript-language-server" t))
|
|
||||||
(eglot-ensure))))
|
(eglot-ensure))))
|
||||||
)
|
)
|
||||||
:custom
|
:custom
|
||||||
|
@ -1053,16 +1049,19 @@ Calls `project-remember-projects-under' for ~/Projects/"
|
||||||
(display-fill-column-indicator-mode +1))
|
(display-fill-column-indicator-mode +1))
|
||||||
|
|
||||||
(use-package python
|
(use-package python
|
||||||
:hook ((python-base-mode . (lambda () (my/enable-fill-column 88))))
|
:hook ((python-base-mode . (lambda () (my/enable-fill-column 88)))
|
||||||
|
(python-base-mode . (lambda () (setq-local
|
||||||
|
python-check-command (cond
|
||||||
|
((executable-find "mypy" t) "mypy --check-untyped-defs --warn-unreachable --show-error-codes --ignore-missing-imports")
|
||||||
|
(t "pyflakes"))
|
||||||
|
python-flymake-command (cond
|
||||||
|
((executable-find "ruff" t) '("ruff" "check" "--output-format=concise" "--stdin-filename=stdin" "-"))
|
||||||
|
((executable-find "flake8" t) '("flake8" "--max-line-length" "88" "-"))
|
||||||
|
(t '("pyflakes")))))))
|
||||||
:custom
|
:custom
|
||||||
(python-shell-interpreter "python3")
|
(python-shell-interpreter "python3")
|
||||||
(python-shell-dedicated 'project)
|
(python-shell-dedicated nil)
|
||||||
(python-indent-def-block-scale 1)
|
(python-indent-def-block-scale 1)
|
||||||
(python-check-command "mypy --check-untyped-defs --warn-unreachable --show-error-codes --ignore-missing-imports")
|
|
||||||
(python-flymake-command
|
|
||||||
(cond ((executable-find "ruff") '("ruff" "check" "--output-format=concise" "--stdin-filename=stdin" "-"))
|
|
||||||
((executable-find "flake8") '("flake8" "--max-line-length" "88" "-"))
|
|
||||||
(t '("pyflakes"))))
|
|
||||||
:config
|
:config
|
||||||
(setq python-ts-mode-hook python-mode-hook))
|
(setq python-ts-mode-hook python-mode-hook))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue