diff options
author | gxlin <[email protected]> | 2021-04-16 11:04:08 +0800 |
---|---|---|
committer | gxlin <[email protected]> | 2021-04-18 09:35:49 +0800 |
commit | 8aaabedde4f1ee045c9fedbcf20fecb3d217531a (patch) | |
tree | ca246e2a5aac5375a93c5549d0da76d74de12863 | |
parent | c81b6905aa178349c8633ac623ae2cd1d91f88a9 (diff) | |
download | dotfiles-8aaabedde4f1ee045c9fedbcf20fecb3d217531a.tar.gz dotfiles-8aaabedde4f1ee045c9fedbcf20fecb3d217531a.tar.bz2 dotfiles-8aaabedde4f1ee045c9fedbcf20fecb3d217531a.zip |
Add a lot of emacs config
-rw-r--r-- | .emacs.d/init.el | 152 | ||||
-rw-r--r-- | .emacs.d/modes/init-evil-mode.el | 29 | ||||
-rw-r--r-- | .emacs.d/modes/init-org-mode.el | 49 | ||||
-rw-r--r-- | .emacs.d/site-lisp/load-config.el | 6 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .vim/plugins/tex.vim | 2 | ||||
-rw-r--r-- | .zshrc | 2 |
7 files changed, 172 insertions, 70 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 141702e..bf131b5 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,87 +1,101 @@ ;; Set up package.el to work with MELPA (require 'package) -(add-to-list 'package-archives - '("melpa" . "https://melpa.org/packages/")) +(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/"))) (package-initialize) +(when (version<= "26.0.50" emacs-version) + (global-display-line-numbers-mode)) +(setq vc-follow-symlinks t) +(setq backup-directory-alist + `(("." . ,(concat user-emacs-directory "backups")))) + +(defun set-exec-path-from-shell-PATH () + "Set up Emacs' `exec-path' and PATH environment variable to match +that used by the user's shell. + +This is particularly useful under Mac OS X and macOS, where GUI +apps are not started from a shell." + (interactive) + (let ((path-from-shell (replace-regexp-in-string + "[ \t\n]*$" "" (shell-command-to-string + "$SHELL --login -c 'echo $PATH'" + )))) + (setenv "PATH" path-from-shell) + (setq exec-path (split-string path-from-shell path-separator)))) + +(set-exec-path-from-shell-PATH) (dolist (package '(use-package)) (unless (package-installed-p package) + (package-refresh-contents) (package-install package))) (require 'use-package) - -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(package-selected-packages - '(evil-escape counsel evil-org paredit auto-complete ledger-mode evil))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) -(when (version<= "26.0.50" emacs-version) - (global-display-line-numbers-mode)) +(setq use-package-always-ensure t) (xterm-mouse-mode 1) ;; Enable mouse +(add-to-list 'load-path "~/.dotfiles/.emacs.d/modes/") -;; Evil -(unless (package-installed-p 'evil) - (package-install 'evil)) -(require 'evil) -(evil-mode 1) -(evil-set-leader 'normal ",") +(use-package atom-one-dark-theme + :config + (load-theme 'atom-one-dark t)) +(set-face-attribute 'default nil :font "Monaco" :height 150) -;; Evil escape -(unless (package-installed-p 'evil-escape) - (package-install 'evil-escape)) -(require 'evil-escape) -(evil-escape-mode) -(setq-default - evil-escape-key-sequence "jk" - evil-escape-unordered-key-sequence t) +(use-package which-key) +(use-package undo-tree + :config + (global-undo-tree-mode)) -;; Org Mode -(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil))) -(use-package evil-org - :ensure t - :after org - :hook (org-mode . (lambda () evil-org-mode)) - :config - (require 'evil-org-agenda) - (evil-org-agenda-set-keys)) +(require 'init-evil-mode) +(require 'init-org-mode) ;; ledger-mode -(unless (package-installed-p 'ledger-mode) - (package-install 'ledger-mode)) -(require 'ledger-mode) -(add-to-list 'auto-mode-alist '("\\.journal$" . ledger-mode)) -(add-hook 'ledger-mode-hook - (lambda () - (setq-local tab-always-indent 'complete) - (setq-local completion-cycle-threshold t) - (setq-local ledger-complete-in-steps t))) -(setq ledger-highlight-xact-under-point nil) +(use-package ledger-mode + :config + (add-to-list 'auto-mode-alist '("\\.journal$" . ledger-mode)) + (add-hook 'ledger-mode-hook + (lambda () + (setq-local tab-always-indent 'complete) + (setq-local completion-cycle-threshold t) + (setq-local ledger-complete-in-steps t))) + (setq ledger-highlight-xact-under-point nil)) + +;; Company Mode +(use-package company + :hook ((after-init . global-company-mode) + (org-mode . (lambda () (company-mode -1))) + (ledger-mode . (lambda () (company-mode -1))))) + +;; Projectile +(use-package projectile + :config + (setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)) + (projectile-mode 1) + (evil-define-key 'normal projectile-mode-map + (kbd "<leader>p") 'projectile-command-map)) -;; Auto-Complete -(unless (package-installed-p 'auto-complete) - (package-install 'auto-complete)) -(require 'auto-complete) -(ac-config-default) +(use-package counsel + :after evil + :config + (ivy-mode 1) + (setq ivy-use-virtual-buffers t) + (setq ivy-count-format "(%d/%d) ") + (setq ivy-re-builders-alist + '((t . ivy--regex-fuzzy) + (t . ivy--regex-plus))) + (evil-define-key 'normal ivy-mode-map + (kbd "<leader>fb") 'ivy-switch-buffer + (kbd "<leader>fm") 'counsel-recentf)) -;; Par Edit -(unless (package-installed-p 'paredit) - (package-install 'paredit)) -(require 'paredit) -(add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode 1))) +(use-package vterm + :config + (setq vterm-kill-buffer-on-exit t)) -;; Counsel -(unless (package-installed-p 'counsel) - (package-install 'counsel)) -(ivy-mode) -(setq ivy-use-virutal-buffers t) -(setq enable-recursive-minibuffers t) -(evil-define-key 'normal 'global (kbd "<leader>ff") 'counsel-find-file) -(evil-define-key 'normal 'global (kbd "go") 'counsel-git-grep) +(use-package dashboard + :ensure t + :config + (dashboard-setup-startup-hook) + (setq dashboard-items '((recents . 5) + (bookmarks . 5) + (projects . 5) + (agenda . 5) + (registers . 5)))) diff --git a/.emacs.d/modes/init-evil-mode.el b/.emacs.d/modes/init-evil-mode.el new file mode 100644 index 0000000..ee7983a --- /dev/null +++ b/.emacs.d/modes/init-evil-mode.el @@ -0,0 +1,29 @@ +(use-package evil + :ensure t + :hook (evil-org-mode . (lambda () (setq evil-want-C-i-jump nil))) + :init + (setq evil-want-integration t + evil-want-keybinding nil) + :config + (evil-set-leader 'normal ",") + (setq evil-want-C-u-scroll t) + (setq evil-want-fine-undo t) + (evil-set-undo-system 'undo-tree) + (evil-mode 1)) + +(use-package evil-collection + :after evil + :ensure t +; :custom (evil-collection-setup-minibuffer t) + :config + (evil-collection-init)) + +(use-package evil-escape + :after evil + :config + (evil-escape-mode) + (setq-default + evil-escape-key-sequence "jk" + evil-escape-unordered-key-sequence t)) + +(provide 'init-evil-mode) diff --git a/.emacs.d/modes/init-org-mode.el b/.emacs.d/modes/init-org-mode.el new file mode 100644 index 0000000..ca1be2a --- /dev/null +++ b/.emacs.d/modes/init-org-mode.el @@ -0,0 +1,49 @@ +(use-package org + :after evil + :config + (setq org-directory "~/notes/") + (setq org-default-notes-file (concat org-directory "/inbox.org")) + (setq org-capture-templates + '(("t" "TODO" entry (file+headline org-default-notes-file "Tasks") + "* TODO %?\nCaptured on %U\n %i\n %a") + ("j" "Journal" entry (file+datetree org-default-notes-file) + "* %?\nCaptured on %U\n %i\n %a"))) + (add-hook 'org-mode-hook (lambda () (setq truncate-lines nil))) +; (setq org-agenda-files (directory-files-recursively "~/notes/" "\\.org$")) + (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) + (setq org-agenda-start-on-weekday 0) + (setq org-adapt-indentation nil) + (setq org-return-follows-link t) + (setq org-log-done t) + (evil-define-key 'normal 'global + (kbd "<leader>a") 'org-agenda + (kbd "<leader>l") 'org-store-link + (kbd "<leader>c") 'org-capture) + (evil-define-key 'normal org-mode-map + (kbd "TAB") 'org-cycle + (kbd "RET") 'org-open-at-point) + + (setq org-todo-keywords + '((sequence "TODO" "|" "DONE" "CANCELED"))) + (setq org-tag-alist '((:startgroup . nil) + ("work" . ?w) ("home" . ?h) ("errants" . ?e) + (:endgroup . nil) + ("@phone" . ?p))) + + (setq org-icalendar-include-todo t) + (setq org-icalendar-combined-agenda-file "~/notes/org.ics") + (add-hook 'org-mode-hook + (lambda () + (add-hook 'after-save-hook 'org-icalendar-combine-agenda-files nil t)))) + +(use-package evil-org + :ensure t + :after (org evil) + :hook (org-mode . (lambda () (evil-org-mode))) + + :config + (evil-org-set-key-theme '(navigation insert textobjects additional calendar todo)) + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) + +(provide 'init-org-mode) diff --git a/.emacs.d/site-lisp/load-config.el b/.emacs.d/site-lisp/load-config.el new file mode 100644 index 0000000..02f9113 --- /dev/null +++ b/.emacs.d/site-lisp/load-config.el @@ -0,0 +1,6 @@ +(defun load-config (filename &optional dirname) + (unless dirname (setq dirname "~/.dotfiles/.emacs.d/")) + (load (concat dirname (symbol-name filename)) 'noerror)) + +(defun load-mode (modename) + (load-config modename "~/.dotfiles/.emacs.d/modes/")) @@ -1,2 +1,4 @@ .DS_Store .tags + +.cache diff --git a/.vim/plugins/tex.vim b/.vim/plugins/tex.vim index b74256a..6c3f788 100644 --- a/.vim/plugins/tex.vim +++ b/.vim/plugins/tex.vim @@ -1 +1 @@ -Plug 'lervag/vimtex' +" Plug 'lervag/vimtex' @@ -59,3 +59,5 @@ if ! zplug check --verbose; then fi fi zplug load + +alias emacs='emacs -nw' |