change python config, add jupyter and ein

This commit is contained in:
2024-05-05 20:36:39 +02:00
parent b18d02d8d5
commit 8b80ceda39
168 changed files with 177127 additions and 46 deletions

View File

@@ -1,14 +1,20 @@
;;; dot-settings.el --- dot settings -*- lexical-binding: t -*-
;;; Commentary:
;; https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-dot.html
;;; Code:
(use-package graphviz-dot-mode
:after (org)
:commands graphviz-dot-mode
:mode ("\\.gv\\'" "\\.dot\\'")
:init
(setq org-src-lang-modes
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)))
:config
(setq graphviz-dot-indent-width 2)
(setq graphviz-dot-preview-extension "png"))
(setq graphviz-dot-preview-extension "svg")
(setq graphviz-dot-view-command "open %s"))
(provide 'dot-settings)
;;; dot-settings.el ends here

View File

@@ -293,10 +293,12 @@ Example defines
(csharp . t)
(ditaa . t)
(dot . t)
(ein . t)
(emacs-lisp . t)
(gnuplot . t)
(haskell . t)
(js . t)
(jupyter .t)
(latex . t)
(octave . t)
(plantuml . t)

View File

@@ -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 kernels 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

View File

@@ -3,6 +3,9 @@
;;; Commentary:
;; Syntax checking configurations
;; - flymake built-in
;; - flycheck
;; Requirements:
;; - flycheck https://melpa.org/#/flycheck https://github.com/flycheck/flycheck
@@ -15,22 +18,23 @@
;; https://melpa.org/#/flycheck-pos-tip require pos-tip
;;; Code:
;; do not load directly with e.g. (global-flycheck-mode) or via
;; after-init-hook while loading the init because flycheck will freeze
;; for a short while. Therefore better defer loading.
;;(require 'flycheck (concat config-dir "lisp/flycheck/flycheck.el"))
(use-package flycheck
:defer 2
:init
(setq flycheck-mode-line-prefix "F") ;; \u24BB \u01D4D5 \u2708 f ;; other flycheck settings see syntax-checking-settings.el
(setq flycheck-mode-line '(:eval (concat (flycheck-mode-line-status-text) " ")))
:config
(setq-default flycheck-disabled-checkers '(python-flake8)) ;; disable the python-flake8 checker. This will make the next checker which is python-pylint to be used.
(setq flycheck-check-syntax-automatically '(save mode-enabled)) ;; flycheck only while saving, default is (save idle-change new-line mode-enabled)
;; flycheck-mode-line-prefix see general-settings-post.el
(setq flycheck-emacs-lisp-load-path 'inherit)
;;(add-hook 'after-init-hook #'global-flycheck-mode) ;; deactivated bc of defer
(global-flycheck-mode))
;; (use-package flycheck
;; :defer 2
;; :init
;; (setq flycheck-mode-line-prefix "F") ;; \u24BB \u01D4D5 \u2708 f ;; other flycheck settings see syntax-checking-settings.el
;; (setq flycheck-mode-line '(:eval (concat (flycheck-mode-line-status-text) " ")))
;; :config
;; (setq-default flycheck-disabled-checkers '(python-flake8)) ;; disable the python-flake8 checker. This will make the next checker which is python-pylint to be used.
;; (setq flycheck-check-syntax-automatically '(save mode-enabled)) ;; flycheck only while saving, default is (save idle-change new-line mode-enabled)
;; ;; flycheck-mode-line-prefix see general-settings-post.el
;; (setq flycheck-emacs-lisp-load-path 'inherit)
;; ;;(add-hook 'after-init-hook #'global-flycheck-mode) ;; deactivated bc of defer
;; (global-flycheck-mode))
;; flycheck also has tooltips
;; flycheck-pos-tip shows errors under point in pos-tip popups.