change python config, add jupyter and ein
This commit is contained in:
@@ -6,6 +6,29 @@
|
||||
;; program: python
|
||||
;; Emacs packages: anaconda-mode company-anaconda sphinx-doc
|
||||
|
||||
;; Language Server Support, Emacs built-in package `eglot'
|
||||
;; https://github.com/joaotavora/eglot
|
||||
;; connects to LSP
|
||||
;; activate with `eglot'
|
||||
;; after changing comfigurations run `eglot-reconnect'
|
||||
;; follow documentation at point `eldoc-doc-buffer'
|
||||
|
||||
;; Language Server Protocol (LSP), python package `python-lsp-server'
|
||||
;; https://github.com/python-lsp/python-lsp-server
|
||||
;; install via: pip install "python-lsp-server[all]"
|
||||
;; arch linux: extra/python-lsp-server
|
||||
;; - pycodestyle (formerly called pep8) - Python style guide checker
|
||||
;; https://pycodestyle.pycqa.org/en/latest/
|
||||
;; arch linux: extra/python-pycodestyle
|
||||
;; to ignore a check in a code line use # noqa
|
||||
;; config via ~/.config/pycodestyle
|
||||
;; - pylsp-mypy: pylsp plugin, type checking for Python >=3.8
|
||||
;; https://mypy-lang.org/
|
||||
;; pip install pylsp-mypy
|
||||
;; arch linux: aur/python-pylsp-mypy
|
||||
|
||||
;; Syntax Checking, Emacs built-in package `flymake'
|
||||
|
||||
;;; Code:
|
||||
(use-package python
|
||||
:delight (python-mode "Py") ;; "Py " "\u1F15F"
|
||||
@@ -97,40 +120,40 @@ process."
|
||||
)
|
||||
|
||||
;; needs system package python-jedi
|
||||
(use-package anaconda-mode ;; works with company-mode via company-anaconda
|
||||
:after python
|
||||
:delight (anaconda-mode "A") ;; \u24B6 a
|
||||
:bind (([remap anaconda-mode-show-doc] . my-anaconda-mode-show-doc)) ;; M-?
|
||||
:hook (python-mode
|
||||
(python-mode . anaconda-eldoc-mode)) ;; if cursor is between function's parenthesis show parameter in echo area
|
||||
:config
|
||||
(setq anaconda-mode-installation-directory (concat user-cache-directory "anaconda-mode"))
|
||||
;; compared to `anaconda-mode-show-doc' using `my-anaconda-mode-show-doc-callback'
|
||||
(defun my-anaconda-mode-show-doc ()
|
||||
"Show documentation for context at point."
|
||||
(interactive)
|
||||
;;(anaconda-mode-call "show_doc" 'anaconda-mode-show-doc-callback) ;; removed
|
||||
(anaconda-mode-call "show_doc" 'my-anaconda-mode-show-doc-callback) ;; instead
|
||||
)
|
||||
;; compared to `anaconda-mode-show-doc-callback' no change of focus
|
||||
(defun my-anaconda-mode-show-doc-callback (result)
|
||||
"Process view doc RESULT."
|
||||
(if (> (length result) 0)
|
||||
(if (and anaconda-mode-use-posframe-show-doc
|
||||
(require 'posframe nil 'noerror)
|
||||
(posframe-workable-p))
|
||||
(anaconda-mode-documentation-posframe-view result)
|
||||
;;(pop-to-buffer (anaconda-mode-documentation-view result) t) ;; removed
|
||||
(anaconda-mode-documentation-view result) ;; instead
|
||||
)
|
||||
(message "No documentation available")))
|
||||
)
|
||||
;; (use-package anaconda-mode ;; works with company-mode via company-anaconda
|
||||
;; :after python
|
||||
;; :delight (anaconda-mode "A") ;; \u24B6 a
|
||||
;; :bind (([remap anaconda-mode-show-doc] . my-anaconda-mode-show-doc)) ;; M-?
|
||||
;; :hook (python-mode
|
||||
;; (python-mode . anaconda-eldoc-mode)) ;; if cursor is between function's parenthesis show parameter in echo area
|
||||
;; :config
|
||||
;; (setq anaconda-mode-installation-directory (concat user-cache-directory "anaconda-mode"))
|
||||
;; ;; compared to `anaconda-mode-show-doc' using `my-anaconda-mode-show-doc-callback'
|
||||
;; (defun my-anaconda-mode-show-doc ()
|
||||
;; "Show documentation for context at point."
|
||||
;; (interactive)
|
||||
;; ;;(anaconda-mode-call "show_doc" 'anaconda-mode-show-doc-callback) ;; removed
|
||||
;; (anaconda-mode-call "show_doc" 'my-anaconda-mode-show-doc-callback) ;; instead
|
||||
;; )
|
||||
;; ;; compared to `anaconda-mode-show-doc-callback' no change of focus
|
||||
;; (defun my-anaconda-mode-show-doc-callback (result)
|
||||
;; "Process view doc RESULT."
|
||||
;; (if (> (length result) 0)
|
||||
;; (if (and anaconda-mode-use-posframe-show-doc
|
||||
;; (require 'posframe nil 'noerror)
|
||||
;; (posframe-workable-p))
|
||||
;; (anaconda-mode-documentation-posframe-view result)
|
||||
;; ;;(pop-to-buffer (anaconda-mode-documentation-view result) t) ;; removed
|
||||
;; (anaconda-mode-documentation-view result) ;; instead
|
||||
;; )
|
||||
;; (message "No documentation available")))
|
||||
;; )
|
||||
|
||||
(use-package company-anaconda
|
||||
:after (python anaconda-mode company)
|
||||
:bind (([remap anaconda-mode-complete] . company-anaconda))
|
||||
:config
|
||||
(add-to-list 'company-backends '(company-anaconda :with company-capf))) ;; to see anaconda-mode completions together with ones comes from inferior python process
|
||||
;; (use-package company-anaconda
|
||||
;; :after (python anaconda-mode company)
|
||||
;; :bind (([remap anaconda-mode-complete] . company-anaconda))
|
||||
;; :config
|
||||
;; (add-to-list 'company-backends '(company-anaconda :with company-capf))) ;; to see anaconda-mode completions together with ones comes from inferior python process
|
||||
|
||||
;; https://melpa.org/#/sphinx-doc
|
||||
;; https://github.com/naiquevin/sphinx-doc.el
|
||||
@@ -139,5 +162,57 @@ process."
|
||||
:delight (sphinx-doc-mode "Sph") ;; \u24C8 s
|
||||
:hook (python-mode . sphinx-doc-mode))
|
||||
|
||||
|
||||
|
||||
|
||||
;; jupyter repl
|
||||
;; optional markdown-mode
|
||||
;; optional company-mode
|
||||
;; emacs-websocket
|
||||
;; simple-httpd
|
||||
;; zmq
|
||||
(use-package jupyter
|
||||
:commands (;; launch a new local kernel and displays a REPL buffer
|
||||
jupyter-run-repl
|
||||
;; connect to an existing kernel using the kernel’s connection
|
||||
;; file, which is supplied by the user, and displays a REPL buffer
|
||||
jupyter-connect-repl
|
||||
;; associate the buffer to an existing emacs-jupyter REPL or create a new one choosing the appropriate Jupyter kernel
|
||||
jupyter-repl-associate-buffer)
|
||||
:init
|
||||
(setq jupyter-use-zmq nil)
|
||||
:config
|
||||
(add-to-list 'org-structure-template-alist '("py" . "src jupyter-python"))
|
||||
;; emacs-jupyter will always use the Python kernel found on startup
|
||||
(defun my-jupyter-refresh-kernelspecs ()
|
||||
"Refresh Jupyter kernelspecs"
|
||||
(interactive)
|
||||
(jupyter-available-kernelspecs t))
|
||||
)
|
||||
|
||||
;; https://github.com/astoff/code-cells.el
|
||||
;; .ipynb
|
||||
(use-package code-cells
|
||||
:commands (code-cells-mode code-cells-convert-ipynb)
|
||||
;;:mode ("\\.ipynb\\'" . code-cells-mode)
|
||||
:hook (code-cells-mode . code-cells-convert-ipynb)
|
||||
:config
|
||||
(setq code-cells-convert-ipynb-style '(("pandoc" "--to" "ipynb" "--from" "org")
|
||||
("pandoc" "--to" "org" "--from" "ipynb")
|
||||
(lambda () #'org-mode)))
|
||||
)
|
||||
|
||||
(use-package ox-ipynb
|
||||
:after ox)
|
||||
|
||||
;; https://millejoh.github.io/emacs-ipython-notebook/
|
||||
;; requires: anaphora dash deferred polymode request websocket with-editor
|
||||
(use-package ein
|
||||
:commands (ein:run ein:jupyter-server-start ein:notebooklist-open)
|
||||
:config
|
||||
(require 'ein-jupyter)
|
||||
(require 'ein-notebook)
|
||||
(setq ein:output-area-inlined-images t))
|
||||
|
||||
(provide 'python-settings)
|
||||
;;; python-settings.el ends here
|
||||
|
||||
Reference in New Issue
Block a user