emacs : org-mode, rust

This commit is contained in:
2024-09-04 16:11:18 +09:00
parent 16d23ca7da
commit fa34474524
3 changed files with 209 additions and 170 deletions

View File

@ -81,7 +81,7 @@ Otherwise the startup will be very slow. "
;;;; markdown ;;;; markdown
(require 'init-markdown) (require 'init-markdown)
;;(require 'init-org) (require 'init-org)
(require 'init-reader) (require 'init-reader)
;; ;;
@ -102,7 +102,7 @@ Otherwise the startup will be very slow. "
;; ;;
;;(require 'init-elisp) ;;(require 'init-elisp)
;;(require 'init-c) ;;(require 'init-c)
;;(require 'init-rust) (require 'init-rust)
;;(require 'init-python) ;;(require 'init-python)
;;(require 'init-ruby) ;;(require 'init-ruby)
;;(require 'init-shell) ;;(require 'init-shell)

View File

@ -4,7 +4,7 @@
(require 'init-custom) (require 'init-custom)
(use-package org (use-package org
:ensure nil :ensure nil ; built-in
:custom-face (org-ellipsis ((t (:foreground unspecified)))) :custom-face (org-ellipsis ((t (:foreground unspecified))))
:pretty-hydra :pretty-hydra
;; See `org-structure-template-alist' ;; See `org-structure-template-alist'
@ -145,31 +145,9 @@ prepended to the element after the #+HEADER: tag."
org-startup-indented t org-startup-indented t
org-ellipsis (if (char-displayable-p ?⏷) "\t" nil) org-ellipsis (if (char-displayable-p ?⏷) "\t" nil)
org-pretty-entities nil org-pretty-entities nil
org-hide-emphasis-markers t) org-hide-emphasis-markers t
org-confirm-babel-evaluate nil
(use-package org-journal
:defer t
:config
(setq org-journal-dir (expand-file-name "journal/" org-directory))
(setq org-journal-file-type 'weekly))
;; Add new template
(add-to-list 'org-structure-template-alist '("n" . "note"))
(use-package org-modern
:hook ((org-mode . org-modern-mode)
(org-agenda-finalize . org-modern-agenda))
:config
(setq org-modern-table nil))
(use-package valign
:hook (org-mode . valign-mode)
:custom
(valign-fancy-bar t))
(setq org-confirm-babel-evaluate nil
org-src-fontify-natively t org-src-fontify-natively t
org-src-tab-acts-natively t) org-src-tab-acts-natively t)
@ -178,7 +156,8 @@ prepended to the element after the #+HEADER: tag."
(python . t) (python . t)
(ruby . t) (ruby . t)
(rust . t) (rust . t)
(C . t)) (C . t)
(shell . t))
"Alist of org ob languages.") "Alist of org ob languages.")
;;(unless ON-WINDOWS ;;(unless ON-WINDOWS
;; (add-to-list 'load-language-alist '(latex-as-png . t))) ;; (add-to-list 'load-language-alist '(latex-as-png . t)))
@ -194,70 +173,13 @@ prepended to the element after the #+HEADER: tag."
(add-to-list 'org-structure-template-alist '("oc" . "src octave")) (add-to-list 'org-structure-template-alist '("oc" . "src octave"))
(add-to-list 'org-structure-template-alist '("vl" . "src verilog")) (add-to-list 'org-structure-template-alist '("vl" . "src verilog"))
(add-to-list 'org-structure-template-alist '("vh" . "src vhdl")) (add-to-list 'org-structure-template-alist '("vh" . "src vhdl"))
(add-to-list 'org-structure-template-alist '("n" . "note"))
(org-babel-do-load-languages 'org-babel-load-languages
load-language-alist)
;; ob-sh renamed to ob-shell since 26.1. ;; ob-sh renamed to ob-shell since 26.1.
(cl-pushnew '(shell . t) load-language-alist) (cl-pushnew '(shell . t) load-language-alist)
; useful functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package ob-go
:init (cl-pushnew '(go . t) load-language-alist))
(use-package ob-rust
:init (cl-pushnew '(rust . t) load-language-alist))
(org-babel-do-load-languages 'org-babel-load-languages
load-language-alist)
;; Auto-toggle Org LaTeX fragments
(use-package org-fragtog
:diminish
:hook (org-mode . org-fragtog-mode))
;; Make invisible parts of Org elements appear visible.
(use-package org-appear
:hook (org-mode)
:config
(setq org-appear-autoemphasis t
org-appear-autolinks t
org-appear-autoentities t
org-appear-autosubmarkers t))
;; Presentation
(use-package org-tree-slide
:diminish
:functions (org-display-inline-images
org-remove-inline-images)
:bind (:map org-mode-map
("s-<f7>" . org-tree-slide-mode))
:hook ((org-tree-slide-play . (lambda ()
(text-scale-increase 4)
(org-display-inline-images)
(read-only-mode 1)))
(org-tree-slide-stop . (lambda ()
(text-scale-increase 0)
(org-remove-inline-images)
(read-only-mode -1))))
:init (setq org-tree-slide-header nil
org-tree-slide-slide-in-effect t
org-tree-slide-heading-emphasis nil
org-tree-slide-cursor-init t
org-tree-slide-modeline-display 'outside
org-tree-slide-skip-done nil
org-tree-slide-skip-comments t
org-tree-slide-skip-outline-level 3))
;; support drawio
(use-package org-drawio
:commands (org-drawio-add
org-drawio-open)
:custom ((org-drawio-input-dir "./draws")
(org-drawio-output-dir "./images")
(org-drawio-output-page "0")
;; set to t, if you want to crop the image.
(org-drawio-crop t)))
; attachment ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package org-contrib ;; to use org-screenshot-take
:defer t)
(use-package org-attach-screenshot
:defer t)
(use-package org-download
:defer t)
(use-package ob-latex-as-png
:ensure t)
(defun my/org-remove-link-and-trash-linked-file () (defun my/org-remove-link-and-trash-linked-file ()
"Remove `org-mode' link at point and trash linked file." "Remove `org-mode' link at point and trash linked file."
(interactive) (interactive)
@ -305,9 +227,97 @@ prepended to the element after the #+HEADER: tag."
(defun org-time-stamp-with-time() (defun org-time-stamp-with-time()
"Insert org mode timestamp at point with current date and time" "Insert org mode timestamp at point with current date and time"
(interactive) (interactive)
(org-insert-time-stamp (current-time) t)) (org-insert-time-stamp (current-time) t)))
; org-roam ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org mode improvement ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package org-journal
:straight t
:ensure t
:defer t
:config
(setq org-journal-dir (expand-file-name "journal/" org-directory))
(setq org-journal-file-type 'weekly))
(use-package org-modern
:straight t
:ensure t
:defer t
:hook ((org-mode . org-modern-mode)
(org-agenda-finalize . org-modern-agenda))
:config
(setq org-modern-table nil))
(use-package valign
:straight t
:ensure t
:defer t
:hook (org-mode . valign-mode)
:custom
(valign-fancy-bar t))
;; Auto-toggle Org LaTeX fragments
(use-package org-fragtog
:straight t
:ensure t
:defer t
:diminish
:hook (org-mode . org-fragtog-mode))
;; Make invisible parts of Org elements appear visible.
(use-package org-appear
:straight t
:ensure t
:defer t
:hook (org-mode . org-appear-mode)
:config
(setq org-appear-autoemphasis t
org-appear-autolinks t
org-appear-autoentities t
org-appear-autosubmarkers t))
;; support drawio
(use-package org-drawio
:straight t
:ensure t
:defer t
:commands (org-drawio-add
org-drawio-open)
:custom ((org-drawio-input-dir "./draws")
(org-drawio-output-dir "./images")
(org-drawio-output-page "0")
;; set to t, if you want to crop the image.
(org-drawio-crop t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org mode attachment ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package org-contrib ;; to use org-screenshot-take
:straight t
:ensure t
:defer t
:defer t)
(use-package org-attach-screenshot
:straight t
:ensure t
:defer t
:defer t)
(use-package org-download
:straight t
:ensure t
:defer t
:defer t)
(use-package ob-latex-as-png
:straight t
:ensure t
:defer t
:ensure t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org roam ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package org-roam (use-package org-roam
:straight t
:ensure t
:defer t
:demand t ;; ensure org-roam is loaded by default :demand t ;; ensure org-roam is loaded by default
:custom :custom
(org-roam-directory custom-org-roam-directory) (org-roam-directory custom-org-roam-directory)
@ -328,15 +338,6 @@ prepended to the element after the #+HEADER: tag."
"#+title: ${title}\n#+category: ${title}\n#+filetags: Project" "#+title: ${title}\n#+category: ${title}\n#+filetags: Project"
("Tasks")) ("Tasks"))
:unnarrowed t))) :unnarrowed t)))
(org-roam-db-autosync-mode))
;; Org roam ui
(use-package org-roam-ui
:defer t
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start nil))
;; functions ;; functions
(defun my/org-roam-rg-search () (defun my/org-roam-rg-search ()
"Search org-roam directory using consult-ripgrep. With live-preview." "Search org-roam directory using consult-ripgrep. With live-preview."
@ -365,18 +366,30 @@ prepended to the element after the #+HEADER: tag."
(unless org-note-abort (unless org-note-abort
(with-current-buffer (org-capture-get :buffer) (with-current-buffer (org-capture-get :buffer)
(add-to-list 'org-agenda-files (buffer-file-name))))) (add-to-list 'org-agenda-files (buffer-file-name)))))
; Tools ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package ob-async ; database sync
(org-roam-db-autosync-mode))
;; Org roam ui
(use-package org-roam-ui
:straight t
:ensure t
:defer t
:config :config
(setq ob-async-no-async-languages-alist '("ipython"))) (setq org-roam-ui-sync-theme t
(unless ON-WINDOWS org-roam-ui-follow t
(use-package org-pdftools org-roam-ui-update-on-save t
:hook (org-mode . org-pdftools-setup-link))) org-roam-ui-open-on-start nil))
; Exporter ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org mode exporter ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package ox-hugo (use-package ox-hugo
:straight t
:ensure t
:defer t :defer t
:after ox) :after ox)
(setq org-latex-minted-options '(("breaklines" "true")
(setq org-latex-minted-options
'(("breaklines" "true")
("tabsize" "4") ("tabsize" "4")
("autogobble") ("autogobble")
("breakanywhere" "true") ("breakanywhere" "true")
@ -418,11 +431,24 @@ prepended to the element after the #+HEADER: tag."
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))) ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
;; support calendar ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package calfw) ;; Org babel related ;
(use-package calfw-org ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:after calfw) (use-package ob-async
:straight t
:ensure t
:config
(setq ob-async-no-async-languages-alist '("ipython")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tools ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(unless ON-WINDOWS
(use-package org-pdftools
:straight t
:ensure t
:defer t
:hook (org-mode . org-pdftools-setup-link)))
(provide 'init-org) (provide 'init-org)
;;; init-org.el ends here ;;; init-org.el ends here

View File

@ -32,18 +32,31 @@
;; Rust ;; Rust
(use-package rustic (use-package rustic
:straight t
:ensure t
:defer t
:init :init
(if ON-LINUX (if ON-LINUX
(setq rustic-analyzer-command '("~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rust-analyzer")) (setq rustic-analyzer-command '("~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rust-analyzer"))
(setq rustic-analyzer-command '("~/.rustup/toolchains/stable-x86_64-pc-windows-msvc/bin/rust-analyzer.exe"))) (setq rustic-analyzer-command '("~/.rustup/toolchains/stable-x86_64-pc-windows-msvc/bin/rust-analyzer.exe")))
(setq rustic-lsp-client 'eglot)) (setq rustic-lsp-client 'eglot))
(use-package rust-playground) (use-package rust-playground
:straight t
:ensure t
:defer t)
(use-package toml-mode (use-package toml-mode
:straight t
:ensure t
:defer t :defer t
:config :config
(add-to-list 'auto-mode-alist '("/\\(Cargo.lock\\|\\.cargo/config\\)\\'" . toml-mode))) (add-to-list 'auto-mode-alist '("/\\(Cargo.lock\\|\\.cargo/config\\)\\'" . toml-mode)))
(provide 'init-rust) ; org-babel integration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package ob-rust
:straight t
:ensure t
:defer t)
(provide 'init-rust)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-rust.el ends here ;;; init-rust.el ends here