IMPORTANT NOTICE: Devheroes public code hosting will shut down at 1st of March 2023. Due to some difficulties, we have to shut down the instance. Since codeberg.org is pretty mature and welcoming, We highly recommend you to move your code there. Please be advised that on 1st of March, your data will be removed. Thanks for your time with us, and may the source be with you.

Browse Source

Add support for pyright lsp lang server for python

ep8
Sameer Rahmani 7 months ago
parent
commit
2ce52208ea
  1. 66
      core/cubes/python.el

66
core/cubes/python.el

@ -54,16 +54,22 @@ interactive `pyvenv-workon' function before `lsp'" @@ -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'" @@ -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

Loading…
Cancel
Save