Skip to content

Instantly share code, notes, and snippets.

@kimitoboku
Created April 8, 2019 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimitoboku/219ea470c6b9210862196c55bb862d8d to your computer and use it in GitHub Desktop.
Save kimitoboku/219ea470c6b9210862196c55bb862d8d to your computer and use it in GitHub Desktop.
(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
(package-refresh-contents)
(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.
'(doom-themes-enable-bold t)
'(doom-themes-enable-italic t)
'(package-selected-packages
(quote
(exec-path-from-shell e2wm eglot rustic hippie-expand-slime smart-jump ivy-yasnippet yasnippet symbol-overlay ob-ipython inf-ruby lsp-ui google-this counsel-projectile projectile dumb-jump company-irony irony lsp-go company-lsp go-autocomplete go-eldoc go company-box company-quickhelp company magit howm open-junk-file evil counsel ace-window rainbow-delimiters imenu-listn doom-modeline dashboard ivy-rich swiper hydra which-key neotree git-gutter beacon amx doom-themes use-package))))
(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.
'(default ((t (:foundry "Source Code Pro" :family "Source Code Pro" :height 130))))
'(aw-leading-char-face ((t (:height 4.0 :foreground "#f1fa8c"))))
'(doom-modeline-bar ((t (:background "#6272a4"))))
'(git-gutter:added ((t (:background "#50fa7b"))))
'(git-gutter:deleted ((t (:background "#ff79c6"))))
'(git-gutter:modified ((t (:background "#f1fa8c"))))
'(show-paren-match ((nil (:background "#44475a" :foreground "#f1fa8c")))))
;; 環境変数の設定
(exec-path-from-shell-initialize)
;; 外観設定
;;;; メニューバーを消す
(menu-bar-mode -1)
;;;; ツールバーを消す
(tool-bar-mode -1)
;;;; 列数を表示する
(column-number-mode t)
;;;; 行数を表示する
(global-linum-mode t)
;;;; フォントの設定
;;;;;; 日本語フォント
(set-fontset-font t 'japanese-jisx0208 (font-spec :family "Note Serif CJK JP"))
;; キーバインド
;;;; C-h をBackspaceに
(global-set-key "\C-h" 'delete-backward-char)
;;;; C-3でhashを挿入
(global-unset-key (kbd "C-3"))
(global-set-key (kbd "C-3") '(lambda() (interactive) (insert "#")))
;;;; shift+十字キーでウィンドウを移動
(windmove-default-keybindings)
;; バックアップファイルほ保存先を設定する
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup"))
backup-directory-alist))
(setq auto-save-file-name-transforms
`((".*", (expand-file-name "~/.emacs.d/backup/") t)))
;; yes noをyとnに変更する
(fset 'yes-or-no-p 'y-or-n-p)
;; eww-search
(setq eww-search-prefix "https://www.google.co.jp/search?btnI&q=")
;; Emacs Server
(require 'server)
(unless (server-running-p)
(server-start))
(defun utils/emacs/wm ()
(use-package e2wm
:bind
("M-+" . e2wm:start-management)
)
)
(defun utils/emacs/vim ()
(use-package evil
:init
(setq evil-disable-insert-state-bindings t)
:config
(evil-mode 1)
(if (evil-mode)
(progn
(bind-keys :map evil-visual-state-map
("TAB" . indent-for-tab-command))
(bind-keys :map evil-normal-state-map
("SPC b" . ido-switch-buffer)
("SPC f" . projectile-find-file)
("SPC x" . smex)
("SPC s" . save-buffer)
("SPC d" . dired-jump)
("SPC k" . kill-this-buffer)
("SPC r" . ido-recentf-open)
("SPC 1" . delete-other-windows)
("SPC 0" . delete-window)
("SPC q" . delete-frame)
("SPC t" . xref-find-definitions-other-window)
("SPC y" . browse-kill-ring)
("SPC u" . undo-tree)
("SPC g s" . magit-status)
("SPC g g" . counsel-git)
("SPC g r" . counsel-git-grep)
("SPC SPC" . counsel-M-x)
("TAB" . indent-for-tab-command))
(bind-keys :map evil-insert-state-map
("C-g" . evil-normal-state)))
)
)
)
(defun utils/emacs/appearance ()
(use-package doom-themes
:custom
(doom-themes-enable-italic t)
(doom-themes-enable-bold t)
:custom-face
(doom-modeline-bar ((t (:background "#6272a4"))))
:config
(load-theme 'doom-dracula t)
(doom-themes-neotree-config)
(doom-themes-org-config))
(use-package doom-modeline
:custom
(doom-modeline-buffer-file-name-style 'truncate-with-project)
(doom-modeline-icon t)
(doom-modeline-major-mode-icon nil)
(doom-modeline-minor-modes nil)
:hook
(after-init . doom-modeline-mode)
:config
(line-number-mode 0)
(column-number-mode 0)
(doom-modeline-def-modeline 'main
'(bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info)
'(misc-info persp-name lsp github debug minor-modes input-method major-mode process vcs checker)))
;; 設定されているキーバインドを見えるようにする
(use-package which-key
:diminish which-key-mode
:hook (after-init . which-key-mode))
;; 括弧の対応を虹色にして分かりやすくする
(use-package rainbow-delimiters
:hook
(prog-mode . rainbow-delimiters-mode))
;; 対応する括弧の協調
(use-package paren
:ensure nil
:hook
(after-init . show-paren-mode)
:custom-face
(show-paren-match ((nil (:background "#44475a" :foreground "#f1fa8c"))))
:custom
(show-paren-style 'mixed)
(show-paren-when-point-inside-paren t)
(show-paren-when-point-in-periphery t))
;; バッファに戻った時に,現在の行を強調する
(use-package beacon
:custom
(beacon-color "yellow")
:config
(beacon-mode 1))
;; メールなどの一行に表示できる制限を可視化する
(use-package fill-column-indicator
:hook
((markdown-mode
git-commit-mode) . fci-mode))
;; タブとかスペースとかを可視化
(use-package whitespace
:config
(setq whitespace-style '(face ; faceで可視化
trailing ; 行末
tabs ; タブ
spaces ; スペース
empty ; 先頭/末尾の空行
space-mark ; 表示のマッピング
tab-mark
))
(setq whitespace-display-mappings
'((space-mark ?\u3000 [?\u25a1])
;; WARNING: the mapping below has a problem.
;; When a TAB occupies exactly one column, it will display the
;; character ?\xBB at that column followed by a TAB which goes to
;; the next TAB column.
;; If this is a problem for you, please, comment the line below.
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])))
;; スペースは全角のみを可視化
(setq whitespace-space-regexp "\\(\u3000+\\)")
;; 保存前に自動でクリーンアップ
(setq whitespace-action '(auto-cleanup))
(global-whitespace-mode 1)
(defvar my/bg-color "#232323")
(set-face-attribute 'whitespace-trailing nil
:background my/bg-color
:foreground "DeepPink"
:underline t)
(set-face-attribute 'whitespace-tab nil
:background my/bg-color
:foreground "LightSkyBlue"
:underline t)
(set-face-attribute 'whitespace-space nil
:background my/bg-color
:foreground "GreenYellow"
:weight 'bold)
(set-face-attribute 'whitespace-empty nil
:background my/bg-color)
)
)
(defun utils/org ()
(setq org-default-notes-file "~/Dropbox/howm/caputre/notes.org")
(setq org-agenda-files (list org-default-notes-file))
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(ruby . t)
(emacs-lisp . t)
))
(use-package org-bullets
:custom (org-bullets-bullet-list '("" "" "" "" "" "" "" "" "" ""))
:hook (org-mode . org-bullets-mode)
)
)
(defun utils/emacs/keybinds ()
;; よく使う機能をキーバインドにまとめるためのプラグイン
(use-package hydra
:ensure t
:defer t
:init
(defhydra hydra-zoom (global-map "<f2>")
"zoom"
("g" text-scale-increase)
("l" text-scale-decrease))
)
(use-package ace-window
:functions hydra-frame-window/body
:bind
("C-M-o" . hydra-frame-window/body)
:custom
(aw-keys '(?j ?k ?l ?i ?o ?h ?y ?u ?p))
:custom-face
(aw-leading-char-face ((t (:height 4.0 :foreground "#f1fa8c")))))
)
(defun utils/interactive/filtering ()
(use-package amx)
(use-package swiper
:bind
(("C-x C-c" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("C-s" . swiper)
("C-x C-i" . counsel-imenu)
("C-x C-y" . counsel-yank-pop)
("C-x g" . counsel-git)
("C-x j" . counsel-git-grep)
("C-x C-r" . ivy-recentf)
)
)
(use-package ivy-rich
:bind
(("C-x C-b" . ivy-switch-buffer)
)
:config
(ivy-rich-mode 1)
)
(use-package ivy-yasnippet
:bind
("C-c y" . ivy-yasnippet)
)
)
(defun utils/finder ()
(use-package neotree
:after
projectile
:commands
(neotree-show neotree-hide neotree-dir neotree-find)
:custom
(neo-theme 'nerd2)
:bind
("<f9>" . neotree)
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
)
(use-package recentf
:init
(setq recentf-max-saved-items 2000) ;; 2000ファイルまで履歴保存する
(setq recentf-auto-cleanup 'never) ;; 存在しないファイルは消さない
(setq recentf-exclude '("/recentf" "COMMIT_EDITMSG" "/.?TAGS" "^/sudo:" "/\\.emacs\\.d/games/*-scores" "/\\.emacs\\.d/\\.cask/"))
(setq recentf-auto-save-timer (run-with-idle-timer 30 t 'recentf-save-list))
:bind
("C-c t" . ivy-recentfe)
:config
(recentf-mode 1)
)
)
;; (use-package git-gutter
;; :custom
;; (git-gutter:modified-sign "~")
;; (git-gutter:added-sign "+")
;; (git-gutter:deleted-sign "-")
;; :custom-face
;; (git-gutter:modified ((t (:background "#f1fa8c"))))
;; (git-gutter:added ((t (:background "#50fa7b"))))
;; (git-gutter:deleted ((t (:background "#ff79c6"))))
;; :config
;; (global-git-gutter-mode +1))
(defun utils/file/tempfile ()
(use-package open-junk-file
:config
(setq open-junk-file-format "~/dev/junk/%Y/%m/junk%d%H%M%S.")
)
)
(defun utils/file/wiki ()
(use-package howm
:init
(defvar howm-view-title-header "#+TITLE:")
:bind
(("C-c , ," . howm-menu)
)
:config
(setq howm-menu-lang 'ja)
(autoload 'howm-menu "howm" "Hitori Otegaru Wiki Modoki" t)
(setq howm-home-directory "~/Dropbox/howm/")
(setq howm-directory "~/Dropbox/howm/")
(setq howm-keyword-file (concat howm-home-directory ".howm-keys"))
(setq howm-history-file (concat howm-home-directory ".howm-history"))
(setq howm-file-name-format "%Y/%m/%Y-%m-%d-%H%M%S.org")
)
)
(defun utils/ui/vc ()
(use-package magit
:bind
(("C-x C-g" . magit-status)
)
:config
(setq magit-repository-directories
'(("~/dev/src/bitbucket.org/kimitoboku" . 1)
("~/dev/src/github.com/kimitoboku" . 1)
))
)
(use-package projectile
:config
(projectile-mode +1)
)
(use-package counsel-projectile
:config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
)
)
(defun utils/code/snippet ()
(use-package yasnippet
:config
(setq yas-snippet-dirs
'("~/.emacs.d/snippet/yasnippet-snippets/snippets"
"~/.emacs.d/snippet/my_snippets"
))
(yas-global-mode 1)
)
)
(defun utils/code/auto_complete ()
;; 閉じ括弧の自動挿入
(electric-pair-mode 1)
;; 保管インターフェース
(use-package company
:bind
(("C-/" . company-complete)
)
:config
(global-company-mode)
(setq company-idel-delay 0)
(setq company-minimum-prefix-length 2)
(setq company-selection-wrap-around t)
(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-search-map (kbd "C-n") 'company-select-next)
(define-key company-search-map (kbd "C-p") 'company-select-previous)
;; C-sで絞り込む
(define-key company-active-map (kbd "C-s") 'company-filter-candidates)
;; TABで候補を設定
(define-key company-active-map (kbd "C-i") 'company-complete-selection)
;; 各種メジャーモードでも C-M-iで company-modeの補完を使う
(define-key emacs-lisp-mode-map (kbd "C-M-i") 'company-complete)
)
(use-package company-lsp
:config
(push 'company-lsp company-backends)
)
(use-package company-quickhelp
:hook
(company-mode . company-quickhelp-mode)
)
(use-package company-box
:hook
(company-mode . company-box-mode)
)
(use-package lsp-mode
:commands lsp
:init
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "gopls")
:major-modes '(go-mode)
:server-id 'gopls))
)
(use-package eglot
:disabled t
:config
(add-to-list 'eglot-server-programs '(go-mode . ("/Users/kawakami/dev/bin/go-langserver")))
(add-hook 'go-mode-hook 'eglot-ensure)
)
)
(defun lang/go ()
(use-package go-mode
:commands go-mode
:mode (("\\.go?\\'" . go-mode))
:defer t
:init
(add-hook 'go-mode-hook #'lsp)
(add-hook 'go-mode-hook (lambda ()
(let ((envs '("GOROOT" "GOPATH")))
(exec-path-from-shell-copy-envs envs))
(setq-default)
))
:config
;; インデント関係の設定
(setq indent-tabs-mode nil)
(setq c-basic-offset 4)
(setq tab-width 4)
;; 保存前に lsp-format-buffer
(add-hook 'before-save-hook 'lsp-format-buffer)
)
(use-package go-eldoc
:config
(set-face-attribute 'eldoc-highlight-function-argument nil
:underline t :foreground "green"
:weight 'bold)
)
)
(defun lang/cpp ()
(use-package irony
:ensure t
:config
(progn
(use-package company-irony
:ensure t
:config
(add-to-list 'company-backends 'company-irony))
(add-hook 'irony-mode-hook 'electric-pair-mode)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
)
)
(defun lang/rust ()
(use-package rustic
:config
(setq rustic-lsp-server 'ra_lsp_server)
(setq rustic-rls-pkg 'elgot)
)
)
(defun utils/code/define_jump()
(use-package dumb-jump
:bind
(("M-g o" . dumb-jump-go-other-window)
("M-g j" . dumb-jump-go)
("M-g i" . dumb-jump-go-prompt)
("M-g x" . dumb-jump-go-prefer-external)
("M-g z" . dumb-jump-go-prefer-external-other-window)
)
:config
(setq dumb-jump-default-project "")
(setq dumb-jump-selector 'ivy)
(setq dumb-jump-force-searcher 'rg)
)
(use-package smart-jump
:ensure
:config
(smart-jump-setup-default-registers)
)
)
(defun utils/other/google_search ()
(use-package google-this
:bind
(("C-x g" . google-this-mode-submap)
)
)
)
(defun plugin_load()
(utils/emacs/wm)
(utils/emacs/vim)
(utils/emacs/appearance)
(utils/org)
(utils/emacs/keybinds)
(utils/interactive/filtering)
(utils/finder)
(utils/file/tempfile)
(utils/file/wiki)
(utils/ui/vc)
(utils/code/snippet)
(utils/code/auto_complete)
(utils/code/define_jump)
(utils/other/google_search)
(lang/go)
(lang/cpp)
)
;; プラグイン設定
(plugin_load)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment