From 7819f86a46f31b8fdc0e11ce158fa49f36bb110f Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Mon, 24 Aug 2020 15:23:46 -0700 Subject: [PATCH] LSP server stuff for python --- dotfiles/emacs.d/init.el | 23 +++++++++++++++++++++++ dotfiles/emacs.d/package.el | 9 +++++++++ 2 files changed, 32 insertions(+) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index f706097..0a36a59 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -198,6 +198,10 @@ There are two things you can do about this warning: ;; Globally enable flycheck (add-hook 'after-init-hook #'global-flycheck-mode) +;; LSP + +(require 'lsp-mode) + ;;;;; PYTHON ;;;;;;;;;;;;;;;;;; ;; ;; NOTES: @@ -256,6 +260,22 @@ There are two things you can do about this warning: (add-hook 'python-mode-hook (lambda () (add-to-list 'company-backends 'company-jedi))) +;; Use microsoft's python language server +(require 'lsp-python-ms) +(use-package lsp-python-ms + :ensure t + :init (setq lsp-python-ms-auto-install-server t) + :hook (python-mode . (lambda () + (require 'lsp-python-ms) + (lsp)))) ; or lsp-deferred + +;; Add LSP to python mode +(add-hook 'python-mode-hook #'lsp) + + +;; Python testing helpers +(use-package python-pytest) + ;;-------------------------------------------------------------------------------------- ;; Save hooks ;;-------------------------------------------------------------------------------------- @@ -278,6 +298,9 @@ There are two things you can do about this warning: ;; Switch windows with M-o (global-set-key (kbd "M-o") 'other-window) +;; Bind pytest in python mode to M-p +(define-key python-mode-map (kbd "M-p") 'python-pytest-file) + ;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lisp Binds ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; Note: SLIME bindings require slime to be running. diff --git a/dotfiles/emacs.d/package.el b/dotfiles/emacs.d/package.el index 0db17c4..44ea251 100644 --- a/dotfiles/emacs.d/package.el +++ b/dotfiles/emacs.d/package.el @@ -18,6 +18,12 @@ irony counsel swiper + + ;; LSP is compatible with company and the lsp-ui gives a + ;; vscode-like experience. + lsp-mode + lsp-ui + lsp-python-ms ;;;;;;;;;;;;;;;;;;;;;;;; cmake-ide @@ -41,6 +47,9 @@ slime ;;;;;;;;;;;;;;;;;;;; + ;; Test helpers + python-pytest + ;; Cleanup ws-butler ;;;;;;;;;;