diff options
author | gxlin <[email protected]> | 2021-07-06 22:00:15 +0800 |
---|---|---|
committer | gxlin <[email protected]> | 2021-07-06 22:00:15 +0800 |
commit | 43b356933766807cff3cce9dda6955469f4df49c (patch) | |
tree | b13768fdd9c3d4fd00571870639a9100b1086bbf | |
parent | 20f2705342e1c444bda1b4c9a2077408ae14389a (diff) | |
download | dotfiles-43b356933766807cff3cce9dda6955469f4df49c.tar.gz dotfiles-43b356933766807cff3cce9dda6955469f4df49c.tar.bz2 dotfiles-43b356933766807cff3cce9dda6955469f4df49c.zip |
Reorganized emacs config
-rw-r--r-- | .aliases | 5 | ||||
-rw-r--r-- | .emacs.d/.gitignore | 6 | ||||
-rw-r--r-- | .emacs.d/init-mu4e.el | bin | 2519 -> 0 bytes | |||
-rw-r--r-- | .emacs.d/init.el | 107 | ||||
-rw-r--r-- | .emacs.d/lisp/init-evil.el (renamed from .emacs.d/modes/init-evil-mode.el) | 2 | ||||
-rw-r--r-- | .emacs.d/lisp/init-lang.el | 33 | ||||
-rw-r--r-- | .emacs.d/lisp/init-misc.el | 52 | ||||
-rw-r--r-- | .emacs.d/lisp/init-mu4e.el | bin | 0 -> 2610 bytes | |||
-rw-r--r-- | .emacs.d/lisp/init-org.el (renamed from .emacs.d/modes/init-org-mode.el) | 6 | ||||
-rw-r--r-- | .emacs.d/lisp/init-package.el | 14 | ||||
-rw-r--r-- | .emacs.d/modes/init-lsp-mode.el | 13 | ||||
-rw-r--r-- | .emacs.d/site-lisp/load-config.el | 6 | ||||
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | .vim/init.vim | 5 | ||||
-rwxr-xr-x | bootstrap.sh | 5 | ||||
-rw-r--r-- | install.sh | 52 |
16 files changed, 134 insertions, 174 deletions
@@ -1,4 +1,5 @@ #!/usr/bin/env bash -alias mu4e='emacs -f mu4e' -alias todo='emacs ~/notes/todo.org' +alias emacs='emacs -nw' +alias mu4e='emacs -nw -f mu4e' +alias todo='emacs -nw ~/notes/todo.org' diff --git a/.emacs.d/.gitignore b/.emacs.d/.gitignore new file mode 100644 index 0000000..d01fcd1 --- /dev/null +++ b/.emacs.d/.gitignore @@ -0,0 +1,6 @@ +auto-save-list +recentf +backups +custom.el +elpa +*.eld diff --git a/.emacs.d/init-mu4e.el b/.emacs.d/init-mu4e.el Binary files differdeleted file mode 100644 index bf72115..0000000 --- a/.emacs.d/init-mu4e.el +++ /dev/null diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4f08fd7..4c4f865 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,17 +1,17 @@ +;; -*- coding: utf-8; lexical-binding: t; -*- + ;; Make startup faster by reducing frequency of garbage collection. (setq gc-cons-percentage 0.6) (setq gc-cons-threshold most-positive-fixnum) ;; Make gc pauses faster by decreasing the threhold to 8 MiB (default is ;; 800kB) (add-hook 'emacs-startup-hook - (lambda () - (setq gc-cons-threshold (expt 2 23)))) + (lambda () (setq gc-cons-threshold (expt 2 23)))) + +(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) + +(defconst *is-a-mac* (eq system-type 'darwin)) -;; Set up package.el to work with MELPA -(require 'package) -(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) @@ -19,19 +19,9 @@ `(("." . ,(concat user-emacs-directory "backups")))) (setq-default fill-column 72) (menu-bar-mode -1) - -(setq recentf-max-saved-items 100) - -(dolist (package '(use-package)) - (unless (package-installed-p package) - (package-refresh-contents) - (package-install package))) -(require 'use-package) -(setq use-package-always-ensure t) - (xterm-mouse-mode 1) ;; Enable mouse -(add-to-list 'load-path "~/.dotfiles/.emacs.d/") -(add-to-list 'load-path "~/.dotfiles/.emacs.d/modes/") + +(require 'init-package) (use-package atom-one-dark-theme :config @@ -47,78 +37,13 @@ :config (global-undo-tree-mode)) -(require 'init-evil-mode) -(require 'init-org-mode) -(require 'init-lsp-mode) +(require 'init-evil) +(require 'init-org) (require 'init-mu4e) +(require 'init-lang) -(use-package ledger-mode - :mode (("\\.journal$" . ledger-mode)) - :config - (add-hook 'ledger-mode-hook - (setq-local tab-always-indent 'complete) - (setq-local completion-cycle-threshold t))) - -;; Company Mode -(use-package company - :init - (setq company-global-modes - '(emacs-lisp-mode go-mode ledger-mode)) - :hook ((after-init . global-company-mode))) - -;; Projectile -(use-package projectile - :init - (evil-define-key 'normal projectile-mode-map - (kbd "<leader>p") 'projectile-command-map) - :config - (setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)) - (projectile-mode 1)) - -(use-package counsel - :after evil - :init - (evil-define-key 'normal ivy-mode-map - (kbd "<leader>fb") 'ivy-switch-buffer - (kbd "<leader>fm") 'counsel-recentf) - :config - (ivy-mode 1) - (setq ivy-use-virtual-buffers t) - (setq ivy-count-format "(%d/%d) ") - (setq ivy-re-builders-alist - '((read-file-name-internal . ivy--regex-fuzzy) - (t . ivy--regex-plus)))) - -(use-package vterm - :commands (vterm) - :config - (setq vterm-kill-buffer-on-exit t)) - -(use-package markdown-mode - :ensure t - :commands (markdown-mode gfm-mode) - :mode (("README\\.md\\'" . gfm-mode) - ("\\.md\\'" . markdown-mode) - ("\\.markdown\\'" . markdown-mode)) - :init - (evil-define-key 'normal markdown-mode-map - (kbd "<RET>") 'markdown-follow-link-at-point) - (setq markdown-command "multimarkdown")) - -(use-package exec-path-from-shell - :if (memq window-system '(mac ns)) - :ensure t - :config - (exec-path-from-shell-initialize)) - -(use-package go-mode - :ensure t - :commands (go-mode) - :mode (("\\.go\\'" . go-mode)) - :hook ((go-mode . (lambda () (setq tab-width 4))))) - -(use-package avy) +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +(when (file-exists-p custom-file) + (load custom-file)) -(use-package esup - :ensure t - :pin melpa) +(require 'init-local nil t) diff --git a/.emacs.d/modes/init-evil-mode.el b/.emacs.d/lisp/init-evil.el index c15e403..6e4a95c 100644 --- a/.emacs.d/modes/init-evil-mode.el +++ b/.emacs.d/lisp/init-evil.el @@ -25,4 +25,4 @@ :config (evilem-default-keybindings "SPC")) -(provide 'init-evil-mode) +(provide 'init-evil) diff --git a/.emacs.d/lisp/init-lang.el b/.emacs.d/lisp/init-lang.el new file mode 100644 index 0000000..f8e96b6 --- /dev/null +++ b/.emacs.d/lisp/init-lang.el @@ -0,0 +1,33 @@ +(use-package ledger-mode + :mode (("\\.journal$" . ledger-mode))) + +(use-package markdown-mode + :ensure t + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :init + (evil-define-key 'normal markdown-mode-map + (kbd "<RET>") 'markdown-follow-link-at-point) + (setq markdown-command "multimarkdown")) + +(use-package go-mode + :ensure t + :commands (go-mode) + :mode (("\\.go\\'" . go-mode)) + :hook ((go-mode . (lambda () (setq tab-width 4))))) + +(use-package lsp-mode + :ensure t + :hook + ((go-mode . lsp-deferred) + (lsp-mode . lsp-enable-which-key-integration)) + :commands (lsp lsp-deferred) + :config + (evil-define-key 'normal lsp-mode-map + (kbd "gd") 'lsp-find-definition + (kbd "gr") 'lsp-find-references) + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.git\\'")) + +(provide 'init-lang) diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el new file mode 100644 index 0000000..07eef14 --- /dev/null +++ b/.emacs.d/lisp/init-misc.el @@ -0,0 +1,52 @@ +(setq tab-always-indent 'complete + completion-cycle-threshold t) + +(use-package recentf + :ensure nil + :config + (add-hook 'after-init-hook 'recentf-mode) + (setq-default + recentf-max-saved-items 1024 + recentf-exclude `("/tmp/"))) + +(use-package counsel + :after evil + :init + (evil-define-key 'normal ivy-mode-map + (kbd "<leader>fb") 'ivy-switch-buffer + (kbd "<leader>fm") 'counsel-recentf) + :config + (ivy-mode 1) + (setq ivy-use-virtual-buffers t) + (setq ivy-count-format "(%d/%d) ") + (setq ivy-re-builders-alist + '((read-file-name-internal . ivy--regex-fuzzy) + (t . ivy--regex-plus)))) + +(use-package vterm + :commands (vterm) + :config + (setq vterm-kill-buffer-on-exit t)) + +(use-package exec-path-from-shell + :if (memq window-system '(mac ns)) + :ensure t + :config + (exec-path-from-shell-initialize)) + +(use-package avy + :ensure t) + +(use-package company + :init + (setq company-global-modes + '(emacs-lisp-mode go-mode ledger-mode)) + :hook ((after-init . global-company-mode))) + +(use-package projectile + :init + (evil-define-key 'normal projectile-mode-map + (kbd "<leader>p") 'projectile-command-map) + :config + (setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)) + (projectile-mode 1)) diff --git a/.emacs.d/lisp/init-mu4e.el b/.emacs.d/lisp/init-mu4e.el Binary files differnew file mode 100644 index 0000000..8a2c5a6 --- /dev/null +++ b/.emacs.d/lisp/init-mu4e.el diff --git a/.emacs.d/modes/init-org-mode.el b/.emacs.d/lisp/init-org.el index 32bdc4f..caadeec 100644 --- a/.emacs.d/modes/init-org-mode.el +++ b/.emacs.d/lisp/init-org.el @@ -22,7 +22,6 @@ (add-hook 'org-mode-hook (lambda () (setq truncate-lines nil))) (setq org-agenda-start-on-weekday 0) (setq org-adapt-indentation nil) - (setq org-return-follows-link t) (setq org-descriptive-links nil) (evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle @@ -33,7 +32,8 @@ (kbd "<leader>oil") 'org-insert-link (kbd "<leader>oih") 'org-insert-heading (kbd "<leader>oci") 'org-clock-in - (kbd "<leader>oco") 'org-clock-out) + (kbd "<leader>oco") 'org-clock-out + (kbd "<leader>sp") 'org-set-property) (setq org-tags-exclude-from-inheritance '("PROJECT")) @@ -125,4 +125,4 @@ (org-save-all-org-buffers) (org-agenda-quit)))) -(provide 'init-org-mode) +(provide 'init-org) diff --git a/.emacs.d/lisp/init-package.el b/.emacs.d/lisp/init-package.el new file mode 100644 index 0000000..5e6a0c7 --- /dev/null +++ b/.emacs.d/lisp/init-package.el @@ -0,0 +1,14 @@ +(require 'package) +(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/"))) +(setq package-enable-at-startup nil) +(package-initialize) + +(dolist (package '(use-package)) + (unless (package-installed-p package) + (package-refresh-contents) + (package-install package))) +(require 'use-package) +(setq use-package-always-ensure t) + +(provide 'init-package) diff --git a/.emacs.d/modes/init-lsp-mode.el b/.emacs.d/modes/init-lsp-mode.el deleted file mode 100644 index a44c722..0000000 --- a/.emacs.d/modes/init-lsp-mode.el +++ /dev/null @@ -1,13 +0,0 @@ -(use-package lsp-mode - :ensure t - :hook - ((go-mode . lsp-deferred) - (lsp-mode . lsp-enable-which-key-integration)) - :commands (lsp lsp-deferred) - :config - (evil-define-key 'normal lsp-mode-map - (kbd "gd") 'lsp-find-definition - (kbd "gr") 'lsp-find-references) - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.git\\'")) - -(provide 'init-lsp-mode) diff --git a/.emacs.d/site-lisp/load-config.el b/.emacs.d/site-lisp/load-config.el deleted file mode 100644 index 02f9113..0000000 --- a/.emacs.d/site-lisp/load-config.el +++ /dev/null @@ -1,6 +0,0 @@ -(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/")) diff --git a/.gitattributes b/.gitattributes index b9aae35..0da544c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -.emacs.d/init-mu4e.el filter=git-crypt diff=git-crypt +.emacs.d/lisp/init-mu4e.el filter=git-crypt diff=git-crypt offlineimap/.offlineimaprc filter=git-crypt diff=git-crypt .mutt/muttrc filter=git-crypt diff=git-crypt .mutt/mailboxes filter=git-crypt diff=git-crypt diff --git a/.vim/init.vim b/.vim/init.vim index 275e838..73c025b 100644 --- a/.vim/init.vim +++ b/.vim/init.vim @@ -94,11 +94,6 @@ set tags=./.tags;,.tags " mapping let mapleader=',' " change the key <leader> -inoremap jk <Esc> -nnoremap [w <c-w>h <CR> -nnoremap [ww <c-w>k <CR> -nnoremap ]w :wincmd l <CR> -nnoremap ]ww :wincmd j <CR> nnoremap <leader>cd :cd %:p:h<CR> :pwd<CR> source ~/.dotfiles/.vim/plugins/init.vim diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..ca2e734 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +dotfiles_dir=$(cd -- "$(dirname ${BASH_SOURCE})" > /dev/null 2>&1; pwd -P) + +ln -s $dotfiles_dir/.emacs.d $HOME/.emacs.d diff --git a/install.sh b/install.sh deleted file mode 100644 index e4a5761..0000000 --- a/install.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# install.sh - -check_is_sudo() { - if [ "$EUID" -ne 0 ]; then - echo "Please run as root." - exit - fi -} - -usage() { - echo "Usage: sudo bash install.sh [OPTION]" - echo " dotfiles - link all dotfiles" - echo " all - install all things listed above" -} - -get_dotfiles() { - # create subshell - ( - echo "--------- Get Dotfiles Now ---------" - - - cd "$HOME" - - rm -rf .vimrc .tmux.conf .bashrc .zshrc .i3/config .emacs.d/init.el .gitconfig - ln -s ~/.dotfiles/.tmux.conf .tmux.conf - ln -s ~/.dotfiles/.bashrc .bashrc - ln -s ~/.dotfiles/.zshrc .zshrc - ln -s ~/.dotfiles/.emacs.d/init.el .emacs.d/init.el - ln -s ~/.dotfiles/.i3/config .i3/config - ln -s ~/.dotfiles/.gitconfig .gitconfig - echo "source ~/.dotfiles/.vim/init.vim" > ~/.vimrc - ) -} - -main() { - local cmd=$1 - - if [[ -z "$cmd" ]]; then - usage - exit 1 - fi - - check_is_sudo - - if [[ $cmd == all ]]; then - get_dotfiles - fi -} - -main "$@" |