Created
November 2, 2019 20:13
-
-
Save bennofs/1eaf99a9338b84ad2066c2c0a197db0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; enable python version switching | |
(defvar +python-interpreter-executable-history nil | |
"History list for recently selected python interpreters.") | |
(defun +set-python-interpreter-executable (command) | |
"Set the python interpreter for the current buffer to the given executable." | |
(interactive | |
(list | |
(read-shell-command | |
"Python interpreter: " nil '+python-interpreter-executable-history "python" | |
))) | |
(setq-local python-shell-interpreter command) | |
(setq-local flycheck-python-pycompile-executable command) | |
(setq-local lsp-python-ms-python-executable-cmd command) | |
(when (= (length lsp--buffer-workspaces) 1) | |
(lsp-workspace-restart (nth 0 lsp--buffer-workspaces))) | |
(flycheck-buffer) | |
(let | |
((process (python-shell-get-process))) | |
(when (and process (y-or-n-p "Python interpreter already running. Kill currently running process?")) | |
(kill-process process)))) | |
(after! python | |
(map! :map python-mode-map | |
:localleader | |
"p" #'+set-python-interpreter-executable)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment