mirror of
http://github.com/JaeUs3792/dotfiles
synced 2025-12-13 23:51:34 +09:00
<2023-05-21 Sun 20:30>
This commit is contained in:
@ -41,3 +41,7 @@
|
||||
(setq custom-theme-sel 'doom-one)
|
||||
;; default transparency (85 . 50) or (100 . 100)
|
||||
(set-frame-parameter (selected-frame) 'alpha '(85 . 50))
|
||||
|
||||
;; Org setup
|
||||
(setq custom-org-directory "~/org"
|
||||
custom-org-agenda-files "~/org/agenda/agenda.org")
|
||||
|
||||
@ -73,5 +73,34 @@ Otherwise the startup will be very slow. "
|
||||
(require 'init-persp)
|
||||
(require 'init-window)
|
||||
(require 'init-treemacs)
|
||||
|
||||
;; shell
|
||||
(require 'init-eshell)
|
||||
|
||||
;; markdown
|
||||
(require 'init-markdown)
|
||||
(require 'init-org)
|
||||
(require 'init-reader)
|
||||
|
||||
;;
|
||||
(require 'init-dict)
|
||||
|
||||
;; docker
|
||||
(require 'init-docker)
|
||||
;; utils
|
||||
(require 'init-utils)
|
||||
|
||||
;; Programming
|
||||
(require 'init-vcs)
|
||||
(require 'init-flycheck)
|
||||
(require 'init-eglot)
|
||||
(require 'init-ctags)
|
||||
(require 'init-prog)
|
||||
|
||||
(require 'init-elisp)
|
||||
(require 'init-c)
|
||||
(require 'init-rust)
|
||||
(require 'init-python)
|
||||
(require 'init-ruby)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init.el ends here
|
||||
|
||||
49
.config/emacs/lisp/init-c.el
Normal file
49
.config/emacs/lisp/init-c.el
Normal file
@ -0,0 +1,49 @@
|
||||
;; init-c.el --- Initialize c configurations. -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2006-2022 Vincent Zhang
|
||||
|
||||
;; Author: Vincent Zhang <seagle0128@gmail.com>
|
||||
;; URL: https://github.com/seagle0128/.emacs.d
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
;; Floor, Boston, MA 02110-1301, USA.
|
||||
;;
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; C/C++ configuration.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'init-funcs)
|
||||
|
||||
;; C/C++ Mode
|
||||
(use-package cc-mode
|
||||
:ensure nil
|
||||
:bind (:map c-mode-base-map
|
||||
("<f12>" . compile))
|
||||
:init (setq-default c-basic-offset 4))
|
||||
|
||||
(use-package c-ts-mode
|
||||
:ensure nil
|
||||
:init (setq c-ts-mode-indent-offset 4))
|
||||
|
||||
(provide 'init-c)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-c.el ends here
|
||||
79
.config/emacs/lisp/init-ctags.el
Normal file
79
.config/emacs/lisp/init-ctags.el
Normal file
@ -0,0 +1,79 @@
|
||||
;;; init-ctags.el -*- lexical-binding: t -*-
|
||||
(require 'init-const)
|
||||
(require 'init-custom)
|
||||
|
||||
;; Ctags IDE on the True Editor
|
||||
;; @see https://github.com/universal-ctags/citre#quick-start
|
||||
(use-package citre
|
||||
:diminish
|
||||
:commands citre-jump-back
|
||||
:functions xref-go-back
|
||||
:init
|
||||
(setq citre-auto-enable-citre-mode-modes '(prog-mode)
|
||||
citre-default-create-tags-file-location 'global-cache
|
||||
citre-use-project-root-when-creating-tags t
|
||||
citre-prompt-language-for-ctags-command t)
|
||||
|
||||
(defun citre-jump+ ()
|
||||
"Jump to the definition of the symbol at point.
|
||||
Fallback to `xref-find-definitions'."
|
||||
(interactive)
|
||||
(condition-case _
|
||||
(citre-jump)
|
||||
(error (call-interactively #'xref-find-definitions))))
|
||||
|
||||
(defun citre-jump-back+ ()
|
||||
"Go back to the position before last `citre-jump'.
|
||||
Fallback to `xref-go-back'."
|
||||
(interactive)
|
||||
(condition-case _
|
||||
(citre-jump-back)
|
||||
(error (if (fboundp #'xref-go-back)
|
||||
(call-interactively #'xref-go-back)
|
||||
(call-interactively #'xref-pop-marker-stack)))))
|
||||
:config
|
||||
(with-eval-after-load 'cc-mode (require 'citre-lang-c))
|
||||
(with-eval-after-load 'dired (require 'citre-lang-fileref))
|
||||
(with-eval-after-load 'verilog-mode (require 'citre-lang-verilog))
|
||||
|
||||
(with-no-warnings
|
||||
;; Use Citre xref backend as a fallback
|
||||
(define-advice xref--create-fetcher (:around (fn &rest args) fallback)
|
||||
(let ((fetcher (apply fn args))
|
||||
(citre-fetcher
|
||||
(let ((xref-backend-functions '(citre-xref-backend t)))
|
||||
(ignore xref-backend-functions)
|
||||
(apply fn args))))
|
||||
(lambda ()
|
||||
(or (with-demoted-errors "%s, fallback to citre"
|
||||
(funcall fetcher))
|
||||
(funcall citre-fetcher)))))
|
||||
|
||||
;; Combine completions from Citre and lsp
|
||||
(defun lsp-citre-capf-function ()
|
||||
"A capf backend that tries lsp first, then Citre."
|
||||
(let ((lsp-result (cond
|
||||
((bound-and-true-p lsp-mode)
|
||||
(and (fboundp #'lsp-completion-at-point)
|
||||
(lsp-completion-at-point)))
|
||||
((bound-and-true-p eglot--managed-mode)
|
||||
(and (fboundp #'eglot-completion-at-point)
|
||||
(eglot-completion-at-point))))))
|
||||
(if (and lsp-result
|
||||
(try-completion
|
||||
(buffer-substring (nth 0 lsp-result)
|
||||
(nth 1 lsp-result))
|
||||
(nth 2 lsp-result)))
|
||||
lsp-result
|
||||
(citre-completion-at-point))))
|
||||
|
||||
(defun enable-lsp-citre-capf-backend ()
|
||||
"Enable the lsp + Citre capf backend in current buffer."
|
||||
(add-hook 'completion-at-point-functions #'lsp-citre-capf-function nil t))
|
||||
|
||||
(add-hook 'citre-mode-hook #'enable-lsp-citre-capf-backend)))
|
||||
|
||||
|
||||
|
||||
(provide 'init-ctags)
|
||||
;;; init-ctags.el ends here
|
||||
15
.config/emacs/lisp/init-custom.el
Normal file
15
.config/emacs/lisp/init-custom.el
Normal file
@ -0,0 +1,15 @@
|
||||
;; init-custom.el -*- lexical-binding: t -*-
|
||||
(customize-set-variable 'large-file-warning-threshold 100000000) ;; 100MB
|
||||
|
||||
(with-no-warnings
|
||||
(custom-declare-face
|
||||
'+org-todo-active '((t (:inherit (bold font-lock-constant-face org-todo)))) "")
|
||||
(custom-declare-face
|
||||
'+org-todo-project '((t (:inherit (bold font-lock-doc-face org-todo)))) "")
|
||||
(custom-declare-face
|
||||
'+org-todo-onhold '((t (:inherit (bold warning org-todo)))) "")
|
||||
(custom-declare-face
|
||||
'+org-todo-cancel '((t (:inherit (bold error org-todo)))) ""))
|
||||
|
||||
(provide 'init-custom)
|
||||
;;; init-custom.el ends here
|
||||
@ -64,8 +64,9 @@
|
||||
dashboard-center-content t
|
||||
dashboard-show-shortcuts t
|
||||
dashboard-items '((recents . 10)
|
||||
(bookmarks . 5)
|
||||
(projects . 5)
|
||||
(agenda . 5)
|
||||
(bookmarks . 5)
|
||||
(registers . 5))
|
||||
|
||||
dashboard-set-init-info t
|
||||
|
||||
45
.config/emacs/lisp/init-dict.el
Normal file
45
.config/emacs/lisp/init-dict.el
Normal file
@ -0,0 +1,45 @@
|
||||
;;; init-dict.el -*- lexical-binding: t -*-
|
||||
(require 'init-const)
|
||||
(use-package go-translate
|
||||
:init (setq gts-translate-list '(("en" "ko") ("ko" "en")))
|
||||
:config
|
||||
;; config the default translator, it will be used by command gts-do-translate
|
||||
(setq gts-default-translator
|
||||
(gts-translator
|
||||
:picker ; used to pick source text, from, to. choose one.
|
||||
|
||||
;;(gts-noprompt-picker)
|
||||
;;(gts-noprompt-picker :texter (gts-whole-buffer-texter))
|
||||
(gts-prompt-picker)
|
||||
;;(gts-prompt-picker :single t)
|
||||
;;(gts-prompt-picker :texter (gts-current-or-selection-texter) :single t)
|
||||
|
||||
:engines ; engines, one or more. Provide a parser to give different output.
|
||||
|
||||
(list
|
||||
(gts-bing-engine)
|
||||
(gts-google-engine)
|
||||
;;(gts-google-rpc-engine)
|
||||
;;(gts-deepl-engine :auth-key [YOUR_AUTH_KEY] :pro nil)
|
||||
;;(gts-google-engine :parser (gts-google-summary-parser))
|
||||
;;(gts-google-engine :parser (gts-google-parser))
|
||||
;;(gts-google-rpc-engine :parser (gts-google-rpc-summary-parser) :url "https://translate.google.com")
|
||||
;;(gts-google-rpc-engine :parser (gts-google-rpc-parser) :url "https://translate.google.com")
|
||||
)
|
||||
|
||||
:render ; render, only one, used to consumer the output result. Install posframe yourself when use gts-posframe-xxx
|
||||
|
||||
(gts-buffer-render)
|
||||
;;(gts-posframe-pop-render)
|
||||
;;(gts-posframe-pop-render :backcolor "#333333" :forecolor "#ffffff")
|
||||
;;(gts-posframe-pin-render)
|
||||
;;(gts-posframe-pin-render :position (cons 1200 20))
|
||||
;;(gts-posframe-pin-render :width 80 :height 25 :position (cons 1000 20) :forecolor "#ffffff" :backcolor "#111111")
|
||||
;;(gts-kill-ring-render)
|
||||
|
||||
:splitter ; optional, used to split text into several parts, and the translation result will be a list.
|
||||
|
||||
(gts-paragraph-splitter))))
|
||||
|
||||
(provide 'init-dict)
|
||||
;;; init-dict.el ends here
|
||||
11
.config/emacs/lisp/init-docker.el
Normal file
11
.config/emacs/lisp/init-docker.el
Normal file
@ -0,0 +1,11 @@
|
||||
;;; init-docker.el -*- lexical-binding: t -*-
|
||||
;; Docker
|
||||
(use-package docker
|
||||
:defines docker-image-run-arguments
|
||||
:init (setq docker-image-run-arguments '("-i" "-t" "--rm")
|
||||
docker-container-shell-file-name "/bin/bash"))
|
||||
;;(use-package docker-tramp)
|
||||
(use-package dockerfile-mode)
|
||||
|
||||
(provide 'init-docker)
|
||||
;;; init-docker.el ends here
|
||||
13
.config/emacs/lisp/init-eglot.el
Normal file
13
.config/emacs/lisp/init-eglot.el
Normal file
@ -0,0 +1,13 @@
|
||||
;;; init-eglot.el -*- lexical-binding: t -*-
|
||||
;;(use-package eglot
|
||||
;; :hook
|
||||
;; ((prog-mode . (lambda ()
|
||||
;; (unless (derived-mode-p
|
||||
;; 'emacs-lisp-mode
|
||||
;; 'lisp-mode
|
||||
;; 'makefile-mode
|
||||
;; 'snippet-mode)
|
||||
;; (eglot-ensure))))
|
||||
;; ((markdown-mode yaml-mode yaml-ts-mode) . eglot-ensure)))
|
||||
(provide 'init-eglot)
|
||||
;;; init-eglot.el ends here
|
||||
244
.config/emacs/lisp/init-elisp.el
Normal file
244
.config/emacs/lisp/init-elisp.el
Normal file
@ -0,0 +1,244 @@
|
||||
;; init-elisp.el -*- lexical-binding: t -*-
|
||||
(require 'init-custom)
|
||||
(require 'init-funcs)
|
||||
|
||||
;; Emacs lisp mode
|
||||
(use-package elisp-mode
|
||||
:ensure nil
|
||||
:defines flycheck-disabled-checkers
|
||||
:bind (:map emacs-lisp-mode-map
|
||||
("C-c C-x" . ielm)
|
||||
("C-c C-c" . eval-defun)
|
||||
("C-c C-b" . eval-buffer))
|
||||
:hook (emacs-lisp-mode . (lambda ()
|
||||
"Disable the checkdoc checker."
|
||||
(setq-local flycheck-disabled-checkers
|
||||
'(emacs-lisp-checkdoc))))
|
||||
:config
|
||||
(when (boundp 'elisp-flymake-byte-compile-load-path)
|
||||
(add-to-list 'elisp-flymake-byte-compile-load-path load-path))
|
||||
|
||||
;; Syntax highlighting of known Elisp symbols
|
||||
(use-package highlight-defined
|
||||
:hook ((emacs-lisp-mode inferior-emacs-lisp-mode) . highlight-defined-mode))
|
||||
|
||||
(with-no-warnings
|
||||
;; Align indent keywords
|
||||
;; @see https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned
|
||||
(defun my-lisp-indent-function (indent-point state)
|
||||
"This function is the normal value of the variable `lisp-indent-function'.
|
||||
The function `calculate-lisp-indent' calls this to determine
|
||||
if the arguments of a Lisp function call should be indented specially.
|
||||
|
||||
INDENT-POINT is the position at which the line being indented begins.
|
||||
Point is located at the point to indent under (for default indentation);
|
||||
STATE is the `parse-partial-sexp' state for that position.
|
||||
|
||||
If the current line is in a call to a Lisp function that has a non-nil
|
||||
property `lisp-indent-function' (or the deprecated `lisp-indent-hook'),
|
||||
it specifies how to indent. The property value can be:
|
||||
|
||||
* `defun', meaning indent `defun'-style
|
||||
\(this is also the case if there is no property and the function
|
||||
has a name that begins with \"def\", and three or more arguments);
|
||||
|
||||
* an integer N, meaning indent the first N arguments specially
|
||||
(like ordinary function arguments), and then indent any further
|
||||
arguments like a body;
|
||||
|
||||
* a function to call that returns the indentation (or nil).
|
||||
`lisp-indent-function' calls this function with the same two arguments
|
||||
that it itself received.
|
||||
|
||||
This function returns either the indentation to use, or nil if the
|
||||
Lisp function does not specify a special indentation."
|
||||
(let ((normal-indent (current-column))
|
||||
(orig-point (point)))
|
||||
(goto-char (1+ (elt state 1)))
|
||||
(parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
|
||||
(cond
|
||||
;; car of form doesn't seem to be a symbol, or is a keyword
|
||||
((and (elt state 2)
|
||||
(or (not (looking-at "\\sw\\|\\s_"))
|
||||
(looking-at ":")))
|
||||
(if (not (> (save-excursion (forward-line 1) (point))
|
||||
calculate-lisp-indent-last-sexp))
|
||||
(progn (goto-char calculate-lisp-indent-last-sexp)
|
||||
(beginning-of-line)
|
||||
(parse-partial-sexp (point)
|
||||
calculate-lisp-indent-last-sexp 0 t)))
|
||||
;; Indent under the list or under the first sexp on the same
|
||||
;; line as calculate-lisp-indent-last-sexp. Note that first
|
||||
;; thing on that line has to be complete sexp since we are
|
||||
;; inside the innermost containing sexp.
|
||||
(backward-prefix-chars)
|
||||
(current-column))
|
||||
((and (save-excursion
|
||||
(goto-char indent-point)
|
||||
(skip-syntax-forward " ")
|
||||
(not (looking-at ":")))
|
||||
(save-excursion
|
||||
(goto-char orig-point)
|
||||
(looking-at ":")))
|
||||
(save-excursion
|
||||
(goto-char (+ 2 (elt state 1)))
|
||||
(current-column)))
|
||||
(t
|
||||
(let ((function (buffer-substring (point)
|
||||
(progn (forward-sexp 1) (point))))
|
||||
method)
|
||||
(setq method (or (function-get (intern-soft function)
|
||||
'lisp-indent-function)
|
||||
(get (intern-soft function) 'lisp-indent-hook)))
|
||||
(cond ((or (eq method 'defun)
|
||||
(and (null method)
|
||||
(length> function 3)
|
||||
(string-match "\\`def" function)))
|
||||
(lisp-indent-defform state indent-point))
|
||||
((integerp method)
|
||||
(lisp-indent-specform method state
|
||||
indent-point normal-indent))
|
||||
(method
|
||||
(funcall method indent-point state))))))))
|
||||
(add-hook 'emacs-lisp-mode-hook
|
||||
(lambda () (setq-local lisp-indent-function #'my-lisp-indent-function)))
|
||||
|
||||
;; Add remove buttons for advices
|
||||
(add-hook 'help-mode-hook 'cursor-sensor-mode)
|
||||
|
||||
(defun function-advices (function)
|
||||
"Return FUNCTION's advices."
|
||||
(let ((flist (indirect-function function)) advices)
|
||||
(while (advice--p flist)
|
||||
(setq advices `(,@advices ,(advice--car flist)))
|
||||
(setq flist (advice--cdr flist)))
|
||||
advices))
|
||||
|
||||
(defun add-remove-advice-button (advice function)
|
||||
(when (and (functionp advice) (functionp function))
|
||||
(let ((inhibit-read-only t)
|
||||
(msg (format "Remove advice `%s'" advice)))
|
||||
(insert "\t")
|
||||
(insert-button
|
||||
"Remove"
|
||||
'face 'custom-button
|
||||
'cursor-sensor-functions `((lambda (&rest _) ,msg))
|
||||
'help-echo msg
|
||||
'action (lambda (_)
|
||||
(when (yes-or-no-p msg)
|
||||
(message "%s from function `%s'" msg function)
|
||||
(advice-remove function advice)
|
||||
(if (eq major-mode 'helpful-mode)
|
||||
(helpful-update)
|
||||
(revert-buffer nil t))))
|
||||
'follow-link t))))
|
||||
|
||||
(defun add-button-to-remove-advice (buffer-or-name function)
|
||||
"Add a button to remove advice."
|
||||
(with-current-buffer buffer-or-name
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let ((ad-list (function-advices function)))
|
||||
(while (re-search-forward "^\\(?:This function has \\)?:[-a-z]+ advice: \\(.+\\)$" nil t)
|
||||
(let ((advice (car ad-list)))
|
||||
(add-remove-advice-button advice function)
|
||||
(setq ad-list (delq advice ad-list))))))))
|
||||
|
||||
(define-advice describe-function-1 (:after (function) advice-remove-button)
|
||||
(add-button-to-remove-advice (help-buffer) function))
|
||||
(with-eval-after-load 'helpful
|
||||
(define-advice helpful-update (:after () advice-remove-button)
|
||||
(when helpful--callable-p
|
||||
(add-button-to-remove-advice (current-buffer) helpful--sym))))
|
||||
|
||||
;; Remove hooks
|
||||
(defun remove-hook-at-point ()
|
||||
"Remove the hook at the point in the *Help* buffer."
|
||||
(interactive)
|
||||
(unless (memq major-mode '(help-mode helpful-mode))
|
||||
(error "Only for help-mode or helpful-mode"))
|
||||
|
||||
(let ((orig-point (point)))
|
||||
(save-excursion
|
||||
(when-let
|
||||
((hook (progn (goto-char (point-min)) (symbol-at-point)))
|
||||
(func (when (and
|
||||
(or (re-search-forward (format "^Value:?[\s|\n]") nil t)
|
||||
(goto-char orig-point))
|
||||
(sexp-at-point))
|
||||
(end-of-sexp)
|
||||
(backward-char 1)
|
||||
(catch 'break
|
||||
(while t
|
||||
(condition-case _err
|
||||
(backward-sexp)
|
||||
(scan-error (throw 'break nil)))
|
||||
(let ((bounds (bounds-of-thing-at-point 'sexp)))
|
||||
(when (<= (car bounds) orig-point (cdr bounds))
|
||||
(throw 'break (sexp-at-point)))))))))
|
||||
(when (yes-or-no-p (format "Remove %s from %s? " func hook))
|
||||
(remove-hook hook func)
|
||||
(if (eq major-mode 'helpful-mode)
|
||||
(helpful-update)
|
||||
(revert-buffer nil t)))))))
|
||||
(bind-key "r" #'remove-hook-at-point help-mode-map)))
|
||||
|
||||
;; Show function arglist or variable docstring
|
||||
;; `global-eldoc-mode' is enabled by default.
|
||||
(use-package eldoc
|
||||
:ensure nil
|
||||
:diminish)
|
||||
|
||||
;; A better *Help* buffer
|
||||
(use-package helpful
|
||||
:bind (([remap describe-function] . helpful-callable)
|
||||
([remap describe-command] . helpful-command)
|
||||
([remap describe-variable] . helpful-variable)
|
||||
([remap describe-key] . helpful-key)
|
||||
([remap describe-symbol] . helpful-symbol)
|
||||
("C-c C-d" . helpful-at-point)
|
||||
:map helpful-mode-map
|
||||
("r" . remove-hook-at-point))
|
||||
:hook (helpful-mode . cursor-sensor-mode) ; for remove-advice button
|
||||
:init
|
||||
(with-no-warnings
|
||||
(with-eval-after-load 'counsel
|
||||
(setq counsel-describe-function-function #'helpful-callable
|
||||
counsel-describe-variable-function #'helpful-variable
|
||||
counsel-describe-symbol-function #'helpful-symbol
|
||||
counsel-descbinds-function #'helpful-callable))
|
||||
|
||||
(with-eval-after-load 'apropos
|
||||
;; patch apropos buttons to call helpful instead of help
|
||||
(dolist (fun-bt '(apropos-function apropos-macro apropos-command))
|
||||
(button-type-put
|
||||
fun-bt 'action
|
||||
(lambda (button)
|
||||
(helpful-callable (button-get button 'apropos-symbol)))))
|
||||
(dolist (var-bt '(apropos-variable apropos-user-option))
|
||||
(button-type-put
|
||||
var-bt 'action
|
||||
(lambda (button)
|
||||
(helpful-variable (button-get button 'apropos-symbol)))))))
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; Open the buffer in other window
|
||||
(defun my-helpful--navigate (button)
|
||||
"Navigate to the path this BUTTON represents."
|
||||
(find-file-other-window (substring-no-properties (button-get button 'path)))
|
||||
;; We use `get-text-property' to work around an Emacs 25 bug:
|
||||
;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f7c4bad17d83297ee9a1b57552b1944020f23aea
|
||||
(-when-let (pos (get-text-property button 'position
|
||||
(marker-buffer button)))
|
||||
(helpful--goto-char-widen pos)))
|
||||
(advice-add #'helpful--navigate :override #'my-helpful--navigate)))
|
||||
|
||||
;;;; For ERT
|
||||
;;(use-package overseer
|
||||
;; :diminish
|
||||
;; :hook (emacs-lisp-mode . overseer-mode))
|
||||
|
||||
(provide 'init-elisp)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-elisp.el ends here
|
||||
115
.config/emacs/lisp/init-eshell.el
Normal file
115
.config/emacs/lisp/init-eshell.el
Normal file
@ -0,0 +1,115 @@
|
||||
;;; init-eshell.el -*- lexical-binding: t -*-
|
||||
;; Emacs command shell
|
||||
(use-package eshell
|
||||
:ensure nil
|
||||
:defines eshell-prompt-function
|
||||
:bind (:map eshell-mode-map
|
||||
([remap recenter-top-bottom] . eshell/clear))
|
||||
:config
|
||||
(with-no-warnings
|
||||
(defun eshell/clear ()
|
||||
"Clear the eshell buffer."
|
||||
(interactive)
|
||||
(let ((inhibit-read-only t))
|
||||
(erase-buffer)
|
||||
(eshell-send-input)))
|
||||
|
||||
(defun eshell/emacs (&rest args)
|
||||
"Open a file (ARGS) in Emacs. Some habits die hard."
|
||||
(if (null args)
|
||||
;; If I just ran "emacs", I probably expect to be launching
|
||||
;; Emacs, which is rather silly since I'm already in Emacs.
|
||||
;; So just pretend to do what I ask.
|
||||
(bury-buffer)
|
||||
;; We have to expand the file names or else naming a directory in an
|
||||
;; argument causes later arguments to be looked for in that directory,
|
||||
;; not the starting directory
|
||||
(mapc #'find-file (mapcar #'expand-file-name (flatten-tree (reverse args))))))
|
||||
(defalias 'eshell/e #'eshell/emacs)
|
||||
(defalias 'eshell/ec #'eshell/emacs)
|
||||
|
||||
(defun eshell/ebc (&rest args)
|
||||
"Compile a file (ARGS) in Emacs. Use `compile' to do background make."
|
||||
(if (eshell-interactive-output-p)
|
||||
(let ((compilation-process-setup-function
|
||||
(list 'lambda nil
|
||||
(list 'setq 'process-environment
|
||||
(list 'quote (eshell-copy-environment))))))
|
||||
(compile (eshell-flatten-and-stringify args))
|
||||
(pop-to-buffer compilation-last-buffer))
|
||||
(throw 'eshell-replace-command
|
||||
(let ((l (eshell-stringify-list (flatten-tree args))))
|
||||
(eshell-parse-command (car l) (cdr l))))))
|
||||
(put 'eshell/ebc 'eshell-no-numeric-conversions t)
|
||||
|
||||
(defun eshell-view-file (file)
|
||||
"View FILE. A version of `view-file' which properly rets the eshell prompt."
|
||||
(interactive "fView file: ")
|
||||
(unless (file-exists-p file) (error "%s does not exist" file))
|
||||
(let ((buffer (find-file-noselect file)))
|
||||
(if (eq (get (buffer-local-value 'major-mode buffer) 'mode-class)
|
||||
'special)
|
||||
(progn
|
||||
(switch-to-buffer buffer)
|
||||
(message "Not using View mode because the major mode is special"))
|
||||
(let ((undo-window (list (window-buffer) (window-start)
|
||||
(+ (window-point)
|
||||
(length (funcall eshell-prompt-function))))))
|
||||
(switch-to-buffer buffer)
|
||||
(view-mode-enter (cons (selected-window) (cons nil undo-window))
|
||||
'kill-buffer)))))
|
||||
|
||||
(defun eshell/less (&rest args)
|
||||
"Invoke `view-file' on a file (ARGS).
|
||||
|
||||
\"less +42 foo\" will go to line 42 in the buffer for foo."
|
||||
(while args
|
||||
(if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
|
||||
(let* ((line (string-to-number (match-string 1 (pop args))))
|
||||
(file (pop args)))
|
||||
(eshell-view-file file)
|
||||
(forward-line line))
|
||||
(eshell-view-file (pop args)))))
|
||||
(defalias 'eshell/more #'eshell/less))
|
||||
|
||||
;;(defun ju/eshell-prompt ()
|
||||
;; (let ((current-branch (magit-get-current-branch)))
|
||||
;; (concat
|
||||
;; "\n"
|
||||
;; (propertize (system-name) 'face `(:foreground "#62aeed"))
|
||||
;; (propertize " ॐ " 'face `(:foreground "white"))
|
||||
;; (propertize (ju/get-prompt-path) 'face `(:foreground "#82cfd3"))
|
||||
;; (when current-branch
|
||||
;; (concat
|
||||
;; (propertize " • " 'face `(:foreground "white"))
|
||||
;; (propertize (concat " " current-branch) 'face `(:foreground "#c475f0"))))
|
||||
;; (propertize " • " 'face `(:foreground "white"))
|
||||
;; (propertize (format-time-string "%I:%M:%S %p") 'face `(:foreground "#5a5b7f"))
|
||||
;; (if (= (user-uid) 0)
|
||||
;; (propertize "\n#" 'face `(:foreground "red2"))
|
||||
;; (propertize "\nλ" 'face `(:foreground "#aece4a")))
|
||||
;; (propertize " " 'face `(:foreground "white")))))
|
||||
|
||||
;;(setq eshell-prompt-function 'ju/eshell-prompt
|
||||
;; eshell-prompt-regexp "^λ ")
|
||||
|
||||
|
||||
;; Display extra information for prompt
|
||||
(use-package eshell-prompt-extras
|
||||
:after esh-opt
|
||||
:defines eshell-highlight-prompt
|
||||
:autoload (epe-theme-lambda epe-theme-dakrone epe-theme-pipeline)
|
||||
:init (setq eshell-highlight-prompt t
|
||||
eshell-prompt-function #'epe-theme-lambda))
|
||||
|
||||
;; `eldoc' support
|
||||
(use-package esh-help
|
||||
:init (setup-esh-help-eldoc))
|
||||
|
||||
;; `cd' to frequent directory in `eshell'
|
||||
(use-package eshell-z
|
||||
:hook (eshell-mode . (lambda () (require 'eshell-z)))))
|
||||
|
||||
|
||||
(provide 'init-eshell)
|
||||
;;; init-eshell.el ends here
|
||||
70
.config/emacs/lisp/init-flycheck.el
Normal file
70
.config/emacs/lisp/init-flycheck.el
Normal file
@ -0,0 +1,70 @@
|
||||
;;; init-flycheck.el -*- lexical-binding: t -*-
|
||||
(require 'init-const)
|
||||
(require 'init-funcs)
|
||||
|
||||
(use-package flycheck
|
||||
:diminish
|
||||
:autoload flycheck-redefine-standard-error-levels
|
||||
:hook (after-init . global-flycheck-mode)
|
||||
:init (setq flycheck-global-modes
|
||||
'(not text-mode outline-mode fundamental-mode lisp-interaction-mode
|
||||
org-mode diff-mode shell-mode eshell-mode term-mode vterm-mode)
|
||||
flycheck-emacs-lisp-load-path 'inherit
|
||||
flycheck-indication-mode (if (display-graphic-p)
|
||||
'right-fringe
|
||||
'right-margin)
|
||||
;; Only check while saving and opening files
|
||||
flycheck-check-syntax-automatically '(save mode-enabled))
|
||||
:config
|
||||
;; Prettify indication styles
|
||||
(when (fboundp 'define-fringe-bitmap)
|
||||
(define-fringe-bitmap 'flycheck-fringe-bitmap-arrow
|
||||
[16 48 112 240 112 48 16] nil nil 'center))
|
||||
(flycheck-redefine-standard-error-levels "⏴" 'flycheck-fringe-bitmap-arrow)
|
||||
|
||||
;; Display Flycheck errors
|
||||
(if (childframe-workable-p)
|
||||
(use-package flycheck-posframe
|
||||
:custom-face
|
||||
(flycheck-posframe-face ((t (:foreground ,(face-foreground 'success)))))
|
||||
(flycheck-posframe-info-face ((t (:foreground ,(face-foreground 'success)))))
|
||||
(flycheck-posframe-background-face ((t (:inherit tooltip))))
|
||||
(flycheck-posframe-border-face ((t (:inherit posframe-border))))
|
||||
:hook (flycheck-mode . flycheck-posframe-mode)
|
||||
:init
|
||||
(setq flycheck-posframe-border-width 1)
|
||||
(add-hook 'flycheck-posframe-inhibit-functions
|
||||
(lambda (&rest _) (bound-and-true-p company-backend)))
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; FIXME: Prettify the child frame.
|
||||
;; @see https://github.com/alexmurray/flycheck-posframe/issues/28
|
||||
(defun my-flycheck-posframe-show-posframe (errors)
|
||||
"Display ERRORS, using posframe.el library."
|
||||
(posframe-hide flycheck-posframe-buffer)
|
||||
(when (and errors
|
||||
(not (run-hook-with-args-until-success 'flycheck-posframe-inhibit-functions)))
|
||||
(let ((poshandler (intern (format "posframe-poshandler-%s" flycheck-posframe-position))))
|
||||
(unless (functionp poshandler)
|
||||
(setq poshandler nil))
|
||||
(flycheck-posframe-check-position)
|
||||
(posframe-show
|
||||
flycheck-posframe-buffer
|
||||
:string (flycheck-posframe-format-errors errors)
|
||||
:background-color (face-background 'flycheck-posframe-background-face nil t)
|
||||
:position (point)
|
||||
:left-fringe 4
|
||||
:right-fringe 4
|
||||
:max-width (round (* (frame-width) 0.62))
|
||||
:max-height (round (* (frame-height) 0.62))
|
||||
:internal-border-width flycheck-posframe-border-width
|
||||
:internal-border-color (face-background 'flycheck-posframe-border-face nil t)
|
||||
:poshandler poshandler
|
||||
:hidehandler #'flycheck-posframe-hidehandler))))
|
||||
(advice-add #'flycheck-posframe-show-posframe :override #'my-flycheck-posframe-show-posframe)))
|
||||
(use-package flycheck-popup-tip
|
||||
:hook (flycheck-mode . flycheck-popup-tip-mode))))
|
||||
|
||||
|
||||
(provide 'init-flycheck)
|
||||
;;; init-flycheck.el ends here
|
||||
@ -15,6 +15,14 @@
|
||||
(require 'nerd-icons nil t)))
|
||||
;;(or (featurep 'all-the-icons)
|
||||
;; (require 'all-the-icons nil t)))
|
||||
(defun childframe-workable-p ()
|
||||
"Whether childframe is workable."
|
||||
(or (not (or noninteractive
|
||||
emacs-basic-display
|
||||
(not (display-graphic-p))))
|
||||
(daemonp)))
|
||||
|
||||
|
||||
(defun toggle-transparency ()
|
||||
(interactive)
|
||||
(let ((alpha (frame-parameter nil 'alpha)))
|
||||
|
||||
@ -42,6 +42,13 @@
|
||||
"b B" '(ibuffer-list-buffers :which-key "IBuffer List Buffers")
|
||||
"b K" '(kill-buffer :which-key "IBuffer Kill Buffers")
|
||||
"b s" '(consult-buffer :which-key "switch buffer")
|
||||
;; Citre
|
||||
"c" '(:ignore t :which-key "citre")
|
||||
"c j" 'citre-jump+
|
||||
"c k" 'citre-jump-back+
|
||||
"c p" 'citre-peek
|
||||
"c a" 'citre-ace-peek
|
||||
"c u" 'citre-update-tags-file
|
||||
;; Eshell
|
||||
"e" '(:ignore t :which-key "eshell")
|
||||
"e h" '(counsel-esh-history :which-key "Kill history")
|
||||
@ -62,8 +69,11 @@
|
||||
"i" '(:ignore t :which-key "insert something.")
|
||||
"i s" '(yas-insert-snippet :which-key "snippet")
|
||||
"i e" '(emojify-insert-emoji :which-key "emoji")
|
||||
;; Managements
|
||||
"m" '(:ignore t :which "Managements")
|
||||
"m d" '(docker :which-key "Docker")
|
||||
;; Org Journal / Org Roam
|
||||
"j" '(:ignore t :which-key "Journal / Roam")
|
||||
"n" '(:ignore t :which-key "Journal / Roam")
|
||||
"n j" '(:ignore t :which-key "Org Journal")
|
||||
"n j j" '(org-journal-new-entry :which-key "new Entry")
|
||||
"n j J" '(org-journal-new-scheduled-entry :which-key "New Scheduled entry")
|
||||
@ -106,6 +116,7 @@
|
||||
"t" '(:ignore t :which-key "extra")
|
||||
"t a" '(toggle-transparency :which-key "Toggle Transparency")
|
||||
"t t" '(toggle-truncate-lines :which-key "Toggle truncate lines")
|
||||
"t g" '(gts-do-translate :which-key "Goggle Translate")
|
||||
;; Avy
|
||||
"v" '(:ignore t :which-key "Avy")
|
||||
"vc" '(avy-goto-char :which-key "Avy Goto Char")
|
||||
|
||||
14
.config/emacs/lisp/init-markdown.el
Normal file
14
.config/emacs/lisp/init-markdown.el
Normal file
@ -0,0 +1,14 @@
|
||||
;;; init-markdown.el -*- lexical-binding: t -*-
|
||||
;; using multimarkdown compiler, could be found at AUR
|
||||
(use-package markdown-mode
|
||||
:mode ("README\\.md\\'" . gfm-mode)
|
||||
:init (setq markdown-command "multimarkdown")
|
||||
(setq markdown-enable-wiki-links t
|
||||
markdown-italic-underscore t
|
||||
markdown-asymmetric-header t
|
||||
markdown-make-gfm-checkboxes-buttons t
|
||||
markdown-gfm-uppercase-checkbox t
|
||||
markdown-fontify-code-blocks-natively t))
|
||||
(provide 'init-markdown)
|
||||
|
||||
;;; init-markdown.el ends here
|
||||
428
.config/emacs/lisp/init-org.el
Normal file
428
.config/emacs/lisp/init-org.el
Normal file
@ -0,0 +1,428 @@
|
||||
;;; init-org.el -*- lexical-binding: t -*-
|
||||
(require 'init-const)
|
||||
(require 'init-funcs)
|
||||
(require 'init-custom)
|
||||
|
||||
(use-package org
|
||||
:ensure nil
|
||||
:custom-face (org-ellipsis ((t (:foreground unspecified))))
|
||||
:pretty-hydra
|
||||
;; See `org-structure-template-alist'
|
||||
((:title (pretty-hydra-title "Org Template" 'sucicon "nf-custom-orgmode" :face 'nerd-icons-green)
|
||||
:color blue :quit-key ("q" "C-g"))
|
||||
("Basic"
|
||||
(("a" (hot-expand "<a") "ascii")
|
||||
("c" (hot-expand "<c") "center")
|
||||
("C" (hot-expand "<C") "comment")
|
||||
("e" (hot-expand "<e") "example")
|
||||
("E" (hot-expand "<E") "export")
|
||||
("h" (hot-expand "<h") "html")
|
||||
("l" (hot-expand "<l") "latex")
|
||||
("n" (hot-expand "<n") "note")
|
||||
("o" (hot-expand "<q") "quote")
|
||||
("v" (hot-expand "<v") "verse"))
|
||||
"Head"
|
||||
(("i" (hot-expand "<i") "index")
|
||||
("A" (hot-expand "<A") "ASCII")
|
||||
("I" (hot-expand "<I") "INCLUDE")
|
||||
("H" (hot-expand "<H") "HTML")
|
||||
("L" (hot-expand "<L") "LaTeX"))
|
||||
"Source"
|
||||
(("s" (hot-expand "<s") "src")
|
||||
("m" (hot-expand "<s" "emacs-lisp") "emacs-lisp")
|
||||
("y" (hot-expand "<s" "python :results output") "python")
|
||||
("p" (hot-expand "<s" "perl") "perl")
|
||||
("w" (hot-expand "<s" "powershell") "powershell")
|
||||
("r" (hot-expand "<s" "ruby") "ruby")
|
||||
("S" (hot-expand "<s" "sh") "sh")
|
||||
("g" (hot-expand "<s" "go :imports '\(\"fmt\"\)") "golang"))
|
||||
"Misc"
|
||||
(("u" (hot-expand "<s" "plantuml :file CHANGE.png") "plantuml")
|
||||
("Y" (hot-expand "<s" "ipython :session :exports both :results raw drawer\n$0") "ipython")
|
||||
("P" (progn
|
||||
(insert "#+HEADERS: :results output :exports both :shebang \"#!/usr/bin/env perl\"\n")
|
||||
(hot-expand "<s" "perl")) "Perl tangled")
|
||||
("<" self-insert-command "ins"))))
|
||||
:bind (("C-c a" . org-agenda)
|
||||
("C-c b" . org-switchb)
|
||||
("C-c x" . org-capture)
|
||||
:map org-mode-map
|
||||
("<" . (lambda ()
|
||||
"Insert org template."
|
||||
(interactive)
|
||||
(if (or (region-active-p) (looking-back "^\s*" 1))
|
||||
(org-hydra/body)
|
||||
(self-insert-command 1)))))
|
||||
:hook (((org-babel-after-execute org-mode) . org-redisplay-inline-images) ; display image
|
||||
(org-indent-mode . (lambda()
|
||||
(diminish 'org-indent-mode)
|
||||
;; HACK: Prevent text moving around while using brackets
|
||||
;; @see https://github.com/seagle0128/.emacs.d/issues/88
|
||||
(make-variable-buffer-local 'show-paren-mode)
|
||||
(setq show-paren-mode nil)))
|
||||
(org-mode . org-fold-hide-drawer-all)
|
||||
(org-mode . visual-line-mode))
|
||||
:config
|
||||
;; For hydra
|
||||
(defun hot-expand (str &optional mod)
|
||||
"Expand org template.
|
||||
|
||||
STR is a structure template string recognised by org like <s. MOD is a
|
||||
string with additional parameters to add the begin line of the
|
||||
structure element. HEADER string includes more parameters that are
|
||||
prepended to the element after the #+HEADER: tag."
|
||||
(let (text)
|
||||
(when (region-active-p)
|
||||
(setq text (buffer-substring (region-beginning) (region-end)))
|
||||
(delete-region (region-beginning) (region-end)))
|
||||
(insert str)
|
||||
(if (fboundp 'org-try-structure-completion)
|
||||
(org-try-structure-completion) ; < org 9
|
||||
(progn
|
||||
;; New template expansion since org 9
|
||||
(require 'org-tempo nil t)
|
||||
(org-tempo-complete-tag)))
|
||||
(when mod (insert mod) (forward-line))
|
||||
(when text (insert text))))
|
||||
|
||||
;; To speed up startup, don't put to init section
|
||||
(setq org-modules nil ; Faster loading
|
||||
org-directory custom-org-directory
|
||||
org-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))
|
||||
|
||||
org-todo-keywords
|
||||
'((sequence
|
||||
"TODO(t)" ; A task that needs doing & is ready to do
|
||||
"PROJ(p)" ; A project, which usually contains other tasks
|
||||
"STRT(s)" ; A task that is in progress
|
||||
"WAIT(w)" ; Something external is holding up this task
|
||||
"HOLD(h)" ; This task is paused/on hold because of me
|
||||
"IDEA(i)" ; An unconfirmed and unapproved task or notion
|
||||
"|"
|
||||
"DONE(d)" ; Task successfully completed
|
||||
"KILL(k)") ; Task was cancelled, aborted or is no longer applicable
|
||||
(sequence "⚑(T)" "🏴(S)" "❓(W)" "|" "✔(D)" "✘(C)"))
|
||||
org-todo-keyword-faces
|
||||
'(("[-]" . +org-todo-active)
|
||||
("STRT" . +org-todo-active)
|
||||
("[?]" . +org-todo-onhold)
|
||||
("WAIT" . +org-todo-onhold)
|
||||
("HOLD" . +org-todo-onhold)
|
||||
("PROJ" . +org-todo-project)
|
||||
("KILL" . +org-todo-cancel))
|
||||
org-priority-faces '((?A . error)
|
||||
(?B . warning)
|
||||
(?C . success))
|
||||
|
||||
;; Agenda styling
|
||||
org-agenda-files (list custom-org-agenda-files)
|
||||
org-agenda-block-separator ?─
|
||||
org-agenda-start-with-log-mode t
|
||||
org-agenda-time-grid
|
||||
'((daily today require-timed)
|
||||
(800 1000 1200 1400 1600 1800 2000)
|
||||
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
|
||||
org-agenda-current-time-string
|
||||
"⭠ now ─────────────────────────────────────────────────"
|
||||
|
||||
;; formula a_{i}
|
||||
org-use-sub-superscripts '{}
|
||||
;; scale org-latex
|
||||
org-format-latex-options (plist-put org-format-latex-options :scale 2.0)
|
||||
|
||||
org-image-actual-width nil
|
||||
|
||||
;; export options
|
||||
org-odt-preferred-output-format "docx" ;; opt -> docx
|
||||
org-export-with-sub-superscripts '{} ;; ODT export to docx
|
||||
org-latex-compiler "xelatex"
|
||||
|
||||
org-tags-column -80
|
||||
org-log-done 'time
|
||||
org-log-into-drawer "LOGBOOK"
|
||||
org-clock-into-drawer "CLOCKING"
|
||||
org-catch-invisible-edits 'smart
|
||||
org-startup-indented t
|
||||
org-ellipsis (if (char-displayable-p ?⏷) "\t⤵" nil)
|
||||
org-pretty-entities nil
|
||||
org-hide-emphasis-markers t)
|
||||
|
||||
(use-package org-journal
|
||||
:defer t
|
||||
:config
|
||||
(setq org-journal-dir (expand-file-name "journal/" org-directory))
|
||||
(setq org-journal-file-type 'weekly))
|
||||
(use-package calfw)
|
||||
(use-package calfw-org
|
||||
:after calfw)
|
||||
|
||||
;; 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))
|
||||
(org-modern-mode . (lambda ()
|
||||
"Adapt `org-modern-mode'."
|
||||
;; Disable Prettify Symbols mode
|
||||
(setq prettify-symbols-alist nil)
|
||||
(prettify-symbols-mode -1))))
|
||||
(use-package org-superstar
|
||||
:if (and (display-graphic-p) (char-displayable-p ?◉))
|
||||
:hook (org-mode . org-superstar-mode)
|
||||
:init
|
||||
(setq org-superstar-headline-bullets-list '("◉""○""◈""◇""⁕")
|
||||
org-superstar-item-bullet-alist ;; dont work with org-modern
|
||||
'((?+ . ?➢)
|
||||
(?* . ?✰)
|
||||
(?- . ?➸))))
|
||||
|
||||
(use-package org-fancy-priorities
|
||||
:diminish
|
||||
:hook (org-mode . org-fancy-priorities-mode)
|
||||
:init (setq org-fancy-priorities-list
|
||||
(if (and (display-graphic-p) (char-displayable-p ?🅐))
|
||||
'("🅐" "🅑" "🅒" "🅓")
|
||||
'("HIGH" "MEDIUM" "LOW" "OPTIONAL"))))
|
||||
|
||||
(setq org-confirm-babel-evaluate nil
|
||||
org-src-fontify-natively t
|
||||
org-src-tab-acts-natively t)
|
||||
|
||||
(defconst load-language-alist
|
||||
'((emacs-lisp . t)
|
||||
(latex-as-png . t)
|
||||
(python . t)
|
||||
(ruby . t)
|
||||
(rust . t)
|
||||
(C . t))
|
||||
"Alist of org ob languages.")
|
||||
;; ob-sh renamed to ob-shell since 26.1.
|
||||
(cl-pushnew '(shell . t) load-language-alist)
|
||||
|
||||
(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))
|
||||
; 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 ()
|
||||
"Remove `org-mode' link at point and trash linked file."
|
||||
(interactive)
|
||||
(let* ((link (org-element-context))
|
||||
(path (org-element-property :path link)))
|
||||
(move-file-to-trash path)
|
||||
(delete-region (org-element-property :begin link)
|
||||
(org-element-property :end link))))
|
||||
(defun my/powershell (script)
|
||||
"executes the given script within a powershell and returns its return value"
|
||||
(call-process "powershell.exe" nil nil nil
|
||||
"-Command" (concat "& {" script "}")))
|
||||
(defun my/as-windows-path (unix-path)
|
||||
"Takes a unix path and returns a matching WSL path"
|
||||
;; substring removes the trailing \n
|
||||
(substring
|
||||
(shell-command-to-string
|
||||
(concat "wslpath -w " unix-path)) 0 -1))
|
||||
(defun my/org-paste-image-win2wsl ()
|
||||
"Paste an image into a time stamped unique-named file in the
|
||||
same directory as the org-buffer and insert a link to this file."
|
||||
(interactive)
|
||||
(let* ((target-file
|
||||
(concat
|
||||
(make-temp-name
|
||||
(concat org-directory
|
||||
"/images/"
|
||||
(f-filename buffer-file-name)
|
||||
"_"
|
||||
(format-time-string "%Y%m%d_%H%M%S_"))) ".png"))
|
||||
(wsl-path
|
||||
(concat (my/as-windows-path(file-name-directory target-file))
|
||||
"/"
|
||||
(file-name-nondirectory target-file)))
|
||||
(ps-script
|
||||
(concat "(Get-Clipboard -Format image).Save('" wsl-path "')")))
|
||||
|
||||
(my/powershell ps-script)
|
||||
|
||||
(if (file-exists-p target-file)
|
||||
(progn (insert (concat "[[" target-file "]]"))
|
||||
(org-display-inline-images))
|
||||
(user-error
|
||||
"Error pasting the image, make sure you have an image in the clipboard!"))))
|
||||
(defun org-time-stamp-with-time()
|
||||
"Insert org mode timestamp at point with current date and time"
|
||||
(interactive)
|
||||
(org-insert-time-stamp (current-time) t))
|
||||
; org-roam ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(use-package org-roam
|
||||
:demand t ;; ensure org-roam is loaded by default
|
||||
:custom
|
||||
(org-roam-directory "~/org/roam")
|
||||
(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)))
|
||||
(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
|
||||
(defun my/org-roam-rg-search ()
|
||||
"Search org-roam directory using consult-ripgrep. With live-preview."
|
||||
(interactive)
|
||||
(let ((consult-ripgrep-command "rg --null --ignore-case --type org --line-buffered --color=always --max-columns=500 --no-heading --line-number . -e ARG OPTS"))
|
||||
(consult-ripgrep org-roam-directory)))
|
||||
(defun my/org-roam-filter-by-tag (tag-name)
|
||||
(lambda (node)
|
||||
(member tag-name (org-roam-node-tags node))))
|
||||
(defun my/org-roam-list-notes-by-tag (tag-name)
|
||||
(mapcar #'org-roam-node-file
|
||||
(seq-filter
|
||||
(my/org-roam-filter-by-tag tag-name)
|
||||
(org-roam-node-list))))
|
||||
(defun my/org-roam-refresh-agenda-list ()
|
||||
(interactive)
|
||||
(setq org-agenda-files (my/org-roam-list-notes-by-tag "Project"))
|
||||
(add-to-list 'org-agenda-files custom-org-agenda-files))
|
||||
(defun my/org-roam-project-finalize-hook ()
|
||||
"Adds the captured project file to `org-agenda-files' if the
|
||||
capture was not aborted."
|
||||
;; Remove the hook since it was added temporarily
|
||||
(remove-hook 'org-capture-after-finalize-hook #'my/org-roam-project-finalize-hook)
|
||||
|
||||
;; Add project file to the agenda list if the capture was confirmed
|
||||
(unless org-note-abort
|
||||
(with-current-buffer (org-capture-get :buffer)
|
||||
(add-to-list 'org-agenda-files (buffer-file-name)))))
|
||||
(my/org-roam-refresh-agenda-list)
|
||||
; Tools ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(use-package ob-async
|
||||
:config
|
||||
(setq ob-async-no-async-languages-alist '("ipython")))
|
||||
(use-package org-pdftools
|
||||
:hook (org-mode . org-pdftools-setup-link))
|
||||
; Exporter ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(use-package ox-hugo
|
||||
:defer t
|
||||
:after ox)
|
||||
(setq org-latex-minted-options '(("breaklines" "true")
|
||||
("tabsize" "4")
|
||||
("autogobble")
|
||||
("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}
|
||||
[DEFAULT-PACKAGES]
|
||||
\\usepackage{kotex}
|
||||
[PACKAGES]
|
||||
[EXTRA]
|
||||
\\linespread{1.1}
|
||||
\\hypersetup{pdfborder=0 0 0}"
|
||||
("\\section{%s}" . "\\section*{%s}")
|
||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||
("\\paragraph{%s}" . "\\paragraph*{%s}")))
|
||||
(add-to-list 'org-latex-classes
|
||||
'("org-plain-latex"
|
||||
"\\documentclass[a4paper,11pt,titlepage]{memoir}
|
||||
\\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm,a4paper]{geometry}
|
||||
[DEFAULT-PACKAGES]
|
||||
\\usepackage{kotex}
|
||||
[PACKAGES]
|
||||
[EXTRA]
|
||||
\\linespread{1.1}
|
||||
\\hypersetup{pdfborder=0 0 0}"
|
||||
("\\chapter{%s}" . "\\chapter*{%s}")
|
||||
("\\section{%s}" . "\\section*{%s}")
|
||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))))
|
||||
(provide 'init-org)
|
||||
;;; init-org.el ends here
|
||||
183
.config/emacs/lisp/init-prog.el
Normal file
183
.config/emacs/lisp/init-prog.el
Normal file
@ -0,0 +1,183 @@
|
||||
;; init-prog.el -*- lexical-binding: t -*-
|
||||
(require 'init-custom)
|
||||
(require 'init-const)
|
||||
(require 'init-funcs)
|
||||
|
||||
;; Tree-sitter support
|
||||
(use-package treesit-auto
|
||||
:hook (after-init . global-treesit-auto-mode)
|
||||
:init (setq treesit-auto-install 'prompt))
|
||||
|
||||
;; Search tool
|
||||
(use-package grep
|
||||
:ensure nil
|
||||
:autoload grep-apply-setting
|
||||
:config
|
||||
(cond
|
||||
((executable-find "ugrep")
|
||||
(grep-apply-setting
|
||||
'grep-command "ugrep --color=auto -0In -e ")
|
||||
(grep-apply-setting
|
||||
'grep-template "ugrep --color=auto -0In -e <R> <D>")
|
||||
(grep-apply-setting
|
||||
'grep-find-command '("ugrep --color=auto -0Inr -e ''" . 30))
|
||||
(grep-apply-setting
|
||||
'grep-find-template "ugrep <C> -0Inr -e <R> <D>"))
|
||||
((executable-find "rg")
|
||||
(grep-apply-setting
|
||||
'grep-command "rg --color=auto --null -nH --no-heading -e ")
|
||||
(grep-apply-setting
|
||||
'grep-template "rg --color=auto --null --no-heading -g '!*/' -e <R> <D>")
|
||||
(grep-apply-setting
|
||||
'grep-find-command '("rg --color=auto --null -nH --no-heading -e ''" . 38))
|
||||
(grep-apply-setting
|
||||
'grep-find-template "rg --color=auto --null -nH --no-heading -e <R> <D>"))))
|
||||
|
||||
;;;; Cross-referencing commands
|
||||
(use-package xref
|
||||
:ensure nil
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; Use faster search tool
|
||||
(add-to-list 'xref-search-program-alist
|
||||
'(ugrep . "xargs -0 ugrep <C> --null -ns -e <R>"))
|
||||
(cond
|
||||
((executable-find "ugrep")
|
||||
(setq xref-search-program 'ugrep))
|
||||
((executable-find "rg")
|
||||
(setq xref-search-program 'ripgrep)))
|
||||
|
||||
;; Select from xref candidates with Ivy
|
||||
(setq xref-show-definitions-function #'xref-show-definitions-completing-read
|
||||
xref-show-xrefs-function #'xref-show-definitions-completing-read)))
|
||||
|
||||
;;;; Jump to definition
|
||||
(use-package dumb-jump
|
||||
:pretty-hydra
|
||||
((:title (pretty-hydra-title "Dump Jump" 'faicon "nf-fa-anchor")
|
||||
:color blue :quit-key ("q" "C-g"))
|
||||
("Jump"
|
||||
(("j" dumb-jump-go "Go")
|
||||
("o" dumb-jump-go-other-window "Go other window")
|
||||
("e" dumb-jump-go-prefer-external "Go external")
|
||||
("x" dumb-jump-go-prefer-external-other-window "Go external other window"))
|
||||
"Other"
|
||||
(("i" dumb-jump-go-prompt "Prompt")
|
||||
("l" dumb-jump-quick-look "Quick look")
|
||||
("b" dumb-jump-back "Back"))))
|
||||
:bind (("M-g o" . dumb-jump-go-other-window)
|
||||
("M-g j" . dumb-jump-go)
|
||||
("M-g i" . dumb-jump-go-prompt)
|
||||
("M-g x" . dumb-jump-go-prefer-external)
|
||||
("M-g z" . dumb-jump-go-prefer-external-other-window)
|
||||
("C-M-j" . dumb-jump-hydra/body))
|
||||
:init
|
||||
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
|
||||
(setq dumb-jump-prefer-searcher 'rg
|
||||
dumb-jump-selector 'ivy))
|
||||
|
||||
;; Code styles
|
||||
(use-package editorconfig
|
||||
:diminish
|
||||
:hook (after-init . editorconfig-mode))
|
||||
|
||||
;; Run commands quickly
|
||||
(use-package quickrun
|
||||
:bind (("C-<f5>" . quickrun)
|
||||
("C-c X" . quickrun)))
|
||||
|
||||
;; Browse devdocs.io documents using EWW
|
||||
(use-package devdocs
|
||||
:autoload (devdocs--installed-docs devdocs--available-docs)
|
||||
:bind (:map prog-mode-map
|
||||
("M-<f1>" . devdocs-dwim)
|
||||
("C-h D" . devdocs-dwim))
|
||||
:init
|
||||
(defconst devdocs-major-mode-docs-alist
|
||||
'((c-mode . ("c"))
|
||||
(c++-mode . ("cpp"))
|
||||
(python-mode . ("python~3.10" "python~2.7"))
|
||||
(ruby-mode . ("ruby~3.1"))
|
||||
(go-mode . ("go"))
|
||||
(rustic-mode . ("rust"))
|
||||
(css-mode . ("css"))
|
||||
(html-mode . ("html"))
|
||||
(julia-mode . ("julia~1.8"))
|
||||
(js-mode . ("javascript" "jquery"))
|
||||
(js2-mode . ("javascript" "jquery"))
|
||||
(emacs-lisp-mode . ("elisp")))
|
||||
"Alist of major-mode and docs.")
|
||||
|
||||
(mapc
|
||||
(lambda (mode)
|
||||
(add-hook (intern (format "%s-hook" (car mode)))
|
||||
(lambda ()
|
||||
(setq-local devdocs-current-docs (cdr mode)))))
|
||||
devdocs-major-mode-docs-alist)
|
||||
|
||||
(setq devdocs-data-dir (expand-file-name "devdocs" user-emacs-directory))
|
||||
|
||||
(defun devdocs-dwim()
|
||||
"Look up a DevDocs documentation entry.
|
||||
|
||||
Install the doc if it's not installed."
|
||||
(interactive)
|
||||
;; Install the doc if it's not installed
|
||||
(mapc
|
||||
(lambda (slug)
|
||||
(unless (member slug (let ((default-directory devdocs-data-dir))
|
||||
(seq-filter #'file-directory-p
|
||||
(when (file-directory-p devdocs-data-dir)
|
||||
(directory-files "." nil "^[^.]")))))
|
||||
(mapc
|
||||
(lambda (doc)
|
||||
(when (string= (alist-get 'slug doc) slug)
|
||||
(devdocs-install doc)))
|
||||
(devdocs--available-docs))))
|
||||
(alist-get major-mode devdocs-major-mode-docs-alist))
|
||||
|
||||
;; Lookup the symbol at point
|
||||
(devdocs-lookup nil (thing-at-point 'symbol t))))
|
||||
|
||||
;;;; Misc. programming modes
|
||||
(use-package csv-mode)
|
||||
(use-package csharp-mode)
|
||||
;;(use-package cask-mode)
|
||||
(use-package cmake-mode)
|
||||
;;(use-package dart-mode)
|
||||
;;(use-package groovy-mode)
|
||||
;;(use-package julia-mode)
|
||||
;;(use-package lua-mode)
|
||||
;;(use-package mermaid-mode)
|
||||
;;(use-package plantuml-mode)
|
||||
(use-package rmsbolt) ; A compiler output viewer
|
||||
;;(use-package scala-mode)
|
||||
;;(use-package swift-mode)
|
||||
;;(use-package v-mode)
|
||||
;;(use-package vimrc-mode)
|
||||
|
||||
;;(use-package protobuf-mode
|
||||
;; :hook (protobuf-mode . (lambda ()
|
||||
;; (setq imenu-generic-expression
|
||||
;; '((nil "^[[:space:]]*\\(message\\|service\\|enum\\)[[:space:]]+\\([[:alnum:]]+\\)" 2))))))
|
||||
|
||||
;;(use-package nxml-mode
|
||||
;; :ensure nil
|
||||
;; :mode (("\\.xaml$" . xml-mode)))
|
||||
|
||||
;; Batch Mode eXtras
|
||||
(use-package bmx-mode
|
||||
:after company
|
||||
:diminish
|
||||
:hook (after-init . bmx-mode-setup-defaults))
|
||||
|
||||
;; Fish shell
|
||||
(use-package fish-mode
|
||||
:hook (fish-mode . (lambda ()
|
||||
(add-hook 'before-save-hook
|
||||
#'fish_indent-before-save))))
|
||||
|
||||
(provide 'init-prog)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-prog.el ends here
|
||||
60
.config/emacs/lisp/init-python.el
Normal file
60
.config/emacs/lisp/init-python.el
Normal file
@ -0,0 +1,60 @@
|
||||
;; init-python.el --- Initialize python configurations. -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2010-2022 Vincent Zhang
|
||||
|
||||
;; Author: Vincent Zhang <seagle0128@gmail.com>
|
||||
;; URL: https://github.com/seagle0128/.emacs.d
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
;; Floor, Boston, MA 02110-1301, USA.
|
||||
;;
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Python configurations.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Python Mode
|
||||
;; Install: pip install pyflakes autopep8
|
||||
(use-package python
|
||||
:ensure nil
|
||||
:hook (inferior-python-mode . (lambda ()
|
||||
(process-query-on-exit-flag
|
||||
(get-process "Python"))))
|
||||
:init
|
||||
;; Disable readline based native completion
|
||||
(setq python-shell-completion-native-enable nil)
|
||||
:config
|
||||
;; Default to Python 3. Prefer the versioned Python binaries since some
|
||||
;; systems stupidly make the unversioned one point at Python 2.
|
||||
(when (and (executable-find "python3")
|
||||
(string= python-shell-interpreter "python"))
|
||||
(setq python-shell-interpreter "python3"))
|
||||
|
||||
;; Env vars
|
||||
(with-eval-after-load 'exec-path-from-shell
|
||||
(exec-path-from-shell-copy-env "PYTHONPATH"))
|
||||
|
||||
;; Live Coding in Python
|
||||
(use-package live-py-mode))
|
||||
|
||||
(provide 'init-python)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-python.el ends here
|
||||
148
.config/emacs/lisp/init-reader.el
Normal file
148
.config/emacs/lisp/init-reader.el
Normal file
@ -0,0 +1,148 @@
|
||||
;;; init-reader.el -*- lexical-binding: t -*-
|
||||
(when (display-graphic-p)
|
||||
(use-package pdf-view
|
||||
:ensure pdf-tools
|
||||
:diminish (pdf-view-themed-minor-mode
|
||||
pdf-view-midnight-minor-mode
|
||||
pdf-view-printer-minor-mode)
|
||||
:defines pdf-annot-activate-created-annotations
|
||||
:hook ((pdf-tools-enabled . pdf-view-auto-slice-minor-mode)
|
||||
(pdf-tools-enabled . pdf-isearch-minor-mode)
|
||||
(pdf-tools-enabled . pdf-view-themed-minor-mode))
|
||||
:mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode)
|
||||
:magic ("%PDF" . pdf-view-mode)
|
||||
:bind (:map pdf-view-mode-map
|
||||
("C-s" . isearch-forward))
|
||||
:init (setq pdf-view-use-scaling t
|
||||
pdf-view-use-imagemagick nil
|
||||
pdf-annot-activate-created-annotations t
|
||||
pdf-view-display-size 'fit-page)
|
||||
:config
|
||||
;; Activate the package
|
||||
(pdf-tools-install t nil t nil)
|
||||
;; my funtion
|
||||
(defun my/pdf-view-open-in-zathura ()
|
||||
(interactive)
|
||||
(save-window-excursion
|
||||
(let ((current-file (buffer-file-name))
|
||||
(current-page (number-to-string (pdf-view-current-page))))
|
||||
(async-shell-command
|
||||
(format "zathura -P %s \"%s\"" current-page current-file))))
|
||||
(message "Sent to zathura"))
|
||||
;; Recover last viewed position
|
||||
(use-package pdf-view-restore
|
||||
:defer t
|
||||
:hook (pdf-view-mode . pdf-view-restore-mode)
|
||||
:config
|
||||
(setq pdf-view-restore-filename
|
||||
(expand-file-name "pdf-view-restore" user-emacs-directory)))))
|
||||
|
||||
|
||||
;; Epub reader
|
||||
(use-package nov
|
||||
:mode ("\\.epub\\'" . nov-mode)
|
||||
:hook (nov-mode . my-nov-setup)
|
||||
:init
|
||||
(defun my-nov-setup ()
|
||||
"Setup `nov-mode' for better reading experience."
|
||||
(visual-line-mode 1)
|
||||
(face-remap-add-relative 'variable-pitch :family "NanumGothic" :height 1.5))
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; WORKAROUND: errors while opening `nov' files with Unicode characters
|
||||
;; @see https://github.com/wasamasa/nov.el/issues/63
|
||||
(defun my-nov-content-unique-identifier (content)
|
||||
"Return the the unique identifier for CONTENT."
|
||||
(let* ((name (nov-content-unique-identifier-name content))
|
||||
(selector (format "package>metadata>identifier[id='%s']"
|
||||
(regexp-quote name)))
|
||||
(id (car (esxml-node-children (esxml-query selector content)))))
|
||||
(and id (intern id))))
|
||||
(advice-add #'nov-content-unique-identifier :override #'my-nov-content-unique-identifier))
|
||||
|
||||
;; Fix encoding issue on Windows
|
||||
(when ON-WINDOWS
|
||||
(setq process-coding-system-alist
|
||||
(cons `(,nov-unzip-program . (gbk . gbk))
|
||||
process-coding-system-alist))))
|
||||
;; Atom/RSS reader
|
||||
(use-package elfeed
|
||||
:pretty-hydra
|
||||
((:title (pretty-hydra-title "Elfeed" 'faicon "nf-fa-rss_square" :face 'nerd-icons-orange)
|
||||
:color amaranth :quit-key ("q" "C-g"))
|
||||
("Search"
|
||||
(("c" elfeed-db-compact "compact db")
|
||||
("g" elfeed-search-update--force "refresh")
|
||||
("G" elfeed-search-fetch "update")
|
||||
("y" elfeed-search-yank "copy URL")
|
||||
("+" elfeed-search-tag-all "tag all")
|
||||
("-" elfeed-search-untag-all "untag all"))
|
||||
"Filter"
|
||||
(("l" elfeed-search-live-filter "live filter")
|
||||
("s" elfeed-search-set-filter "set filter")
|
||||
("*" (elfeed-search-set-filter "@6-months-ago +star") "starred")
|
||||
("a" (elfeed-search-set-filter "@6-months-ago") "all")
|
||||
("t" (elfeed-search-set-filter "@1-day-ago") "today"))
|
||||
"Article"
|
||||
(("b" elfeed-search-browse-url "browse")
|
||||
("n" next-line "next")
|
||||
("p" previous-line "previous")
|
||||
("u" elfeed-search-tag-all-unread "mark unread")
|
||||
("r" elfeed-search-untag-all-unread "mark read")
|
||||
("RET" elfeed-search-show-entry "show"))))
|
||||
;;:init (setq url-queue-timeout 30
|
||||
;; elfeed-show-entry-switch #'pop-to-buffer
|
||||
;; elfeed-show-entry-delete #'delete-window)
|
||||
:config
|
||||
(evil-collection-define-key 'normal 'elfeed-search-mode-map "?" 'elfeed-hydra/body)
|
||||
(evil-collection-define-key 'normal 'elfeed-show-mode-map "q" 'delete-window)
|
||||
;; Ignore db directory in recentf
|
||||
(push elfeed-db-directory recentf-exclude)
|
||||
|
||||
;; Use xwidget if possible
|
||||
(with-no-warnings
|
||||
(defun my-elfeed-show-visit (&optional use-generic-p)
|
||||
"Visit the current entry in your browser using `browse-url'.
|
||||
If there is a prefix argument, visit the current entry in the
|
||||
browser defined by `browse-url-generic-program'."
|
||||
(interactive "P")
|
||||
(let ((link (elfeed-entry-link elfeed-show-entry)))
|
||||
(when link
|
||||
(message "Sent to browser: %s" link)
|
||||
(cond
|
||||
((featurep 'xwidget-internal)
|
||||
(centaur-webkit-browse-url link))
|
||||
(use-generic-p
|
||||
(browse-url-generic link))
|
||||
(t (browse-url link))))))
|
||||
(advice-add #'elfeed-show-visit :override #'my-elfeed-show-visit)
|
||||
|
||||
(defun my-elfeed-search-browse-url (&optional use-generic-p)
|
||||
"Visit the current entry in your browser using `browse-url'.
|
||||
If there is a prefix argument, visit the current entry in the
|
||||
browser defined by `browse-url-generic-program'."
|
||||
(interactive "P")
|
||||
(let ((entries (elfeed-search-selected)))
|
||||
(cl-loop for entry in entries
|
||||
do (elfeed-untag entry 'unread)
|
||||
when (elfeed-entry-link entry)
|
||||
do (cond
|
||||
((featurep 'xwidget-internal)
|
||||
(centaur-webkit-browse-url it t))
|
||||
(use-generic-p
|
||||
(browse-url-generic it))
|
||||
(t (browse-url it))))
|
||||
(mapc #'elfeed-search-update-entry entries)
|
||||
(unless (or elfeed-search-remain-on-entry (use-region-p))
|
||||
(forward-line))))
|
||||
(advice-add #'elfeed-search-browse-url :override #'my-elfeed-search-browse-url)))
|
||||
(use-package elfeed-goodies
|
||||
:defer t)
|
||||
(use-package elfeed-org
|
||||
:defer t
|
||||
:config
|
||||
(elfeed-org)
|
||||
(setq rmh-elfeed-org-files (list (expand-file-name "elfeed.org" org-directory))))
|
||||
|
||||
(provide 'init-reader)
|
||||
;;; init-reader.el ends here
|
||||
71
.config/emacs/lisp/init-ruby.el
Normal file
71
.config/emacs/lisp/init-ruby.el
Normal file
@ -0,0 +1,71 @@
|
||||
;; init-ruby.el --- Initialize ruby configurations. -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2010-2022 Vincent Zhang
|
||||
|
||||
;; Author: Vincent Zhang <seagle0128@gmail.com>
|
||||
;; URL: https://github.com/seagle0128/.emacs.d
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
;; Floor, Boston, MA 02110-1301, USA.
|
||||
;;
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Ruby configurations.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Integrate rbenv
|
||||
(use-package rbenv
|
||||
:hook (after-init . global-rbenv-mode)
|
||||
:init (setq rbenv-show-active-ruby-in-modeline nil))
|
||||
|
||||
;; YAML mode
|
||||
(use-package yaml-mode)
|
||||
|
||||
;; Run a Ruby process in a buffer
|
||||
(use-package inf-ruby
|
||||
:hook ((ruby-mode . inf-ruby-minor-mode)
|
||||
(compilation-filter . inf-ruby-auto-enter)))
|
||||
|
||||
;; Ruby YARD comments
|
||||
(use-package yard-mode
|
||||
:diminish
|
||||
:hook (ruby-mode . yard-mode))
|
||||
|
||||
;; Ruby refactoring helpers
|
||||
(use-package ruby-refactor
|
||||
:diminish
|
||||
:hook (ruby-mode . ruby-refactor-mode-launch))
|
||||
|
||||
;; Yet Another RI interface for Emacs
|
||||
(use-package yari
|
||||
:bind (:map ruby-mode-map ([f1] . yari)))
|
||||
|
||||
;; RSpec
|
||||
(use-package rspec-mode
|
||||
:diminish
|
||||
:autoload rspec-install-snippets
|
||||
:hook (dired-mode . rspec-dired-mode)
|
||||
:config (with-eval-after-load 'yasnippet
|
||||
(rspec-install-snippets)))
|
||||
|
||||
(provide 'init-ruby)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-ruby.el ends here
|
||||
40
.config/emacs/lisp/init-rust.el
Normal file
40
.config/emacs/lisp/init-rust.el
Normal file
@ -0,0 +1,40 @@
|
||||
;; init-rust.el --- Initialize Rust configurations. -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2019-2022 Vincent Zhang
|
||||
|
||||
;; Author: Vincent Zhang <seagle0128@gmail.com>
|
||||
;; URL: https://github.com/seagle0128/.emacs.d
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
;; Floor, Boston, MA 02110-1301, USA.
|
||||
;;
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Rust configurations.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Rust
|
||||
(use-package rustic)
|
||||
(use-package rust-playground)
|
||||
|
||||
(provide 'init-rust)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; init-rust.el ends here
|
||||
78
.config/emacs/lisp/init-utils.el
Normal file
78
.config/emacs/lisp/init-utils.el
Normal file
@ -0,0 +1,78 @@
|
||||
;;; init-utils.el -*- lexical-binding: t -*-
|
||||
(use-package rg)
|
||||
;; Nice writing
|
||||
(use-package olivetti
|
||||
:diminish
|
||||
:bind ("<f7>" . olivetti-mode)
|
||||
:hook (org-mode)
|
||||
:init (setq olivetti-body-width 0.62))
|
||||
|
||||
;; text mode directory tree
|
||||
(use-package ztree
|
||||
:custom-face
|
||||
(ztreep-header-face ((t (:inherit diff-header))))
|
||||
(ztreep-arrow-face ((t (:inherit font-lock-comment-face))))
|
||||
(ztreep-leaf-face ((t (:inherit diff-index))))
|
||||
(ztreep-node-face ((t (:inherit font-lock-variable-name-face))))
|
||||
(ztreep-expand-sign-face ((t (:inherit font-lock-function-name-face))))
|
||||
(ztreep-diff-header-face ((t (:inherit (diff-header bold)))))
|
||||
(ztreep-diff-header-small-face ((t (:inherit diff-file-header))))
|
||||
(ztreep-diff-model-normal-face ((t (:inherit font-lock-doc-face))))
|
||||
(ztreep-diff-model-ignored-face ((t (:inherit font-lock-doc-face :strike-through t))))
|
||||
(ztreep-diff-model-diff-face ((t (:inherit diff-removed))))
|
||||
(ztreep-diff-model-add-face ((t (:inherit diff-nonexistent))))
|
||||
:pretty-hydra
|
||||
((:title (pretty-hydra-title "Ztree" 'octicon "nf-oct-diff" :face 'nerd-icons-green)
|
||||
:color pink :quit-key ("q" "C-g"))
|
||||
("Diff"
|
||||
(("C" ztree-diff-copy "copy" :exit t)
|
||||
("h" ztree-diff-toggle-show-equal-files "show/hide equals" :exit t)
|
||||
("H" ztree-diff-toggle-show-filtered-files "show/hide ignores" :exit t)
|
||||
("D" ztree-diff-delete-file "delete" :exit t)
|
||||
("v" ztree-diff-view-file "view" :exit t)
|
||||
("d" ztree-diff-simple-diff-files "simple diff" :exit t)
|
||||
("r" ztree-diff-partial-rescan "partial rescan" :exit t)
|
||||
("R" ztree-diff-full-rescan "full rescan" :exit t))
|
||||
"View"
|
||||
(("RET" ztree-perform-action "expand/collapse or view" :exit t)
|
||||
("SPC" ztree-perform-soft-action "expand/collapse or view in other" :exit t)
|
||||
("TAB" ztree-jump-side "jump side" :exit t)
|
||||
("g" ztree-refresh-buffer "refresh" :exit t)
|
||||
("x" ztree-toggle-expand-subtree "expand/collapse" :exit t)
|
||||
("<backspace>" ztree-move-up-in-tree "go to parent" :exit t))))
|
||||
:bind (:map ztreediff-mode-map
|
||||
("C-<f5>" . ztree-hydra/body))
|
||||
:init (setq ztree-draw-unicode-lines t
|
||||
ztree-show-number-of-children t))
|
||||
|
||||
(use-package list-environment
|
||||
:hook (list-environment-mode . (lambda ()
|
||||
(setq tabulated-list-format
|
||||
(vconcat `(("" ,(if (icons-displayable-p) 2 0)))
|
||||
tabulated-list-format))
|
||||
(tabulated-list-init-header)))
|
||||
:init
|
||||
(with-no-warnings
|
||||
(defun my-list-environment-entries ()
|
||||
"Generate environment variable entries list for tabulated-list."
|
||||
(mapcar (lambda (env)
|
||||
(let* ((kv (split-string env "="))
|
||||
(key (car kv))
|
||||
(val (mapconcat #'identity (cdr kv) "=")))
|
||||
(list key (vector
|
||||
""
|
||||
;;(if (icons-displayable-p)
|
||||
;; (nerd-icons-octicon "key" :height 0.8 :v-adjust -0.05)
|
||||
;; "")
|
||||
`(,key face font-lock-keyword-face)
|
||||
`(,val face font-lock-string-face)))))
|
||||
process-environment))
|
||||
(advice-add #'list-environment-entries :override #'my-list-environment-entries)))
|
||||
|
||||
(unless ON-WINDOWS
|
||||
(use-package daemons) ; system services/daemons
|
||||
(use-package tldr))
|
||||
|
||||
|
||||
(provide 'init-utils)
|
||||
;;; init-utils.el ends here
|
||||
118
.config/emacs/lisp/init-vcs.el
Normal file
118
.config/emacs/lisp/init-vcs.el
Normal file
@ -0,0 +1,118 @@
|
||||
;;; init-vcs.el -*- lexical-binding: t -*-
|
||||
(require 'init-const)
|
||||
(require 'init-funcs)
|
||||
|
||||
;; Git
|
||||
;; See `magit-maybe-define-global-key-bindings'
|
||||
(use-package magit
|
||||
:commands (magit-status magit-get-current-branch)
|
||||
:init (setq magit-diff-refine-hunk t)
|
||||
:config
|
||||
(setq magit-clone-default-directory "~/Project/")
|
||||
(when ON-WINDOWS
|
||||
(setenv "GIT_ASKPASS" "git-gui--askpass"))
|
||||
|
||||
;; Exterminate Magit buffers
|
||||
(with-no-warnings
|
||||
(defun my-magit-kill-buffers (&rest _)
|
||||
"Restore window configuration and kill all Magit buffers."
|
||||
(interactive)
|
||||
(magit-restore-window-configuration)
|
||||
(let ((buffers (magit-mode-get-buffers)))
|
||||
(when (eq major-mode 'magit-status-mode)
|
||||
(mapc (lambda (buf)
|
||||
(with-current-buffer buf
|
||||
(if (and magit-this-process
|
||||
(eq (process-status magit-this-process) 'run))
|
||||
(bury-buffer buf)
|
||||
(kill-buffer buf))))
|
||||
buffers))))
|
||||
(setq magit-bury-buffer-function #'my-magit-kill-buffers))
|
||||
|
||||
;; Show TODOs in magit
|
||||
(use-package magit-todos
|
||||
:defines magit-todos-nice
|
||||
:commands magit-todos--scan-with-git-grep
|
||||
:init
|
||||
(setq magit-todos-nice (if (executable-find "nice") t nil))
|
||||
(setq magit-todos-scanner #'magit-todos--scan-with-git-grep)
|
||||
(let ((inhibit-message t))
|
||||
(magit-todos-mode 1))))
|
||||
|
||||
;; Walk through git revisions of a file
|
||||
(use-package git-timemachine
|
||||
:custom-face
|
||||
(git-timemachine-minibuffer-author-face ((t (:inherit success :foreground unspecified))))
|
||||
(git-timemachine-minibuffer-detail-face ((t (:inherit warning :foreground unspecified))))
|
||||
:hook ((git-timemachine-mode . (lambda ()
|
||||
"Improve `git-timemachine' buffers."
|
||||
;; Display different colors in mode-line
|
||||
(if (facep 'mode-line-active)
|
||||
(face-remap-add-relative 'mode-line-active 'custom-state)
|
||||
(face-remap-add-relative 'mode-line 'custom-state))
|
||||
|
||||
;; Highlight symbols in elisp
|
||||
(and (derived-mode-p 'emacs-lisp-mode)
|
||||
(fboundp 'highlight-defined-mode)
|
||||
(highlight-defined-mode t))
|
||||
|
||||
;; Display line numbers
|
||||
(and (derived-mode-p 'prog-mode 'yaml-mode)
|
||||
(fboundp 'display-line-numbers-mode)
|
||||
(display-line-numbers-mode t))))
|
||||
(before-revert . (lambda ()
|
||||
(when (bound-and-true-p git-timemachine-mode)
|
||||
(user-error "Cannot revert the timemachine buffer"))))))
|
||||
;; Resolve diff3 conflicts
|
||||
(use-package smerge-mode
|
||||
:ensure nil
|
||||
:diminish
|
||||
:pretty-hydra
|
||||
((:title (pretty-hydra-title "Smerge" 'octicon "nf-oct-diff")
|
||||
:color pink :quit-key ("q" "C-g"))
|
||||
("Move"
|
||||
(("n" smerge-next "next")
|
||||
("p" smerge-prev "previous"))
|
||||
"Keep"
|
||||
(("b" smerge-keep-base "base")
|
||||
("u" smerge-keep-upper "upper")
|
||||
("l" smerge-keep-lower "lower")
|
||||
("a" smerge-keep-all "all")
|
||||
("RET" smerge-keep-current "current")
|
||||
("C-m" smerge-keep-current "current"))
|
||||
"Diff"
|
||||
(("<" smerge-diff-base-upper "upper/base")
|
||||
("=" smerge-diff-upper-lower "upper/lower")
|
||||
(">" smerge-diff-base-lower "upper/lower")
|
||||
("R" smerge-refine "refine")
|
||||
("E" smerge-ediff "ediff"))
|
||||
"Other"
|
||||
(("C" smerge-combine-with-next "combine")
|
||||
("r" smerge-resolve "resolve")
|
||||
("k" smerge-kill-current "kill")
|
||||
("ZZ" (lambda ()
|
||||
(interactive)
|
||||
(save-buffer)
|
||||
(bury-buffer))
|
||||
"Save and bury buffer" :exit t))))
|
||||
:bind (:map smerge-mode-map
|
||||
("C-c m" . smerge-mode-hydra/body))
|
||||
:hook ((find-file . (lambda ()
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^<<<<<<< " nil t)
|
||||
(smerge-mode 1)))))
|
||||
(magit-diff-visit-file . (lambda ()
|
||||
(when smerge-mode
|
||||
(smerge-mode-hydra/body))))))
|
||||
;; Open github/gitlab/bitbucket page
|
||||
(use-package browse-at-remote
|
||||
:bind (:map vc-prefix-map
|
||||
("B" . browse-at-remote)))
|
||||
|
||||
;; Git configuration modes
|
||||
(use-package git-modes)
|
||||
|
||||
|
||||
(provide 'init-vcs)
|
||||
;;; init-vcs.el ends here
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
(when (display-graphic-p)
|
||||
(use-package vertico-posframe
|
||||
:disabled
|
||||
:after vertico
|
||||
:hook (vertico-mode . vertico-posframe-mode)
|
||||
:config
|
||||
|
||||
@ -41,6 +41,10 @@ paru -S tmux --noconfirm
|
||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
TMUX_PLUGIN_MANAGER_PATH=~/.config/tmux/plugins/tpm ~/.tmux/plugins/tpm/scripts/install_plugins.sh
|
||||
TMUX_PLUGIN_MANAGER_PATH=~/.config/tmux/plugins/tpm ~/.tmux/plugins/tpm/bin/update_plugins all
|
||||
##################################################
|
||||
# tldr
|
||||
##################################################
|
||||
paru -S tldr --noconfirm
|
||||
|
||||
##################################################
|
||||
# Wallpaper
|
||||
@ -53,7 +57,7 @@ git clone https://git.jaeus.net/walls
|
||||
##################################################
|
||||
# Fonts
|
||||
##################################################
|
||||
paru -S ttf-firacode-nerd ttf-nanum noto-fonts-emoji ttf-symbola noto-font-cjk --noconfirm
|
||||
paru -S ttf-firacode-nerd ttf-momonoki-nerd ttf-times-new-roman ttf-nanum noto-fonts-emoji ttf-symbola noto-font-cjk --noconfirm
|
||||
|
||||
##################################################
|
||||
# EMACS Related
|
||||
@ -65,8 +69,9 @@ paru -S ripgrep emacs texlive-most texlive-lang --noconfirm
|
||||
paru -S python python-pip jupyter openssh inetutils --noconfirm
|
||||
pip install matplotlib numpy pandas tabulate
|
||||
|
||||
# verilator for lsp
|
||||
# verilator for syntax checker
|
||||
paru -S verilator --noconfirm
|
||||
paru -S uctags-git --noconfirm
|
||||
|
||||
# nov
|
||||
paru -S zip unzip --noconfirm
|
||||
|
||||
Reference in New Issue
Block a user