Add support for pyright lsp lang server for python

This commit is contained in:
Sameer Rahmani 2022-06-27 23:38:14 +01:00
parent 4656df14e9
commit 2ce52208ea
1 changed files with 58 additions and 8 deletions

View File

@ -54,16 +54,22 @@ interactive `pyvenv-workon' function before `lsp'"
(call-interactively #'pyvenv-workon)
(lsp)))))
(defcube fg42/python-black-cube
"This cube reformats python code using black formatter tool."
(:title "Python lang server via pyls"
:flag python-black
:flag-default t)
(defcube fg42/python-cube
"Python support cube."
(:title "Python cube"
:flag python)
(fpkg/use python-black
:demand t
:after python
:hook (python-mode . (lambda ()
(python-black-on-save-mode)))))
(fpkg/use pyvenv
:defer t
:config
(setenv "WORKON_HOME" "~/.pyenv/versions"))
(defcube fg42/python-cube-pyls
"Python language server using pyls"
(:title "Python lang server via pyls"
:flag python-pyls)
(when-flag lsp
(with-eval-after-load "lsp"
@ -76,5 +82,49 @@ interactive `pyvenv-workon' function before `lsp'"
(add-hook 'python-mode #'fg42/py-auto-lsp))))
(defcube fg42/python-cube-pyright
"Python language server using pyright."
(:title "Python lang server via pyright"
:flag python-pyright)
(fpkg/use lsp-pyright
:ensure t
:after (python lsp-mode)
:hook
(python-mode . (lambda ()
;; Pyls and pylsp can be annoying
(add-to-list 'lsp-disabled-clients 'pyls)
(add-to-list 'lsp-disabled-clients 'pylsp)
(add-to-list 'lsp-enabled-clients 'pyright)
;;(fg42/py-auto-lsp)
(require 'lsp-pyright)
(lsp)))))
(defcube fg42/python-cube
"Python support cube."
(:title "Python cube"
:flag python)
(fpkg/use pyvenv
:defer t
:after python
:custom
(pyvenv-workon "env")
:hook
((python-mode-hook . pyvenv-mode)
(pyvenv-post-activate-hooks . pyvenv-restart-python)
(pyvenv-post-deactivate-hooks . pyvenv-restart-python)))
(fpkg/use pyenv-mode
:ensure t
:after python
:hook
(python-mode-hook . pyenv-mode))
(fg42/python-black-cube)
(fg42/python-cube-pyls)
(fg42/python-cube-pyright))
(provide 'cubes/python)
;;; python.el ends here