mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 03:20:26 +10:00
Minor updates.
This commit is contained in:
@@ -20,14 +20,17 @@ Adds Python support to Doom Emacs.
|
||||
+ Snippets
|
||||
+ Run tests (~nose~, ~pytest~)
|
||||
+ Auto-format (~black~), requires ~:editor format~
|
||||
+ LSP integration (mspyls, pyls, or pyright)
|
||||
|
||||
** Module Flags
|
||||
+ ~+lsp~ Language Server Protocol support
|
||||
+ ~+pyright~ Use the pyright LSP server instead of mspyls or pyls (requires
|
||||
~+lsp~).
|
||||
+ ~+pyenv~ Python virtual environment support via [[https://github.com/pyenv/pyenv][pyenv]]
|
||||
+ ~+conda~ Python virtual environment support via [[https://conda.io/en/latest/][Conda]]
|
||||
+ ~+poetry~ Python packaging, dependency management, and virtual environment
|
||||
support via [[https://python-poetry.org/][Poetry]]
|
||||
+ ~+cython~ Cython files support via [[https://github.com/cython/cython/blob/master/Tools/cython-mode.el][Cython-mode]]
|
||||
+ ~+cython~ Cython files support via [[https://github.com/cython/cython/blob/master/Tools/cython-mode.el][cython-mode]]
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/pythonic-emacs/anaconda-mode][anaconda-mode]]*
|
||||
@@ -37,66 +40,55 @@ Adds Python support to Doom Emacs.
|
||||
+ [[https://github.com/wbolster/emacs-python-pytest][python-pytest]]*
|
||||
+ [[https://github.com/Wilfred/pip-requirements.el][pip-requirements]]*
|
||||
+ [[https://github.com/pwalsh/pipenv.el][pipenv]]*
|
||||
+ ~:editor format~
|
||||
+ [[https://github.com/lassik/emacs-format-all-the-code][format-all]]*
|
||||
+ ~+conda~
|
||||
+ if ~+conda~
|
||||
+ [[https://github.com/necaris/conda.el][conda]]*
|
||||
+ ~+pyenv~
|
||||
+ if ~+pyenv~
|
||||
+ [[https://github.com/pythonic-emacs/pyenv-mode][pyenv]]*
|
||||
+ ~+poetry~
|
||||
+ if ~+poetry~
|
||||
+ [[https://github.com/galaunay/poetry.el][poetry]]*
|
||||
+ ~+lsp~ and ~:tools lsp~
|
||||
+ if ~+lsp~ and ~:tools lsp~
|
||||
+ [[https://github.com/emacs-lsp/lsp-mode][lsp]]
|
||||
+ [[https://github.com/emacs-lsp/lsp-python-ms][lsp-python-ms]]*
|
||||
+ ~+cython~
|
||||
+ [[https://github.com/cython/cython/blob/master/Tools/cython-mode.el][Cython-mode]]
|
||||
+ ~:checkers syntax~ [[https://github.com/lbolla/emacs-flycheck-cython/tree/master][Flycheck-cython]]
|
||||
+ if ~+pyright~
|
||||
+ [[https://github.com/emacs-lsp/lsp-pyright][lsp-pyright]]
|
||||
+ else
|
||||
+ [[https://github.com/emacs-lsp/lsp-python-ms][lsp-python-ms]]
|
||||
+ if ~+cython~
|
||||
+ [[https://github.com/cython/cython/blob/master/Tools/cython-mode.el][cython-mode]]
|
||||
+ if ~:checkers syntax~: [[https://github.com/lbolla/emacs-flycheck-cython/tree/master][flycheck-cython]]
|
||||
|
||||
* Prerequisites
|
||||
This module has no direct prerequisites. Here are some of its soft dependencies.
|
||||
This module has no hard prerequisites, but a few soft ones:
|
||||
|
||||
+ To run tests inside of Emacs:
|
||||
+ For this module's supported test runners:
|
||||
+ ~pip install pytest~
|
||||
+ ~pip install nose~
|
||||
|
||||
+ The ~:editor format~ module uses [[https://github.com/psf/black][Black]] for python files
|
||||
+ ~pip install black~
|
||||
|
||||
+ ~pyimport~ requires Python's module ~pyflakes~:
|
||||
+ ~pip install pyflakes~
|
||||
|
||||
+ ~py-isort~ requires [[https://github.com/timothycrosley/isort][isort]] to be installed:
|
||||
+ ~pip install isort~
|
||||
|
||||
+ The ~:editor format~ module uses [[https://github.com/psf/black][Black]] for python files :: ~pip install black~
|
||||
+ ~pyimport~ requires Python's module ~pyflakes~ :: ~pip install pyflakes~
|
||||
+ ~py-isort~ requires [[https://github.com/timothycrosley/isort][isort]] to be installed :: ~pip install isort~
|
||||
+ Python virtual environments install instructions at:
|
||||
+ [[https://github.com/pyenv/pyenv][pyenv]]
|
||||
+ [[https://conda.io/en/latest/][Conda]]
|
||||
+ [[https://python-poetry.org/][Poetry]]
|
||||
|
||||
+ ~pipenv~ requires [[https://pipenv.readthedocs.io/en/latest/][pipenv]]
|
||||
|
||||
+ [[https://pipenv.readthedocs.io/en/latest/][pipenv]]
|
||||
+ ~cython~ requires [[https://cython.org/][Cython]]
|
||||
|
||||
** Language Server Protocol Support
|
||||
This module must be enabled with the =+lsp= flag, and the =:tools lsp= module
|
||||
must be enabled. LSP will try pyls then mspyls; the first that is available.
|
||||
For LSP support the =:tools lsp= module must be enabled, along with this
|
||||
module's =+lsp= flag. By default, it supports =mspyls= and =pyls=, in that
|
||||
order. With the =+pyright= flag, it will try Pyright first.
|
||||
|
||||
*To use [[https://pypi.org/project/python-language-server/][Python Language Server]] (pyls)* install it with ~pip install
|
||||
'python-language-server[all]'~
|
||||
Each of these servers must be installed on your system via your OS package
|
||||
manager or manually:
|
||||
|
||||
*To use mspyls*, install it with ~M-x lsp-install-server~ and add this to your
|
||||
private config.el:
|
||||
|
||||
#+BEGIN_SRC elisp
|
||||
(after! lsp-python-ms
|
||||
(set-lsp-priority! 'mspyls 1))
|
||||
#+END_SRC
|
||||
+ [[https://pypi.org/project/python-language-server/][*pyls*]] can be installed with ~pip install python-language-server[all]~.
|
||||
+ *mspyls* can be installed by typing =M-x lsp-install-server RET mspyls=.
|
||||
+ *pyright* can be installed with ~pip install pyright~ or ~npm i -g pyright~.
|
||||
|
||||
* Features
|
||||
This module supports LSP. It requires installation of [[https://pypi.org/project/python-language-server/][Python Language
|
||||
Server]] or [[https://github.com/Microsoft/python-language-server][Microsoft Language Server]], see [[Language Server Protocol Support][LSP Support]].
|
||||
Server]], [[https://github.com/Microsoft/python-language-server][Microsoft Language Server]], or [[https://github.com/microsoft/pyright][pyright]], see [[Language Server Protocol Support][LSP Support]].
|
||||
|
||||
To enable support for auto-formatting with black enable ~:editor format-all~ in
|
||||
To enable support for auto-formatting with black enable ~:editor format~ in
|
||||
~init.el~ file.
|
||||
|
||||
** Keybindings
|
||||
|
||||
@@ -13,7 +13,7 @@ called.")
|
||||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
;;; Packages
|
||||
|
||||
(use-package! python
|
||||
:mode ("[./]flake8\\'" . conf-mode)
|
||||
@@ -198,7 +198,7 @@ called.")
|
||||
|
||||
|
||||
;;
|
||||
;; Environment management
|
||||
;;; Environment management
|
||||
|
||||
(use-package! pipenv
|
||||
:commands pipenv-project-p
|
||||
@@ -266,14 +266,15 @@ called.")
|
||||
"~/.anaconda"
|
||||
"~/.miniconda"
|
||||
"~/.miniconda3"
|
||||
"~/anaconda3"
|
||||
"~/miniconda3"
|
||||
"/usr/bin/anaconda3"
|
||||
"/usr/local/anaconda3"
|
||||
"/usr/local/miniconda3"
|
||||
"/usr/local/Caskroom/miniconda/base")
|
||||
if (file-directory-p dir)
|
||||
return (setq conda-anaconda-home dir
|
||||
conda-env-home-directory dir))
|
||||
return (setq conda-anaconda-home (expand-file-name dir)
|
||||
conda-env-home-directory (expand-file-name dir)))
|
||||
(message "Cannot find Anaconda installation"))
|
||||
|
||||
;; integration with term/eshell
|
||||
@@ -290,23 +291,6 @@ called.")
|
||||
:after python)
|
||||
|
||||
|
||||
(use-package! lsp-python-ms
|
||||
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
|
||||
:after lsp-clients
|
||||
:preface
|
||||
(after! python
|
||||
(setq lsp-python-ms-python-executable-cmd python-shell-interpreter))
|
||||
:init
|
||||
;; HACK If you don't have python installed, then opening python buffers with
|
||||
;; this on causes a "wrong number of arguments: nil 0" error, because of
|
||||
;; careless usage of `cl-destructuring-bind'. This silences that error,
|
||||
;; since we may still want to write some python on a system without
|
||||
;; python installed!
|
||||
(defadvice! +python--silence-errors-a (orig-fn &rest args)
|
||||
:around #'lsp-python-ms--extra-init-params
|
||||
(ignore-errors (apply orig-fn args))))
|
||||
|
||||
|
||||
(use-package! cython-mode
|
||||
:when (featurep! +cython)
|
||||
:mode "\\.p\\(yx\\|x[di]\\)\\'"
|
||||
@@ -322,3 +306,21 @@ called.")
|
||||
:when (featurep! +cython)
|
||||
:when (featurep! :checkers syntax)
|
||||
:after cython-mode)
|
||||
|
||||
|
||||
;;
|
||||
;;; LSP
|
||||
|
||||
(when! (and (featurep! +lsp)
|
||||
(not (featurep! :tools lsp +eglot)))
|
||||
|
||||
(use-package! lsp-python-ms
|
||||
:unless (featurep! +pyright)
|
||||
:after lsp-clients
|
||||
:preface
|
||||
(after! python
|
||||
(setq lsp-python-ms-python-executable-cmd python-shell-interpreter)))
|
||||
|
||||
(use-package! lsp-pyright
|
||||
:when (featurep! +pyright)
|
||||
:after lsp-clients))
|
||||
|
||||
@@ -4,17 +4,22 @@
|
||||
;; Major modes
|
||||
(package! pip-requirements :pin "216cd1690f80cc965d4ae47b8753fc185f778ff6")
|
||||
(when (featurep! +cython)
|
||||
(package! cython-mode :pin "12ab8bc0056a0e77ccc0756955eb1621fd3b35db")
|
||||
(package! cython-mode :pin "0208bf2b71f478779491bf4a63a6b61de3d7269e")
|
||||
(when (featurep! :checkers syntax)
|
||||
(package! flycheck-cython :pin "ecc4454d35ab5317ab66a04406f36f0c1dbc0b76")))
|
||||
|
||||
;; LSP
|
||||
(when (and (featurep! +lsp)
|
||||
(not (featurep! :tools lsp +eglot)))
|
||||
(package! lsp-python-ms :pin "db6f2636da1037bda06d5a2d992c4857ce3ad9b0"))
|
||||
(when (featurep! +lsp)
|
||||
(unless (featurep! :tools lsp +eglot)
|
||||
(if (featurep! +pyright)
|
||||
(package! lsp-pyright
|
||||
;; REVIEW Remove this when added to melpa
|
||||
:recipe (:host github :repo "emacs-lsp/lsp-pyright")
|
||||
:pin "3cf2e8fc652e35270b1b39aeecc990d4a97de91f")
|
||||
(package! lsp-python-ms :pin "7a502e6c09456cbe8b5f6c64883c79f5ce08e5a9"))))
|
||||
|
||||
;; Programming environment
|
||||
(package! anaconda-mode :pin "10299bd9ff38c4f0da1d892905d02ef828e7fdce")
|
||||
(package! anaconda-mode :pin "73266a48fa964d44268c3f3478597e553b9843f1")
|
||||
(when (featurep! :completion company)
|
||||
(package! company-anaconda :pin "da1566db41a68809ef7f91ebf2de28118067c89b"))
|
||||
|
||||
@@ -26,14 +31,14 @@
|
||||
(when (featurep! +conda)
|
||||
(package! conda :pin "9d0213020ff170b17e11b35cad40ac9a8bf30f4c"))
|
||||
(when (featurep! +poetry)
|
||||
(package! poetry :pin "d876522e5af576d53c62b2838f85c9441fe62258"))
|
||||
(package! poetry :pin "22a76cdcba180b4689a6b45c97669e3c76cd36ed"))
|
||||
|
||||
;; Testing frameworks
|
||||
(package! nose
|
||||
;; REVIEW Remove this when emacsmirror/epkgs updates its emacsattic index
|
||||
:recipe (:host github :repo "emacsattic/nose")
|
||||
:pin "f8528297519eba911696c4e68fa88892de9a7b72")
|
||||
(package! python-pytest :pin "09ad688df207ee9b02c990d3897a9e2841931d97")
|
||||
(package! python-pytest :pin "6a3b4e560f26b5b8c9dca5699a3573f554592ac9")
|
||||
|
||||
;; Import managements
|
||||
(package! pyimport :pin "a6f63cf7ed93f0c0f7c207e6595813966f8852b9")
|
||||
|
||||
Reference in New Issue
Block a user