From cfc5a0801c791b852453600f50c10bb0a5779d56 Mon Sep 17 00:00:00 2001 From: Gerry Agbobada Date: Tue, 15 Oct 2019 09:09:24 +0200 Subject: [PATCH 1/3] Add cython-specific flag and packages --- modules/lang/python/config.el | 17 +++++++++++++++++ modules/lang/python/packages.el | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index c80598b67..9f66ae304 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -276,3 +276,20 @@ called.") (defadvice! +python--dont-auto-install-server-a () :override #'lsp-python-ms--command-string lsp-python-ms-executable)) + +(use-package! cython-mode + :when (featurep! +cython) + :mode (("\\.pyx\\'" . cython-mode) + ("\\.pxd\\'" . cython-mode) + ("\\.pxi\\'" . cython-mode)) + :config + (setq cython-default-compile-format "cython -a %s") + (map! :map cython-mode-map + :localleader + :prefix "c" + :desc "Cython compile buffer" "c" #'cython-compile) + ) + +(use-package! flycheck-cython + :when (featurep! :tools flycheck) + :after cython-mode) diff --git a/modules/lang/python/packages.el b/modules/lang/python/packages.el index e04502601..600af8529 100644 --- a/modules/lang/python/packages.el +++ b/modules/lang/python/packages.el @@ -3,6 +3,10 @@ ;; Major modes (package! pip-requirements) +(when (featurep! +cython) + (package! cython-mode) + (when (featurep! :tools flycheck) + (package! flycheck-cython))) ;; LSP (when (featurep! +lsp) From 02e96926fdac2006f3a88f1c1354aed1ccca5b08 Mon Sep 17 00:00:00 2001 From: Gerry Agbobada Date: Tue, 15 Oct 2019 10:00:56 +0200 Subject: [PATCH 2/3] Add documentation --- modules/lang/python/README.org | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/lang/python/README.org b/modules/lang/python/README.org index c2604a50b..779055568 100644 --- a/modules/lang/python/README.org +++ b/modules/lang/python/README.org @@ -25,6 +25,7 @@ Adds Python support to Doom Emacs. + ~+lsp~ Language Server Protocol support + ~+pyenv~ Python virtual environment support via [[https://github.com/pyenv/pyenv][pyenv]] + ~+conda~ Python virtual environment support via [[https://conda.io/en/latest/][Conda]] ++ ~+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]]* @@ -43,6 +44,9 @@ Adds Python support to Doom Emacs. + ~+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]] + + ~:tools flycheck~ [[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. @@ -63,6 +67,8 @@ This module has no direct prerequisites. Here are some of its soft dependencies. + ~pipenv~ requires [[https://pipenv.readthedocs.io/en/latest/][pipenv]] ++ ~cython~ requires [[https://cython.org/][Cython]] + ** Language Server Protocol Support Requires the ~+lsp~ flag and ~:tools lsp~ module to be enabled. By default LSP will use Microsoft's language server if installed. @@ -86,6 +92,7 @@ To enable support for auto-formatting with black enable ~:editor format-all~ in | Binding | Description | |---------------------+----------------------------------| +| ~ c c~ | ~Compile Cython buffer~ | | ~ i i~ | ~Insert mising imports~ | | ~ i r~ | ~Remove unused imports~ | | ~ i s~ | ~Sort imports~ | From 8820a70a69f2fee4124f0ca4e2f0d372140c6074 Mon Sep 17 00:00:00 2001 From: Gerry Agbobada Date: Thu, 17 Oct 2019 08:51:18 +0200 Subject: [PATCH 3/3] Review --- modules/lang/python/config.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index 9f66ae304..b26030bf0 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -277,18 +277,17 @@ called.") :override #'lsp-python-ms--command-string lsp-python-ms-executable)) + (use-package! cython-mode :when (featurep! +cython) - :mode (("\\.pyx\\'" . cython-mode) - ("\\.pxd\\'" . cython-mode) - ("\\.pxi\\'" . cython-mode)) + :mode "\\.p\\(yx\\|x[di]\\)\\'" :config (setq cython-default-compile-format "cython -a %s") (map! :map cython-mode-map :localleader :prefix "c" - :desc "Cython compile buffer" "c" #'cython-compile) - ) + :desc "Cython compile buffer" "c" #'cython-compile)) + (use-package! flycheck-cython :when (featurep! :tools flycheck)