持续更新中...
- 准备拥抱 spacemacs, 将自己的 init.el 配置放在这里留待参考
闪光点
css, js, typescript 等 自动缩进为2格
Emacs 模式下禁用鼠标
使用主题 dracula
默认进入 Emacs 模式
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; 添加 melpa 源
;; melpa => http://melpa.milkbox.net/packages/
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
;; 显示行号
(global-linum-mode t)
;; 状态栏显示行列信息
(column-number-mode t)
;; 括号匹配高亮
(show-paren-mode t)
;; 高亮当前行
(global-hl-line-mode 1)
;; 关闭缩进
;;(electric-indent-mode -1)
;; 关闭工具栏
(tool-bar-mode 0)
;; 自动补全括号
(electric-pair-mode t)
;; 关闭自动生成文件备份
(setq make-backup-files nil)
;; 更改字体大小
;; (set-face-attribute 'default nil :height 140).
;; 选中的文本可直接删除
(delete-selection-mode 1)
;; 关闭启动帮助画面
(setq inhibit-splash-screen 1)
;; 添加最近打开的文件
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-item 10)
;; 删除换行符
(defun remove-dos-eol ()
"Replace DOS eolns CR LF with Unix eolns CR"
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))
;; 统计选择的字符数
;; (require 'modeline-posn)
;; (size-indication-mode 1)
(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.
'(custom-safe-themes
(quote
("bd7b7c5df1174796deefce5debc2d976b264585d51852c962362be83932873d9" default)))
'(package-selected-packages
(quote
(helm-ls-git w3 helm-projectile helm-ag yasnippet-snippets org-plus-contrib helm-google evil smex whitespace-cleanup-mode company tide emmet-mode helm magit tern list-packages-ext dracula-theme scss-mode auto-complete react-snippets js2-mode disable-mouse web-mode monokai-theme))))
(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.
)
;; 加载 monokai-theme
;;(load-theme 'monokai t)
(load-theme 'dracula t)
;; 编辑时禁用触摸板与鼠标
(global-disable-mouse-mode)
;; 开启evil
(add-to-list 'load-path "~/.emacs.d/evil")
(require 'evil)
(evil-mode 1)
;; 默认进入emacs模式
(setq evil-default-state 'emacs)
;; C-o按键调用vim功能 (就是临时进入normal模式,然后自动回来)
(define-key evil-emacs-state-map (kbd "C-o") 'evil-execute-in-normal-state)
;; 设置缩进
;;(setq indent-tabs-mode nil)
;;(setq default-tab-width 2)
;;(setq web-mode-code-indent-offset 2)
;;(setq web-mode-s-indent-offset 2)
;;(setq web-mode-typescript-indent-offset 2)
;; 开启自动补全
;;(ac-config-default)
;;;;;;;;;;;;;;
;emmet-mode
;;;;;;;;;;;;;
(require 'emmet-mode)
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'html-mode-hook 'emmet-mode)
(add-hook 'web-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook 'emmet-mode)
;;;;;;;;;;;;;;
;web-mode
;;;;;;;;;;;;;;;
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(defun my-web-mode-hook ()
"Hooks for Web mode."
;; (setq web-mode-markup-indent-offset 2)
;; (setq web-mode-code-indent-offset 2)
;; (setq web-mode-css-indent-offset 2)
;; (setq web-mode-enable-auto-pairing t)
;; (setq web-mode-enabled-css-colorization t)
;; (setq tab-width 2 indent-tab-mode nil)
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
;; Autoremove final white spaces on save
(add-hook 'local-write-file-hooks
(lambda ()
(delete-trailing-whitespace)
nil))
;; How can I trun auto indentation on?
;;(local-set-key (kbd "RET") 'newline-and-indent)
(setq-default show-trailing-whitespace t)
;; enable smex
(require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; enable typescript
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
;; set helm global keys
(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
;; enable helm
(helm-mode 1)
;; enable yasnippet
(require 'yasnippet)
(yas-global-mode 1)
;; enable helm-projectile
;; (setq helm-projectile-fuzzy-match nil)
(require 'helm-projectile)
(helm-projectile-on)
;; 设置缩进为2个空格
(defun my-setup-indent (n)
;; java/c/c++
(setq c-basic-offset n)
;; web development
(setq coffee-tab-width n)
(setq javascript-indent-level n)
(setq js-indent-level n)
(setq js2-basic-offset n)
(setq web-mode-markup-indent-offset n)
(setq web-mode-css-indent-offset n)
(setq web-mode-code-indent-offset n)
(setq css-indent-offset n))
(my-setup-indent 2)
``
网友评论