mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
breaking: Remove setup script and use chezmoi
This commit is contained in:
parent
02bbb24cac
commit
0051a163c3
190 changed files with 118 additions and 3456 deletions
3
tools/doom/.gitignore
vendored
3
tools/doom/.gitignore
vendored
|
|
@ -1,3 +0,0 @@
|
|||
.custom.el
|
||||
local.el
|
||||
themes/
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
;;; init-beancount.el --- beancount support -*- lexical-binding: t -*-
|
||||
(after! beancount
|
||||
|
||||
;; 1. 自动启用 outline-minor-mode
|
||||
(add-hook! 'beancount-mode-hook #'outline-minor-mode)
|
||||
|
||||
;; 2. 设置大纲导航快捷键 (使用 Doom 的 map! 宏)
|
||||
(map! :map beancount-mode-map
|
||||
"C-c C-n" #'outline-next-visible-heading
|
||||
"C-c C-p" #'outline-previous-visible-heading)
|
||||
|
||||
;; 3. 核心功能:跨文件账户补全 (这部分逻辑完全保留)
|
||||
(defvar my-beancount-accounts-files nil "List of account files.")
|
||||
(setq my-beancount-accounts-files
|
||||
(directory-files "~/Documents/Finance/Beancount/config/" 'full (rx ".beancount" eos)))
|
||||
|
||||
(defun my-beancount--collect-accounts-from-files (oldfun &rest args)
|
||||
"Collect all accounts from files specified in `my-beancount-accounts-files'."
|
||||
(let ((keys (apply oldfun args))
|
||||
(hash (make-hash-table :test 'equal)))
|
||||
(dolist (key keys)
|
||||
(puthash key nil hash))
|
||||
;; collect accounts from files
|
||||
(save-excursion
|
||||
(dolist (f my-beancount-accounts-files)
|
||||
;; `ignore-errors` is a good practice for file operations
|
||||
(ignore-errors
|
||||
(with-current-buffer (find-file-noselect f)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward beancount-account-regexp nil t)
|
||||
(puthash (match-string-no-properties 1) nil hash))))))
|
||||
(hash-table-keys hash)))
|
||||
|
||||
(advice-add #'beancount-collect
|
||||
:around #'my-beancount--collect-accounts-from-files))
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
;;; ~/.doom.d/+calendar.el -*- lexical-binding: t; -*-
|
||||
;;; https://github.com/cnsunyour/.doom.d/blob/master/modules/cnsunyour/calendar/config.el
|
||||
|
||||
|
||||
;; 日历及纪念日相关设置
|
||||
|
||||
;; 定义可以设置农历纪念日的函数
|
||||
;; (defun cnsunyour/diary-chinese-anniversary (lunar-month lunar-day &optional year mark)
|
||||
;; (if year
|
||||
;; (let* ((d-date (diary-make-date lunar-month lunar-day year))
|
||||
;; (a-date (calendar-absolute-from-gregorian d-date))
|
||||
;; (c-date (calendar-chinese-from-absolute a-date))
|
||||
;; (cycle (car c-date))
|
||||
;; (yy (cadr c-date))
|
||||
;; (y (+ (* 100 cycle) yy)))
|
||||
;; (diary-chinese-anniversary lunar-month lunar-day y mark))
|
||||
;; (diary-chinese-anniversary lunar-month lunar-day year mark)))
|
||||
|
||||
(setq calendar-date-style 'iso)
|
||||
(setq diary-date-forms '((year "年" month "月" day "日" " 星期[" "日一二三四五六" "]") ;; Chinese
|
||||
(year "-" month "-" day) ;; ISO
|
||||
(month "[-/]" day "[^-/0-9]") (year "[-/]" month "[-/]" day "[^0-9]")
|
||||
(monthname " *" day "[^-0-9]") (year " *" monthname " *" day "[^0-9]")
|
||||
(dayname "\\W")))
|
||||
|
||||
(setq calendar-mark-holidays-flag t
|
||||
calendar-week-start-day 1)
|
||||
|
||||
(use-package! cal-china-x
|
||||
:custom
|
||||
(cal-china-x-important-holidays '((holiday-chinese-new-year)
|
||||
(holiday-lunar 12 23 "小年(北)" 1)
|
||||
(holiday-lunar 12 24 "小年(南)" 1)
|
||||
(holiday-lunar 12 30 "除夕" 1)
|
||||
(holiday-lunar 1 1 "春节" 0)
|
||||
(holiday-lunar 1 2 "春节" 0)
|
||||
(holiday-lunar 1 3 "春节" 0)
|
||||
(holiday-lunar 1 4 "春节" 0)
|
||||
(holiday-lunar 1 5 "春节(破五)" 0)
|
||||
(holiday-lunar 1 15 "元宵节" 0)
|
||||
(holiday-lunar 2 2 "龙抬头" 0)
|
||||
(holiday-solar-term "清明" "清明节")
|
||||
(holiday-fixed 5 1 "劳动节")
|
||||
(holiday-lunar 5 5 "端午节" 0)
|
||||
(holiday-lunar 7 7 "七夕节" 0)
|
||||
(holiday-lunar 7 15 "中元节" 0)
|
||||
(holiday-lunar 8 15 "中秋节" 0)
|
||||
(holiday-fixed 10 1 "国庆节")
|
||||
(holiday-fixed 10 2 "国庆节")
|
||||
(holiday-fixed 10 3 "国庆节")
|
||||
(holiday-lunar 9 9 "重阳节" 0)
|
||||
(holiday-lunar 10 1 "寒衣节" 0)
|
||||
(holiday-lunar 12 8 "腊八" 1)
|
||||
(holiday-solar-term "立春" "立春")
|
||||
(holiday-solar-term "立夏" "立夏")
|
||||
(holiday-solar-term "立秋" "立秋")
|
||||
(holiday-solar-term "立冬" "立冬")
|
||||
(holiday-solar-term "春分" "春分")
|
||||
(holiday-solar-term "夏至" "夏至")
|
||||
(holiday-solar-term "秋分" "秋分")
|
||||
(holiday-solar-term "冬至" "冬至")))
|
||||
(cal-china-x-general-holidays '((holiday-fixed 1 1 "元旦")
|
||||
(holiday-fixed 2 14 "情人节")
|
||||
(holiday-fixed 3 8 "妇女节")
|
||||
(holiday-fixed 4 1 "愚人节")
|
||||
(holiday-fixed 5 4 "青年节")
|
||||
(holiday-float 5 0 2 "母亲节")
|
||||
(holiday-fixed 6 1 "儿童节")
|
||||
(holiday-float 6 0 3 "父亲节")
|
||||
(holiday-fixed 9 10 "教师节")
|
||||
(holiday-float 11 4 4 "感恩节")
|
||||
(holiday-fixed 12 25 "圣诞节")))
|
||||
:config
|
||||
(setq calendar-holidays (append cal-china-x-important-holidays
|
||||
cal-china-x-general-holidays)))
|
||||
|
||||
;; diary
|
||||
|
||||
(setq diary-file "~/.local/js0ny/diary")
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Place your private configuration here! Remember, you do not need to run 'doom
|
||||
;; sync' after modifying this file!
|
||||
|
||||
|
||||
;; Some functionality uses this to identify you, e.g. GPG configuration, email
|
||||
;; clients, file templates and snippets. It is optional.
|
||||
;; (setq user-full-name "John Doe"
|
||||
;; user-mail-address "john@doe.com")
|
||||
|
||||
;; Doom exposes five (optional) variables for controlling fonts in Doom:
|
||||
;;
|
||||
;; - `doom-font' -- the primary font to use
|
||||
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
|
||||
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
|
||||
;; presentations or streaming.
|
||||
;; - `doom-symbol-font' -- for symbols
|
||||
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
|
||||
;;
|
||||
;; See 'C-h v doom-font' for documentation and more examples of what they
|
||||
;; accept. For example:
|
||||
;;
|
||||
;; https://emacs-china.org/t/doom-emacs/23513/13
|
||||
(setq doom-font (font-spec :family "Maple Mono NF CN" :size 14)
|
||||
doom-serif-font doom-font
|
||||
doom-symbol-font (font-spec :family "Maple Mono NF CN")
|
||||
doom-variable-pitch-font (font-spec :family "Maple Mono NF CN" :weight 'extra-bold))
|
||||
|
||||
;; 如果不把这玩意设置为 nil, 会默认去用 fontset-default 来展示, 配置无效
|
||||
(setq use-default-font-for-symbols nil)
|
||||
|
||||
;; Doom 的字体加载顺序问题, 如果不设定这个 hook, 配置会被覆盖失效
|
||||
;;(add-hook! 'after-setting-font-hook
|
||||
;; (set-fontset-font t 'latin (font-spec :family "Iosevka Nerd Font Propo"))
|
||||
;; (set-fontset-font t 'symbol (font-spec :family "Symbola"))
|
||||
;; (set-fontset-font t 'mathematical (font-spec :family "Symbola"))
|
||||
;; (set-fontset-font t 'emoji (font-spec :family "Symbola")))
|
||||
|
||||
;; (dolist (charset '(kana han cjk-misc bopomofo))
|
||||
;; (set-fontset-font t charset (font-spec :family "LXGW WenKai Mono" :size 16)))
|
||||
;;
|
||||
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
|
||||
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
|
||||
;; refresh your font settings. If Emacs still can't find your font, it likely
|
||||
;; wasn't installed correctly. Font issues are rarely Doom issues!
|
||||
|
||||
;; There are two ways to load a theme. Both assume the theme is installed and
|
||||
;; available. You can either set `doom-theme' or manually load a theme with the
|
||||
;; `load-theme' function. This is the default:
|
||||
(setq doom-theme 'catppuccin)
|
||||
(setq catppuccin-flavor 'mocha)
|
||||
;(catppuccin-reload)
|
||||
|
||||
;; This determines the style of line numbers in effect. If set to `nil', line
|
||||
;; numbers are disabled. For relative line numbers, set this to `relative'.
|
||||
(setq display-line-numbers t)
|
||||
(setq display-line-numbers-type 'visual)
|
||||
|
||||
|
||||
|
||||
|
||||
;; Whenever you reconfigure a package, make sure to wrap your config in an
|
||||
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
|
||||
;;
|
||||
;; (after! PACKAGE
|
||||
;; (setq x y))
|
||||
;;
|
||||
;; The exceptions to this rule:
|
||||
;;
|
||||
;; - Setting file/directory variables (like `org-directory')
|
||||
;; - Setting variables which explicitly tell you to set them before their
|
||||
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
|
||||
;; - Setting doom variables (which start with 'doom-' or '+').
|
||||
;;
|
||||
;; Here are some additional functions/macros that will help you configure Doom.
|
||||
;;
|
||||
;; - `load!' for loading external *.el files relative to this one
|
||||
;; - `use-package!' for configuring packages
|
||||
;; - `after!' for running code after a package has loaded
|
||||
;; - `add-load-path!' for adding directories to the `load-path', relative to
|
||||
;; this file. Emacs searches the `load-path' when you load packages with
|
||||
;; `require' or `use-package'.
|
||||
;; - `map!' for binding new keys
|
||||
;;
|
||||
;; To get information about any of these functions/macros, move the cursor over
|
||||
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
|
||||
;; This will open documentation for it, including demos of how they are used.
|
||||
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
|
||||
;; etc).
|
||||
;;
|
||||
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
|
||||
;; they are implemented.
|
||||
|
||||
(add-to-list 'load-path (expand-file-name "lisp" doom-user-dir))
|
||||
(setq doom-local-dir (expand-file-name "emacs" (getenv "XDG_DATA_HOME")))
|
||||
(setq doom-data-dir (expand-file-name "etc" doom-local-dir))
|
||||
|
||||
(after! recentf
|
||||
(setq recentf-max-saved-items 200)
|
||||
(add-to-list 'recentf-exclude "\\.revive$")
|
||||
(add-to-list 'recentf-exclude "\\.windows$")
|
||||
(add-to-list 'recentf-exclude "\\.#.+$")
|
||||
(add-to-list 'recentf-exclude "^/tmp/")
|
||||
(add-to-list 'recentf-exclude "COMMIT_EDITMSG\\'")
|
||||
)[1][2]
|
||||
|
||||
|
||||
|
||||
(after! wakatime-mode
|
||||
(global-wakatime-mode)
|
||||
(setq wakatime-cli-path "~/.local/bin/wakatime"))
|
||||
|
||||
;; accept completion from copilot and fallback to company
|
||||
(use-package! copilot
|
||||
:hook (prog-mode . copilot-mode)
|
||||
:bind (:map copilot-completion-map
|
||||
("<tab>" . 'copilot-accept-completion)
|
||||
("TAB" . 'copilot-accept-completion)
|
||||
("C-TAB" . 'copilot-accept-completion-by-word)
|
||||
("C-<tab>" . 'copilot-accept-completion-by-word)))
|
||||
|
||||
(load! "evil.el")
|
||||
|
||||
(load! "treemacs.el")
|
||||
|
||||
(load! "org.el")
|
||||
|
||||
(after! evil-matchit
|
||||
(global-evil-matchit-mode 1)
|
||||
)
|
||||
|
||||
|
||||
(if (eq system-type 'gnu/linux)
|
||||
(use-package! rime
|
||||
:custom
|
||||
(rime-user-data-dir (expand-file-name "emacs-rime" (getenv "XDG_CONFIG_HOME")))
|
||||
; (rime-share-data-dir "~/.local/share/fcitx5/rime")
|
||||
(default-input-method "rime")
|
||||
;; :config
|
||||
;; (add-hook! (org-mode markdown-mode) (activate-input-method default-input-method))
|
||||
))
|
||||
|
||||
(load! "calendar.el")
|
||||
|
||||
(when (file-exists-p (expand-file-name "local.el" doom-user-dir))
|
||||
(load! "local.el"))
|
||||
|
||||
;; (load! "telega.el")
|
||||
|
||||
(use-package! eee
|
||||
:config
|
||||
(if (eq system-type 'gnu/linux)
|
||||
(setq ee-terminal-command "kitty"))
|
||||
)
|
||||
|
||||
|
||||
(load! "beancount.el")
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
(map!
|
||||
:nvm "H" 'evil-prev-buffer
|
||||
:nvm "L" 'evil-next-buffer
|
||||
:nvom "J" '(lambda () (interactive) (evil-next-line 5)) ; 5j
|
||||
:nvom "K" '(lambda () (interactive) (evil-previous-line 5)) ; 5k
|
||||
)
|
||||
|
||||
;; Swap ; and :
|
||||
(map! :leader
|
||||
";" #'execute-extended-command
|
||||
":" #'pp-eval-expression
|
||||
"f h" #'consult-recent-file
|
||||
"b D" #'kill-some-buffers
|
||||
"f c" #'doom/open-private-config
|
||||
"f C" #'editorconfig-find-current-editorconfig)
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
;;; init.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; This file controls what Doom modules are enabled and what order they load
|
||||
;; in. Remember to run 'doom sync' after modifying it!
|
||||
|
||||
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
|
||||
;; documentation. There you'll find a link to Doom's Module Index where all
|
||||
;; of our modules are listed, including what flags they support.
|
||||
|
||||
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
|
||||
;; 'C-c c k' for non-vim users) to view its documentation. This works on
|
||||
;; flags as well (those symbols that start with a plus).
|
||||
;;
|
||||
;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
|
||||
;; directory (for easy access to its source code).
|
||||
|
||||
(doom! :input
|
||||
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
|
||||
;;; 关闭 chinese 以启用 best Chinese IME
|
||||
;; chinese
|
||||
;;japanese
|
||||
;;layout ; auie,ctsrnm is the superior home row
|
||||
|
||||
:completion
|
||||
;;company ; the ultimate code completion backend
|
||||
(corfu +orderless) ; complete with cap(f), cape and a flying feather!
|
||||
;;helm ; the *other* search engine for love and life
|
||||
;;ido ; the other *other* search engine...
|
||||
;;ivy ; a search engine for love and life
|
||||
vertico ; the search engine of the future
|
||||
|
||||
:ui
|
||||
;;deft ; notational velocity for Emacs
|
||||
doom ; what makes DOOM look the way it does
|
||||
doom-dashboard ; a nifty splash screen for Emacs
|
||||
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
|
||||
;;(emoji +unicode) ; 🙂
|
||||
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
|
||||
indent-guides ; highlighted indent columns
|
||||
ligatures ; ligatures and symbols to make your code pretty again
|
||||
minimap ; show a map of the code on the side
|
||||
modeline ; snazzy, Atom-inspired modeline, plus API
|
||||
;;nav-flash ; blink cursor line after big motions
|
||||
;;neotree ; a project drawer, like NERDTree for vim
|
||||
ophints ; highlight the region an operation acts on
|
||||
(popup +defaults) ; tame sudden yet inevitable temporary windows
|
||||
tabs ; a tab bar for Emacs
|
||||
treemacs ; a project drawer, like neotree but cooler
|
||||
unicode ; extended unicode support for various languages
|
||||
(vc-gutter +pretty) ; vcs diff in the fringe
|
||||
vi-tilde-fringe ; fringe tildes to mark beyond EOB
|
||||
;;window-select ; visually switch windows
|
||||
workspaces ; tab emulation, persistence & separate workspaces
|
||||
;;zen ; distraction-free coding or writing
|
||||
|
||||
:editor
|
||||
(evil +everywhere); come to the dark side, we have cookies
|
||||
file-templates ; auto-snippets for empty files
|
||||
fold ; (nigh) universal code folding
|
||||
(format +onsave) ; automated prettiness
|
||||
;;god ; run Emacs commands without modifier keys
|
||||
;;lispy ; vim for lisp, for people who don't like vim
|
||||
multiple-cursors ; editing in many places at once
|
||||
;;objed ; text object editing for the innocent
|
||||
;;parinfer ; turn lisp into python, sort of
|
||||
;;rotate-text ; cycle region at point between text candidates
|
||||
snippets ; my elves. They type so I don't have to
|
||||
word-wrap ; soft wrapping with language-aware indent
|
||||
|
||||
:emacs
|
||||
dired ; making dired pretty [functional]
|
||||
electric ; smarter, keyword-based electric-indent
|
||||
;;eww ; the internet is gross
|
||||
;;ibuffer ; interactive buffer management
|
||||
undo ; persistent, smarter undo for your inevitable mistakes
|
||||
vc ; version-control and Emacs, sitting in a tree
|
||||
|
||||
:term
|
||||
eshell ; the elisp shell that works everywhere
|
||||
;;shell ; simple shell REPL for Emacs
|
||||
;;term ; basic terminal emulator for Emacs
|
||||
;;vterm ; the best terminal emulation in Emacs
|
||||
|
||||
:checkers
|
||||
syntax ; tasing you for every semicolon you forget
|
||||
;;(spell +flyspell) ; tasing you for misspelling mispelling
|
||||
grammar ; tasing grammar mistake every you make
|
||||
|
||||
:tools
|
||||
;;ansible
|
||||
;;biblio ; Writes a PhD for you (citation needed)
|
||||
;;collab ; buffers with friends
|
||||
;;debugger ; FIXME stepping through code, to help you add bugs
|
||||
;;direnv
|
||||
;;docker
|
||||
editorconfig ; let someone else argue about tabs vs spaces
|
||||
;;ein ; tame Jupyter notebooks with emacs
|
||||
(eval +overlay) ; run code, run (also, repls)
|
||||
lookup ; navigate your code and its documentation
|
||||
lsp ; M-x vscode
|
||||
magit ; a git porcelain for Emacs
|
||||
;;make ; run make tasks from Emacs
|
||||
;;pass ; password manager for nerds
|
||||
;;pdf ; pdf enhancements
|
||||
;;prodigy ; FIXME managing external services & code builders
|
||||
;;terraform ; infrastructure as code
|
||||
;;tmux ; an API for interacting with tmux
|
||||
tree-sitter ; syntax and parsing, sitting in a tree...
|
||||
;;upload ; map local to remote projects via ssh/ftp
|
||||
|
||||
:os
|
||||
(:if (featurep :system 'macos) macos) ; improve compatibility with macOS
|
||||
;;tty ; improve the terminal Emacs experience
|
||||
|
||||
:lang
|
||||
;;agda ; types of types of types of types...
|
||||
beancount ; mind the GAAP
|
||||
(cc +lsp) ; C > C++ == 1
|
||||
;;clojure ; java with a lisp
|
||||
;;common-lisp ; if you've seen one lisp, you've seen them all
|
||||
;;coq ; proofs-as-programs
|
||||
;;crystal ; ruby at the speed of c
|
||||
;;csharp ; unity, .NET, and mono shenanigans
|
||||
data ; config/data formats
|
||||
;;(dart +flutter) ; paint ui and not much else
|
||||
;;dhall
|
||||
;;elixir ; erlang done right
|
||||
;;elm ; care for a cup of TEA?
|
||||
emacs-lisp ; drown in parentheses
|
||||
;;erlang ; an elegant language for a more civilized age
|
||||
;;ess ; emacs speaks statistics
|
||||
;;factor
|
||||
;;faust ; dsp, but you get to keep your soul
|
||||
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
|
||||
;;fsharp ; ML stands for Microsoft's Language
|
||||
;;fstar ; (dependent) types and (monadic) effects and Z3
|
||||
;;gdscript ; the language you waited for
|
||||
;;(go +lsp) ; the hipster dialect
|
||||
;;(graphql +lsp) ; Give queries a REST
|
||||
(haskell +lsp) ; a language that's lazier than I am
|
||||
;;hy ; readability of scheme w/ speed of python
|
||||
;;idris ; a language you can depend on
|
||||
(json +lsp +tree-sitter) ; At least it ain't XML
|
||||
;;(java +lsp) ; the poster child for carpal tunnel syndrome
|
||||
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||
;;julia ; a better, faster MATLAB
|
||||
;;kotlin ; a better, slicker Java(Script)
|
||||
(latex +latexmk +cdlatex +lsp) ; writing papers in Emacs has never been so fun
|
||||
;;lean ; for folks with too much to prove
|
||||
;;ledger ; be audit you can be
|
||||
;lua ; one-based indices? one-based indices
|
||||
markdown ; writing docs for people to ignore
|
||||
;;nim ; python + lisp at the speed of c
|
||||
nix ; I hereby declare "nix geht mehr!"
|
||||
;;ocaml ; an objective camel
|
||||
(org ; organize your plain life in plain text
|
||||
+pomodoro
|
||||
+dragndrop
|
||||
+noter
|
||||
+pandoc
|
||||
+pretty
|
||||
)
|
||||
;;php ; perl's insecure younger brother
|
||||
;;plantuml ; diagrams for confusing people more
|
||||
;;graphviz ; diagrams for confusing yourself even more
|
||||
;;purescript ; javascript, but functional
|
||||
(python +lsp +tree-sitter +pyright) ; beautiful is better than ugly
|
||||
;;qt ; the 'cutest' gui framework ever
|
||||
;;racket ; a DSL for DSLs
|
||||
;;raku ; the artist formerly known as perl6
|
||||
;;rest ; Emacs as a REST client
|
||||
;;rst ; ReST in peace
|
||||
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
|
||||
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
||||
;;scala ; java, but good
|
||||
(scheme +guile) ; a fully conniving family of lisps
|
||||
(sh +lsp +tree-sitter +fish) ; she sells {ba,z,fi}sh shells on the C xor
|
||||
;;sml
|
||||
;;solidity ; do you need a blockchain? No.
|
||||
;;swift ; who asked for emoji variables?
|
||||
;;terra ; Earth and Moon in alignment for performance.
|
||||
;;web ; the tubes
|
||||
(yaml +lsp +tree-sitter) ; JSON, but readable
|
||||
;;zig ; C, but simpler
|
||||
|
||||
:email
|
||||
(mu4e +org +gmail)
|
||||
;;notmuch
|
||||
;;(wanderlust +gmail)
|
||||
|
||||
:app
|
||||
calendar
|
||||
;;emms
|
||||
;;everywhere ; *leave* Emacs!? You must be joking
|
||||
;;irc ; how neckbeards socialize
|
||||
(rss +org) ; emacs as an RSS reader
|
||||
|
||||
:config
|
||||
;;literate
|
||||
(default +bindings +smartparens)
|
||||
:personal
|
||||
telega
|
||||
)
|
||||
|
||||
(setq custom-file (expand-file-name ".custom.el" doom-user-dir))
|
||||
(load custom-file t)
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
;;; org-pomodoro-music-controller.el --- Play music during org-pomodoro breaks -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
;;; Add music control to org-pomodoro breaks.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-pomodoro)
|
||||
|
||||
;; Variables
|
||||
|
||||
(defcustom org-pomodoro-music-player-command
|
||||
(cond
|
||||
((eq system-type 'windows-nt) "clmcontrol")
|
||||
((eq system-type 'darwin) "nowplaying-cli")
|
||||
((eq system-type 'gnu/linux) "playerctl")
|
||||
(t "playerctl"))
|
||||
"Command to control the music player."
|
||||
:type 'string
|
||||
:group 'org-pomodoro)
|
||||
|
||||
|
||||
(defcustom org-pomodoro-music-player-args nil
|
||||
"Arguments to pass to the music player command."
|
||||
:type '(repeat string)
|
||||
:group 'org-pomodoro)
|
||||
|
||||
|
||||
(defun org-pomodoro-music-get-status ()
|
||||
"Get thestatus of the music player."
|
||||
(with-temp-buffer
|
||||
(let ((args (append org-pomodoro-music-player-args '("status"))))
|
||||
(apply #'call-process org-pomodoro-music-player-command nil t nil args)
|
||||
(string-trim (buffer-string)))))
|
||||
|
||||
(defun org-pomodoro-music-is-playing-p ()
|
||||
"Check if the music player is playing."
|
||||
(let ((status (org-pomodoro-music-get-status)))
|
||||
(string= status "Playing")))
|
||||
|
||||
(defun org-pomodoro-music-pause ()
|
||||
"Stop the music player."
|
||||
(let ((args (append org-pomodoro-music-player-args '("pause"))))
|
||||
(apply #'call-process org-pomodoro-music-player-command nil nil nil args)))
|
||||
|
||||
(defun org-pomodoro-music-play ()
|
||||
"Start the music player."
|
||||
(let ((args (append org-pomodoro-music-player-args '("play"))))
|
||||
(apply #'call-process org-pomodoro-music-player-command nil nil nil args)))
|
||||
|
||||
;; Defining Hooks
|
||||
(defun org-pomodoro-music-break-started-hook ()
|
||||
"When a break start, pause the music player."
|
||||
(setq org-pomodoro-music-was-playing (org-pomodoro-music-is-playing-p))
|
||||
(when org-pomodoro-music-was-playing
|
||||
(org-pomodoro-music-pause)
|
||||
(message "休息开始,音乐已暂停")))
|
||||
|
||||
;; (defun org-pomodoro-music-break-finished-hook ()
|
||||
;; "When a break finishes, resume the music player."
|
||||
;; (when (and org-pomodoro-music-was-playing
|
||||
;; (not (org-pomodoro-music-is-playing-p)))
|
||||
;; (org-pomodoro-music-play)
|
||||
;; (message "休息结束,音乐已恢复播放"))
|
||||
;; (setq org-pomodoro-music-was-playing nil))
|
||||
|
||||
(defun org-pomodoro-music-started-hook ()
|
||||
"When a pomodoro start, play the music player."
|
||||
(unless (org-pomodoro-music-is-playing-p)
|
||||
(org-pomodoro-music-play)
|
||||
(message "番茄开始,音乐已开始播放"))
|
||||
)
|
||||
|
||||
;; Adding hooks
|
||||
;; (add-hook 'org-pomodoro-break-started-hook #'org-pomodoro-music-break-started-hook)
|
||||
;; (add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-music-break-finished-hook)
|
||||
|
||||
;; (add-hook 'org-pomodoro-long-break-started-hook #'org-pomodoro-music-break-started-hook)
|
||||
;; (add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-music-break-finished-hook)
|
||||
|
||||
(add-hook 'org-pomodoro-started-hook #'org-pomodoro-music-started-hook)
|
||||
|
||||
(provide 'org-pomodoro-music-controller)
|
||||
;;; org-pomodoro-music-controller.el ends here
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
;;; org-pomodoro-telegram-notifier.el --- 为 org-pomodoro 添加发送 Telegram 通知的功能。 -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
;;; Provide a way to send Telegram notifications when org-pomodoro breaks end.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-pomodoro)
|
||||
(require 'request)
|
||||
|
||||
(defcustom org-pomodoro-telegram-bot-token ""
|
||||
"Your Telegram bot token."
|
||||
:type 'string
|
||||
:group 'org-pomodoro)
|
||||
|
||||
(defcustom org-pomodoro-telegram-chat-id ""
|
||||
"Your Telegram chat ID."
|
||||
:type 'string
|
||||
:group 'org-pomodoro)
|
||||
|
||||
(defcustom org-pomodoro-telegram-break-end-message "休息时间结束"
|
||||
"The message to send when a break ends."
|
||||
:type 'string
|
||||
:group 'org-pomodoro)
|
||||
|
||||
(defun org-pomodoro-send-telegram-message (message)
|
||||
"Send a message to the Telegram chat.
|
||||
MESSAGE is the message to send."
|
||||
(interactive)
|
||||
(when (and (not (string-empty-p org-pomodoro-telegram-bot-token))
|
||||
(not (string-empty-p org-pomodoro-telegram-chat-id)))
|
||||
(request
|
||||
(format "https://api.telegram.org/bot%s/sendMessage" org-pomodoro-telegram-bot-token)
|
||||
:type "POST"
|
||||
:data `(("chat_id" . ,org-pomodoro-telegram-chat-id)
|
||||
("text" . ,"⏳<b>[Emacs]</b> <code>org-pomodoro</code>: 休息时间结束")
|
||||
("parse_mode" . "HTML"))
|
||||
:parser 'json-read
|
||||
:success (cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(message "成功发送 Telegram 通知")))
|
||||
:error (cl-function
|
||||
(lambda (&key error-thrown &allow-other-keys)
|
||||
(message "发送 Telegram 通知失败: %S" error-thrown))))
|
||||
)
|
||||
)
|
||||
|
||||
(defun org-pomodoro-telegram-break-finished-hook ()
|
||||
"Send a Telegram message when a break ends."
|
||||
(org-pomodoro-send-telegram-message org-pomodoro-telegram-break-end-message))
|
||||
|
||||
(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
|
||||
(add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
|
||||
|
||||
|
||||
(provide 'org-pomodoro-telegram-notifier)
|
||||
;;; org-pomodoro-telegram-notifier.el ends here
|
||||
|
|
@ -1,228 +0,0 @@
|
|||
;; If use `org' and don't want your org files in the default location below,
|
||||
;; change `org-directory'. It must be set before org loads!
|
||||
(setq org-directory "~/OrgFiles/")
|
||||
;; (setq org-roam-directory "~/OrgFiles/roam/")
|
||||
|
||||
;;; org general
|
||||
|
||||
(after! org
|
||||
;; For CJK users
|
||||
;; Insert zero width space around the emphasis symbols, this might be useful for
|
||||
;; languages that does not rely on space
|
||||
(defun my/insert-emphasis-with-zws (char)
|
||||
(interactive "c")
|
||||
(insert ?\u200B char)
|
||||
(save-excursion (insert char ?\u200B)))
|
||||
|
||||
;; Directory
|
||||
(setq org-archive-location "~/OrgFiles/.archive/%s_archive::")
|
||||
(setq org-default-notes-file "~/OrgFiles/tasks/inbox.org")
|
||||
|
||||
;; Initial Visibility
|
||||
(setq org-startup-folded "show2levels")
|
||||
|
||||
;; Log into drawer
|
||||
(setq org-log-into-drawer "LOGBOOK")
|
||||
|
||||
;;
|
||||
|
||||
(setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d@/!)" "CANCELLED(c@)")
|
||||
))
|
||||
|
||||
(setq org-todo-keyword-faces
|
||||
'(("TODO" . (:foreground "red" :weight bold :background "yellow"))
|
||||
("NEXT" . (:foreground "blue" :weight bold :background "lightgray"))
|
||||
("WAIT" . (:foreground "orange" :weight bold))
|
||||
("DONE" . (:foreground "grey" :weight bold :italic t))
|
||||
("CANCELLED" . (:foreground "grey" :weight bold))
|
||||
))
|
||||
|
||||
;; Keymaps
|
||||
(map! :map org-mode-map
|
||||
:desc "Bold with ZWS" "C-c b" (lambda () (interactive) (my/insert-emphasis-with-zws ?*))
|
||||
:desc "Italic with ZWS" "C-c i" (lambda () (interactive) (my/insert-emphasis-with-zws ?/))
|
||||
:desc "Underline with ZWS" "C-c u" (lambda () (interactive) (my/insert-emphasis-with-zws ?_))
|
||||
:desc "Code with ZWS" "C-c c" (lambda () (interactive) (my/insert-emphasis-with-zws ?~))
|
||||
:nvom "M-n" 'org-metadown
|
||||
:nvom "M-e" 'org-metaup)
|
||||
|
||||
(setq org-capture-templates
|
||||
'(("t" "Task" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Tasks")
|
||||
"* TODO %?\n %U\n %a\n %i"
|
||||
:empty-lines 1)
|
||||
("n" "Note" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Notes"))
|
||||
))
|
||||
|
||||
;; 处理 Zotero 链接
|
||||
(org-link-set-parameters
|
||||
"zotero"
|
||||
:follow (lambda (path) (browse-url (concat "zotero://" path)))
|
||||
:export (lambda (path desc format)
|
||||
(cond
|
||||
((eq format 'html) (format "<a href=\"zotero://%s\">%s</a>" path (or desc path)))
|
||||
((eq format 'latex) (format "\\href{zotero://%s}{%s}" path (or desc path)))
|
||||
(t path))))
|
||||
|
||||
;; 处理 Obsidian 链接
|
||||
(org-link-set-parameters
|
||||
"obsidian"
|
||||
:follow (lambda (path) (browse-url (concat "obsidian://" path)))
|
||||
:export (lambda (path desc format)
|
||||
(cond
|
||||
((eq format 'html) (format "<a href=\"obsidian://%s\">%s</a>" path (or desc path)))
|
||||
((eq format 'latex) (format "\\href{obsidian://%s}{%s}" path (or desc path)))
|
||||
(t path))))
|
||||
|
||||
)
|
||||
|
||||
(after! evil-org
|
||||
(map! :map evil-org-mode-map
|
||||
:n "L" 'evil-org-insert-line
|
||||
:n "I" 'evil-next-buffer
|
||||
)
|
||||
)
|
||||
|
||||
;;; org-agenda
|
||||
|
||||
(after! org-agenda
|
||||
;; (setq org-agenda-files (directory-files-recursively "~/OrgFiles/tasks/" "\\.org$"))
|
||||
(setq org-agenda-files (list (concat org-directory "tasks/")))
|
||||
)
|
||||
|
||||
|
||||
(map! :after org-agenda
|
||||
:map evil-org-agenda-mode-map
|
||||
:m "n" #'org-agenda-next-line
|
||||
:m "e" #'org-agenda-previous-line
|
||||
:m "gn" #'org-agenda-next-item
|
||||
:m "ge" #'org-agenda-previous-item
|
||||
:m "N" #'org-agenda-priority-up
|
||||
:m "E" #'org-agenda-priority-down
|
||||
:m "i" #'evil-forward-char
|
||||
:m "," #'org-agenda-priority
|
||||
:m "x" #'org-agenda-todo
|
||||
:m "t" #'org-agenda-set-tags
|
||||
:m "w" #'org-save-all-org-buffers
|
||||
;; d: date reschedule
|
||||
:m "ds" #'org-agenda-schedule
|
||||
:m "dd" #'org-agenda-deadline
|
||||
:m "$" #'org-agenda-archive
|
||||
:m "!" #'org-agenda-toggle-deadlines
|
||||
;; c: clock
|
||||
:m "cp" #'org-pomodoro
|
||||
:m "vd" #'org-agenda-day-view
|
||||
:m "vw" #'org-agenda-week-view
|
||||
:m "vm" #'org-agenda-month-view
|
||||
:m "vy" #'org-agenda-year-view
|
||||
:m "v." #'org-agenda-reset-view
|
||||
:leader :desc "Org Agenda" "A" #'org-agenda)
|
||||
|
||||
(setq org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s")
|
||||
(todo . " %i %-12:c %e")
|
||||
(tags . " %i %-12:c %e ")
|
||||
(search . " %i %-12:c %e ")))
|
||||
|
||||
|
||||
;; https://github.com/AbstProcDo/Master-Emacs-From-Scratch-with-Solid-Procedures/blob/master/06.Emacs-as-Agenda-by-Org.org
|
||||
;;Sunrise and Sunset
|
||||
;;日出而作, 日落而息
|
||||
(defun js0ny/diary-sunrise ()
|
||||
(let ((dss (diary-sunrise-sunset)))
|
||||
(with-temp-buffer
|
||||
(insert dss)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward " ([^)]*)" nil t)
|
||||
(replace-match "" nil nil))
|
||||
(goto-char (point-min))
|
||||
(search-forward ",")
|
||||
(buffer-substring (point-min) (match-beginning 0)))))
|
||||
|
||||
(defun js0ny/diary-sunset ()
|
||||
(let ((dss (diary-sunrise-sunset))
|
||||
start end)
|
||||
(with-temp-buffer
|
||||
(insert dss)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward " ([^)]*)" nil t)
|
||||
(replace-match "" nil nil))
|
||||
(goto-char (point-min))
|
||||
(search-forward ", ")
|
||||
(setq start (match-end 0))
|
||||
(search-forward " at")
|
||||
(setq end (match-beginning 0))
|
||||
(goto-char start)
|
||||
(capitalize-word 1)
|
||||
(buffer-substring start end))))
|
||||
|
||||
(after! (org-agenda cal-china-x)
|
||||
(setq org-agenda-format-date 'org-agenda-format-date-aligned)
|
||||
|
||||
|
||||
(defun org-agenda-format-date-aligned (date)
|
||||
"Format a DATE string for display in the daily/weekly agenda, or timeline.
|
||||
This function makes sure that dates are aligned for easy reading."
|
||||
(require 'cal-iso)
|
||||
(let* ((dayname (aref cal-china-x-days
|
||||
(calendar-day-of-week date)))
|
||||
(day (cadr date))
|
||||
(month (car date))
|
||||
(year (nth 2 date))
|
||||
(cn-date (calendar-chinese-from-absolute (calendar-absolute-from-gregorian date)))
|
||||
(cn-month (cl-caddr cn-date))
|
||||
(cn-day (cl-cadddr cn-date))
|
||||
(cn-month-string (concat (aref cal-china-x-month-name
|
||||
(1- (floor cn-month)))
|
||||
(if (integerp cn-month)
|
||||
""
|
||||
"(闰月)")))
|
||||
(cn-day-string (aref cal-china-x-day-name
|
||||
(1- cn-day))))
|
||||
(format "%04d-%02d-%02d 周%s %s%s" year month
|
||||
day dayname cn-month-string cn-day-string))))
|
||||
|
||||
|
||||
(setq org-agenda-time-grid (quote ((daily today require-timed)
|
||||
(300 600 900 1200 1500 1800 2100 2400)
|
||||
"......"
|
||||
"-----------------------------------------------------"
|
||||
)))
|
||||
|
||||
;; org-agenda-clockreport
|
||||
|
||||
(setq org-agenda-clockreport-parameter-plist '(:link t :maxlevel 3 :fileskip0 t :compact t :narrow 80))
|
||||
|
||||
;;; org-clock
|
||||
|
||||
;; org-pomodoro
|
||||
|
||||
(after! org-pomodoro
|
||||
(setq org-pomodoro-format "Pomo~%s")
|
||||
(setq org-pomodoro-short-break-format "摸~%s")
|
||||
(setq org-pomodoro-long-break-format "猛摸~%s")
|
||||
)
|
||||
|
||||
|
||||
;;; org-babel
|
||||
|
||||
(if (not (eq system-type 'gnu/linux))
|
||||
(setq org-babel-C-compiler "clang"))
|
||||
|
||||
|
||||
;;; org-export
|
||||
|
||||
;; icalendar
|
||||
|
||||
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
|
||||
(setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo))
|
||||
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics")
|
||||
|
||||
|
||||
(use-package! org-pomodoro-music-controller
|
||||
:after org-pomodoro
|
||||
:config
|
||||
(customize-set-variable 'org-pomodoro-music-player-args '("--player=cider"))
|
||||
)
|
||||
|
||||
(use-package! org-pomodoro-telegram-notifier
|
||||
:after org-pomodoro
|
||||
)
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; $DOOMDIR/packages.el
|
||||
|
||||
;; To install a package with Doom you must declare them here and run 'doom sync'
|
||||
;; on the command line, then restart Emacs for the changes to take effect -- or
|
||||
|
||||
|
||||
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
|
||||
;; (package! some-package)
|
||||
|
||||
;; To install a package directly from a remote git repo, you must specify a
|
||||
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
|
||||
;; https://github.com/radian-software/straight.el#the-recipe-format
|
||||
;; (package! another-package
|
||||
;; :recipe (:host github :repo "username/repo"))
|
||||
|
||||
;; If the package you are trying to install does not contain a PACKAGENAME.el
|
||||
;; file, or is located in a subdirectory of the repo, you'll need to specify
|
||||
;; `:files' in the `:recipe':
|
||||
;; (package! this-package
|
||||
;; :recipe (:host github :repo "username/repo"
|
||||
;; :files ("some-file.el" "src/lisp/*.el")))
|
||||
|
||||
;; If you'd like to disable a package included with Doom, you can do so here
|
||||
;; with the `:disable' property:
|
||||
;; (package! builtin-package :disable t)
|
||||
|
||||
;; You can override the recipe of a built in package without having to specify
|
||||
;; all the properties for `:recipe'. These will inherit the rest of its recipe
|
||||
;; from Doom or MELPA/ELPA/Emacsmirror:
|
||||
;; (package! builtin-package :recipe (:nonrecursive t))
|
||||
;; (package! builtin-package-2 :recipe (:repo "myfork/package"))
|
||||
|
||||
;; Specify a `:branch' to install a package from a particular branch or tag.
|
||||
;; This is required for some packages whose default branch isn't 'master' (which
|
||||
;; our package manager can't deal with; see radian-software/straight.el#279)
|
||||
;; (package! builtin-package :recipe (:branch "develop"))
|
||||
|
||||
;; Use `:pin' to specify a particular commit to install.
|
||||
;; (package! builtin-package :pin "1a2b3c4d5e")
|
||||
|
||||
|
||||
;; Doom's packages are pinned to a specific commit and updated from release to
|
||||
;; release. The `unpin!' macro allows you to unpin single packages...
|
||||
;; (unpin! pinned-package)
|
||||
;; ...or multiple packages
|
||||
;; (unpin! pinned-package another-pinned-package)
|
||||
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
|
||||
;; (unpin! t)
|
||||
|
||||
(package! wakatime-mode)
|
||||
(package! copilot
|
||||
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
|
||||
(package! evil-matchit)
|
||||
(package! rime)
|
||||
(package! ox-typst)
|
||||
(package! cal-china-x)
|
||||
|
||||
(package! telega :recipe (:files (:defaults "contrib/*.el" "etc" "server" "Makefile")))
|
||||
|
||||
|
||||
(package! org-super-agenda)
|
||||
|
||||
(package! catppuccin-theme)
|
||||
|
||||
(package! eee
|
||||
:recipe (:host github :repo "eval-exec/eee.el"
|
||||
:files (:defaults "*.el" "*.sh")))
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: align-math
|
||||
# key: ali
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# --
|
||||
\\begin{align*}
|
||||
$1
|
||||
\\end{align*}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: display-math
|
||||
# key: dm
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# --
|
||||
\\[
|
||||
$1
|
||||
\\]
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: inline-math
|
||||
# key: mk
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# --
|
||||
\\( $1 \\)
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: Limit
|
||||
# key: lim
|
||||
# condition: (org-inside-LaTeX-fragment-p)
|
||||
# --
|
||||
\\lim_{$1 \to $2} $0
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: Summation
|
||||
# key: sum
|
||||
# condition: (org-inside-LaTeX-fragment-p)
|
||||
# --
|
||||
\\sum_{$1}^{$2} $0
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: unnumbered
|
||||
# key: unnumbered
|
||||
# --
|
||||
:PROPERTIES:
|
||||
:UNNUMBERED: t
|
||||
:END:
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
;; -*- lexical-binding: t; -*-
|
||||
;; telegram client for emacs
|
||||
(use-package! telega
|
||||
:init
|
||||
(setq telega-server-libs-prefix "/usr")
|
||||
(setq telega-directory (expand-file-name "~/.local/share/telega"))
|
||||
|
||||
|
||||
;; (prefix-key global-map (kbd "C-c t") telega-prefix-map)
|
||||
(unless (display-graphic-p) (setq telega-use-images nil))
|
||||
(when (modulep! :editor evil)
|
||||
(cl-pushnew 'telega +evil-collection-disabled-list :test #'equal)
|
||||
(setq evil-collection-mode-list (remove 'telega evil-collection-mode-list))
|
||||
(set-evil-initial-state! '(telega-root-mode telega-chat-mode) 'emacs))
|
||||
|
||||
:hook
|
||||
(telega-load . telega-mode-line-mode)
|
||||
(telega-load . global-telega-url-shorten-mode)
|
||||
(telega-load . global-telega-mnz-mode)
|
||||
(telega-load . telega-autoplay-mode)
|
||||
(telega-load . telega-transient-mode)
|
||||
(telega-load . telega-adblock-mode)
|
||||
(telega-chat-mode . (lambda ()
|
||||
(setq-local visual-fill-column-extra-text-width
|
||||
'(0 . 2))))
|
||||
|
||||
:config
|
||||
(add-hook 'telega-msg-ignore-predicates
|
||||
(telega-match-gen-predicate 'msg '(sender is-blocked)))
|
||||
(setq telega-chat-show-deleted-messages-for '(me-is-owner OR-ADMIN)
|
||||
;; telega-use-tracking-for '(or mention (and unread unmuted))
|
||||
telega-open-file-function 'org-open-file
|
||||
;; telega-open-message-as-file '(video video-note)
|
||||
telega-translate-to-language-by-default "zh"
|
||||
telega-avatar-workaround-gaps-for `(return t)
|
||||
telega-mode-line-string-format (remove
|
||||
'(:eval (telega-mode-line-icon))
|
||||
telega-mode-line-string-format))
|
||||
|
||||
(map! (:prefix "C-c"
|
||||
:desc "Telega all chats"
|
||||
"c" #'telega-chat-with
|
||||
:desc "Telega important chats"
|
||||
"v" #'telega-switch-important-chat
|
||||
:desc "Telega next important chat"
|
||||
"SPC" (cmd! (let ((current-prefix-arg '(4)))
|
||||
(call-interactively #'telega-switch-important-chat))))
|
||||
(:map telega-chat-mode-map
|
||||
(:prefix ("C-t" . "Telega chat topic")
|
||||
:desc "Telega filter by chat topic"
|
||||
"C-t" #'telega-chatbuf-filter-by-topic
|
||||
:desc "Telega clear chat topic"
|
||||
"C-c" #'telega-chatbuf-thread-cancel)))
|
||||
|
||||
; (load! "+telega-auto-input-method")
|
||||
|
||||
(set-popup-rule! (regexp-quote telega-root-buffer-name)
|
||||
:slot 10 :vslot 10 :side 'right :size 90 :ttl nil :quit 'current :modeline t)
|
||||
(set-popup-rule! "^◀[^◀\[]*[\[({<].+[\])}>]"
|
||||
:slot 10 :vslot 10 :side 'right :size 90 :ttl 10 :quit 'current :modeline t)
|
||||
(set-popup-rule! (regexp-quote "*Telega User*")
|
||||
:slot 20 :vslot 10 :side 'right :height .5 :ttl 10 :quit t :modeline nil :select t)
|
||||
(set-popup-rule! (regexp-quote "*Telegram Chat Info*")
|
||||
:slot 20 :vslot 10 :side 'right :height .5 :ttl 10 :quit t :modeline nil :select t))
|
||||
|
||||
;; (load! "+telega-addition")
|
||||
|
||||
(use-package! telega-dired-dwim
|
||||
:after telega dired)
|
||||
|
||||
(use-package! telega-bridge-bot
|
||||
:after telega)
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
(after! treemacs
|
||||
(map! :map evil-treemacs-state-map
|
||||
"n" #'treemacs-next-line
|
||||
"e" #'treemacs-previous-line
|
||||
"N" #'treemacs-next-neighbour
|
||||
"E" #'treemacs-previous-neighbour
|
||||
"H" #'treemacs-toggle-show-dotfiles
|
||||
"I" #'treemacs-hide-gitignored-files-mode
|
||||
"i" #'treemacs-RET-action
|
||||
"a" #'treemacs-create-file
|
||||
"A" #'treemacs-create-dir
|
||||
"c" #'treemacs-copy-file
|
||||
"x" #'treemacs-move-file
|
||||
"d" #'treemacs-delete-file
|
||||
"r" #'treemacs-rename-file
|
||||
"q" #'treemacs-quit
|
||||
"y" #'treemacs-copy-relative-path-at-point
|
||||
"Y" #'treemacs-copy-absolute-path-at-point
|
||||
"m" #'treemacs-mark-or-unmark-path-at-point
|
||||
)
|
||||
)
|
||||
|
||||
(map! :leader
|
||||
:desc "Toggle Treemacs" "f t" #'+treemacs/toggle)
|
||||
30
tools/emacs.d/.gitignore
vendored
30
tools/emacs.d/.gitignore
vendored
|
|
@ -1,30 +0,0 @@
|
|||
# 自动生成的目录
|
||||
/auto-save-list/
|
||||
/elpa/
|
||||
/eshell/
|
||||
/server/
|
||||
/url/
|
||||
transient/
|
||||
|
||||
# 临时文件
|
||||
tutorial
|
||||
*~
|
||||
\#*\#
|
||||
.#*
|
||||
*.elc
|
||||
|
||||
# 自动保存的文件
|
||||
auto-save-list
|
||||
tramp
|
||||
|
||||
recentf
|
||||
custom.el
|
||||
.custom.el
|
||||
|
||||
.org-id-locations
|
||||
bookmarks
|
||||
.cache
|
||||
eln-cache
|
||||
org-persist
|
||||
|
||||
local.el
|
||||
|
|
@ -1 +0,0 @@
|
|||
(setq package-enable-at-startup nil)
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
;;; init.el --- Entry point of GNU/Emacs configuration
|
||||
;;; First edit date 2025/01/27
|
||||
|
||||
;;; Organised by such directory structure
|
||||
;;; init.el -- This file, entry point
|
||||
;;; lisp/
|
||||
;;; init-*.el
|
||||
;;; custom.el -- Auto Generated
|
||||
;;; local.el -- Local variables
|
||||
|
||||
;; All elisp files under emacs.d/lisp will be loaded
|
||||
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
|
||||
|
||||
;; Store the auto-generated custom config to `custom.el`
|
||||
(setq custom-file (expand-file-name ".custom.el" user-emacs-directory))
|
||||
|
||||
|
||||
(defvar xdg-data-home
|
||||
(or (getenv "XDG_DATA_HOME")
|
||||
(expand-file-name "~/.local/share")))
|
||||
|
||||
(defvar xdg-cache-home
|
||||
(or (getenv "XDG_CACHE_HOME")
|
||||
(expand-file-name "~/.cache")))
|
||||
|
||||
(defvar xdg-state-home
|
||||
(or (getenv "XDG_STATE_HOME")
|
||||
(expand-file-name "~/.local/state/")))
|
||||
|
||||
(defvar user-emacs-data (expand-file-name "emacs" xdg-data-home))
|
||||
(defvar user-emacs-cache (expand-file-name "emacs" xdg-cache-home))
|
||||
(defvar user-emacs-state (expand-file-name "emacs" xdg-state-home))
|
||||
|
||||
;; Load each modules
|
||||
(require 'init-package) ; package manager should be loaded first
|
||||
(require 'init-basic)
|
||||
(require 'init-appearance)
|
||||
(require 'init-wayland)
|
||||
(require 'init-keymaps)
|
||||
(require 'init-evil)
|
||||
(require 'init-counsel)
|
||||
(require 'init-file)
|
||||
(require 'init-edit)
|
||||
(require 'init-calendar)
|
||||
(require 'init-writer)
|
||||
(require 'init-org)
|
||||
(require 'init-markdown)
|
||||
(require 'init-latex)
|
||||
(require 'init-beancount)
|
||||
(require 'init-treesitter)
|
||||
(require 'init-scratch)
|
||||
(require 'init-ai)
|
||||
|
||||
|
||||
;; Load `custom` file
|
||||
(when (file-exists-p custom-file)
|
||||
(load custom-file))
|
||||
|
||||
|
||||
(when (file-exists-p (expand-file-name "local.el" user-emacs-directory))
|
||||
(load (expand-file-name "local.el" user-emacs-directory)))
|
||||
|
||||
|
||||
|
||||
;;; init.el end
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
;; (use-package copilot
|
||||
;; :vc (:url "https://github.com/copilot-emacs/copilot.el"
|
||||
;; :rev :newest
|
||||
;; :branch "main")
|
||||
;; :hook (prog-mode . copilot-mode)
|
||||
;; :config
|
||||
;; (define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
|
||||
;; (define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion))
|
||||
|
||||
|
||||
(provide 'init-ai)
|
||||
|
||||
;;; init-ai.el ends here
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
;;; init-appearance.el
|
||||
|
||||
;; Always set frame font
|
||||
;; If don't set this, `emacs --daemon' will not set the font
|
||||
;; for new graphical frames.
|
||||
(add-to-list 'default-frame-alist '(font . "Maple Mono NF CN"))
|
||||
|
||||
;; Set CJK Display Font
|
||||
(dolist (charset '(kana han cjk-misc bopomofo))
|
||||
(set-fontset-font t charset (font-spec :family "Maple Mono NF CN")))
|
||||
|
||||
|
||||
;; Variable Pitch Font
|
||||
;; Used in `variable-pitch-mode'
|
||||
(set-face-attribute 'variable-pitch nil
|
||||
:family "LXGW WenKai Screen"
|
||||
:height 140
|
||||
:weight 'regular)
|
||||
|
||||
|
||||
;; Icon Support
|
||||
;; Once installed, Manually install the fonts required:
|
||||
;; M-x all-the-icons-install-fonts
|
||||
;; If under Microsoft Windows, the Installation Directory should be chosen
|
||||
;; and right-click them to install the fonts
|
||||
(use-package all-the-icons
|
||||
:if (display-graphic-p))
|
||||
|
||||
|
||||
(defun js0ny/get-system-theme ()
|
||||
" Get the current system theme. Returns 'light' or 'dark'."
|
||||
;; Default
|
||||
(let ((background 'dark))
|
||||
(if (string= system-type "darwin")
|
||||
(progn
|
||||
;; Check if 'defaults' command is available
|
||||
(when (executable-find "defaults")
|
||||
;; Check if the system is in dark mode
|
||||
(let ((apple-interface-style
|
||||
(shell-command-to-string "defaults read -g AppleInterfaceStyle")))
|
||||
(when (string-match-p "Light" apple-interface-style)
|
||||
(setq background 'light)))))
|
||||
;; Using systemd to check the current theme
|
||||
(when (executable-find "busctl")
|
||||
(let ((result
|
||||
(shell-command-to-string
|
||||
(concat "busctl --user call org.freedesktop.portal.Desktop "
|
||||
"/org/freedesktop/portal/desktop "
|
||||
"org.freedesktop.portal.Settings ReadOne ss "
|
||||
"org.freedesktop.appearance color-scheme"))))
|
||||
;; 结果格式为浅色模式是 "v u 0",暗色模式是 "v u 1"
|
||||
;; v u 0 -> light, v u 1 -> dark
|
||||
(when (string-match "u\\s+\\([0-9]\\)" result)
|
||||
(let ((color-scheme (match-string 1 result)))
|
||||
(when (string= color-scheme "0")
|
||||
(setq background 'light)))))))
|
||||
background))
|
||||
|
||||
(use-package catppuccin-theme
|
||||
:custom
|
||||
(catppuccin-flavor 'mocha)
|
||||
:config
|
||||
(if (string-equal (js0ny/get-system-theme) "light")
|
||||
(setq catppuccin-flavor 'latte)
|
||||
(setq catppuccin-flavor 'mocha))
|
||||
(load-theme 'catppuccin t))
|
||||
|
||||
|
||||
|
||||
;; (use-package doom-themes
|
||||
;; :ensure t
|
||||
;; :config
|
||||
;; ;; Global settings (defaults)
|
||||
;; :custom
|
||||
;; (doom-themes-enable-bold t) ; if nil, bold is universally disabled
|
||||
;; (doom-themes-enable-italic t) ; if nil, italics is universally disabled
|
||||
;; ; (doom-themes-treemacs-theme "doom-nord-aurora") ; use "doom-colors" for less minimal icon theme
|
||||
;; :config
|
||||
;; (load-theme 'doom-nord-aurora t)
|
||||
|
||||
;; ;; Enable flashing mode-line on errors
|
||||
;; (doom-themes-visual-bell-config)
|
||||
|
||||
;; ;; Enable custom neotree theme (nerd-icons must be installed!)
|
||||
;; ;; (doom-themes-neotree-config)
|
||||
|
||||
;; ;; or for treemacs users
|
||||
;; (doom-themes-treemacs-config)
|
||||
;; ;; Corrects (and improves) org-mode's native fontification.
|
||||
;; (doom-themes-org-config))
|
||||
|
||||
|
||||
;; Better mode line, see (L11) for Icon install
|
||||
;; M-x nerd-icons-install-fonts
|
||||
(use-package doom-modeline
|
||||
:ensure t
|
||||
:init (doom-modeline-mode 1))
|
||||
|
||||
(global-tab-line-mode) ; bufferline
|
||||
|
||||
(use-package highlight-indent-guides
|
||||
:hook ((prog-mode yaml-mode org-mode) . highlight-indent-guides-mode)
|
||||
:init
|
||||
(setq highlight-indent-guides-method 'column)
|
||||
(setq highlight-indent-guides-responsive 'top)
|
||||
(setq highlight-indent-guides-auto-character-face-perc 1))
|
||||
|
||||
|
||||
|
||||
(provide 'init-appearance)
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
;;; init-basic.el
|
||||
|
||||
;; Disable startup message
|
||||
(setq inhibit-startup-message t)
|
||||
|
||||
;; Use line number by default
|
||||
(global-display-line-numbers-mode 1)
|
||||
;; Vim-like relativenumber
|
||||
;; fix: work for folded region (visual relative line instead of physical)
|
||||
(use-package display-line-numbers
|
||||
:custom
|
||||
(display-line-numbers-type 'visual)
|
||||
(display-line-numbers-current-absolute t)
|
||||
:hook
|
||||
(prog-mode . display-line-numbers-mode))
|
||||
|
||||
(when (eq system-type 'darwin)
|
||||
(setq mac-option-modifier 'meta)
|
||||
(setq mac-command-modifier 'super))
|
||||
|
||||
|
||||
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs
|
||||
;; (server-mode 1)
|
||||
|
||||
(setq use-short-answers t)
|
||||
|
||||
(require 'recentf)
|
||||
(setq recentf-save-file (expand-file-name "recentf" user-emacs-data))
|
||||
(recentf-mode 1)
|
||||
|
||||
;; Disable topbars
|
||||
(tool-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(menu-bar-mode -1)
|
||||
|
||||
(use-package alert
|
||||
:commands (alert)
|
||||
:config
|
||||
(setq alert-default-style 'libnotify))
|
||||
|
||||
;; 设置 Emacs 备份和自动保存目录
|
||||
(defvar user-backup-directory (expand-file-name "backups" user-emacs-data))
|
||||
(defvar user-autosaves-directory (expand-file-name "autosaves" user-emacs-cache))
|
||||
|
||||
;; 创建目录(如果不存在)
|
||||
(dolist (dir (list user-backup-directory user-autosaves-directory))
|
||||
(unless (file-exists-p dir)
|
||||
(make-directory dir t)
|
||||
(message "Creating directory: %s" dir)))
|
||||
|
||||
;; 配置备份文件目录
|
||||
(setq backup-directory-alist `(("." . ,user-backup-directory)))
|
||||
|
||||
(setq project-list-file (expand-file-name "projects-list" user-emacs-data))
|
||||
|
||||
;; 配置自动保存文件目录
|
||||
(setq auto-save-file-name-transforms
|
||||
`((".*" ,user-autosaves-directory t)))
|
||||
|
||||
;; 配置自动保存列表文件前缀
|
||||
(setq auto-save-list-file-prefix
|
||||
(expand-file-name "auto-save-list/.saves-" user-autosaves-directory))
|
||||
|
||||
;; TRAMP 远程文件的备份设置
|
||||
(setq tramp-backup-directory-alist (copy-tree backup-directory-alist))
|
||||
(setq tramp-persistency-file-name (expand-file-name "tramp" user-emacs-state))
|
||||
|
||||
|
||||
;; 备份设置(可选)
|
||||
(setq backup-by-copying t ; 使用复制而非重命名
|
||||
delete-old-versions t ; 自动删除旧版本
|
||||
kept-new-versions 6 ; 保留的新版本数量
|
||||
kept-old-versions 2 ; 保留的旧版本数量
|
||||
version-control t) ; 使用版本号
|
||||
|
||||
(setq transient-history-file (expand-file-name "transient/history.el" user-emacs-data))
|
||||
(setq transient-values-file (expand-file-name "transient/values.el" user-emacs-data))
|
||||
(setq transient-levels-file (expand-file-name "transient/levels.el" user-emacs-data))
|
||||
|
||||
;; Export module
|
||||
(provide 'init-basic)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
;; (straight-use-package
|
||||
;; '(beancount
|
||||
;; :host github
|
||||
;; :repo "beancount/beancount-mode"
|
||||
;; :files ("*.el")))
|
||||
|
||||
(use-package beancount
|
||||
:mode (("\\.beancount\\'" . beancount-mode)
|
||||
("\\.bean\\'" . beancount-mode))
|
||||
:init
|
||||
(add-hook 'beancount-mode-hook #'outline-minor-mode)
|
||||
(define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
|
||||
(define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
|
||||
|
||||
(defvar beancount-accounts-files nil "List of account files.")
|
||||
(setq beancount-accounts-files
|
||||
(directory-files "~/Dropbox/beancount/accounts/" 'full (rx ".beancount" eos)))
|
||||
|
||||
(defun w/beancount--collect-accounts-from-files (oldfun regex n)
|
||||
"Collect all accounts from files."
|
||||
(let ((keys (funcall oldfun regex n))
|
||||
(hash (make-hash-table :test 'equal)))
|
||||
(dolist (key keys)
|
||||
(puthash key nil hash))
|
||||
;; collect accounts from files
|
||||
(save-excursion
|
||||
(dolist (f beancount-accounts-files)
|
||||
(with-current-buffer (find-file-noselect f)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward beancount-account-regexp nil t)
|
||||
(puthash (match-string-no-properties n) nil hash)))))
|
||||
(hash-table-keys hash)))
|
||||
|
||||
(advice-add #'beancount-collect
|
||||
:around #'w/beancount--collect-accounts-from-files
|
||||
'((name . "collect accounts from files as well"))))
|
||||
|
||||
|
||||
(provide 'init-beancount)
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
;;; init-calendar.el
|
||||
|
||||
(setq calendar-date-style 'iso)
|
||||
(setq diary-date-forms '((year "年" month "月" day "日" " 星期[" "日一二三四五六" "]") ;; Chinese
|
||||
(year "-" month "-" day) ;; ISO
|
||||
(month "[-/]" day "[^-/0-9]") (year "[-/]" month "[-/]" day "[^0-9]")
|
||||
(monthname " *" day "[^-0-9]") (year " *" monthname " *" day "[^0-9]")
|
||||
(dayname "\\W")))
|
||||
|
||||
(setq calendar-mark-holidays-flag t
|
||||
calendar-week-start-day 1)
|
||||
|
||||
|
||||
(use-package cal-china-x
|
||||
:ensure t
|
||||
:custom
|
||||
(cal-china-x-important-holidays '((holiday-chinese-new-year)
|
||||
(holiday-lunar 12 23 "小年(北)" 1)
|
||||
(holiday-lunar 12 24 "小年(南)" 1)
|
||||
(holiday-lunar 12 30 "除夕" 1)
|
||||
(holiday-lunar 1 1 "春节" 0)
|
||||
(holiday-lunar 1 2 "春节" 0)
|
||||
(holiday-lunar 1 3 "春节" 0)
|
||||
(holiday-lunar 1 4 "春节" 0)
|
||||
(holiday-lunar 1 5 "春节(破五)" 0)
|
||||
(holiday-lunar 1 15 "元宵节" 0)
|
||||
(holiday-lunar 2 2 "龙抬头" 0)
|
||||
(holiday-solar-term "清明" "清明节")
|
||||
(holiday-fixed 5 1 "劳动节")
|
||||
(holiday-lunar 5 5 "端午节" 0)
|
||||
(holiday-lunar 7 7 "七夕节" 0)
|
||||
(holiday-lunar 7 15 "中元节" 0)
|
||||
(holiday-lunar 8 15 "中秋节" 0)
|
||||
(holiday-fixed 10 1 "国庆节")
|
||||
(holiday-fixed 10 2 "国庆节")
|
||||
(holiday-fixed 10 3 "国庆节")
|
||||
(holiday-lunar 9 9 "重阳节" 0)
|
||||
(holiday-lunar 10 1 "寒衣节" 0)
|
||||
(holiday-lunar 12 8 "腊八" 1)
|
||||
(holiday-solar-term "立春" "立春")
|
||||
(holiday-solar-term "立夏" "立夏")
|
||||
(holiday-solar-term "立秋" "立秋")
|
||||
(holiday-solar-term "立冬" "立冬")
|
||||
(holiday-solar-term "春分" "春分")
|
||||
(holiday-solar-term "夏至" "夏至")
|
||||
(holiday-solar-term "秋分" "秋分")
|
||||
(holiday-solar-term "冬至" "冬至")))
|
||||
(cal-china-x-general-holidays '((holiday-fixed 1 1 "元旦")
|
||||
(holiday-fixed 2 14 "情人节")
|
||||
(holiday-fixed 3 8 "妇女节")
|
||||
(holiday-fixed 4 1 "愚人节")
|
||||
(holiday-fixed 5 4 "青年节")
|
||||
(holiday-float 5 0 2 "母亲节")
|
||||
(holiday-fixed 6 1 "儿童节")
|
||||
(holiday-float 6 0 3 "父亲节")
|
||||
(holiday-fixed 9 10 "教师节")
|
||||
(holiday-float 11 4 4 "感恩节")
|
||||
(holiday-fixed 12 25 "圣诞节")))
|
||||
:config
|
||||
(setq calendar-holidays (append cal-china-x-important-holidays
|
||||
cal-china-x-general-holidays)))
|
||||
|
||||
;; https://github.com/AbstProcDo/Master-Emacs-From-Scratch-with-Solid-Procedures/blob/master/06.Emacs-as-Agenda-by-Org.org
|
||||
;;Sunrise and Sunset
|
||||
;;日出而作, 日落而息
|
||||
(defun js0ny/diary-sunrise ()
|
||||
(let ((dss (diary-sunrise-sunset)))
|
||||
(with-temp-buffer
|
||||
(insert dss)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward " ([^)]*)" nil t)
|
||||
(replace-match "" nil nil))
|
||||
(goto-char (point-min))
|
||||
(search-forward ",")
|
||||
(buffer-substring (point-min) (match-beginning 0)))))
|
||||
|
||||
(defun js0ny/diary-sunset ()
|
||||
(let ((dss (diary-sunrise-sunset))
|
||||
start end)
|
||||
(with-temp-buffer
|
||||
(insert dss)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward " ([^)]*)" nil t)
|
||||
(replace-match "" nil nil))
|
||||
(goto-char (point-min))
|
||||
(search-forward ", ")
|
||||
(setq start (match-end 0))
|
||||
(search-forward " at")
|
||||
(setq end (match-beginning 0))
|
||||
(goto-char start)
|
||||
(capitalize-word 1)
|
||||
(buffer-substring start end))))
|
||||
|
||||
|
||||
|
||||
(setq diary-file "~/.local/js0ny/diary")
|
||||
|
||||
|
||||
(provide 'init-calendar)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
;;; init-counsel.el
|
||||
(defun js0ny/open-config-directory ()
|
||||
"Open `user-emacs-directory` using `counsel-find-file`."
|
||||
(interactive)
|
||||
(let ((default-directory user-emacs-directory))
|
||||
(counsel-file-jump)))
|
||||
|
||||
|
||||
(use-package counsel
|
||||
:demand t
|
||||
:init
|
||||
(counsel-mode 1)
|
||||
:config
|
||||
(global-set-key (kbd "C-x C-f") #'counsel-find-file)
|
||||
(global-set-key (kbd "M-x") #'counsel-M-x)
|
||||
(evil-leader/set-key
|
||||
"SPC" #'counsel-file-jump
|
||||
"/" #'counsel-rg
|
||||
";" #'counsel-M-x
|
||||
"fc" #'js0ny/open-config-directory
|
||||
"fh" #'counsel-recentf))
|
||||
|
||||
;; Replace `cd' with `counsel-cd'
|
||||
(defun cd ()
|
||||
"Change currend default directory"
|
||||
(interactive)
|
||||
(counsel-cd))
|
||||
|
||||
(provide 'init-counsel)
|
||||
|
||||
;;; init-counsel.el ends
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
;;; init-edit.el
|
||||
|
||||
;; Use UTF-8 & LF
|
||||
(setq-default buffer-file-coding-system 'utf-8-unix)
|
||||
|
||||
;; Auto input pairred brackets
|
||||
(electric-pair-mode 1)
|
||||
|
||||
;; Enable Folding
|
||||
(add-hook 'prog-mode-hook #'hs-minor-mode)
|
||||
|
||||
;; Company - Complete Anything
|
||||
(use-package company
|
||||
:ensure t
|
||||
:hook (after-init . global-company-mode) ; 在启动后自动启用 global-company-mode
|
||||
:bind (:map company-active-map
|
||||
("C-n" . company-select-next)
|
||||
("C-p" . company-select-previous))
|
||||
:custom
|
||||
(company-minimum-prefix-length 1) ; 设置最短补全前缀
|
||||
(company-idle-delay 0.2)) ; 设置补全延迟(秒)
|
||||
|
||||
;; minibuffer 补全增强
|
||||
(use-package vertico
|
||||
:init
|
||||
(vertico-mode))
|
||||
|
||||
;; 提供补全注解
|
||||
(use-package marginalia
|
||||
:init
|
||||
(marginalia-mode))
|
||||
|
||||
|
||||
;; (set-language-environment "UTF-8")
|
||||
(set-default-coding-systems 'utf-8)
|
||||
;; (prefer-coding-system 'utf-8)
|
||||
|
||||
;;; 设置语言环境为 UTF-8
|
||||
;
|
||||
;;; 强制使用 UTF-8
|
||||
;(set-terminal-coding-system 'utf-8)
|
||||
;(set-keyboard-coding-system 'utf-8)
|
||||
;
|
||||
;;; Windows 系统特殊设置
|
||||
;(when (eq system-type 'windows-nt)
|
||||
; (set-file-name-coding-system 'gbk) ;; 文件名使用 GBK
|
||||
; (set-clipboard-coding-system 'utf-16le)) ;; 剪贴板使用 UTF-16LE
|
||||
;
|
||||
;(setq-default buffer-file-coding-system 'utf-8-unix)
|
||||
;
|
||||
;;; 设置行尾为 Unix 风格
|
||||
;(add-hook 'find-file-hook 'find-file-check-line-endings)
|
||||
;
|
||||
;(defun dos-file-endings-p ()
|
||||
; (string-match "dos" (symbol-name buffer-file-coding-system)))
|
||||
;
|
||||
;(defun find-file-check-line-endings ()
|
||||
; (when (dos-file-endings-p)
|
||||
; (set-buffer-file-coding-system 'undecided-unix)
|
||||
; (set-buffer-modified-p nil)))
|
||||
|
||||
(setq-default buffer-file-coding-system 'utf-8-unix)
|
||||
|
||||
;; Avy - act like Vim Easymotion
|
||||
(use-package avy
|
||||
:ensure t
|
||||
:config
|
||||
(evil-define-key '(normal) 'global (kbd "T") 'avy-goto-char)
|
||||
(evil-define-key '(normal) 'global (kbd "s") 'avy-goto-char-2)
|
||||
(evil-define-key '(normal) 'global (kbd "s") 'avy-goto-char-2-above))
|
||||
|
||||
(use-package yasnippet
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands yas-minor-mode
|
||||
:hook ((prog-mode . yas-minor-mode)
|
||||
(org-mode . yas-minor-mode))
|
||||
:config
|
||||
(setq yas-indent-line 'fixed) ;; 让 snippet 展开时不影响缩进
|
||||
(setq yas-wrap-around-region nil) ;; 关闭自动包裹选中区域
|
||||
(advice-add 'yas-expand-snippet :around
|
||||
(lambda (orig-fn &rest args)
|
||||
(let ((inhibit-field-text-motion t)) ;; 禁止字段自动换行
|
||||
(apply orig-fn args))))
|
||||
;; (setq yas-snippet-dirs '("~/.dotfiles/tools/doom/snippets/"))
|
||||
(add-to-list 'yas-snippet-dirs "~/.dotfiles/tools/doom/snippets/" t)
|
||||
|
||||
(yas-reload-all)
|
||||
)
|
||||
|
||||
(use-package diff-hl
|
||||
:straight t
|
||||
:hook ((prog-mode . diff-hl-mode)
|
||||
(vc-dir-mode . diff-hl-dir-mode)
|
||||
(magit-post-refresh . diff-hl-magit-post-refresh))
|
||||
:config
|
||||
(setq diff-hl-margin-mode nil)
|
||||
(diff-hl-flydiff-mode))
|
||||
|
||||
(global-font-lock-mode t)
|
||||
|
||||
(provide 'init-edit)
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
;;; init-evil.el
|
||||
|
||||
;; Evil - Extensible VI Layer
|
||||
;; (defvar evil-colemak-state-map (make-sparse-keymap))
|
||||
|
||||
|
||||
|
||||
(use-package evil
|
||||
:ensure t
|
||||
:config
|
||||
(evil-mode 1)
|
||||
; Colemak Vim Arrow
|
||||
; Motion - Emacs built-in read-only mode
|
||||
(evil-define-key '(normal visual operator motion) 'global
|
||||
;; To see the keybindings, use <C-h> k then type the key
|
||||
; "n" 'evil-next-line
|
||||
; "e" 'evil-previous-line
|
||||
; "i" 'evil-forward-char
|
||||
; ;"l" 'evil-insert
|
||||
; ;"L" 'evil-insert-0-line
|
||||
; "k" 'evil-search-next
|
||||
; "K" 'evil-search-previous
|
||||
; "j" 'evil-forward-word-end
|
||||
; "J" 'evil-forward-WORD-end
|
||||
"J" '(lambda () (interactive) (evil-next-line 5)) ; 5n
|
||||
"K" '(lambda () (interactive) (evil-previous-line 5)) ; 5e
|
||||
; (kbd "C-w n") 'evil-window-down
|
||||
; (kbd "C-w e") 'evil-window-up
|
||||
; (kbd "C-w i") 'evil-window-right
|
||||
; (kbd "C-w C-n") 'evil-window-down
|
||||
; (kbd "C-w C-e") 'evil-window-up
|
||||
; (kbd "C-w C-i") 'evil-window-right)
|
||||
; (evil-define-key '(normal visual) 'global
|
||||
; "l" 'evil-insert
|
||||
; "L" 'evil-insert-0-line)
|
||||
(evil-define-key '(normal motion) 'global
|
||||
"H" #'tab-line-switch-to-prev-tab
|
||||
"L" #'tab-line-switch-to-next-tab)
|
||||
(evil-define-key '(visual operator) 'global
|
||||
"H" #'evil-beginning-of-line
|
||||
"L" #'evil-end-of-line)
|
||||
(evil-ex-define-cmd "bn" #'tab-line-switch-to-next-tab)
|
||||
(evil-ex-define-cmd "bp" #'tab-line-switch-to-prev-tab)))
|
||||
|
||||
;; Text Objects Keymap - Use `l` for inner (swap i and l)
|
||||
;; https://github.com/emacs-evil/evil/blob/master/evil-maps.el#L398-L421
|
||||
(define-key evil-visual-state-map "l" evil-inner-text-objects-map)
|
||||
(define-key evil-operator-state-map "l" evil-inner-text-objects-map)
|
||||
|
||||
|
||||
;; Provides Vim-like Leader key <SPC>
|
||||
(use-package evil-leader
|
||||
:after evil
|
||||
:config
|
||||
(global-evil-leader-mode)
|
||||
(evil-leader/set-leader "<SPC>")
|
||||
(evil-leader/set-key
|
||||
"ft" #'treemacs
|
||||
"bb" #'buffer-menu))
|
||||
|
||||
;; Evil Commentary: Use gc<action> to toggle comments
|
||||
(use-package evil-commentary
|
||||
:after evil
|
||||
:config
|
||||
(evil-commentary-mode))
|
||||
|
||||
;; Evil Surround: Vim-surround Evil fork
|
||||
(use-package evil-surround
|
||||
:after evil
|
||||
:config
|
||||
(global-evil-surround-mode 1))
|
||||
|
||||
(use-package evil-mc
|
||||
:config
|
||||
(global-evil-mc-mode 1))
|
||||
|
||||
|
||||
;; Evil-goggles: Highlight-yank (and more)
|
||||
(use-package evil-goggles
|
||||
:ensure t
|
||||
:config
|
||||
(evil-goggles-mode)
|
||||
|
||||
;; optionally use diff-mode's faces; as a result, deleted text
|
||||
;; will be highlighed with `diff-removed` face which is typically
|
||||
;; some red color (as defined by the color theme)
|
||||
;; other faces such as `diff-added` will be used for other actions
|
||||
(evil-goggles-use-diff-faces))
|
||||
|
||||
(with-eval-after-load 'evil
|
||||
(evil-set-initial-state 'org-agenda-mode 'motion))
|
||||
|
||||
(provide 'init-evil)
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
;;; init-file.el -- File Management configuration
|
||||
;;; First edit at 2025/01/29
|
||||
|
||||
;; Dired
|
||||
|
||||
;; Dired Configuration
|
||||
(with-eval-after-load 'dired
|
||||
(setq dired-recursive-deletes 'top) ;; Ask Before Delete Dir
|
||||
(setq dired-recursive-copies 'always) ;; Always Copy Dir
|
||||
(setq dired-dwim-target t)) ;; dwim for Do What I Mean - 当分屏显示两个 Buffer 时,复制或移动文件会自动将另一个 dired buffer 作为目标目录
|
||||
|
||||
;; Dired Keybindings - Colemak
|
||||
(evil-define-key 'normal dired-mode-map
|
||||
"h" 'dired-up-directory
|
||||
"i" 'dired-find-file
|
||||
"n" 'dired-next-line
|
||||
"e" 'dired-previous-line)
|
||||
|
||||
;; This prevents Dired from opening more buffers
|
||||
;; https://stackoverflow.com/q/1839313
|
||||
(setq dired-kill-when-opening-new-dired-buffer t)
|
||||
|
||||
;; Treemacs - Sidebar File Tree
|
||||
(use-package treemacs
|
||||
:straight t
|
||||
:defer t
|
||||
:init
|
||||
(with-eval-after-load 'winum
|
||||
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
|
||||
:bind
|
||||
(:map global-map
|
||||
("M-0" . treemacs-select-window)
|
||||
("C-x t 1" . treemacs-delete-other-windows)
|
||||
;; ("C-x t t" . treemacs)
|
||||
("C-x t d" . treemacs-select-directory)
|
||||
("C-x t B" . treemacs-bookmark)
|
||||
("C-x t C-t" . treemacs-find-file)
|
||||
("C-x t M-t" . treemacs-find-tag)
|
||||
)
|
||||
:config
|
||||
(setq treemacs-persist-file (expand-file-name "treemacs-persist" user-emacs-data)))
|
||||
|
||||
|
||||
(use-package treemacs-nerd-icons
|
||||
:config
|
||||
(treemacs-load-theme "nerd-icons"))
|
||||
|
||||
(use-package treemacs-evil
|
||||
:after (treemacs evil)
|
||||
:ensure t
|
||||
:config
|
||||
;; Evil treemacs state bindings
|
||||
(evil-define-key '(normal motion) evil-treemacs-state-map
|
||||
(kbd "n") #'treemacs-next-line
|
||||
(kbd "e") #'treemacs-previous-line
|
||||
(kbd "N") #'treemacs-next-neighbour
|
||||
(kbd "E") #'treemacs-previous-neighbour
|
||||
(kbd "H") #'treemacs-toggle-show-dotfiles
|
||||
(kbd "I") #'treemacs-hide-gitignored-files-mode
|
||||
(kbd "i") #'treemacs-RET-action
|
||||
(kbd "a") #'treemacs-create-file
|
||||
(kbd "A") #'treemacs-create-dir
|
||||
(kbd "c") #'treemacs-copy-file
|
||||
(kbd "x") #'treemacs-move-file
|
||||
(kbd "d") #'treemacs-delete-file
|
||||
(kbd "r") #'treemacs-rename-file
|
||||
(kbd "q") #'treemacs-quit
|
||||
(kbd "y") #'treemacs-copy-relative-path-at-point
|
||||
(kbd "Y") #'treemacs-copy-absolute-path-at-point
|
||||
(kbd "m") #'treemacs-mark-or-unmark-path-at-point)
|
||||
|
||||
;; Treemacs mode specific binding
|
||||
(evil-define-key 'treemacs treemacs-mode-map (kbd "i") #'treemacs-RET-action))
|
||||
|
||||
(use-package dirvish)
|
||||
|
||||
|
||||
;; magit - Git Client
|
||||
(use-package magit
|
||||
:ensure t
|
||||
:after (evil-leader)
|
||||
:config
|
||||
(evil-leader/set-key
|
||||
"g" 'magit-status)
|
||||
)
|
||||
|
||||
(provide 'init-file)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
;;; init-keymaps.el
|
||||
|
||||
;; Once this is defined, `M-x open-init-file` will open this file
|
||||
(defun open-org-config()
|
||||
(interactive) ;; Mark function as `interactive` that allows user to access by M-x open-init-file RET
|
||||
(find-file "~/.dotfiles/tools/emacs.d/lisp/init-org.el"))
|
||||
|
||||
(provide 'init-keymaps)
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
(use-package texfrag
|
||||
;; :init
|
||||
;; (texfrag-global-mode)
|
||||
:config
|
||||
(evil-define-key 'normal texfrag-mode-map
|
||||
(kbd "zL") #'texfrag-document)
|
||||
:hook (markdown-mode . texfrag-mode))
|
||||
|
||||
(use-package laas
|
||||
:hook (
|
||||
(LaTeX-mode . laas-mode)
|
||||
(org-mode . laas-mode))
|
||||
:config ; do whatever here
|
||||
(aas-set-snippets 'laas-mode
|
||||
;; set condition!
|
||||
:cond #'texmathp ; expand only while in math
|
||||
"nabl" "\\nabla"
|
||||
"lg" "\\lg"
|
||||
"hat" "\\hat"
|
||||
;; "iint" "\\iint"
|
||||
;; "int" "\\int"
|
||||
"cdot" "\\cdot"
|
||||
"dif" "\\mathrm{d}"
|
||||
"pm" "\\pm"
|
||||
"mp" "\\mp"
|
||||
"sq" "\\sqrt"
|
||||
;; bind to functions!
|
||||
"mk" (lambda () (interactive)
|
||||
(yas-expand-snippet "\\( $1 \\)$0"))
|
||||
"ppart" (lambda () (interactive)
|
||||
(yas-expand-snippet "\\frac{\\partial $2}{\\partial $1} $0"))
|
||||
"rm" (lambda () (interactive)
|
||||
(yas-expand-snippet "\\mathrm{$1} $0"))
|
||||
"sb" (lambda () (interactive)
|
||||
(yas-expand-snippet "_{$1} $0"))
|
||||
"Sum" (lambda () (interactive)
|
||||
(yas-expand-snippet "\\sum_{$1}^{$2} $0"))
|
||||
"Span" (lambda () (interactive)
|
||||
(yas-expand-snippet "\\Span($1)$0"))
|
||||
;; add accent snippets
|
||||
:cond #'laas-object-on-left-condition
|
||||
"qq" (lambda () (interactive) (laas-wrap-previous-object "sqrt"))
|
||||
:cond #'(lambda () (and (not (texmathp))
|
||||
(looking-back "^" nil)))
|
||||
"dm" '(yas "\\[\n$1\n\\]$0"))
|
||||
)
|
||||
|
||||
(provide 'init-latex)
|
||||
;;; init-latex.el ends
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(use-package yaml-mode :straight t)
|
||||
|
||||
(use-package markdown-mode
|
||||
:mode ("\\.md\\'" . markdown-mode)
|
||||
:init
|
||||
(setq markdown-fontify-code-blokcs-natively t)
|
||||
:custom
|
||||
(setq markdown-fontify-code-block-natively t)
|
||||
:hook ((markdown-mode . visual-line-mode)))
|
||||
|
||||
(provide 'init-markdown)
|
||||
;;; init-markdown.el ends
|
||||
|
|
@ -1,315 +0,0 @@
|
|||
;;; init-org.el
|
||||
|
||||
;; Use =M-x org-mode-restart= to take effects
|
||||
;; After =M-x eval-buffer=
|
||||
|
||||
;; Org General
|
||||
|
||||
(use-package org
|
||||
:straight (:type built-in) ;; Tell straight to not install org
|
||||
:custom
|
||||
(org-log-done 'time)
|
||||
(org-startup-indented nil)
|
||||
;; Use inline image
|
||||
(org-startup-with-inline-images t)
|
||||
(org-display-remote-inline-images 'cache) ; 预览网络图片
|
||||
|
||||
;; Use LaTeX rendering
|
||||
;; (org-startup-with-latex-preview nil)
|
||||
(org-image-actual-width 600)
|
||||
;; Conceal on markup markers
|
||||
(org-hide-emphasis-markers t)
|
||||
(org-directory "~/OrgFiles/")
|
||||
(org-agenda-files (list (concat org-directory "tasks/")))
|
||||
(org-persist-directory (expand-file-name "org-persist" user-emacs-data))
|
||||
(org-archive-location "~/OrgFiles/.archive/%s_archive::")
|
||||
(org-default-notes-file "~/OrgFiles/tasks/inbox.org")
|
||||
(org-id-locations-file (expand-file-name ".org-id-locations" org-directory))
|
||||
(org-startup-folded "show2levels")
|
||||
(org-log-into-drawer "LOGBOOK")
|
||||
(org-pretty-entities t)
|
||||
(org-src-fontify-natively t)
|
||||
(org-src-tab-acts-natively t) ; Use TAB to indent inside source block
|
||||
(org-src-preserve-indentation t) ; Prevent from auto-indent
|
||||
(org-startup-folded 'showall)
|
||||
:config
|
||||
(require 'org-habit)
|
||||
(with-eval-after-load 'org
|
||||
(define-key org-mode-map (kbd "C-j") 'org-return-indent)
|
||||
(evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle))
|
||||
(evil-define-key 'normal org-mode-map (kbd "SPC a") 'org-agenda-list) ; TODO: Here Simulates the leader
|
||||
;; (setq org-emphasis-alist
|
||||
;; '(("*" (bold :foreground "cyan" ))
|
||||
;; ("/" (italic :foreground "green"))
|
||||
;; ("_" underline)
|
||||
;; ("=" (org-verbatim verbatim :background "maroon" :foreground "white"))
|
||||
;; ("~" (org-code verbatim :background "maroon" :foreground "white"))
|
||||
;; ("+" (:strike-through t))))
|
||||
(custom-set-faces
|
||||
'(org-bold ((t (:weight bold :foreground unspecified))))
|
||||
'(org-italic ((t (:slant italic :foreground unspecified))))
|
||||
'(org-underline ((t (:underline t :foreground unspecified))))
|
||||
'(org-code ((t (:inherit fixed-pitch :background unspecified :foreground unspecified))))
|
||||
'(org-verbatim ((t (:inherit fixed-pitch :background unspecified :foreground unspecified))))
|
||||
'(org-strike-through ((t (:strike-through t :foreground unspecified)))))
|
||||
|
||||
|
||||
(dolist (face '((org-level-1 . 1.6)
|
||||
(org-level-2 . 1.4)
|
||||
(org-level-3 . 1.2)
|
||||
(org-level-4 . 1.1)
|
||||
(org-level-5 . 1.0)
|
||||
(org-level-6 . 1.0)
|
||||
(org-level-7 . 1.0)
|
||||
(org-level-8 . 1.0)))
|
||||
(set-face-attribute (car face) nil :height (cdr face))))
|
||||
|
||||
|
||||
;; Org Styling
|
||||
|
||||
;; Set Org Styles
|
||||
|
||||
|
||||
;; Org Preview
|
||||
|
||||
;; Better LaTeX preview
|
||||
|
||||
(setq org-latex-preview-ltxpng-directory (expand-file-name "emacs/org/latex" xdg-cache-home))
|
||||
(setq org-preview-latex-default-process 'dvisvgm)
|
||||
(setq org-format-latex-options (plist-put org-format-latex-options :scale 0.8))
|
||||
|
||||
;; org-appear: Show hidden emphasis markers
|
||||
;; Just like Obsidian
|
||||
(use-package org-appear
|
||||
:hook
|
||||
(org-mode . org-appear-mode))
|
||||
|
||||
|
||||
(use-package org-latex-impatient
|
||||
:defer t
|
||||
:hook (org-mode . org-latex-impatient-mode)
|
||||
:init
|
||||
(setq org-latex-impatient-tex2svg-bin
|
||||
;; location of tex2svg executable
|
||||
"~/.local/share/pnpm/tex2svg"))
|
||||
|
||||
(use-package org-fragtog
|
||||
:after org
|
||||
:hook (org-mode . org-fragtog-mode))
|
||||
|
||||
;; Pasting Images
|
||||
;; Use =M-x org-download-clipboard= to paste image
|
||||
;; Additional program required: magick
|
||||
;; Windows: scoop install imagemagick
|
||||
;; org-download config
|
||||
(use-package org-download
|
||||
:ensure t
|
||||
:after org
|
||||
:config
|
||||
;; Hardcoding the image dir
|
||||
(setq-default org-download-image-dir (expand-file-name ".attach" org-directory))
|
||||
|
||||
(setq org-download-heading-lvl nil ; don't use heading when creating files
|
||||
org-download-timestamp "%Y%m%d-%H%M%S"
|
||||
org-download-screenshot-method "screencapture -i %s" ; for macOS only
|
||||
org-download-backend 'curl) ; use curl to `download` image
|
||||
|
||||
(org-download-enable)
|
||||
|
||||
:bind (:map org-mode-map
|
||||
("C-c d c" . org-download-clipboard) ; 粘贴剪贴板内容
|
||||
("C-c d s" . org-download-screenshot))) ; 截图
|
||||
|
||||
|
||||
;; For CJK users
|
||||
;; Insert zero width space around the emphasis symbols, this might be useful for
|
||||
;; languages that does not rely on space
|
||||
(defun js0ny/insert-emphasis-with-zws (char)
|
||||
(interactive "c")
|
||||
(insert ?\u200B char)
|
||||
(save-excursion (insert char ?\u200B)))
|
||||
|
||||
(global-set-key (kbd "C-c b") (lambda () (interactive) (js0ny/insert-emphasis-with-zws ?*)))
|
||||
(global-set-key (kbd "C-c i") (lambda () (interactive) (js0ny/insert-emphasis-with-zws ?/)))
|
||||
|
||||
;; Pomodoro for org clock
|
||||
(use-package org-pomodoro
|
||||
:straight t
|
||||
:bind (:map org-mode-map
|
||||
("C-c p" . org-pomodoro)))
|
||||
|
||||
|
||||
(defun js0ny/org-pomodoro-resume-last-task ()
|
||||
"Clock in to the last task and start Pomodoro on it."
|
||||
(interactive)
|
||||
(let ((marker (car org-clock-history)))
|
||||
(if marker
|
||||
(progn
|
||||
(org-with-point-at marker
|
||||
(org-clock-in))
|
||||
(org-pomodoro))
|
||||
(message "No previous clock task found."))))
|
||||
|
||||
(use-package org-modern
|
||||
:ensure t
|
||||
:config
|
||||
;; (setopt org-modern-star 'replace
|
||||
;; org-modern-replace-stars '("§")
|
||||
;; org-modern-hide-stars "§")
|
||||
(setopt org-modern-list '((?- . "•")))
|
||||
(setopt org-modern-timestamp '(" %Y-%m-%d " . " %H:%M "))
|
||||
(setopt org-modern-block-fringe nil)
|
||||
|
||||
;; https://github.com/neoheartbeats/.emacs.d/blob/main/lisp/init-org.el#L126C1-L159C47
|
||||
(defun sthenno/org-modern-spacing ()
|
||||
"Adjust line-spacing for `org-modern' to correct svg display."
|
||||
|
||||
;; FIXME: This may not set properly
|
||||
(setq-local line-spacing (cond ((eq major-mode #'org-mode) 0.20)
|
||||
(t nil))))
|
||||
(add-hook 'org-mode-hook #'sthenno/org-modern-spacing)
|
||||
|
||||
|
||||
;; Hooks
|
||||
(add-hook 'org-mode-hook #'org-modern-mode))
|
||||
|
||||
;; WARNING: This package will cause infinite recursion when initialising org
|
||||
;; Test on 2025-03-14 Emacs 30 and Arch Linux
|
||||
;(use-package mixed-pitch
|
||||
; :hook
|
||||
; (text-mode . org-mode))
|
||||
|
||||
;; Org Agenda
|
||||
|
||||
(with-eval-after-load 'org-agenda
|
||||
(evil-define-key 'motion org-agenda-mode-map
|
||||
(kbd "n") #'org-agenda-next-line
|
||||
(kbd "e") #'org-agenda-previous-line
|
||||
(kbd "gn") #'org-agenda-next-item
|
||||
(kbd "ge") #'org-agenda-previous-item
|
||||
(kbd "N") #'org-agenda-priority-up
|
||||
(kbd "E") #'org-agenda-priority-down
|
||||
(kbd "i") #'evil-forward-char
|
||||
(kbd ",") #'org-agenda-priority
|
||||
(kbd "x") #'org-agenda-todo
|
||||
(kbd "t") #'org-agenda-set-tags
|
||||
(kbd "w") #'org-save-all-org-buffers
|
||||
(kbd "ds") #'org-agenda-schedule
|
||||
(kbd "dd") #'org-agenda-deadline
|
||||
(kbd "$") #'org-agenda-archive
|
||||
(kbd "!") #'org-agenda-toggle-deadlines
|
||||
(kbd "cp") #'org-pomodoro
|
||||
(kbd "vd") #'org-agenda-day-view
|
||||
(kbd "vw") #'org-agenda-week-view
|
||||
(kbd "vm") #'org-agenda-month-view
|
||||
(kbd "vy") #'org-agenda-year-view
|
||||
(kbd "v.") #'org-agenda-reset-view))
|
||||
|
||||
(evil-leader/set-key "A" #'org-agenda)
|
||||
|
||||
(setq org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s")
|
||||
(todo . " %i %-12:c %e")
|
||||
(tags . " %i %-12:c %e ")
|
||||
(search . " %i %-12:c %e ")))
|
||||
|
||||
|
||||
;; Org Babel
|
||||
|
||||
;; Run source block with C-c C-c
|
||||
;; Add supports for non-elisp langs
|
||||
(use-package ob-python
|
||||
:straight (:type built-in) ; Part of Org Mode
|
||||
:after org)
|
||||
|
||||
(use-package ob-C ;; C++ support is integrated in ob-C
|
||||
:straight (:type built-in) ; Part of Org Mode
|
||||
:after org)
|
||||
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'(
|
||||
(python . t) ; No need to declare C/C++/emacs-lisp since is integrated
|
||||
(shell . t)
|
||||
(dot . t)
|
||||
(ditaa . t)
|
||||
))
|
||||
;; Don't ask me again when running source block
|
||||
;; Use clang as default C/C++ Compiler on macOS and Windows
|
||||
(setq org-confirm-babel-evaluate nil)
|
||||
(if (not (eq system-type 'gnu/linux))
|
||||
(setq org-babel-C-compiler "clang"))
|
||||
|
||||
(setq org-babel-default-header-args:C
|
||||
'((:includes . "<stdio.h> <stdlib.h> <string.h>")))
|
||||
|
||||
(setq org-babel-default-header-args:C++
|
||||
'((:includes . "<iostream> <vector>")))
|
||||
|
||||
;; Org Export
|
||||
|
||||
;; icalendar
|
||||
|
||||
(defun my/org-icalendar-filter-out-habits (entry backend info)
|
||||
"Filter out Org entries that are marked as habits when exporting to iCalendar."
|
||||
(when (and (eq backend 'icalendar)
|
||||
(string-match ":STYLE:.*habit" (or entry "")))
|
||||
nil))
|
||||
|
||||
(add-hook 'org-export-filter-entry-functions #'my/org-icalendar-filter-out-habits)
|
||||
|
||||
|
||||
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
|
||||
(setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo))
|
||||
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics")
|
||||
|
||||
|
||||
;; ;; Integrate Emacs Timer with System Notifications
|
||||
;; ;; 定义通知函数
|
||||
;; (defun js0ny/org-clock-notification (title message &optional icon)
|
||||
;; "发送一个系统通知"
|
||||
;; (alert message
|
||||
;; :title title
|
||||
;; :icon icon
|
||||
;; :category 'org-clock))
|
||||
|
||||
;; ;; 添加定时器检查函数
|
||||
;; (defun js0ny/org-clock-check-timer ()
|
||||
;; "检查当前正在运行的 clock 是否到期"
|
||||
;; (when (org-clocking-p)
|
||||
;; (let* ((clocked-time (org-clock-get-clocked-time))
|
||||
;; (effort (org-duration-to-minutes
|
||||
;; (or (org-entry-get (org-clock-is-active) "Effort")
|
||||
;; "0")))
|
||||
;; (remaining (- effort clocked-time)))
|
||||
;; (when (and (> effort 0) (<= remaining 0))
|
||||
;; (js0ny/org-clock-notification
|
||||
;; "Org Clock 提醒"
|
||||
;; (format "任务 '%s' 的预计时间已到!"
|
||||
;; (org-clock-get-clock-string)))))))
|
||||
|
||||
;; ;; 设置定时器,每分钟检查一次
|
||||
;; (run-with-timer 0 60 #'js0ny/org-clock-check-timer)
|
||||
|
||||
;; 在 org-clock-in-hook 中添加检查
|
||||
;; (add-hook 'org-clock-in-hook
|
||||
;; (lambda ()
|
||||
;; (let ((effort (org-entry-get (point) "Effort")))
|
||||
;; (when effort
|
||||
;; (js0ny/org-clock-notification
|
||||
;; "开始计时"
|
||||
;; (format "开始计时任务: %s\n预计用时: %s"
|
||||
;; (org-get-heading t t t t)
|
||||
;; effort))))))
|
||||
(use-package org-node
|
||||
:after org
|
||||
:config (org-node-cache-mode))
|
||||
|
||||
|
||||
;; ;; 执行最后一行,重新生成解析表达式
|
||||
;; (with-eval-after-load 'org
|
||||
;; ;; 添加常见全角标点
|
||||
;; (setf (nth 1 org-emphasis-regexp-components)
|
||||
;; " \t\r\n,.:!?:;。,!?、」』)〉》」』〕〗】})]")
|
||||
;; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components))
|
||||
|
||||
(provide 'init-org)
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
;;; init-package.el --- Package management setup using straight.el -*- lexical-binding: t -*-
|
||||
|
||||
(setq straight-base-dir user-emacs-data)
|
||||
|
||||
;; Bootstrap straight.el
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name
|
||||
"straight/repos/straight.el/bootstrap.el"
|
||||
(or (bound-and-true-p straight-base-dir)
|
||||
user-emacs-directory)))
|
||||
(bootstrap-version 7))
|
||||
(unless (file-exists-p bootstrap-file)
|
||||
(with-current-buffer
|
||||
(url-retrieve-synchronously
|
||||
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
|
||||
'silent 'inhibit-cookies)
|
||||
(goto-char (point-max))
|
||||
(eval-print-last-sexp)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
|
||||
;; Use straight.el with use-package
|
||||
(straight-use-package 'use-package)
|
||||
(setq straight-use-package-by-default t) ;; Automatically use straight for all packages
|
||||
|
||||
;; Ensure gnu-elpa-keyring-update (equivalent to your previous keyring update logic)
|
||||
(use-package gnu-elpa-keyring-update)
|
||||
|
||||
|
||||
;; Which Key - Prompt available commands
|
||||
(use-package which-key
|
||||
:ensure t
|
||||
:init
|
||||
(which-key-mode)
|
||||
:custom
|
||||
(which-key-idle-delay 0.1))
|
||||
|
||||
;; Dashboard
|
||||
(use-package dashboard
|
||||
;; Open with :dashboard-open<CR>
|
||||
:after evil
|
||||
:bind (:map dashboard-mode-map
|
||||
;; Navigation
|
||||
("n" . dashboard-next-line)
|
||||
("e" . dashboard-previous-line)
|
||||
;; Buffer switching
|
||||
("H" . previous-buffer)
|
||||
("I" . next-buffer))
|
||||
:custom
|
||||
(dashboard-center-content t)
|
||||
:config
|
||||
(dashboard-setup-startup-hook)
|
||||
;; Use Emacs mode to use number to navigate dashboard
|
||||
)
|
||||
|
||||
|
||||
(use-package wakatime-mode
|
||||
:ensure t
|
||||
:custom
|
||||
;; Use expand-file-name to prevent from error parsing on windows-nt
|
||||
(wakatime-cli-path (expand-file-name "~/.local/bin/wakatime"))
|
||||
:config
|
||||
(global-wakatime-mode)
|
||||
)
|
||||
|
||||
|
||||
(provide 'init-package)
|
||||
;;; init-package.el ends here
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
(setq initial-major-mode 'org-mode)
|
||||
|
||||
|
||||
(provide 'init-scratch)
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
;;; init-treesitter.el tree-sitter integration for emacs
|
||||
;;; Reference: https://emacs.liujiacai.net/post/038-hello-treesitter/
|
||||
;;; Download: https://github.com/emacs-tree-sitter/tree-sitter-langs/releases/tag/0.12.268
|
||||
|
||||
|
||||
(add-to-list 'treesit-extra-load-path (expand-file-name "tree-sitter" user-emacs-data))
|
||||
|
||||
(setq major-mode-remap-alist
|
||||
'((yaml-mode . yaml-ts-mode)
|
||||
(sh-mode . bash-ts-mode)
|
||||
(js-mode . js-ts-mode)
|
||||
(css-mode . css-ts-mode)
|
||||
(c-mode . c-ts-mode)
|
||||
(c++-mode . c++-ts-mode)
|
||||
(c-or-c++-mode . c-or-c++-ts-mode)
|
||||
(python-mode . python-ts-mode)
|
||||
(js-json-mode . json-ts-mode)))
|
||||
|
||||
(add-to-list 'treesit-language-source-alist
|
||||
'(hyprlang "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang"))
|
||||
|
||||
(use-package hyprlang-ts-mode
|
||||
:ensure t
|
||||
:custom
|
||||
(hyprlang-ts-mode-indent-offset 4))
|
||||
|
||||
|
||||
(provide 'init-treesitter)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
(when (getenv "WAYLAND_DISPLAY")
|
||||
;; Fix: Emacs nox does not have clipboard integration under wayland
|
||||
(use-package xclip
|
||||
:config
|
||||
(setq xclip-program "wl-copy")
|
||||
(setq xclip-select-enable-clipboard t)
|
||||
(setq xclip-mode t)
|
||||
(setq xclip-method (quote wl-copy))))
|
||||
|
||||
(provide 'init-wayland)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
;; TODO
|
||||
(use-package flyspell)
|
||||
|
||||
(use-package olivetti
|
||||
:hook (olivetti-mode . org-mode))
|
||||
|
||||
(provide 'init-writer)
|
||||
|
|
@ -1 +0,0 @@
|
|||
../doom/lisp/
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: begin_quote
|
||||
# key: quote
|
||||
# --
|
||||
#+BEGIN_QUOTE
|
||||
$1
|
||||
#+END_QUOTE
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: begin_src
|
||||
# key: src
|
||||
# --
|
||||
#+BEGIN_SRC $1
|
||||
$2
|
||||
#+END_SRC
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: elisp
|
||||
# key: elisp
|
||||
# --
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
$1
|
||||
#+END_SRC
|
||||
4
tools/fish/.gitignore
vendored
4
tools/fish/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
|||
fish_variables
|
||||
completions
|
||||
functions/br.fish
|
||||
functions/dotenv.fish
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
# $DOTFILES/tools/fish/conf.d/0init.fish
|
||||
# Date: 2024-12-19
|
||||
# Author: js0ny
|
||||
# By dictionary order, this file is sourced first in fish shell
|
||||
# Define user-specific environment variables for fish
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/conf.d/0init.fish (default location)
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
|
||||
set -gx DOTFILES $HOME/.dotfiles
|
||||
# XDG Base Directory Specification
|
||||
set -gx XDG_CONFIG_HOME (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo $HOME/.config)
|
||||
set -gx XDG_DATA_HOME (set -q XDG_DATA_HOME; and echo $XDG_DATA_HOME; or echo $HOME/.local/share)
|
||||
set -gx XDG_STATE_HOME (set -q XDG_STATE_HOME; and echo $XDG_STATE_HOME; or echo $HOME/.local/state)
|
||||
set -gx XDG_CACHE_HOME (set -q XDG_CACHE_HOME; and echo $XDG_CACHE_HOME; or echo $HOME/.local/cache)
|
||||
|
||||
if test (uname) = "Darwin"
|
||||
set -gx XDG_RUNTIME_DIR $HOME/.tmp/run/
|
||||
else
|
||||
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
|
||||
end
|
||||
|
||||
set -gx GHCUP_USE_XDG_DIRS 1
|
||||
|
||||
set -gx PAGER "less -R"
|
||||
set -gx EDITOR nvim
|
||||
set -gx VISUAL nvim
|
||||
|
||||
# Minimal PATH for early commands
|
||||
for dir in /usr/local/bin /usr/bin /bin /usr/sbin /sbin "$HOME/.local/bin" /opt/share/bin
|
||||
if test -d "$dir" -a ! -L "$dir"
|
||||
fish_add_path "$dir"
|
||||
end
|
||||
end
|
||||
|
||||
# Homebrew/Linuxbrew
|
||||
test -d /opt/homebrew/bin && fish_add_path /opt/homebrew/bin
|
||||
test -d /home/linuxbrew/.linuxbrew/bin && fish_add_path /home/linuxbrew/.linuxbrew/bin
|
||||
|
||||
if command -v brew > /dev/null
|
||||
set -gx HOMEBREW_NO_ENV_HINTS
|
||||
end
|
||||
|
||||
# Azure CLI
|
||||
if command -v az > /dev/null
|
||||
set -gx AZURE_CONFIG_DIR $XDG_DATA_HOME/azure
|
||||
end
|
||||
# Bun JS
|
||||
if command -v bun > /dev/null
|
||||
set -gx BUN_INSTALL "$XDG_DATA_HOME/bun"
|
||||
set -gx PATH $BUN_INSTALL/bin $PATH
|
||||
end
|
||||
# Rust Cargo
|
||||
if command -v cargo > /dev/null
|
||||
set -gx CARGO_HOME $XDG_DATA_HOME/cargo
|
||||
set -gx PATH $CARGO_HOME/bin $PATH
|
||||
end
|
||||
# CGDB
|
||||
if command -v cgdb > /dev/null
|
||||
set -gx CGDB_DIR $XDG_CONFIG_HOME/cgdb
|
||||
end
|
||||
# .NET
|
||||
if command -v dotnet > /dev/null
|
||||
set -gx DOTNET_CLI_HOME $XDG_DATA_HOME/dotnet
|
||||
set -gx PATH $DOTNET_CLI_HOME/.dotnet/tools $PATH
|
||||
end
|
||||
# Docker
|
||||
if command -v docker > /dev/null
|
||||
set -gx DOCKER_CONFIG $XDG_CONFIG_HOME/docker
|
||||
end
|
||||
# GnuPG
|
||||
if command -v gpg > /dev/null
|
||||
set -gx GNUPGHOME $XDG_DATA_HOME/gnupg
|
||||
end
|
||||
# Go
|
||||
if command -v go > /dev/null
|
||||
set -gx GOPATH $XDG_DATA_HOME/go
|
||||
set PATH $GOPATH/bin $PATH
|
||||
end
|
||||
# Julia
|
||||
if command -v julia > /dev/null
|
||||
set -gx JULIA_DEPOT_PATH $XDG_DATA_HOME/julia
|
||||
end
|
||||
# Node.js
|
||||
if command -v node > /dev/null
|
||||
set -gx NODE_REPL_HISTORY $XDG_STATE_HOME/node/repl_history
|
||||
set -gx TS_NODE_REPL_HISTORY $XDG_STATE_HOME/node/ts_repl_history
|
||||
set -gx NPM_CONFIG_USERCONFIG $XDG_CONFIG_HOME/npm/npmrc
|
||||
set -gx NPM_CONFIG_INIT_MODULE $XDG_CONFIG_HOME/npm/config/npm-init.js
|
||||
set -gx NPM_CONFIG_CACHE $XDG_CACHE_HOME/npm
|
||||
set -gx NPM_CONFIG_TMP $XDG_RUNTIME_DIR/npm
|
||||
end
|
||||
# Parallel
|
||||
if command -v parallel > /dev/null
|
||||
set -gx PARALLEL_CONFIG $XDG_CONFIG_HOME/parallel
|
||||
end
|
||||
# Python
|
||||
# Works only with Python 3.13.0a3 and later
|
||||
if command -v python3 > /dev/null
|
||||
set -gx PYTHON_HISTORY $XDG_DATA_HOME/python/history
|
||||
end
|
||||
# GNU Screen
|
||||
if command -v screen > /dev/null
|
||||
set -gx SCREENRC $XDG_CONFIG_HOME/screen/screenrc
|
||||
set -gx SCREENDIR $XDG_RUNTIME_DIR/screen
|
||||
end
|
||||
# Ruby Gem
|
||||
if command -v gem > /dev/null
|
||||
for dir in $HOME/.local/share/gem/ruby/*/bin
|
||||
if test -d $dir
|
||||
set -gx PATH $dir $PATH
|
||||
end
|
||||
end
|
||||
set -gx PATH $HOME/.local/share/gem/ruby/3.3.0/bin $PATH
|
||||
end
|
||||
# Spacemacs
|
||||
if command -v emacs > /dev/null
|
||||
set -gx SPACEMACSDIR $XDG_CONFIG_HOME/spacemacs
|
||||
end
|
||||
# tldr
|
||||
if command -v tldr > /dev/null
|
||||
set -gx TLDR_CACHE_DIR $XDG_CACHE_HOME/tldr
|
||||
end
|
||||
# W3M
|
||||
if command -v w3m > /dev/null
|
||||
set -gx W3M_DIR $XDG_DATA_HOME/w3m
|
||||
end
|
||||
# Wakatime
|
||||
if command -v wakatime > /dev/null
|
||||
set -gx WAKATIME_HOME $XDG_CONFIG_HOME/wakatime
|
||||
end
|
||||
# Wget
|
||||
if command -v wget > /dev/null
|
||||
alias wget="wget --hsts-file=$XDG_CACHE_HOME/wget-hsts"
|
||||
end
|
||||
# z
|
||||
if command -v z > /dev/null
|
||||
set -gx _Z_DATA $XDG_DATA_HOME/z
|
||||
end
|
||||
if command -v tldr > /dev/null
|
||||
set -gx TLDR_CACHE_DIR $XDG_CACHE_HOME/tldr
|
||||
end
|
||||
if status is-interactive
|
||||
if command -v ipython > /dev/null
|
||||
set IPYTHONDIR $XDG_CONFIG_HOME/ipython
|
||||
end
|
||||
end
|
||||
|
||||
if command -v opam > /dev/null
|
||||
set OPAMROOT $XDG_DATA_HOME/opam
|
||||
test -r $OPAMROOT/opam-init/init.fish && source $OPAMROOT/opam-init/init.fish > /dev/null 2> /dev/null; or true
|
||||
end
|
||||
|
||||
# Coursier: Scala dependency manager
|
||||
if command -v coursier > /dev/null
|
||||
set -gx PATH "$PATH:$XDG_DATA_HOME/coursier/bin"
|
||||
end
|
||||
# pnpm
|
||||
set -gx PNPM_HOME "$XDG_DATA_HOME/pnpm"
|
||||
if not string match -q -- $PNPM_HOME $PATH
|
||||
set -gx PATH "$PNPM_HOME" $PATH
|
||||
end
|
||||
# pnpm end
|
||||
|
||||
test -d /opt/miniconda3 && source /opt/miniconda3/etc/fish/conf.d/conda.fish
|
||||
|
||||
test -f /opt/miniconda3/etc/fish/conf.d/conda.fish && source /opt/miniconda3/etc/fish/conf.d/conda.fish
|
||||
|
||||
# User-specific PATH
|
||||
test -d $HOME/.local/scripts && fish_add_path $HOME/.local/scripts
|
||||
test -d $HOME/.local/build && fish_add_path $HOME/.local/build
|
||||
|
||||
source "/home/js0ny/.deno/env.fish"
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
# $DOTFILES/tools/fish/conf.d/alias.fish
|
||||
# Date: 2024-12-22
|
||||
# Author: js0ny
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/conf.d/alias.fish
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
|
||||
switch (uname)
|
||||
case "Darwin"
|
||||
# macOS Specific
|
||||
#abbr --add clip pbcopy
|
||||
#abbr --add paste pbpaste
|
||||
alias clip="pbcopy"
|
||||
alias paste="pbpaste"
|
||||
# Use GNU Coreutils
|
||||
alias cp=gcp
|
||||
alias ln=gln
|
||||
alias mkdir=gmkdir
|
||||
alias mv=gmv
|
||||
alias rm=grm
|
||||
alias rmdir=grmdir
|
||||
alias touch=gtouch
|
||||
alias clip=pbcopy
|
||||
alias paste=pbpaste
|
||||
alias sed=gsed
|
||||
abbr --add reboot "sudo reboot"
|
||||
case "Linux"
|
||||
# Linux Specific
|
||||
#switch($XDG_SESSION_TYPE)
|
||||
#case "wayland"
|
||||
# Wayland Specific
|
||||
alias clip="wl-copy"
|
||||
alias paste="wl-paste"
|
||||
#case "x11"
|
||||
# # X11 Specific
|
||||
# alias clip="xclip -selection clipboard"
|
||||
# alias paste="xclip -selection clipboard -o"
|
||||
case '*'
|
||||
# Default / Fallback case
|
||||
alias clip="xclip -selection clipboard"
|
||||
alias paste="xclip -selection clipboard -o"
|
||||
end
|
||||
|
||||
# Powershell equivalent
|
||||
abbr --add ni touch
|
||||
abbr --add cls clear
|
||||
abbr --add ii open
|
||||
|
||||
# Editors #
|
||||
abbr --add v nvim
|
||||
abbr --add c code
|
||||
alias svi="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc" # Prevent conflicts with svelte-cli
|
||||
|
||||
# Dev #
|
||||
abbr --add py python3
|
||||
abbr --add ipy ipython
|
||||
|
||||
abbr --add g lazygit
|
||||
|
||||
abbr --add aic "aichat -s"
|
||||
|
||||
# lsd - modern ls
|
||||
if command -v lsd > /dev/null
|
||||
alias ls='lsd'
|
||||
abbr --add l 'lsd -lah'
|
||||
abbr --add ll 'lsd -l'
|
||||
abbr --add la 'lsd -A'
|
||||
abbr --add l. 'lsd -d .*'
|
||||
abbr --add tree 'ls --tree'
|
||||
else
|
||||
abbr --add l 'ls -lah'
|
||||
abbr --add ll 'ls -l'
|
||||
end
|
||||
|
||||
# Functions #
|
||||
function mkcd
|
||||
mkdir -p $argv[1] && cd $argv[1]
|
||||
end
|
||||
function cdls
|
||||
cd $argv[1] && ls
|
||||
end
|
||||
function tc
|
||||
touch $argv[1] && code $argv[1]
|
||||
end
|
||||
function tv
|
||||
touch $argv[1] && nvim $argv[1]
|
||||
end
|
||||
|
||||
# Create a new file, if the directory does not exist, create it
|
||||
# Arg: a file name
|
||||
function mt
|
||||
mkdir -p (dirname $argv[1]) && touch $argv[1]
|
||||
end
|
||||
|
||||
function mtv
|
||||
mkdir -p (dirname $argv[1]) && touch $argv[1] && nvim $argv[1]
|
||||
end
|
||||
|
||||
abbr --add bcat "bat --style=plain"
|
||||
|
||||
# Use neovide as gVim
|
||||
abbr --add gvi "neovide"
|
||||
|
||||
if command -v brew > /dev/null
|
||||
abbr --add brewi "brew install"
|
||||
abbr --add brewu "brew upgrade && brew update"
|
||||
abbr --add brewr "brew remove"
|
||||
abbr --add brewc "brew cleanup"
|
||||
abbr --add brewl "brew list"
|
||||
end
|
||||
|
||||
if command -v pacman > /dev/null
|
||||
abbr --add pac "sudo pacman"
|
||||
abbr --add paci "sudo pacman -S"
|
||||
abbr --add pacr "sudo pacman -R"
|
||||
abbr --add pacu "sudo pacman -Syu"
|
||||
abbr --add pacl "pacman -Q"
|
||||
if command -v paru > /dev/null
|
||||
abbr --add pacs "paru -Ss"
|
||||
else if command -v yay > /dev/null
|
||||
abbr --add pacs "yay -Ss"
|
||||
else
|
||||
abbr --add pacs "pacman -Ss"
|
||||
end
|
||||
end
|
||||
|
||||
if command -v apt > /dev/null
|
||||
abbr --add apt "sudo apt"
|
||||
abbr --add apti "sudo apt install"
|
||||
abbr --add aptr "sudo apt remove"
|
||||
abbr --add aptu "sudo apt update && sudo apt upgrade"
|
||||
abbr --add apts "apt search"
|
||||
abbr --add aptl "apt list --installed"
|
||||
end
|
||||
|
||||
|
||||
if command -v dnf > /dev/null
|
||||
abbr --add dnf "sudo dnf"
|
||||
abbr --add dnfi "sudo dnf install"
|
||||
abbr --add dnfr "sudo dnf remove"
|
||||
abbr --add dnfu "sudo dnf update"
|
||||
abbr --add dnfs "dnf search"
|
||||
abbr --add dnfl "dnf list --installed"
|
||||
end
|
||||
|
||||
if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty"
|
||||
abbr --add icat "kitten icat"
|
||||
else if test "$TERM_PROGRAM" = "WezTerm"
|
||||
if test "$WSL_DISTRO_NAME"
|
||||
abbr --add icat "wezterm.exe imgcat"
|
||||
else
|
||||
abbr --add icat "wezterm imgcat"
|
||||
end
|
||||
end
|
||||
|
||||
# Bash Style Command Substitution
|
||||
# https://github.com/fish-shell/fish-shell/wiki/Bash-Style-Command-Substitution-and-Chaining-(!!-!$)
|
||||
|
||||
function __last_history_item; echo $history[1]; end
|
||||
|
||||
abbr -a !! --position anywhere --function __last_history_item
|
||||
|
||||
function y
|
||||
set tmp (mktemp -t "yazi-cwd.XXXXXX")
|
||||
yazi $argv --cwd-file="$tmp"
|
||||
if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
|
||||
builtin cd -- "$cwd"
|
||||
end
|
||||
rm -f -- "$tmp"
|
||||
end
|
||||
|
||||
abbr --add bcnt "emacs -nw $HOME/Documents/Finance/Beancount/"
|
||||
|
||||
if command -v chezmoi > /dev/null
|
||||
alias pmoi="chezmoi --source ~/.local/share/pmoi --config ~/.config/chezmoi/pmoi.toml"
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
switch (uname)
|
||||
case "Linux"
|
||||
set SYSTEM_COLOR_SCHEME (gsettings get org.gnome.desktop.interface color-scheme)
|
||||
if test $SYSTEM_COLOR_SCHEME = "'prefer-dark'"
|
||||
fish_config theme choose "Catppuccin Mocha"
|
||||
else
|
||||
fish_config theme choose "Catppuccin Latte"
|
||||
end
|
||||
case "Darwin"
|
||||
set SYSTEM_COLOR_SCHEME (defaults read -g AppleInterfaceStyle)
|
||||
if test $SYSTEM_COLOR_SCHEME = "Dark"
|
||||
fish_config theme choose "Catppuccin Mocha"
|
||||
else
|
||||
fish_config theme choose "Catppuccin Latte"
|
||||
end
|
||||
case '*'
|
||||
fish_config theme choose "Catppuccin Mocha"
|
||||
end
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
# $DOTFILES/tools/fish/conf.d/keymap.fish
|
||||
# Date: 2024-12-22
|
||||
# Author: js0ny
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/conf.d/keymap.fish
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
|
||||
# read key: `fish_key_reader`
|
||||
# get current bindings: `bind`
|
||||
|
||||
fish_vi_key_bindings
|
||||
|
||||
# source $DOTFILES/tools/fish/conf.d/keymap/+colemak.fish
|
||||
|
||||
# Emacs Hybrid
|
||||
bind -M default ctrl-p up-or-search
|
||||
bind -M default ctrl-n down-or-search
|
||||
bind -M default ctrl-f forward-char
|
||||
bind -M default ctrl-b backward-char
|
||||
bind -M default ctrl-a beginning-of-line
|
||||
bind -M default ctrl-e end-of-line
|
||||
bind -M default ctrl-k kill-line
|
||||
|
||||
bind -M insert ctrl-p up-or-search
|
||||
bind -M insert ctrl-n down-or-search
|
||||
bind -M insert ctrl-f forward-char
|
||||
bind -M insert ctrl-b backward-char
|
||||
bind -M insert ctrl-a beginning-of-line
|
||||
bind -M insert ctrl-e end-of-line
|
||||
bind -M insert ctrl-k kill-line
|
||||
bind -M insert ctrl-w backward-kill-path-component
|
||||
|
||||
|
||||
# ctrl + backspace
|
||||
bind -M insert ctrl-backspace backward-kill-path-component
|
||||
# alt + backspace
|
||||
bind -M insert alt-backspace backward-kill-line
|
||||
# ctrl + delete
|
||||
bind -M insert ctrl-delete kill-word
|
||||
# alt + delete (d$)
|
||||
bind -M insert alt-delete kill-line
|
||||
|
||||
fzf --fish | source
|
||||
# C-r : fzf history search
|
||||
# C-t : fzf file search
|
||||
# A-c : fzf directory search
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# Colemak hnei
|
||||
# ^
|
||||
# e
|
||||
# < h i >
|
||||
# n
|
||||
# v
|
||||
# bind -M default 'h' backward-char
|
||||
bind -M default n down-or-search
|
||||
bind -M default e up-or-search
|
||||
bind -M default i forward-char
|
||||
|
||||
# Similar position to [i] in QWERTY
|
||||
bind -M default -m insert l repaint-mode
|
||||
bind -M default -m insert L beginning-of-line repaint-mode
|
||||
|
||||
# Ne{[k]s}t -> fish doesnt have this feature
|
||||
|
||||
# [J]ump
|
||||
bind -M default j forward-word
|
||||
bind -M default J forward-bigword
|
||||
|
||||
# Use N to Join
|
||||
bind -M default N end-of-line delete-char
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
# $DOTFILES/tools/fish/conf.d/navi.fish
|
||||
# Date: 2024-12-22
|
||||
# Author: js0ny
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/conf.d/navi.fish
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
set __CD_CMD "cd"
|
||||
|
||||
|
||||
if command -v zoxide > /dev/null
|
||||
set __CD_CMD "z"
|
||||
zoxide init fish | source
|
||||
end
|
||||
|
||||
|
||||
alias ..="$__CD_CMD .."
|
||||
alias ...="$__CD_CMD ../.."
|
||||
alias ....="$__CD_CMD ../../.."
|
||||
alias .....="$__CD_CMD ../../../.."
|
||||
alias ......="$__CD_CMD ../../../../.."
|
||||
|
||||
abbr --add \- "$__CD_CMD -"
|
||||
|
||||
|
||||
function zls
|
||||
$__CD_CMD $argv[1] && ls
|
||||
end
|
||||
|
||||
alias cdls=zls
|
||||
|
||||
function __source_quick_jump
|
||||
set dir (fd --type d --max-depth 1 . ~/Source/ | fzf --preview 'lsd --color always --icon always {}')
|
||||
if test -n "$dir"
|
||||
cd "$dir"
|
||||
end
|
||||
end
|
||||
# Quick Jump Directories
|
||||
test -d $DOTFILES && abbr --add dot "$__CD_CMD $DOTFILES"
|
||||
test -d $HOME/Downloads && abbr --add down "$__CD_CMD $HOME/Downloads"
|
||||
test -d $HOME/.config && abbr --add conf "$__CD_CMD $HOME/.config"
|
||||
test -d $HOME/Obsidian && abbr --add ob "$__CD_CMD $HOME/Obsidian"
|
||||
test -d $HOME/Source && alias src="__source_quick_jump"
|
||||
test -d $HOME/Source/Scripts && alias scr="fd --type f --hidden --exclude .git --exclude '.*' . ~/Source/Scripts/ | fzf --preview 'bat --color=always --style=numbers {}' | xargs -r nvim"
|
||||
test -d $HOME/OrgFiles && abbr --add org "$__CD_CMD $HOME/OrgFiles"
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# $DOTFILES/tools/fish/conf.d/prompt.fish
|
||||
# Date: 2024-12-22
|
||||
# Author: js0ny
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/conf.d/prompt.fish
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
if command -v starship > /dev/null
|
||||
starship init fish | source
|
||||
end
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
if command -v wslpath > /dev/null
|
||||
function cdw
|
||||
cd (wslpath -u $argv)
|
||||
end
|
||||
function zw
|
||||
z (wslpath -u $argv)
|
||||
end
|
||||
alias psw="tasklist.exe"
|
||||
alias killw="taskkill.exe"
|
||||
alias winget="winget.exe"
|
||||
# https://github.com/stuartleeks/wsl-notify-send
|
||||
alias notify-send="wsl-notify-send.exe"
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
# $DOTFILES/tools/fish/config.fish
|
||||
# Date: 2024-12-15
|
||||
# Author: js0ny
|
||||
# Define interactive shell configurations for fish
|
||||
|
||||
# Location:
|
||||
# ~/.config/fish/config.fish (default location)
|
||||
# Linking: Link the whole directory for submodules
|
||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||
|
||||
if status is-interactive
|
||||
# Commands to run in interactive sessions can go here
|
||||
set fish_greeting
|
||||
end
|
||||
|
||||
# bun
|
||||
set --export BUN_INSTALL "$HOME/.bun"
|
||||
set --export PATH $BUN_INSTALL/bin $PATH
|
||||
|
||||
# moonbit
|
||||
fish_add_path "$HOME/.moon/bin"
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
|
||||
|
||||
|
||||
## `type -q` vs `command -v`
|
||||
|
||||
```shell
|
||||
> time for i in (seq 1 10000)
|
||||
type -q vim
|
||||
end
|
||||
|
||||
time for i in (seq 1 10000)
|
||||
command -v vim >/dev/null
|
||||
end
|
||||
|
||||
|
||||
________________________________________________________
|
||||
Executed in 545.79 millis fish external
|
||||
usr time 177.62 millis 174.28 millis 3.34 millis
|
||||
sys time 367.72 millis 366.16 millis 1.56 millis
|
||||
|
||||
|
||||
________________________________________________________
|
||||
Executed in 292.97 millis fish external
|
||||
usr time 71.23 millis 69.31 millis 1.93 millis
|
||||
sys time 215.22 millis 214.78 millis 0.44 millis
|
||||
```
|
||||
|
||||
`command -v` is faster
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# name: 'Catppuccin Latte'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: eff1f5
|
||||
|
||||
fish_color_normal 4c4f69
|
||||
fish_color_command 1e66f5
|
||||
fish_color_param dd7878
|
||||
fish_color_keyword d20f39
|
||||
fish_color_quote 40a02b
|
||||
fish_color_redirection ea76cb
|
||||
fish_color_end fe640b
|
||||
fish_color_comment 8c8fa1
|
||||
fish_color_error d20f39
|
||||
fish_color_gray 9ca0b0
|
||||
fish_color_selection --background=ccd0da
|
||||
fish_color_search_match --background=ccd0da
|
||||
fish_color_option 40a02b
|
||||
fish_color_operator ea76cb
|
||||
fish_color_escape e64553
|
||||
fish_color_autosuggestion 9ca0b0
|
||||
fish_color_cancel d20f39
|
||||
fish_color_cwd df8e1d
|
||||
fish_color_user 179299
|
||||
fish_color_host 1e66f5
|
||||
fish_color_host_remote 40a02b
|
||||
fish_color_status d20f39
|
||||
fish_pager_color_progress 9ca0b0
|
||||
fish_pager_color_prefix ea76cb
|
||||
fish_pager_color_completion 4c4f69
|
||||
fish_pager_color_description 9ca0b0
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# name: 'Catppuccin Mocha'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 1e1e2e
|
||||
|
||||
fish_color_normal cdd6f4
|
||||
fish_color_command 89b4fa
|
||||
fish_color_param f2cdcd
|
||||
fish_color_keyword f38ba8
|
||||
fish_color_quote a6e3a1
|
||||
fish_color_redirection f5c2e7
|
||||
fish_color_end fab387
|
||||
fish_color_comment 7f849c
|
||||
fish_color_error f38ba8
|
||||
fish_color_gray 6c7086
|
||||
fish_color_selection --background=313244
|
||||
fish_color_search_match --background=313244
|
||||
fish_color_option a6e3a1
|
||||
fish_color_operator f5c2e7
|
||||
fish_color_escape eba0ac
|
||||
fish_color_autosuggestion 6c7086
|
||||
fish_color_cancel f38ba8
|
||||
fish_color_cwd f9e2af
|
||||
fish_color_user 94e2d5
|
||||
fish_color_host 89b4fa
|
||||
fish_color_host_remote a6e3a1
|
||||
fish_color_status f38ba8
|
||||
fish_pager_color_progress 6c7086
|
||||
fish_pager_color_prefix f5c2e7
|
||||
fish_pager_color_completion cdd6f4
|
||||
fish_pager_color_description 6c7086
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
# syntax highlighting variables
|
||||
# https://fishshell.com/docs/current/interactive.html#syntax-highlighting-variables
|
||||
fish_color_normal 575279
|
||||
fish_color_command 907aa9
|
||||
fish_color_keyword 56949f
|
||||
fish_color_quote ea9d34
|
||||
fish_color_redirection 286983
|
||||
fish_color_end 797593
|
||||
fish_color_error b4637a
|
||||
fish_color_param d7827e
|
||||
fish_color_comment 797593
|
||||
# fish_color_match --background=brblue
|
||||
fish_color_selection --reverse
|
||||
# fish_color_history_current --bold
|
||||
fish_color_operator 575279
|
||||
fish_color_escape 286983
|
||||
fish_color_autosuggestion 797593
|
||||
fish_color_cwd d7827e
|
||||
# fish_color_cwd_root red
|
||||
fish_color_user ea9d34
|
||||
fish_color_host 56949f
|
||||
fish_color_host_remote 907aa9
|
||||
fish_color_cancel 575279
|
||||
fish_color_search_match --background=faf4ed
|
||||
fish_color_valid_path
|
||||
|
||||
# pager color variables
|
||||
# https://fishshell.com/docs/current/interactive.html#pager-color-variables
|
||||
fish_pager_color_progress d7827e
|
||||
fish_pager_color_background --background=fffaf3
|
||||
fish_pager_color_prefix 56949f
|
||||
fish_pager_color_completion 797593
|
||||
fish_pager_color_description 797593
|
||||
fish_pager_color_secondary_background
|
||||
fish_pager_color_secondary_prefix
|
||||
fish_pager_color_secondary_completion
|
||||
fish_pager_color_secondary_description
|
||||
fish_pager_color_selected_background --background=f2e9e1
|
||||
fish_pager_color_selected_prefix 56949f
|
||||
fish_pager_color_selected_completion 575279
|
||||
fish_pager_color_selected_description 575279
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
# vim:ft=kitty
|
||||
|
||||
## name: Catppuccin-Mocha
|
||||
## author: Pocco81 (https://github.com/Pocco81)
|
||||
## license: MIT
|
||||
## upstream: https://github.com/catppuccin/kitty/blob/main/mocha.conf
|
||||
## blurb: Soothing pastel theme for the high-spirited!
|
||||
|
||||
# Accent: Lavender #B4BEFE
|
||||
|
||||
|
||||
# The basic colors
|
||||
foreground #CDD6F4
|
||||
background #1E1E2E
|
||||
selection_foreground #1E1E2E
|
||||
selection_background #F5E0DC
|
||||
|
||||
# Cursor colors
|
||||
cursor #F5E0DC
|
||||
cursor_text_color #1E1E2E
|
||||
|
||||
# URL underline color when hovering with mouse
|
||||
url_color #F5E0DC
|
||||
|
||||
# Kitty window border colors
|
||||
active_border_color #B4BEFE
|
||||
inactive_border_color #6C7086
|
||||
bell_border_color #F9E2AF
|
||||
|
||||
# OS Window titlebar colors
|
||||
wayland_titlebar_color system
|
||||
macos_titlebar_color system
|
||||
|
||||
# Tab bar colors
|
||||
active_tab_foreground #11111B
|
||||
active_tab_background #B4BEFE
|
||||
inactive_tab_foreground #CDD6F4
|
||||
inactive_tab_background #1E1E2E
|
||||
tab_bar_background #181825
|
||||
|
||||
# Colors for marks (marked text in the terminal)
|
||||
mark1_foreground #1E1E2E
|
||||
mark1_background #B4BEFE
|
||||
mark2_foreground #1E1E2E
|
||||
mark2_background #B4BEFE
|
||||
mark3_foreground #1E1E2E
|
||||
mark3_background #74C7EC
|
||||
|
||||
# The 16 terminal colors
|
||||
|
||||
# black
|
||||
color0 #45475A
|
||||
color8 #585B70
|
||||
|
||||
# red
|
||||
color1 #F38BA8
|
||||
color9 #F38BA8
|
||||
|
||||
# green
|
||||
color2 #A6E3A1
|
||||
color10 #A6E3A1
|
||||
|
||||
# yellow
|
||||
color3 #F9E2AF
|
||||
color11 #F9E2AF
|
||||
|
||||
# blue
|
||||
color4 #89B4FA
|
||||
color12 #89B4FA
|
||||
|
||||
# magenta
|
||||
color5 #F5C2E7
|
||||
color13 #F5C2E7
|
||||
|
||||
# cyan
|
||||
color6 #94E2D5
|
||||
color14 #94E2D5
|
||||
|
||||
# white
|
||||
color7 #BAC2DE
|
||||
color15 #A6ADC8
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
# vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
# Fonts {{{
|
||||
|
||||
# Family
|
||||
font_family family="Maple Mono NF CN"
|
||||
bold_font auto
|
||||
italic_font auto
|
||||
bold_italic_font auto
|
||||
|
||||
# Ligature
|
||||
disable_ligatures never
|
||||
font_size 12.0
|
||||
# }}}
|
||||
|
||||
# Text Cursor {{{
|
||||
# Cursor Trail
|
||||
cursor_trail 1
|
||||
cursor_trail_decay 0.1 0.4
|
||||
cursor_trail_start_threshold 2
|
||||
# }}}
|
||||
|
||||
# Tab Bar {{{
|
||||
tab_bar_edge top
|
||||
tab_bar_align left
|
||||
tab_bar_style powerline
|
||||
# Hide tab bar when there is only one tab
|
||||
tab_bar_min_tabs 2
|
||||
tab_title_template "{f'{title[:30]}…' if title.rindex(title[-1]) + 1 > 30 else (title.center(6) if (title.rindex(title[-1]) + 1) % 2 == 0 else title.center(5))}"
|
||||
active_tab_font_style bold
|
||||
# }}}
|
||||
|
||||
# Color Scheme {{{
|
||||
# BEGIN_KITTY_THEME
|
||||
# Rosé Pine Dawn
|
||||
include current-theme.conf
|
||||
# END_KITTY_THEME
|
||||
# }}}
|
||||
|
||||
|
||||
# macOS {{{
|
||||
macos_option_as_alt yes
|
||||
macos_quit_when_last_window_closed yes
|
||||
# }}}
|
||||
|
||||
# Keyboard Shortcuts {{{
|
||||
map alt+t new_tab
|
||||
map alt+w close_tab
|
||||
map ctrl+c copy_and_clear_or_interrupt
|
||||
map alt+1 goto_tab 1
|
||||
map alt+2 goto_tab 2
|
||||
map alt+3 goto_tab 3
|
||||
map alt+4 goto_tab 4
|
||||
map alt+5 goto_tab 5
|
||||
map alt+6 goto_tab 6
|
||||
map alt+7 goto_tab 7
|
||||
map alt+8 goto_tab 8
|
||||
map alt+9 goto_tab -1
|
||||
# Leader: ctrl+q
|
||||
# https://github.com/sxyazi/dotfiles
|
||||
map ctrl+q noop
|
||||
map ctrl+q>| kitten window.py +split right
|
||||
map ctrl+q>\ kitten window.py +split right
|
||||
map ctrl+q>- kitten window.py +split bottom
|
||||
map ctrl+q>h kitten window.py -jump left
|
||||
map ctrl+q>n kitten window.py -jump bottom
|
||||
map ctrl+q>e kitten window.py -jump top
|
||||
map ctrl+q>i kitten window.py -jump right
|
||||
map alt+shift+h kitten window.py -jump left
|
||||
map alt+shift+n kitten window.py -jump bottom
|
||||
map alt+shift+e kitten window.py -jump top
|
||||
map alt+shift+i kitten window.py -jump right
|
||||
map ctrl+q>shift+H kitten window.py -resize left
|
||||
map ctrl+q>shift+N kitten window.py -resize bottom
|
||||
map ctrl+q>shift+E kitten window.py -resize top
|
||||
map ctrl+q>shift+I kitten window.py -resize right
|
||||
map cmd+enter toggle_layout stack
|
||||
map ctrl+shift+enter toggle_layout stack
|
||||
# }}}
|
||||
|
||||
|
||||
shell fish
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
# vim:ft=kitty
|
||||
|
||||
## name: Catppuccin-Latte
|
||||
## author: Pocco81 (https://github.com/Pocco81)
|
||||
## license: MIT
|
||||
## upstream: https://github.com/catppuccin/kitty/blob/main/latte.conf
|
||||
## blurb: Soothing pastel theme for the high-spirited!
|
||||
|
||||
|
||||
|
||||
# The basic colors
|
||||
foreground #4C4F69
|
||||
background #EFF1F5
|
||||
selection_foreground #EFF1F5
|
||||
selection_background #DC8A78
|
||||
|
||||
# Cursor colors
|
||||
cursor #DC8A78
|
||||
cursor_text_color #EFF1F5
|
||||
|
||||
# URL underline color when hovering with mouse
|
||||
url_color #DC8A78
|
||||
|
||||
# Kitty window border colors
|
||||
active_border_color #7287FD
|
||||
inactive_border_color #9CA0B0
|
||||
bell_border_color #DF8E1D
|
||||
|
||||
# OS Window titlebar colors
|
||||
wayland_titlebar_color system
|
||||
macos_titlebar_color system
|
||||
|
||||
# Tab bar colors
|
||||
active_tab_foreground #EFF1F5
|
||||
active_tab_background #8839EF
|
||||
inactive_tab_foreground #4C4F69
|
||||
inactive_tab_background #9CA0B0
|
||||
tab_bar_background #BCC0CC
|
||||
|
||||
# Colors for marks (marked text in the terminal)
|
||||
mark1_foreground #EFF1F5
|
||||
mark1_background #7287fD
|
||||
mark2_foreground #EFF1F5
|
||||
mark2_background #8839EF
|
||||
mark3_foreground #EFF1F5
|
||||
mark3_background #209FB5
|
||||
|
||||
# The 16 terminal colors
|
||||
|
||||
# black
|
||||
color0 #5C5F77
|
||||
color8 #6C6F85
|
||||
|
||||
# red
|
||||
color1 #D20F39
|
||||
color9 #D20F39
|
||||
|
||||
# green
|
||||
color2 #40A02B
|
||||
color10 #40A02B
|
||||
|
||||
# yellow
|
||||
color3 #DF8E1D
|
||||
color11 #DF8E1D
|
||||
|
||||
# blue
|
||||
color4 #1E66F5
|
||||
color12 #1E66F5
|
||||
|
||||
# magenta
|
||||
color5 #EA76CB
|
||||
color13 #EA76CB
|
||||
|
||||
# cyan
|
||||
color6 #179299
|
||||
color14 #179299
|
||||
|
||||
# white
|
||||
color7 #ACB0BE
|
||||
color15 #BCC0CC
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
# https://github.com/sxyazi/dotfiles
|
||||
from kittens.tui.handler import result_handler
|
||||
|
||||
directions = {
|
||||
"top": "u",
|
||||
"bottom": "e",
|
||||
"left": "n",
|
||||
"right": "i",
|
||||
}
|
||||
|
||||
|
||||
def main(args):
|
||||
pass
|
||||
|
||||
|
||||
@result_handler(no_ui=True)
|
||||
def handle_result(args, answer, target_window_id, boss):
|
||||
window = boss.active_window
|
||||
if window is None:
|
||||
return
|
||||
|
||||
cmd = window.child.foreground_cmdline[0]
|
||||
act = args[1] # e.g. -jump
|
||||
if act[0] == "-" and cmd[-4:] == "nvim":
|
||||
second = directions[args[2]] if len(args) > 2 else ""
|
||||
window.write_to_child(f"\x1b[119;8u{act[1]}{second}")
|
||||
return
|
||||
|
||||
if (act == "-close" or act == "-quit") and cmd[-7:] == "joshuto":
|
||||
window.write_to_child(f"\x1b{act[1]}")
|
||||
return
|
||||
|
||||
def split(direction):
|
||||
if direction == "top" or direction == "bottom":
|
||||
boss.launch("--cwd=current", "--location=hsplit")
|
||||
else:
|
||||
boss.launch("--cwd=current", "--location=vsplit")
|
||||
|
||||
if direction == "top" or direction == "left":
|
||||
boss.active_tab.move_window(direction)
|
||||
|
||||
def close():
|
||||
boss.close_window()
|
||||
|
||||
def quit():
|
||||
boss.quit()
|
||||
|
||||
def jump(direction):
|
||||
boss.active_tab.neighboring_window(direction)
|
||||
|
||||
# https://github.com/chancez/dotfiles/blob/master/kitty/.config/kitty/relative_resize.py
|
||||
def resize(direction):
|
||||
neighbors = boss.active_tab.current_layout.neighbors_for_window(
|
||||
window, boss.active_tab.windows
|
||||
)
|
||||
top, bottom = neighbors.get("top"), neighbors.get("bottom")
|
||||
left, right = neighbors.get("left"), neighbors.get("right")
|
||||
|
||||
if direction == "top":
|
||||
if top and bottom:
|
||||
boss.active_tab.resize_window("shorter", 10)
|
||||
elif top:
|
||||
boss.active_tab.resize_window("taller", 10)
|
||||
elif bottom:
|
||||
boss.active_tab.resize_window("shorter", 10)
|
||||
elif direction == "bottom":
|
||||
if top and bottom:
|
||||
boss.active_tab.resize_window("taller", 10)
|
||||
elif top:
|
||||
boss.active_tab.resize_window("shorter", 10)
|
||||
elif bottom:
|
||||
boss.active_tab.resize_window("taller", 10)
|
||||
elif direction == "left":
|
||||
if left and right:
|
||||
boss.active_tab.resize_window("narrower", 10)
|
||||
elif left:
|
||||
boss.active_tab.resize_window("wider", 10)
|
||||
elif right:
|
||||
boss.active_tab.resize_window("narrower", 10)
|
||||
elif direction == "right":
|
||||
if left and right:
|
||||
boss.active_tab.resize_window("wider", 10)
|
||||
elif left:
|
||||
boss.active_tab.resize_window("narrower", 10)
|
||||
elif right:
|
||||
boss.active_tab.resize_window("wider", 10)
|
||||
|
||||
def move(direction):
|
||||
boss.active_tab.move_window(direction)
|
||||
|
||||
act = act[1:]
|
||||
if act == "split":
|
||||
split(args[2])
|
||||
elif act == "close":
|
||||
close()
|
||||
elif act == "quit":
|
||||
quit()
|
||||
elif act == "jump":
|
||||
jump(args[2])
|
||||
elif act == "resize":
|
||||
resize(args[2])
|
||||
elif act == "move":
|
||||
move(args[2])
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.lua]
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
--[[
|
||||
-*- coding: utf-8 -*-
|
||||
@Filename init.lua
|
||||
@Author js0ny
|
||||
@Date 2024-11-27
|
||||
@Description neovim 配置文件
|
||||
]]
|
||||
|
||||
-- Entry point of neovim configuration
|
||||
require("config.options")
|
||||
if vim.g.vscode then -- TODO: VSCode Neovim Integration
|
||||
require("config.vscode")
|
||||
else
|
||||
require("config.plugins")
|
||||
require("config.colorscheme")
|
||||
end
|
||||
require("config.keymaps")
|
||||
require("config.diagnostics")
|
||||
require("config.migration")
|
||||
|
||||
-- If current session is spawn by neovide, do:
|
||||
if vim.g.neovide then
|
||||
-- Enable input method
|
||||
vim.g.neovide_input_ime = true
|
||||
vim.g.neovide_transparency = 0.85
|
||||
vim.g.transparency = 0.85
|
||||
vim.g.neovide_normal_opacity = 0.85
|
||||
vim.g.neovide_window_blurred = true -- macOS only
|
||||
vim.g.neovide_floating_blur_amount_x = 2.0
|
||||
vim.g.neovide_floating_blur_amount_y = 2.0
|
||||
vim.g.neovide_floating_shadow = true
|
||||
vim.g.neovide_floating_z_height = 10
|
||||
vim.g.neovide_light_angle_degrees = 45
|
||||
vim.g.neovide_light_radius = 5
|
||||
vim.g.neovide_input_macos_option_key_is_meta = "only_left"
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
-- Bash
|
||||
--[[ Installation
|
||||
brew install bash-language-server
|
||||
npm i -g bash-language-server
|
||||
dnf install -y nodejs-bash-language-server # Fedora Linux
|
||||
--]]
|
||||
return {
|
||||
cmd = { "bash-language-server", "start" },
|
||||
filetypes = { "bash", "sh" },
|
||||
settings = {
|
||||
bashIde = {
|
||||
globPattern = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
-- Beancount
|
||||
--[[ Installation:
|
||||
Dependency:
|
||||
uv tool install beancount
|
||||
LSP:
|
||||
cargo install beancount-language-server
|
||||
brew install beancount-language-server
|
||||
--]]
|
||||
|
||||
|
||||
return {
|
||||
cmd = { "beancount-language-server" },
|
||||
filetypes = { "beancount" },
|
||||
settings = {
|
||||
},
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
-- C/C++
|
||||
-- Clangd requires compile_commands.json to work and the easiest way to generate it is to use CMake.
|
||||
-- How to use clangd C/C++ LSP in any project: https://gist.github.com/Strus/042a92a00070a943053006bf46912ae9
|
||||
|
||||
return {
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--clang-tidy",
|
||||
"--header-insertion=iwyu",
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
"--fallback-style=none",
|
||||
},
|
||||
filetypes = { "c", "cpp" },
|
||||
root_markers = {
|
||||
".clangd",
|
||||
".clang-format",
|
||||
"compile_commands.json",
|
||||
"compile_flags.txt",
|
||||
".git",
|
||||
},
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { "utf-8", "utf-16" },
|
||||
},
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
-- Golang
|
||||
--[[ Installation
|
||||
go install golang.org/x/tools/gopls@latest
|
||||
brew install gopls
|
||||
--]]
|
||||
return {
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_markers = { "go.work", "go.mod", ".git" },
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
-- semanticTokens = true, -- go's semantic token highlight is not accurate so far
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
-- Java
|
||||
--[[ Installation
|
||||
go install golang.org/x/tools/gopls@latest
|
||||
brew install gopls
|
||||
--]]
|
||||
return {
|
||||
cmd = { "jdtls" },
|
||||
filetypes = { "java" },
|
||||
root_markers = { ".git", "build.gradle", "build.gradle.kts", "build.xml", "pom.xml"},
|
||||
settings = {
|
||||
},
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
-- JSON
|
||||
--[[
|
||||
npm i vscode-json-languageserver
|
||||
--]]
|
||||
return {
|
||||
cmd = { "vscode-json-language-server", "--stdio" },
|
||||
filetypes = { "json", "jsonc" },
|
||||
root_markers = { ".git" },
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
},
|
||||
settings = {
|
||||
-- See setting options
|
||||
-- https://github.com/microsoft/vscode/tree/main/extensions/json-language-features/server#settings
|
||||
json = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
-- Lua
|
||||
--[[ Installation
|
||||
scoop install lua-language-server
|
||||
brew install lua-language-server
|
||||
sudo port install lua-language-server
|
||||
--]]
|
||||
--[[ Build: Ninja & C++17 Required
|
||||
git clone https://github.com/LuaLS/lua-language-server --depth 1
|
||||
cd lua-language-server
|
||||
./make.sh
|
||||
--]]
|
||||
--[[ Note: For building from source, wrapper script is required
|
||||
Accompanied with a wrapper script
|
||||
#!/bin/bash
|
||||
exec "$HOME/.local/build/lua-language-server/bin/lua-language-server" "$@"
|
||||
--]]
|
||||
return {
|
||||
cmd = { "lua-language-server" },
|
||||
root_markers = {
|
||||
".luarc.json",
|
||||
".luarc.jsonc",
|
||||
".luacheckrc",
|
||||
".stylua.toml",
|
||||
"stylua.toml",
|
||||
"selene.toml",
|
||||
"selene.yml",
|
||||
},
|
||||
filetypes = { "lua" },
|
||||
settings = {
|
||||
Lua = {
|
||||
hint = {
|
||||
enable = true,
|
||||
setType = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
-- Markdown PKM
|
||||
--[[ Installation:
|
||||
cargo install --locked --git https://github.com/Feel-ix-343/markdown-oxide.git markdown-oxide
|
||||
--]]
|
||||
return {
|
||||
cmd = { "markdown-oxide" },
|
||||
root_markers = {
|
||||
".obsidian",
|
||||
},
|
||||
filetypes = { "markdown" },
|
||||
settings = {
|
||||
Markdown = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
-- Python
|
||||
--[[ Installation
|
||||
uv tool install pyright
|
||||
--]]
|
||||
return {
|
||||
cmd = { "pyright-langserver", "--stdio" },
|
||||
filetypes = { "python" },
|
||||
root_markers = {
|
||||
".python_version",
|
||||
"pyproject.toml",
|
||||
"setup.py",
|
||||
"setup.cfg",
|
||||
"requirements.txt",
|
||||
"Pipfile",
|
||||
"pyrightconfig.json",
|
||||
".git",
|
||||
},
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = "openFilesOnly",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
-- Rust
|
||||
--[[ Installation
|
||||
rustup component add rust-src
|
||||
--]]
|
||||
return {
|
||||
cmd = { "rust-analyzer" },
|
||||
filetypes = { "rust" },
|
||||
root_dir = function(bufnr, cb)
|
||||
local root = vim.fs.root(bufnr, { "Cargo.toml" })
|
||||
if root then
|
||||
vim.system({ "cargo", "metadata", "--no-depts", "--format-version", "1" }, { cwd = root }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
cb(root)
|
||||
else
|
||||
local success, result = pcall(vim.json.decode, obj.stdout)
|
||||
if success and result.workspace_root then
|
||||
cb(result.workspace_root)
|
||||
else
|
||||
cb(root)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
cb(vim.fs.root(bufnr, { "rust-project.json", ".git" }))
|
||||
end
|
||||
end,
|
||||
before_init = function(init_params, config)
|
||||
-- See https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26
|
||||
if config.settings and config.settings["rust-analyzer"] then
|
||||
init_params.initializationOptions = config.settings["rust-analyzer"]
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
-- TOML
|
||||
--[[ Installation
|
||||
cargo install taplo-cli --locked
|
||||
brew install taplo
|
||||
pnpm install -g @taplo/cli
|
||||
--]]
|
||||
return {
|
||||
cmd = { "taplo", "lsp", "stdio" },
|
||||
filetypes = { "toml" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
-- See all the setting options
|
||||
-- https://github.com/tamasfe/taplo/blob/master/editors/vscode/package.json
|
||||
evenBetterToml = {
|
||||
taplo = {
|
||||
configFile = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
schema = {
|
||||
enabled = true,
|
||||
catalogs = {
|
||||
"https://www.schemastore.org/api/json/catalog.json",
|
||||
},
|
||||
cache = {
|
||||
memoryExpiration = 60,
|
||||
diskExpiration = 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
return {
|
||||
cmd = { "vim-language-server", "--stdio" },
|
||||
filetypes = { "vim" },
|
||||
root_markers = { ".git" },
|
||||
init_options = {
|
||||
isNeovim = true,
|
||||
iskeyword = "@,48-57,_,192-255,-#",
|
||||
vimruntime = "",
|
||||
runtimepath = "",
|
||||
diagnostic = { enable = true },
|
||||
indexes = {
|
||||
runtimepath = true,
|
||||
gap = 100,
|
||||
count = 3,
|
||||
projectRootPatterns = { "runtime", "nvim", ".git", "autoload", "plugin" },
|
||||
},
|
||||
suggest = { fromVimruntime = true, fromRuntimepath = true },
|
||||
},
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
return {
|
||||
cmd = { "yaml-language-server", "--stdio" },
|
||||
filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
yaml = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
-- This file *currently* contains the colorscheme for lualine (status line)
|
||||
|
||||
local M = {}
|
||||
-- TODO: Change the palatte when the colorscheme changes
|
||||
|
||||
if vim.g.colors_name == "catppuccin-latte" then
|
||||
M.scheme = require("catppuccin.palettes.latte")
|
||||
else
|
||||
M.scheme = require("catppuccin.palettes.mocha")
|
||||
end
|
||||
|
||||
M.accent = M.scheme.lavender
|
||||
|
||||
M.mode = {
|
||||
n = M.scheme.sky,
|
||||
i = M.scheme.green,
|
||||
v = M.scheme.mauve,
|
||||
[""] = M.scheme.mauve,
|
||||
V = M.scheme.mauve,
|
||||
c = M.scheme.mauve,
|
||||
no = M.scheme.red,
|
||||
s = M.scheme.orange,
|
||||
S = M.scheme.orange,
|
||||
[""] = M.scheme.orange,
|
||||
ic = M.scheme.yellow,
|
||||
R = M.scheme.violet,
|
||||
Rv = M.scheme.violet,
|
||||
cv = M.scheme.red,
|
||||
ce = M.scheme.red,
|
||||
r = M.scheme.cyan,
|
||||
rm = M.scheme.cyan,
|
||||
["r?"] = M.scheme.cyan,
|
||||
["!"] = M.scheme.red,
|
||||
t = M.scheme.red,
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
-- Change the colorscheme here, use SPACE u i or :FzfLua colorscheme to change colorscheme
|
||||
|
||||
-- https://www.reddit.com/r/neovim/comments/1d3hk1t/automatic_dark_mode_following_system_theme_on/
|
||||
local function get_system_theme()
|
||||
-- Default value
|
||||
local background = 'light'
|
||||
-- First check whether we are on MacOS
|
||||
if vim.loop.os_uname().sysname == "Darwin" then
|
||||
-- Check if 'defaults' is executable
|
||||
if vim.fn.executable('defaults') ~= 0 then
|
||||
-- Execute command to check if the macOS appearance is set to Dark
|
||||
local appleInterfaceStyle = vim.fn.system({ "defaults", "read", "-g", "AppleInterfaceStyle" })
|
||||
if appleInterfaceStyle:find("Dark") then
|
||||
background = 'dark'
|
||||
end
|
||||
end
|
||||
-- Check if 'busctl' is executable (part of systemd)
|
||||
elseif vim.fn.executable('busctl') ~= 0 then
|
||||
-- Get the current color scheme from xdg-desktop-portal using busctl
|
||||
local result = vim.fn.system({
|
||||
"busctl", "--user", "call", "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop",
|
||||
"org.freedesktop.portal.Settings", "ReadOne", "ss", "org.freedesktop.appearance", "color-scheme"
|
||||
})
|
||||
-- The result is in the form of "v u 0" for light and "v u 1" for dark
|
||||
local color_scheme = result:match("u%s+(%d+)")
|
||||
|
||||
if color_scheme == '1' then
|
||||
background = 'dark'
|
||||
end
|
||||
else
|
||||
end
|
||||
|
||||
return background
|
||||
end
|
||||
|
||||
if get_system_theme() == 'dark' then
|
||||
vim.o.background = 'dark'
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
else
|
||||
vim.o.background = 'light'
|
||||
-- vim.cmd.colorscheme("rose-pine")
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
end
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
local signs = require("config.icons").diagnostics
|
||||
|
||||
-- This provides the diagnostics signs near the line numbers
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
-- icons.lua
|
||||
-- All icons used in the configuration are defined in this file.
|
||||
-- Currently are only used in diagnostics, lualine, gitsigns
|
||||
local M = {
|
||||
diagnostics = {
|
||||
Error = "",
|
||||
Warning = "",
|
||||
Hint = "",
|
||||
Information = "",
|
||||
},
|
||||
lsp = "",
|
||||
indent = "",
|
||||
git = {
|
||||
Change = "",
|
||||
Add = "",
|
||||
Delete = "",
|
||||
Rename = "",
|
||||
Branch = "",
|
||||
},
|
||||
lsp_kind = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
Copilot = "",
|
||||
},
|
||||
telescope = " ",
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
-- Entry point of keymaps configuration
|
||||
require("keymaps")
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
local nvim_version = vim.version()
|
||||
|
||||
|
||||
if nvim_version.minor ~= 11 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = true,
|
||||
})
|
||||
|
||||
-- vim.lsp.enable({
|
||||
-- "clangd",
|
||||
-- "luals",
|
||||
-- })
|
||||
|
||||
local lsp_configs = {}
|
||||
for _, v in ipairs(vim.api.nvim_get_runtime_file('lsp/*', true)) do
|
||||
local name = vim.fn.fnamemodify(v, ':t:r')
|
||||
lsp_configs[name] = true
|
||||
end
|
||||
|
||||
vim.lsp.enable(vim.tbl_keys(lsp_configs))
|
||||
|
||||
-- Delete 0.11 new gr- keymaps
|
||||
vim.keymap.del({ "n" }, "grn")
|
||||
vim.keymap.del({ "n", "x" }, "gra")
|
||||
vim.keymap.del({ "n" }, "gri")
|
||||
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
-- <leader> is space
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
-- Disable netrw (file explorer) use NvimTree instead
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
-- Disable Perl
|
||||
vim.g.loaded_perl_provider = 0 -- Don't load Perl
|
||||
|
||||
-- Format on save
|
||||
vim.g.autoformat = true
|
||||
|
||||
local opt = vim.opt
|
||||
|
||||
-- Clipboard
|
||||
-- `unnamedplus` for system clipboard
|
||||
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus"
|
||||
-- Line number
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
|
||||
-- Confirm before dangerous operations
|
||||
opt.confirm = true
|
||||
|
||||
-- Word wrap
|
||||
opt.linebreak = true
|
||||
|
||||
-- Indentation
|
||||
opt.expandtab = true
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.shiftround = true
|
||||
|
||||
-- Case
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
|
||||
-- Highlight current line
|
||||
opt.cursorline = true
|
||||
-- opt.cursorcolumn = true -- Highlight current column
|
||||
-- Terminal GUI
|
||||
opt.termguicolors = true
|
||||
|
||||
--- Fold
|
||||
opt.foldmethod = "expr"
|
||||
-- Folding provided by treesitter
|
||||
opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
-- Disable fold at start
|
||||
opt.foldlevelstart = 99
|
||||
opt.foldlevel = 99
|
||||
opt.foldenable = false
|
||||
opt.foldlevelstart = 1
|
||||
|
||||
-- Hide Command Line if empty
|
||||
opt.cmdheight = 0
|
||||
|
||||
-- Scroll
|
||||
opt.scrolloff = 5 -- Always show 5 lines above/below cursor
|
||||
opt.sidescrolloff = 10 -- Always show 10 columns left/right of cursor
|
||||
|
||||
-- Conceal: Hide some characters, might be useful for markdown and LaTeX
|
||||
opt.conceallevel = 2
|
||||
|
||||
-- `laststatus`
|
||||
-- Disable status line: Use `lualine` instead
|
||||
-- opt.laststatus = 0
|
||||
-- 3: Global status line (always at the bottom)
|
||||
opt.laststatus = 3
|
||||
|
||||
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
|
||||
-- hover.nvim
|
||||
vim.o.mousemoveevent = true
|
||||
|
||||
-- Hide zero-width space
|
||||
-- vim.api.nvim_create_autocmd("FileType", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- vim.opt_local.conceallevel = 2
|
||||
-- vim.cmd([[
|
||||
-- syntax match ZeroWidthSpace /\%u200b/ conceal
|
||||
-- highlight link ZeroWidthSpace Conceal
|
||||
-- ]])
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
vim.fn.matchadd("Conceal", [[\%u200b]], 10, -1, { conceal = "" })
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
-- Entry point for all plugins
|
||||
require("plugins")
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
--- Available LSP goes here
|
||||
--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
--- for available server and name
|
||||
local M = {}
|
||||
-- Ensure that the following servers are installed and set
|
||||
-- Use :Mason to list all available servers
|
||||
M.servers = {
|
||||
"bashls", -- Bash
|
||||
"clangd", -- C/C++
|
||||
"gopls", -- Go
|
||||
"html", -- HTML
|
||||
"jsonls", -- JSON
|
||||
"lua_ls", -- Lua
|
||||
-- "markdown_oxide", -- Markdown
|
||||
"pyright", -- Python
|
||||
"rust_analyzer", -- Rust
|
||||
"taplo", -- TOML
|
||||
"ts_ls", -- TypeScript
|
||||
"vimls", -- vimscript
|
||||
"yamlls", -- YAML
|
||||
"beancount", -- Beancount
|
||||
}
|
||||
|
||||
-- Configuration for each server defines here
|
||||
M.server_config = {
|
||||
lua_ls = {
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
require("plugins.lazy-nvim")
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
-- { import = "plugins.completion" },
|
||||
-- { import = "plugins.fileutils" },
|
||||
-- { import = "plugins.lsp" },
|
||||
-- { import = "plugins.edit" },
|
||||
-- { import = "plugins.misc" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
})
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
local mode_arrow = { "n", "v", "s", "x", "o" }
|
||||
|
||||
local keymaps_basic = { -- Modification of Original Keymap - Colemak
|
||||
-- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8
|
||||
{
|
||||
mode = mode_arrow,
|
||||
keys = "j",
|
||||
cmd = "v:count == 0 ? 'gj' : 'j'",
|
||||
opts = { desc = "Down", expr = true, silent = true },
|
||||
},
|
||||
{
|
||||
mode = mode_arrow,
|
||||
keys = "<Down>",
|
||||
cmd = "v:count == 0 ? 'gj' : 'j'",
|
||||
opts = { desc = "Down", expr = true, silent = true },
|
||||
},
|
||||
{
|
||||
mode = mode_arrow,
|
||||
keys = "k",
|
||||
cmd = "v:count == 0 ? 'gk' : 'k'",
|
||||
opts = { desc = "Up", expr = true, silent = true },
|
||||
},
|
||||
{
|
||||
mode = mode_arrow,
|
||||
keys = "<Up>",
|
||||
cmd = "v:count == 0 ? 'gk' : 'k'",
|
||||
opts = { desc = "Up", expr = true, silent = true },
|
||||
},
|
||||
|
||||
{
|
||||
mode = "o",
|
||||
keys = "j",
|
||||
cmd = "j",
|
||||
opts = { desc = "Down", silent = true },
|
||||
},
|
||||
{
|
||||
mode = "o",
|
||||
keys = "<Down>",
|
||||
cmd = "j",
|
||||
opts = { desc = "Down", silent = true },
|
||||
},
|
||||
{
|
||||
mode = "o",
|
||||
keys = "k",
|
||||
cmd = "k",
|
||||
opts = { desc = "Up", silent = true },
|
||||
},
|
||||
{
|
||||
mode = "o",
|
||||
keys = "<Up>",
|
||||
cmd = "k",
|
||||
opts = { desc = "Up", silent = true },
|
||||
},
|
||||
|
||||
{ mode = mode_arrow, keys = "h", cmd = "h", opts = { desc = "Left", silent = true } },
|
||||
-- { mode = mode_arrow, keys = "i", cmd = "l", opts = { desc = "Right", silent = true } },
|
||||
{ mode = { "n" }, keys = "H", cmd = "<cmd>bprevious<CR>", opts = { desc = "Previous Buffer" } },
|
||||
{ mode = { "n" }, keys = "L", cmd = "<cmd>bnext<CR>", opts = { desc = "Next Buffer" } },
|
||||
{ mode = { "v", "o", "x" }, keys = "H", cmd = "^", opts = { desc = "Start of Line" } },
|
||||
{ mode = { "v", "o", "x" }, keys = "L", cmd = "$", opts = { desc = "End of Line" } },
|
||||
{ mode = mode_arrow, keys = "J", cmd = "5j", opts = { desc = "Up 5 Lines" } },
|
||||
{ mode = mode_arrow, keys = "K", cmd = "5e", opts = { desc = "Down 5 Lines" } },
|
||||
{ keys = "Y", cmd = "y$", opts = { desc = "Yank to End of Line" } },
|
||||
{ mode = mode_arrow, keys = "J", cmd = "5j" },
|
||||
{ mode = mode_arrow, keys = "K", cmd = "5k" },
|
||||
-- { mode = { "n", "o", "x" }, keys = "l", cmd = "i", opts = { desc = "Insert" } },
|
||||
-- { keys = "L", cmd = "I", opts = { desc = "Insert at Start of Line" } },
|
||||
-- { mode = mode_arrow, keys = "k", cmd = "n", opts = { desc = "Next Search" } },
|
||||
-- { mode = mode_arrow, keys = "K", cmd = "N", opts = { desc = "Previous Search" } },
|
||||
-- { mode = mode_arrow, keys = "j", cmd = "e", opts = { desc = "jump to end of word" } },
|
||||
-- { mode = mode_arrow, keys = "J", cmd = "E", opts = { desc = "jump to end of WORD" } },
|
||||
-- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L60
|
||||
{ keys = "<Esc>", cmd = "<Cmd>nohlsearch<Bar>diffupdate<CR>", opts = { desc = "Clear Search Highlight" } },
|
||||
}
|
||||
|
||||
return keymaps_basic
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
local bufmap = {
|
||||
markdown = {
|
||||
{ mode = "x", keys = "i", cmd = 'c*<C-r>"*', opt = { desc = "Add italic to selected text" } },
|
||||
{ mode = "x", keys = "b", cmd = 'c**<C-r>"**', opt = { desc = "Add bold to selected text" } },
|
||||
{ mode = "x", keys = "c", cmd = 'c`<CR><C-r>"<CR>`', opt = { desc = "Add code block to selected text" } },
|
||||
{ mode = "x", keys = "d", cmd = 'c~~<C-r>"~~', opt = { desc = "Add strikethrough to selected text" } },
|
||||
{ mode = "x", keys = "h", cmd = 'c==<C-r>"==', opt = { desc = "Add highlight to selected text" } },
|
||||
},
|
||||
tex = {
|
||||
{ mode = "x", keys = "i", cmd = 'c\\textit{<C-r>"}', opt = { desc = "Add italic to selected text" } },
|
||||
{ mode = "x", keys = "b", cmd = 'c\\textbf{<C-r>"}', opt = { desc = "Add bold to selected text" } },
|
||||
{
|
||||
mode = "x",
|
||||
keys = "c",
|
||||
cmd = 'c\\begin{verbatim}<CR><C-r>"<CR>\\end{verbatim}',
|
||||
opt = { desc = "Add code block to selected text" },
|
||||
},
|
||||
{ mode = "x", keys = "d", cmd = 'c\\sout{<C-r>"}', opt = { desc = "Add strikethrough to selected text" } },
|
||||
{ mode = "x", keys = "h", cmd = 'c\\hl{<C-r>"}', opt = { desc = "Add highlight to selected text" } },
|
||||
{ mode = "n", keys = "<leader>cc", cmd = "<cmd>w<CR>", opt = { desc = "Save and compile tex file" } },
|
||||
-- { mode = "i", keys = "<C-m><C-m>", cmd = "<cmd>w<CR>", opt = { desc = "Save and compile tex file" } },
|
||||
},
|
||||
org = {
|
||||
{ mode = "x", keys = "i", cmd = 'c/<C-r>/"', opt = { desc = "Add italic to selected text" } },
|
||||
{ mode = "x", keys = "b", cmd = 'c*<C-r>"*', opt = { desc = "Add bold to selected text" } },
|
||||
-- {
|
||||
-- mode = "x",
|
||||
-- keys = "c",
|
||||
-- cmd = 'c#+BEGIN_SRC<CR><C-r>"<CR>#+END_SRC',
|
||||
-- opt = { desc = "Add code block to selected text" },
|
||||
-- },
|
||||
{ mode = "x", keys = "d", cmd = 'c+<C-r>"+', opt = { desc = "Add strikethrough to selected text" } },
|
||||
{ mode = "x", keys = "h", cmd = 'c~<C-r>"~', opt = { desc = "Add highlight to selected text" } },
|
||||
},
|
||||
}
|
||||
|
||||
local function setup_buffer_maps(buffer_map)
|
||||
-- 遍历 buffer_map 中的每个文件类型
|
||||
for ft, mappings in pairs(buffer_map) do
|
||||
-- 1. 为现有缓冲区设置键位映射
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_get_option(buf, "filetype") == ft then
|
||||
for _, mapping in ipairs(mappings) do
|
||||
-- 合并选项,添加 buffer 以确保映射是缓冲区局部的
|
||||
if mapping.mode ~= "n" then
|
||||
mapping.keys = "<C-m>" .. mapping.keys
|
||||
end
|
||||
local opts = vim.tbl_extend("force", mapping.opt, { buffer = buf })
|
||||
vim.keymap.set(mapping.mode, mapping.keys, mapping.cmd, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 2. 为未来缓冲区设置自动命令
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = ft, -- 匹配文件类型,例如 "markdown"
|
||||
callback = function(args)
|
||||
local buf = args.buf -- 获取触发事件的缓冲区号
|
||||
for _, mapping in ipairs(mappings) do
|
||||
local opts = vim.tbl_extend("force", mapping.opt, { buffer = buf })
|
||||
if mapping.mode ~= "n" then
|
||||
mapping.keys = "<C-m>" .. mapping.keys
|
||||
end
|
||||
vim.keymap.set(mapping.mode, mapping.keys, mapping.cmd, opts)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
setup_buffer_maps(bufmap)
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
local M = {}
|
||||
-- local keymaps_user_command = require("keymaps.user-command")
|
||||
require("keymaps.user-command")
|
||||
local utils = require("keymaps.utils")
|
||||
|
||||
local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global
|
||||
|
||||
local keymaps_general = vim.tbl_extend("force", {}, require("keymaps.leaders"), require("keymaps.lspkeys"))
|
||||
-- Tables cannot be merged since `mode` are set in some keymaps of `keymaps_basic`
|
||||
local keymaps_basic = require("keymaps.basic")
|
||||
local keymaps_modifier = require("keymaps.modifier")
|
||||
|
||||
require("keymaps.buffer")
|
||||
|
||||
utils.set_keymaps(keymaps_general)
|
||||
utils.set_keymaps(keymaps_basic)
|
||||
utils.set_keymaps(keymaps_nvim_tree_general)
|
||||
utils.set_keymaps(keymaps_modifier)
|
||||
|
||||
M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin
|
||||
|
||||
-- local function set_markdown_keymaps(bufnr)
|
||||
-- local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
-- vim.keymap.set("v", "`", 'c`<C-r>"`<Esc>', opts)
|
||||
-- end
|
||||
|
||||
-- vim.api.nvim_create_autocmd("FileType", {
|
||||
-- pattern = "markdown",
|
||||
-- callback = function()
|
||||
-- set_markdown_keymaps(0)
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- which-key.nvim
|
||||
if vim.g.loaded_which_key then
|
||||
require("keymaps.which")
|
||||
end
|
||||
require("keymaps.visual-multi")
|
||||
|
||||
return M
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
-- Markdown
|
||||
|
||||
local function set_markdown_keymaps(bufnr)
|
||||
local markdown_opt = { noremap = true, silent = true, buffer = bufnr }
|
||||
for _, map in ipairs(M.markdown) do
|
||||
local opts = vim.tbl_extend("force", markdown_opt, map.opts or {})
|
||||
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.markdown = {
|
||||
{ mode = "v", keys = "`", cmd = "c`<Esc>pi`<Esc>", desc = "Wrap selection in ` for inline code" },
|
||||
{ mode = "v", keys = "*", cmd = "c**<Esc>pi**<Esc>", desc = "Wrap selection in ** for bold" },
|
||||
{ mode = "v", keys = "_", cmd = "c*<Esc>pi*<Esc>", desc = "Wrap selection in * for italic" },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "markdown",
|
||||
callback = function()
|
||||
set_markdown_keymaps(0)
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.tabstop = 2
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
local formatFx = function()
|
||||
require("conform").format({ async = true })
|
||||
end
|
||||
|
||||
local renameCurrentBuffer = function()
|
||||
local old_name = vim.fn.expand("%:p")
|
||||
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
|
||||
|
||||
if new_name == "" then
|
||||
print("No new name provided")
|
||||
return
|
||||
elseif new_name == old_name then
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("write")
|
||||
|
||||
local success, err = os.rename(old_name, new_name)
|
||||
if not success then
|
||||
print("Error renaming file: " .. err)
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("edit " .. new_name)
|
||||
vim.cmd("bdelete " .. old_name)
|
||||
end
|
||||
|
||||
-- 通用映射函数
|
||||
local function apply_mappings(maps, prefix)
|
||||
for _, map in ipairs(maps) do
|
||||
local new_map = {
|
||||
keys = prefix .. map.keys,
|
||||
cmd = map.cmd,
|
||||
opts = map.opts,
|
||||
}
|
||||
table.insert(M, new_map)
|
||||
end
|
||||
end
|
||||
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
|
||||
|
||||
local leader_mappings = {
|
||||
general = {
|
||||
{ keys = "<leader>", cmd = ":Telescope find_files<CR>", opts = { desc = "Find Files" } },
|
||||
{ keys = "/", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
|
||||
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
|
||||
{ keys = "\\", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
|
||||
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
|
||||
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
|
||||
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
|
||||
{ keys = "F", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Explorer" } },
|
||||
{ keys = "<Tab>", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
|
||||
{ keys = "!", cmd = ":FloatermToggle<CR>", opts = { desc = "Toggle Terminal" } },
|
||||
{ keys = '"', cmd = ":!wezterm-gui &<CR>", pots = { desc = "Open External Terminal(wezterm)" } },
|
||||
{ keys = ";", cmd = ":Telescope<CR>", pots = { desc = "Show Telescope Commands" } },
|
||||
},
|
||||
b = { -- +buffer
|
||||
{ keys = "0", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
|
||||
{ keys = "1", cmd = ":BufferLineGotoBuffer 1<CR>", opts = { desc = "Switch to Buffer #1" } },
|
||||
{ keys = "2", cmd = ":BufferLineGotoBuffer 2<CR>", opts = { desc = "Switch to Buffer #2" } },
|
||||
{ keys = "3", cmd = ":BufferLineGotoBuffer 3<CR>", opts = { desc = "Switch to Buffer #3" } },
|
||||
{ keys = "4", cmd = ":BufferLineGotoBuffer 4<CR>", opts = { desc = "Switch to Buffer #4" } },
|
||||
{ keys = "5", cmd = ":BufferLineGotoBuffer 5<CR>", opts = { desc = "Switch to Buffer #5" } },
|
||||
{ keys = "6", cmd = ":BufferLineGotoBuffer 6<CR>", opts = { desc = "Switch to Buffer #6" } },
|
||||
{ keys = "7", cmd = ":BufferLineGotoBuffer 7<CR>", opts = { desc = "Switch to Buffer #7" } },
|
||||
{ keys = "8", cmd = ":BufferLineGotoBuffer 8<CR>", opts = { desc = "Switch to Buffer #8" } },
|
||||
{ keys = "9", cmd = ":BufferLineGotoBuffer 9<CR>", opts = { desc = "Switch to Buffer #9" } },
|
||||
{ keys = "a", cmd = ":Alpha<CR>", opts = { desc = "Dashboard" } },
|
||||
{ keys = "b", cmd = ":BufferLinePick<CR>", opts = { desc = "Quick Switch Buffers" } },
|
||||
{ keys = "B", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
|
||||
{ keys = "d", cmd = ":bdelete<CR>", opts = { desc = "Delete Buffer" } },
|
||||
{ keys = "D", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "xx", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "xh", cmd = ":BufferLineCloseLeft<CR>", opts = { desc = "Delete Buffers Left" } },
|
||||
{ keys = "xi", cmd = ":BufferLineCloseRight<CR>", opts = { desc = "Delete Buffers Right" } },
|
||||
{ keys = "X", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "h", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
|
||||
{ keys = "i", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
|
||||
{ keys = "H", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "I", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
|
||||
{ keys = "0", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "^", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "$", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
|
||||
{ keys = "s", cmd = ":new<CR>", opts = { desc = "Scratch buffers" } },
|
||||
{ keys = "t", cmd = ":BufferLineTogglePin<CR>", opts = { desc = "Pin Buffer" } },
|
||||
{ keys = "y", cmd = ":%y+<CR>", opts = { desc = "Copy Buffer to Clipboard" } },
|
||||
},
|
||||
c = { -- +code/compile
|
||||
{ keys = "r", cmd = ":RunCode<CR>", opts = { desc = "Run code" } },
|
||||
{ keys = "R", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
|
||||
{ keys = "e", cmd = ":Telescope diagnostics<CR>", opts = { desc = "Navigate errors/warnings" } },
|
||||
{ keys = "f", cmd = formatFx, opts = { desc = "Format buffer" } },
|
||||
{ keys = "s", cmd = ":Telescope treesitter<CR>", opts = { desc = "Search symbols" } },
|
||||
{ keys = "S", cmd = ":Telescope grep_string<CR>", opts = { desc = "Search current symbol" } },
|
||||
},
|
||||
f = { -- +file/find
|
||||
{ keys = "f", cmd = ":Telescope fd<CR>", opts = { desc = "Find Files" } },
|
||||
{ keys = "F", cmd = ":GrugFar<CR>", opts = { desc = "Search & Replace" } },
|
||||
{ keys = "l", cmd = ":set filetype=", opts = { desc = "Set Filetype to ..." } },
|
||||
{ keys = "n", cmd = ":new<CR>", opts = { desc = "New File" } },
|
||||
{ keys = "s", cmd = ":write<CR>", opts = { desc = "Save File" } },
|
||||
{ keys = "S", cmd = ":wall<CR>", opts = { desc = "Save All Files" } },
|
||||
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
|
||||
{ keys = "D", cmd = "!trash-rm %<CR>", opts = { desc = "Delete current file" } },
|
||||
{ keys = "t", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Tree" } },
|
||||
{ keys = "T", cmd = ":FloatermNew<CR>", opts = { desc = "Spawn a float terminal" } },
|
||||
{ keys = "h", cmd = ":Telescope oldfiles<CR>", opts = { desc = "Search history files" } },
|
||||
{ keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim<CR>", opts = { desc = "Search Config" } },
|
||||
{ keys = "o", cmd = ":!open %<CR>", opts = { desc = "Open file in default program" } },
|
||||
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
|
||||
{ keys = "x", cmd = ":Lazy<CR>", opts = { desc = "Open extension view" } },
|
||||
{ keys = "yy", cmd = ":let @+ = expand('%:p')<CR>", opts = { desc = "Copy file path" } },
|
||||
{ keys = "yY", cmd = ":let @+ = expand('%')<CR>", opts = { desc = "Copy relative file path" } },
|
||||
{ keys = "yn", cmd = ":let @+ = expand('%:t')<CR>", opts = { desc = "Copy file name" } },
|
||||
{ keys = "yN", cmd = ":let @+ = expand('%:t:r')<CR>", opts = { desc = "Copy file name without extension" } },
|
||||
{ keys = "yd", cmd = ":let @+ = expand('%:p:h')<CR>", opts = { desc = "Copy directory path" } },
|
||||
{
|
||||
keys = "yl",
|
||||
cmd = ":let @+ = expand('%:p') . ':' . line('.')<CR>",
|
||||
opts = { desc = "Copy file path with line number" },
|
||||
},
|
||||
{
|
||||
keys = "yL",
|
||||
cmd = ":let @+ = expand('%') . ':' . line('.')<CR>",
|
||||
opts = { desc = "Copy relative file path with line number" },
|
||||
},
|
||||
},
|
||||
g = { -- +git/version control
|
||||
{ keys = "g", cmd = ":LazyGit<CR>", opts = { desc = "Toggle LazyGit" } },
|
||||
{ keys = "c", cmd = ":Telescope git_commits<CR>", opts = { desc = "Show commits" } },
|
||||
{ keys = "b", cmd = ":Gitsigns blame<CR>", opts = { desc = "Blame file" } },
|
||||
{ keys = "d", cmd = ":Gitsigns diffthis<CR>", opts = { desc = "Diff file" } },
|
||||
{ keys = "B", cmd = ":Gitsigns toggle_current_line_blame<CR>", opts = { desc = "Toggle line blame" } },
|
||||
{ keys = "s", cmd = ":Telescope git_status<CR>", opts = { desc = "Git Status" } },
|
||||
{ keys = "t", cmd = ":Telescope git_branches<CR>", opts = { desc = "Git Branches" } },
|
||||
},
|
||||
j = { -- +lsp
|
||||
{ keys = "r", cmd = vim.lsp.buf.references, opts = { desc = "Show current reference" } },
|
||||
},
|
||||
p = { -- +project
|
||||
{ keys = "p", cmd = ":Telescope projects<CR>", opts = { desc = "List all Projects" } },
|
||||
{ keys = "g", cmd = ":Telescope projects<CR>", opts = { desc = "List all Git Projects" } },
|
||||
{ keys = "s", cmd = ":Telescope session-lens<CR>", opts = { desc = "List all sessions" } },
|
||||
},
|
||||
q = { -- +quit
|
||||
{ keys = "q", cmd = ":q<CR>", opts = { desc = "Quit" } },
|
||||
{ keys = "Q", cmd = ":qa!<CR>", opts = { desc = "Force Quit" } },
|
||||
{ keys = "w", cmd = ":wq<CR>", opts = { desc = "Write and Quit" } },
|
||||
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", opts = { desc = "Write all and Force Quit" } },
|
||||
},
|
||||
t = { -- +toggle/test
|
||||
{ keys = "f", cmd = ":NvimTreeToggle", opts = { desc = "Toggle File Explorer" } },
|
||||
{ keys = "F", cmd = ":FormatToggle<CR>", opts = { desc = "Toggle autoformat-on-save" } },
|
||||
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
|
||||
},
|
||||
u = { -- +ui
|
||||
{ keys = "i", cmd = ":Telescope colorscheme<CR>", opts = { desc = "Change colorscheme" } },
|
||||
{ keys = " ", cmd = ":set list!", opts = { desc = "Toggle show all symbols" } },
|
||||
},
|
||||
w = { -- +window
|
||||
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
|
||||
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
|
||||
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
|
||||
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
|
||||
{ keys = "H", cmd = "<C-w>H", opts = { desc = "Move Window Left" } },
|
||||
{ keys = "N", cmd = "<C-w>J", opts = { desc = "Move Window Down" } },
|
||||
{ keys = "E", cmd = "<C-w>K", opts = { desc = "Move Window Up" } },
|
||||
{ keys = "I", cmd = "<C-w>L", opts = { desc = "Move Window Right" } },
|
||||
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
|
||||
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "/", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "d", cmd = "<C-w>c", opts = { desc = "Close Window" } },
|
||||
{ keys = "D", cmd = "<C-w>o", opts = { desc = "Close Other Windows" } },
|
||||
{ keys = "r", cmd = "<C-w>r", opts = { desc = "Rotate Windows" } },
|
||||
{ keys = "R", cmd = "<C-w>R", opts = { desc = "Reverse Rotate Windows" } },
|
||||
{ keys = "t", cmd = "<C-w>T", opts = { desc = "Move Window to New Tab" } },
|
||||
{ keys = "]", cmd = ":resize +5<CR>", opts = { desc = "Increase Window Size" } },
|
||||
{ keys = "[", cmd = ":resize -5<CR>", opts = { desc = "Decrease Window Size" } },
|
||||
{ keys = "M", cmd = ":resize<CR>:vertical resize<CR>", opts = { desc = "Maximize window size" } },
|
||||
},
|
||||
}
|
||||
|
||||
for key, maps in pairs(leader_mappings) do
|
||||
if key == "general" then
|
||||
apply_mappings(maps, "<leader>")
|
||||
else
|
||||
apply_mappings(maps, "<leader>" .. key)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
local formatFx = function()
|
||||
require("conform").format({ async = true })
|
||||
end
|
||||
|
||||
local renameCurrentBuffer = function()
|
||||
local old_name = vim.fn.expand("%:p")
|
||||
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
|
||||
|
||||
if new_name == "" then
|
||||
print("No new name provided")
|
||||
return
|
||||
elseif new_name == old_name then
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("write")
|
||||
|
||||
local success, err = os.rename(old_name, new_name)
|
||||
if not success then
|
||||
print("Error renaming file: " .. err)
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("edit " .. new_name)
|
||||
vim.cmd("bdelete " .. old_name)
|
||||
end
|
||||
|
||||
-- 通用映射函数
|
||||
local function apply_mappings(maps, prefix)
|
||||
for _, map in ipairs(maps) do
|
||||
local new_map = {
|
||||
keys = prefix .. map.keys,
|
||||
cmd = map.cmd,
|
||||
opts = map.opts,
|
||||
}
|
||||
table.insert(M, new_map)
|
||||
end
|
||||
end
|
||||
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
|
||||
|
||||
local leader_mappings = {
|
||||
general = {
|
||||
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
|
||||
{ keys = "\\", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
|
||||
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
|
||||
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
|
||||
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
|
||||
{ keys = "<Tab>", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
|
||||
{ keys = '"', cmd = ":!wezterm-gui &<CR>", pots = { desc = "Open External Terminal(wezterm)" } },
|
||||
},
|
||||
b = { -- +buffer
|
||||
{ keys = "0", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
|
||||
{ keys = "1", cmd = ":BufferLineGotoBuffer 1<CR>", opts = { desc = "Switch to Buffer #1" } },
|
||||
{ keys = "2", cmd = ":BufferLineGotoBuffer 2<CR>", opts = { desc = "Switch to Buffer #2" } },
|
||||
{ keys = "3", cmd = ":BufferLineGotoBuffer 3<CR>", opts = { desc = "Switch to Buffer #3" } },
|
||||
{ keys = "4", cmd = ":BufferLineGotoBuffer 4<CR>", opts = { desc = "Switch to Buffer #4" } },
|
||||
{ keys = "5", cmd = ":BufferLineGotoBuffer 5<CR>", opts = { desc = "Switch to Buffer #5" } },
|
||||
{ keys = "6", cmd = ":BufferLineGotoBuffer 6<CR>", opts = { desc = "Switch to Buffer #6" } },
|
||||
{ keys = "7", cmd = ":BufferLineGotoBuffer 7<CR>", opts = { desc = "Switch to Buffer #7" } },
|
||||
{ keys = "8", cmd = ":BufferLineGotoBuffer 8<CR>", opts = { desc = "Switch to Buffer #8" } },
|
||||
{ keys = "9", cmd = ":BufferLineGotoBuffer 9<CR>", opts = { desc = "Switch to Buffer #9" } },
|
||||
{ keys = "b", cmd = ":BufferLinePick<CR>", opts = { desc = "Quick Switch Buffers" } },
|
||||
{ keys = "d", cmd = ":bdelete<CR>", opts = { desc = "Delete Buffer" } },
|
||||
{ keys = "D", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "xx", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "xh", cmd = ":BufferLineCloseLeft<CR>", opts = { desc = "Delete Buffers Left" } },
|
||||
{ keys = "xi", cmd = ":BufferLineCloseRight<CR>", opts = { desc = "Delete Buffers Right" } },
|
||||
{ keys = "X", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
|
||||
{ keys = "h", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
|
||||
{ keys = "i", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
|
||||
{ keys = "H", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "I", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
|
||||
{ keys = "0", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "^", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
|
||||
{ keys = "$", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
|
||||
{ keys = "s", cmd = ":new<CR>", opts = { desc = "Scratch buffers" } },
|
||||
{ keys = "t", cmd = ":BufferLineTogglePin<CR>", opts = { desc = "Pin Buffer" } },
|
||||
{ keys = "y", cmd = ":%y+<CR>", opts = { desc = "Copy Buffer to Clipboard" } },
|
||||
},
|
||||
c = { -- +code/compile
|
||||
{ keys = "R", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
|
||||
{ keys = "f", cmd = formatFx, opts = { desc = "Format buffer" } },
|
||||
},
|
||||
f = { -- +file/find
|
||||
{ keys = "n", cmd = ":new<CR>", opts = { desc = "New File" } },
|
||||
{ keys = "s", cmd = ":write<CR>", opts = { desc = "Save File" } },
|
||||
{ keys = "S", cmd = ":wall<CR>", opts = { desc = "Save All Files" } },
|
||||
{ keys = "D", cmd = "!trash-rm %<CR>", opts = { desc = "Delete current file" } },
|
||||
-- { keys = "t", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Tree" } },
|
||||
-- { keys = "o", cmd = ":!open %<CR>", opts = { desc = "Open file in default program" } },
|
||||
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
|
||||
{ keys = "x", cmd = ":Lazy<CR>", opts = { desc = "Open extension view" } },
|
||||
{ keys = "yy", cmd = ":let @+ = expand('%:p')<CR>", opts = { desc = "Copy file path" } },
|
||||
{ keys = "yY", cmd = ":let @+ = expand('%')<CR>", opts = { desc = "Copy relative file path" } },
|
||||
{ keys = "yn", cmd = ":let @+ = expand('%:t')<CR>", opts = { desc = "Copy file name" } },
|
||||
{ keys = "yN", cmd = ":let @+ = expand('%:t:r')<CR>", opts = { desc = "Copy file name without extension" } },
|
||||
{ keys = "yd", cmd = ":let @+ = expand('%:p:h')<CR>", opts = { desc = "Copy directory path" } },
|
||||
{
|
||||
keys = "yl",
|
||||
cmd = ":let @+ = expand('%:p') . ':' . line('.')<CR>",
|
||||
opts = { desc = "Copy file path with line number" },
|
||||
},
|
||||
{
|
||||
keys = "yL",
|
||||
cmd = ":let @+ = expand('%') . ':' . line('.')<CR>",
|
||||
opts = { desc = "Copy relative file path with line number" },
|
||||
},
|
||||
},
|
||||
g = { -- +git/version control
|
||||
},
|
||||
j = { -- +lsp
|
||||
{ keys = "r", cmd = vim.lsp.buf.references, opts = { desc = "Show current reference" } },
|
||||
},
|
||||
p = { -- +project
|
||||
},
|
||||
q = { -- +quit
|
||||
{ keys = "q", cmd = ":q<CR>", opts = { desc = "Quit" } },
|
||||
{ keys = "Q", cmd = ":qa!<CR>", opts = { desc = "Force Quit" } },
|
||||
{ keys = "w", cmd = ":wq<CR>", opts = { desc = "Write and Quit" } },
|
||||
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", opts = { desc = "Write all and Force Quit" } },
|
||||
},
|
||||
t = { -- +toggle/test
|
||||
{ keys = "f", cmd = ":NvimTreeToggle", opts = { desc = "Toggle File Explorer" } },
|
||||
{ keys = "F", cmd = ":FormatToggle<CR>", opts = { desc = "Toggle autoformat-on-save" } },
|
||||
},
|
||||
u = { -- +ui
|
||||
{ keys = " ", cmd = ":set list!", opts = { desc = "Toggle show all symbols" } },
|
||||
},
|
||||
w = { -- +window
|
||||
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
|
||||
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
|
||||
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
|
||||
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
|
||||
{ keys = "H", cmd = "<C-w>H", opts = { desc = "Move Window Left" } },
|
||||
{ keys = "N", cmd = "<C-w>J", opts = { desc = "Move Window Down" } },
|
||||
{ keys = "E", cmd = "<C-w>K", opts = { desc = "Move Window Up" } },
|
||||
{ keys = "I", cmd = "<C-w>L", opts = { desc = "Move Window Right" } },
|
||||
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
|
||||
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "/", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
|
||||
{ keys = "d", cmd = "<C-w>c", opts = { desc = "Close Window" } },
|
||||
{ keys = "D", cmd = "<C-w>o", opts = { desc = "Close Other Windows" } },
|
||||
{ keys = "r", cmd = "<C-w>r", opts = { desc = "Rotate Windows" } },
|
||||
{ keys = "R", cmd = "<C-w>R", opts = { desc = "Reverse Rotate Windows" } },
|
||||
{ keys = "t", cmd = "<C-w>T", opts = { desc = "Move Window to New Tab" } },
|
||||
{ keys = "]", cmd = ":resize +5<CR>", opts = { desc = "Increase Window Size" } },
|
||||
{ keys = "[", cmd = ":resize -5<CR>", opts = { desc = "Decrease Window Size" } },
|
||||
{ keys = "M", cmd = ":resize<CR>:vertical resize<CR>", opts = { desc = "Maximize window size" } },
|
||||
},
|
||||
}
|
||||
|
||||
for key, maps in pairs(leader_mappings) do
|
||||
if key == "general" then
|
||||
apply_mappings(maps, "<leader>")
|
||||
else
|
||||
apply_mappings(maps, "<leader>" .. key)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
local M = {
|
||||
{ keys = "gd", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
|
||||
{ keys = "<C-CR>", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
|
||||
{ keys = "gD", cmd = vim.lsp.buf.declaration, opts = { desc = "Goto Declaration" } },
|
||||
{ keys = "gr", cmd = vim.lsp.buf.references, opts = { desc = "Goto References" } },
|
||||
{ keys = "gi", cmd = vim.lsp.buf.implementation, opts = { desc = "Goto Implementation" } },
|
||||
{ keys = "<leader>,", cmd = vim.lsp.buf.code_action, opts = { desc = "Code Action" } },
|
||||
{ keys = "ga", cmd = vim.lsp.buf.code_action, opts = { desc = "Code Action" } },
|
||||
{ keys = "gh", cmd = vim.lsp.buf.hover, opts = { desc = "Show hover" } },
|
||||
-- [c]hange [d]efinition
|
||||
{ keys = "cd", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
|
||||
}
|
||||
|
||||
-- local function smart_split_definition()
|
||||
-- local width = vim.api.nvim_win_get_width(0)
|
||||
-- if width > 80 then -- Adjust 80 to your preference
|
||||
-- vim.api.nvim_command("vsp")
|
||||
-- else
|
||||
-- vim.api.nvim_command("sp")
|
||||
-- end
|
||||
-- vim.lsp.buf.definition()
|
||||
-- end
|
||||
-- vim.keymap.set("n", "<C-w>d", smart_split_definition, { desc = "Go to Definition (Smart Split)" })
|
||||
|
||||
local function smart_split(func)
|
||||
local width = vim.api.nvim_win_get_width(0)
|
||||
if width > 80 then
|
||||
vim.api.nvim_command("vsp")
|
||||
else
|
||||
vim.api.nvim_command("sp")
|
||||
end
|
||||
func()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<C-w>d", function()
|
||||
smart_split(vim.lsp.buf.definition)
|
||||
end, { desc = "Go to Definition (Smart Split)" })
|
||||
|
||||
vim.keymap.set("n", "<C-w>D", function()
|
||||
smart_split(vim.lsp.buf.declaration)
|
||||
end, { desc = "Go to Declaration (Smart Split)" })
|
||||
|
||||
return M
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
local keymaps_modifier = {
|
||||
-- Use C-w to move between windows
|
||||
-- { keys = "<C-w>h", cmd = "<C-w>h", opts = { desc = "left Window" } },
|
||||
-- { keys = "<C-w>n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
|
||||
-- { keys = "<C-w>e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
|
||||
-- { keys = "<C-w>i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
|
||||
{ keys = "<A-x>", cmd = "<Cmd>FzfLua commands<CR>", opts = { desc = "Commands" } },
|
||||
}
|
||||
|
||||
return keymaps_modifier
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
M.event = "BufEnter"
|
||||
|
||||
M.global = {
|
||||
{ mode = "n", keys = "<leader>E", cmd = ":NvimTreeToggle<CR>" },
|
||||
{ mode = "n", keys = "<A-0>", cmd = ":NvimTreeFindFileToggle<CR>" },
|
||||
}
|
||||
|
||||
function M.plugin(api, opts)
|
||||
-- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua`
|
||||
return {
|
||||
-- Toggle
|
||||
{ keys = "<leader>e", cmd = ":NvimTreeToggle<CR>", opts = opts("Toggle") },
|
||||
-- Arrow 箭头 hnei
|
||||
{ keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
|
||||
{ keys = "i", cmd = api.node.open.edit, opts = opts("Open") },
|
||||
{ keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") },
|
||||
{ keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
|
||||
{ keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
|
||||
{ keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") },
|
||||
-- CONTROL KEYS 控制键
|
||||
{ keys = "<BS>", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
|
||||
{ keys = "<CR>", cmd = api.node.open.edit, opts = opts("Open") },
|
||||
{ keys = "<Tab>", cmd = api.node.open.preview, opts = opts("Open Preview") },
|
||||
-- Alpha 字母键
|
||||
{ keys = "a", cmd = api.fs.create, opts = opts("Create") },
|
||||
{ keys = "A", cmd = api.fs.create, opts = opts("Create") },
|
||||
{ keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") },
|
||||
{ keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") },
|
||||
{ keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") },
|
||||
{ keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") },
|
||||
{ keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") },
|
||||
{ keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") },
|
||||
{ keys = "d", cmd = api.fs.remove, opts = opts("Delete") },
|
||||
{ keys = "D", cmd = api.fs.trash, opts = opts("Trash") },
|
||||
{ keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") },
|
||||
{ keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") },
|
||||
{ keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") },
|
||||
{ keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") },
|
||||
{ keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") },
|
||||
{ keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") },
|
||||
{ keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") },
|
||||
{ keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") },
|
||||
{ keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") },
|
||||
{ keys = "o", cmd = api.node.open.edit, opts = opts("Open") },
|
||||
{ keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") },
|
||||
{ keys = "p", cmd = api.fs.paste, opts = opts("Paste") },
|
||||
{ keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") },
|
||||
{ keys = "q", cmd = api.tree.close, opts = opts("Close") },
|
||||
{ keys = "r", cmd = api.fs.rename, opts = opts("Rename") },
|
||||
{ keys = "R", cmd = api.tree.reload, opts = opts("Refresh") },
|
||||
{ keys = "s", cmd = api.node.run.system, opts = opts("Run System") },
|
||||
{ keys = "S", cmd = api.tree.search_node, opts = opts("Search") },
|
||||
{ keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") },
|
||||
{ keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") },
|
||||
{ keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") },
|
||||
{ keys = "x", cmd = api.fs.cut, opts = opts("Cut") },
|
||||
{ keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") },
|
||||
{ keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") },
|
||||
-- From Directory Opus
|
||||
{ keys = "#", cmd = "<Cmd>set relativenumber!<CR>", opts = opts("Toggle Relative Number") },
|
||||
-- Numeric 数字键
|
||||
{ keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") },
|
||||
-- Non-Alphanumeric 非字母数字键
|
||||
{ keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") },
|
||||
{ keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
|
||||
{ keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
|
||||
{ keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") },
|
||||
{ keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") },
|
||||
{ keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") },
|
||||
-- MOD KEYS Ctrl+
|
||||
{ keys = "<C-]>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
|
||||
{ keys = "<C-e>", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") },
|
||||
{ keys = "<C-k>", cmd = api.node.show_info_popup, opts = opts("Info") },
|
||||
{ keys = "<C-r>", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") },
|
||||
{ keys = "<C-t>", cmd = api.node.open.tab, opts = opts("Open: New Tab") },
|
||||
{ keys = "<C-v>", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") },
|
||||
{ keys = "<C-h>", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") },
|
||||
{ keys = "<A-0>", cmd = ":b#<CR>", opts = opts("Focus to previous buffer") },
|
||||
-- Mouse 鼠标键
|
||||
{ keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") },
|
||||
{ keys = "<2-RightMouse>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
vim.api.nvim_create_user_command("Format", function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
range = {
|
||||
start = { args.line1, 0 },
|
||||
["end"] = { args.line2, end_line:len() },
|
||||
}
|
||||
end
|
||||
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
||||
end, { range = true })
|
||||
|
||||
vim.api.nvim_create_user_command("FormatToggle", function(args)
|
||||
local buffer_local = args.bang
|
||||
if buffer_local then
|
||||
-- Toggle buffer-local formatting
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
else
|
||||
-- Toggle global formatting
|
||||
vim.g.disable_autoformat = not vim.g.disable_autoformat
|
||||
end
|
||||
|
||||
-- Print current status
|
||||
local scope = buffer_local and "buffer" or "global"
|
||||
local status = buffer_local and vim.b.disable_autoformat or vim.g.disable_autoformat
|
||||
print(string.format("Format-on-save %s: %s", scope, status and "disabled" or "enabled"))
|
||||
end, {
|
||||
desc = "Toggle autoformat-on-save (use ! for buffer-local)",
|
||||
bang = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("Reload", function()
|
||||
vim.cmd("luafile ~/.config/nvim/init.lua")
|
||||
end, {
|
||||
desc = "Reload Neovim configuration",
|
||||
})
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
local M = {}
|
||||
-- local mode_arrow = { "n", "v", "o", "s", "x" }
|
||||
|
||||
local default_opts = { noremap = true, silent = true }
|
||||
local default_mode = { "n" }
|
||||
|
||||
M.set_keymaps = function(maps)
|
||||
for _, map in ipairs(maps) do
|
||||
local opts = vim.tbl_extend("force", default_opts, map.opts or {})
|
||||
local mode = map.mode or default_mode
|
||||
vim.keymap.set(mode, map.keys, map.cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.set_lang_keymaps = function(maps)
|
||||
vim.api.create_autocmd("FileType", {
|
||||
pattern = maps.filetype,
|
||||
callback = function()
|
||||
M.set_keymaps(maps.keymaps)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
M.set_buf_keymaps = function(maps)
|
||||
vim.api.create_autocmd("BufEnter", {
|
||||
pattern = maps.filetype,
|
||||
callback = function()
|
||||
M.set_keymaps(maps.keymaps)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
-- Note that this plugin is a fork for colemak
|
||||
-- Use mouse to select multiple cursors
|
||||
vim.g.VM_mouse_mappings = 1
|
||||
-- Disable default mappings
|
||||
|
||||
vim.g.VM_maps = {
|
||||
["Add Cursor Down"] = "<A-n>",
|
||||
["Add Cursor Up"] = "<A-e>",
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
-- local wk = require("which-key")
|
||||
-- wk.add({
|
||||
-- -- https://github.com/folke/which-key.nvim/tree/main?tab=readme-ov-file#%EF%B8%8F-mappings
|
||||
-- {
|
||||
-- -- Nested mappings are allowed and can be added in any order
|
||||
-- -- Most attributes can be inherited or overridden on any level
|
||||
-- -- There's no limit to the depth of nesting
|
||||
-- mode = { "n" },
|
||||
-- { "<leader>b", group = "Buffer" }, -- no need to specify mode since it's inherited
|
||||
-- { "<leader>c", group = "Code/Compile" },
|
||||
-- { "<leader>f", group = "File" },
|
||||
-- { "<leader>p", group = "Project", icon = "" },
|
||||
-- { "<leader>q", group = "Quit" },
|
||||
-- { "<leader>t", group = "Toggle" },
|
||||
-- { "<leader>u", group = "UI" },
|
||||
-- { "<leader>w", group = "Window" },
|
||||
-- },
|
||||
-- { -- https://github.com/folke/which-key.nvim/blob/1f8d414f61e0b05958c342df9b6a4c89ce268766/lua/which-key/plugins/presets.lua#L57-L98
|
||||
-- -- text objects
|
||||
-- mode = { "o", "x" },
|
||||
-- { "l", group = "inside" },
|
||||
-- { 'l"', desc = 'inner " string' },
|
||||
-- { "l'", desc = "inner ' string" },
|
||||
-- { "l(", desc = "inner [(])" },
|
||||
-- { "l)", desc = "inner [(])" },
|
||||
-- { "l<", desc = "inner <>" },
|
||||
-- { "l>", desc = "inner <>" },
|
||||
-- { "lB", desc = "inner [{]}" },
|
||||
-- { "lW", desc = "inner WORD" },
|
||||
-- { "l[", desc = "inner []" },
|
||||
-- { "l]", desc = "inner []" },
|
||||
-- { "l`", desc = "inner ` string" },
|
||||
-- { "lb", desc = "inner [(])" },
|
||||
-- { "lp", desc = "inner paragraph" },
|
||||
-- { "ls", desc = "inner sentence" },
|
||||
-- { "lt", desc = "inner tag block" },
|
||||
-- { "lw", desc = "inner word" },
|
||||
-- { "l{", desc = "inner [{]}" },
|
||||
-- { "l}", desc = "inner [{]}" },
|
||||
-- { "i", desc = "Right" },
|
||||
-- },
|
||||
-- })
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
-- https://stackoverflow.com/a/73365602
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
group = vim.api.nvim_create_augroup("highlight_yank", {}),
|
||||
desc = "Hightlight selection on yank",
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 500 })
|
||||
end,
|
||||
})
|
||||
|
||||
return {
|
||||
-- Colorschemes
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
lazy = true,
|
||||
opts = {
|
||||
flavor = "auto",
|
||||
background = {
|
||||
light = "latte",
|
||||
dark = "mocha",
|
||||
},
|
||||
integrations = {
|
||||
-- lualine = true,
|
||||
"lualine",
|
||||
"blink_cmp"
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"rose-pine/neovim",
|
||||
name = "rose-pine",
|
||||
opts = {
|
||||
variant = "dawn",
|
||||
},
|
||||
cmd = "FzfLua colorschemes",
|
||||
},
|
||||
{ "rebelot/kanagawa.nvim", cmd = "FzfLua colorschemes" },
|
||||
{ -- Modern Status Line
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("plugins.mod.lualine")
|
||||
end,
|
||||
},
|
||||
-- { -- Breadcrumb
|
||||
-- "Bekaboo/dropbar.nvim",
|
||||
-- dependencies = {
|
||||
-- "nvim-telescope/telescope-fzf-native.nvim",
|
||||
-- build = "make",
|
||||
-- },
|
||||
-- opts = {},
|
||||
-- keys = {
|
||||
-- {
|
||||
-- "<Leader>+",
|
||||
-- function()
|
||||
-- require("dropbar.api").pick()
|
||||
-- end,
|
||||
-- desc = "Pick symbols in winbar",
|
||||
-- },
|
||||
-- {
|
||||
-- "[;",
|
||||
-- function()
|
||||
-- require("dropbar.api").goto_context_start()
|
||||
-- end,
|
||||
-- desc = "Go to start of current context",
|
||||
-- },
|
||||
-- {
|
||||
-- "];",
|
||||
-- function()
|
||||
-- require("dropbar.api").select_next_context()
|
||||
-- end,
|
||||
-- desc = "Select next context",
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
{ import = "plugins.mod.bufferline" }, -- Buffer Top Bar
|
||||
{ -- Git Blames, Changes
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {
|
||||
current_line_blame = true,
|
||||
},
|
||||
event = "BufReadPre",
|
||||
keys = {
|
||||
{ "<leader>gb", "<cmd>Gitsigns blame<CR>", desc = "Blame file" },
|
||||
{ "<leader>gd", "<cmd>Gitsigns diffthis<CR>", desc = "Diff file" },
|
||||
{ "<leader>gB", "<cmd>Gitsigns toggle_current_line_blame<CR>", desc = "Toggle line blame" },
|
||||
{ "[g", "<cmd>Gitsigns prev_hunk<CR>", desc = "Prev hunk" },
|
||||
{ "]g", "<cmd>Gitsigns next_hunk<CR>", desc = "Next hunk" },
|
||||
},
|
||||
},
|
||||
-- { -- Highlight and navigate between TODOs
|
||||
-- "folke/todo-comments.nvim",
|
||||
-- cmd = { "TodoTelescope" },
|
||||
-- event = "BufRead",
|
||||
-- opts = {},
|
||||
-- dependencies = { "nvim-lua/plenary.nvim" },
|
||||
-- },
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue