lang/python: use correct executables for flycheck
This commit is contained in:
parent
a124c1b993
commit
77da28f06a
1 changed files with 18 additions and 0 deletions
|
@ -43,6 +43,24 @@ called.")
|
||||||
(when (featurep! +lsp)
|
(when (featurep! +lsp)
|
||||||
(add-hook 'python-mode-local-vars-hook #'lsp!))
|
(add-hook 'python-mode-local-vars-hook #'lsp!))
|
||||||
|
|
||||||
|
(add-hook 'python-mode-hook
|
||||||
|
(defun +python-use-correct-flycheck-executables-h ()
|
||||||
|
"Use the correct Python executables for Flycheck."
|
||||||
|
(let ((executable python-shell-interpreter))
|
||||||
|
(save-excursion
|
||||||
|
(save-match-data
|
||||||
|
(when (or (looking-at "#!/usr/bin/env \\(python[^ \n]+\\)")
|
||||||
|
(looking-at "#!\\([^ \n]+/python[^ \n]+\\)"))
|
||||||
|
(setq executable (substring-no-properties (match-string 1))))))
|
||||||
|
;; Try to compile using the appropriate version of Python for
|
||||||
|
;; the file.
|
||||||
|
(setq-local flycheck-python-pycompile-executable executable)
|
||||||
|
;; We might be running inside a virtualenv, in which case the
|
||||||
|
;; modules won't be available. But calling the executables
|
||||||
|
;; directly will work.
|
||||||
|
(setq-local flycheck-python-pylint-executable "pylint")
|
||||||
|
(setq-local flycheck-python-flake8-executable "flake8"))))
|
||||||
|
|
||||||
(define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens
|
(define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens
|
||||||
(sp-local-pair 'python-mode "'" nil
|
(sp-local-pair 'python-mode "'" nil
|
||||||
:unless '(sp-point-before-word-p
|
:unless '(sp-point-before-word-p
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue