Skip to content

Instantly share code, notes, and snippets.

@kimitoboku kimitoboku/init.el
Created Apr 8, 2019

What would you like to do?
(require 'package)
(setq package-archives
'(("gnu" . "")
("melpa" . "")
("org" . "")))
;; 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)
(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 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")))))
;; 環境変数の設定
;; 外観設定
;;;; メニューバーを消す
(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+十字キーでウィンドウを移動
;; バックアップファイルほ保存先を設定する
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup"))
(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 "")
;; Emacs Server
(require 'server)
(unless (server-running-p)
(defun utils/emacs/wm ()
(use-package e2wm
("M-+" . e2wm:start-management)
(defun utils/emacs/vim ()
(use-package evil
(setq evil-disable-insert-state-bindings t)
(evil-mode 1)
(if (evil-mode)
(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
(doom-themes-enable-italic t)
(doom-themes-enable-bold t)
(doom-modeline-bar ((t (:background "#6272a4"))))
(load-theme 'doom-dracula t)
(use-package doom-modeline
(doom-modeline-buffer-file-name-style 'truncate-with-project)
(doom-modeline-icon t)
(doom-modeline-major-mode-icon nil)
(doom-modeline-minor-modes nil)
(after-init . doom-modeline-mode)
(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
(prog-mode . rainbow-delimiters-mode))
;; 対応する括弧の協調
(use-package paren
:ensure nil
(after-init . show-paren-mode)
(show-paren-match ((nil (:background "#44475a" :foreground "#f1fa8c"))))
(show-paren-style 'mixed)
(show-paren-when-point-inside-paren t)
(show-paren-when-point-in-periphery t))
;; バッファに戻った時に,現在の行を強調する
(use-package beacon
(beacon-color "yellow")
(beacon-mode 1))
;; メールなどの一行に表示できる制限を可視化する
(use-package fill-column-indicator
git-commit-mode) . fci-mode))
;; タブとかスペースとかを可視化
(use-package whitespace
(setq whitespace-style '(face ; faceで可視化
trailing ; 行末
tabs ; タブ
spaces ; スペース
empty ; 先頭/末尾の空行
space-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/")
(setq org-agenda-files (list org-default-notes-file))
'((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
(defhydra hydra-zoom (global-map "<f2>")
("g" text-scale-increase)
("l" text-scale-decrease))
(use-package ace-window
:functions hydra-frame-window/body
("C-M-o" . hydra-frame-window/body)
(aw-keys '(?j ?k ?l ?i ?o ?h ?y ?u ?p))
(aw-leading-char-face ((t (:height 4.0 :foreground "#f1fa8c")))))
(defun utils/interactive/filtering ()
(use-package amx)
(use-package swiper
(("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
(("C-x C-b" . ivy-switch-buffer)
(ivy-rich-mode 1)
(use-package ivy-yasnippet
("C-c y" . ivy-yasnippet)
(defun utils/finder ()
(use-package neotree
(neotree-show neotree-hide neotree-dir neotree-find)
(neo-theme 'nerd2)
("<f9>" . neotree)
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
(use-package recentf
(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))
("C-c t" . ivy-recentfe)
(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
(setq open-junk-file-format "~/dev/junk/%Y/%m/junk%d%H%M%S.")
(defun utils/file/wiki ()
(use-package howm
(defvar howm-view-title-header "#+TITLE:")
(("C-c , ," . howm-menu)
(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/")
(defun utils/ui/vc ()
(use-package magit
(("C-x C-g" . magit-status)
(setq magit-repository-directories
'(("~/dev/src/" . 1)
("~/dev/src/" . 1)
(use-package projectile
(projectile-mode +1)
(use-package counsel-projectile
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(defun utils/code/snippet ()
(use-package yasnippet
(setq yas-snippet-dirs
(yas-global-mode 1)
(defun utils/code/auto_complete ()
;; 閉じ括弧の自動挿入
(electric-pair-mode 1)
;; 保管インターフェース
(use-package company
(("C-/" . company-complete)
(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
(push 'company-lsp company-backends)
(use-package company-quickhelp
(company-mode . company-quickhelp-mode)
(use-package company-box
(company-mode . company-box-mode)
(use-package lsp-mode
:commands lsp
(make-lsp-client :new-connection (lsp-stdio-connection "gopls")
:major-modes '(go-mode)
:server-id 'gopls))
(use-package eglot
:disabled t
(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
(add-hook 'go-mode-hook #'lsp)
(add-hook 'go-mode-hook (lambda ()
(let ((envs '("GOROOT" "GOPATH")))
(exec-path-from-shell-copy-envs envs))
;; インデント関係の設定
(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
(set-face-attribute 'eldoc-highlight-function-argument nil
:underline t :foreground "green"
:weight 'bold)
(defun lang/cpp ()
(use-package irony
:ensure t
(use-package company-irony
:ensure t
(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
(setq rustic-lsp-server 'ra_lsp_server)
(setq rustic-rls-pkg 'elgot)
(defun utils/code/define_jump()
(use-package dumb-jump
(("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)
(setq dumb-jump-default-project "")
(setq dumb-jump-selector 'ivy)
(setq dumb-jump-force-searcher 'rg)
(use-package smart-jump
(defun utils/other/google_search ()
(use-package google-this
(("C-x g" . google-this-mode-submap)
(defun plugin_load()
;; プラグイン設定
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.