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,12 +4,12 @@
(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'
((:title (pretty-hydra-title "Org Template" 'sucicon "nf-custom-orgmode" :face 'nerd-icons-green) ((:title (pretty-hydra-title "Org Template" 'sucicon "nf-custom-orgmode" :face 'nerd-icons-green)
:color blue :quit-key ("q" "C-g")) :color blue :quit-key ("q" "C-g"))
("Basic" ("Basic"
(("a" (hot-expand "<a") "ascii") (("a" (hot-expand "<a") "ascii")
("c" (hot-expand "<c") "center") ("c" (hot-expand "<c") "center")
@ -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)
@ -303,40 +225,119 @@ prepended to the element after the #+HEADER: tag."
(user-error (user-error
"Error pasting the image, make sure you have an image in the clipboard!")))) "Error pasting the image, make sure you have an image in the clipboard!"))))
(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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package org-roam ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:demand t ;; ensure org-roam is loaded by default ;; Org mode improvement ;
:custom ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(org-roam-directory custom-org-roam-directory) (use-package org-journal
(org-roam-node-display-template (concat "${title:*} " (propertize "${tags:*}" 'face 'org-tag))) :straight t
;;(org-roam-completion-everywhere t) :ensure t
:config :defer t
(setq org-roam-capture-templates :config
'(("d" "default" plain "%?" (setq org-journal-dir (expand-file-name "journal/" org-directory))
:target (setq org-journal-file-type 'weekly))
(file+head
"%<%Y%m%d%H%M%S>-${slug}.org" (use-package org-modern
"#+title: ${title}\n") :straight t
:unnarrowed t) :ensure t
("p" "project" plain "* TODO %?" :defer t
:target :hook ((org-mode . org-modern-mode)
(file+head+olp (org-agenda-finalize . org-modern-agenda))
"%<%Y%m%d%H%M%S>-${slug}.org" :config
"#+title: ${title}\n#+category: ${title}\n#+filetags: Project" (setq org-modern-table nil))
("Tasks"))
:unnarrowed t))) (use-package valign
(org-roam-db-autosync-mode)) :straight t
;; Org roam ui :ensure t
(use-package org-roam-ui :defer t
:defer t :hook (org-mode . valign-mode)
:config :custom
(setq org-roam-ui-sync-theme t (valign-fancy-bar t))
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start nil)) ;; 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
:straight t
:ensure t
:defer t
:demand t ;; ensure org-roam is loaded by default
:custom
(org-roam-directory custom-org-roam-directory)
(org-roam-node-display-template (concat "${title:*} " (propertize "${tags:*}" 'face 'org-tag)))
;;(org-roam-completion-everywhere t)
:config
(setq org-roam-capture-templates
'(("d" "default" plain "%?"
:target
(file+head
"%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n")
:unnarrowed t)
("p" "project" plain "* TODO %?"
:target
(file+head+olp
"%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n#+category: ${title}\n#+filetags: Project"
("Tasks"))
:unnarrowed t)))
;; 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,33 +366,45 @@ 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
:config (org-roam-db-autosync-mode))
(setq ob-async-no-async-languages-alist '("ipython"))) ;; Org roam ui
(unless ON-WINDOWS (use-package org-roam-ui
(use-package org-pdftools :straight t
:hook (org-mode . org-pdftools-setup-link))) :ensure t
; Exporter ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :defer t
(use-package ox-hugo :config
:defer t (setq org-roam-ui-sync-theme t
:after ox) org-roam-ui-follow t
(setq org-latex-minted-options '(("breaklines" "true") org-roam-ui-update-on-save t
("tabsize" "4") org-roam-ui-open-on-start nil))
("autogobble") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
("breakanywhere" "true") ;; Org mode exporter ;
("bgcolor" "gray!40") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
("frame" "single") (use-package ox-hugo
("numbers" "left"))) :straight t
(setq org-latex-listings 'minted :ensure t
org-latex-packages-alist '(("" "minted")) :defer t
org-latex-pdf-process :after ox)
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -interaction nonstopmode -output-directory %o %f")) (setq org-latex-minted-options
(with-eval-after-load 'ox-latex '(("breaklines" "true")
(add-to-list 'org-latex-classes ("tabsize" "4")
'("article" ("autogobble")
"\\documentclass[11pt,a4paper]{article} ("breakanywhere" "true")
("bgcolor" "gray!40")
("frame" "single")
("numbers" "left")))
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -interaction nonstopmode -output-directory %o %f"))
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
'("article"
"\\documentclass[11pt,a4paper]{article}
\\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm,a4paper]{geometry} \\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm,a4paper]{geometry}
[DEFAULT-PACKAGES] [DEFAULT-PACKAGES]
\\usepackage{kotex} \\usepackage{kotex}
@ -399,13 +412,13 @@ prepended to the element after the #+HEADER: tag."
[EXTRA] [EXTRA]
\\linespread{1.1} \\linespread{1.1}
\\hypersetup{pdfborder=0 0 0}" \\hypersetup{pdfborder=0 0 0}"
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}"))) ("\\paragraph{%s}" . "\\paragraph*{%s}")))
(add-to-list 'org-latex-classes (add-to-list 'org-latex-classes
'("org-plain-latex" '("org-plain-latex"
"\\documentclass[a4paper,11pt,titlepage]{memoir} "\\documentclass[a4paper,11pt,titlepage]{memoir}
\\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm,a4paper]{geometry} \\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm,a4paper]{geometry}
[DEFAULT-PACKAGES] [DEFAULT-PACKAGES]
\\usepackage{kotex} \\usepackage{kotex}
@ -413,16 +426,29 @@ prepended to the element after the #+HEADER: tag."
[EXTRA] [EXTRA]
\\linespread{1.1} \\linespread{1.1}
\\hypersetup{pdfborder=0 0 0}" \\hypersetup{pdfborder=0 0 0}"
("\\chapter{%s}" . "\\chapter*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
("\\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