Create new, a little bit better structured configuration

* Group configuration by package, and only then by language mode
* Slim down all the languages
This commit is contained in:
Maciej 2018-09-09 00:31:51 +03:00
parent 4d5f300113
commit 1a911716c0
Signed by: maciej
GPG key ID: 41D62D42D3B0D765
38 changed files with 513 additions and 18 deletions

73
01mac.el Normal file
View file

@ -0,0 +1,73 @@
;;;;;;;;; Emacs bindings ;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "RET") 'newline)
;;;;;;;;; Mac binding (fix) ;;;;;;;;;;;;;;;;;;
(define-key global-map [home] 'beginning-of-line)
(define-key global-map [end] 'end-of-line)
(global-set-key (kbd "s-<right>") 'end-of-line)
(global-set-key (kbd "s-<left>") 'beginning-of-line)
(global-set-key (kbd "s-<up>") 'scroll-down) ; WTF is this reverse, I dunno
(global-set-key (kbd "s-<down>") 'scroll-up)
;;; Window display
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;#====================== Backup config #==============================
(setq backup-directory-alist
`((".*" . "~/.emacs_backups/auto-save-list")))
(setq auto-save-file-name-transforms
`((".*", "~/.emacs_backups/auto-save-list" t)))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
; Enable line numbers and show cursors position
(global-linum-mode t)
(column-number-mode 1)
;; Turn off sounds
(setq ring-bell-function 'ignore)
;; Enable y/n answers to questions
(fset 'yes-or-no-p 'y-or-n-p)
;;;;;;;;;;;;;;;;;;;;;; Shell stuff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; Add pgp binary
(add-to-list 'exec-path "/usr/local/bin")
; Use Shells variables
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "GOPATH")
(exec-path-from-shell-copy-env "GOROOT"))
;;;;;;;;;;;;;;;;;;;;;; Font configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun set-font-size (size)
"Set font SIZE to X px."
(interactive "NNew font size: ")
(set-face-attribute 'default nil :font (format "Hasklig %d" size))
(set-face-attribute 'mode-line nil :font (format "Hasklig %d" size)))
;;;;;;;;;;;;;;;;;;;;;; Window configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Always start in fullscreen
(defun toggle-fullscreen ()
"Toggle full screen."
(interactive)
(set-frame-parameter
nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
(toggle-fullscreen)
;; Disable meta on right alt (useful for Polish characters)
(setq ns-right-alternate-modifier nil)

22
02evil.el Normal file
View file

@ -0,0 +1,22 @@
(evil-mode 1)
(global-evil-leader-mode 1)
(require 'evil-leader)
;;;;;;;;; EVIL Leader ;;;;;;;;;;;;;;;;;;;;;;;;
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
"w" 'delete-window
"," 'previous-buffer
"." 'next-buffer
"k" 'kill-buffer-and-window
"rb" 'revert-buffer) ; Reload current file from disk
(evil-leader/set-key "hs" 'split-window-below)
(evil-leader/set-key "vs" 'split-window-right)
(evil-leader/set-key
"gk" 'windmove-up
"gj" 'windmove-down
"gl" 'windmove-right
"gh" 'windmove-left)

9
03ivy.el Normal file
View file

@ -0,0 +1,9 @@
(setq-default ivy-use-virtual-buffers t)
(setq-default ivy-count-format "(%d of %d) ")
(counsel-mode 1)
(evil-leader/set-key "ag" 'counsel-ag)
(evil-leader/set-key "b" 'ivy-switch-buffer)
(evil-leader/set-key "/" 'swiper)
(evil-leader/set-key "t" 'counsel-find-file)

7
04magit.el Normal file
View file

@ -0,0 +1,7 @@
;; Magit
(evil-leader/set-key
"gs" 'magit-status
"gco" 'magit-checkout
;; TODO: Connect these two into one key
"gb" 'magit-blame
"gq" 'magit-blame-quit)

49
05prog-mode.el Normal file
View file

@ -0,0 +1,49 @@
;;; Programmers mode
;;; Wrap long lines
(toggle-truncate-lines t)
;;; Show trailing whitespace and remove whitespace on save
(require 'whitespace)
(add-hook 'prog-mode-hook 'whitespace-mode)
(setq whitespace-style '(face trailing empty))
;;; Cleanup whitespace on save
(add-hook 'before-save-hook 'whitespace-cleanup)
;;; Tabs are spaces and are general at 2. Guide indent with lines
(setq-default indent-tabs-mode nil)
;;; Insert newline on save
(setq require-final-newline t)
;;; Match parenthasis (left-right)
(electric-pair-mode 1)
;;; Rainbow parenthesis
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;;; Show hex colors as colors
(add-hook 'prog-mode-hook 'rainbow-mode)
;;; When pasting/writing over a selection, replace it.
(delete-selection-mode 1)
;; Key bindings
(evil-leader/set-key "cl" 'evilnc-comment-or-uncomment-lines) ;; Comment lines
(evil-leader/set-key "al" 'align-regexp) ;; Align code to some regexp
(evil-leader/set-key "ir" 'indent-region) ;; Indent selected region
(evil-leader/set-key "d" 'dash-at-point) ;; Jump to dash definition
;; When possible, show code documentation
(global-eldoc-mode 1)
;; Function for definiting indentation
(defun set-indent (step)
"Set indentation to X STEPs."
(interactive "NNumber of columns for one step: ")
(setq tab-width step)
(setq tab-stop-list (number-sequence step 200 step)))
;; Enforce column width by number
(global-column-enforce-mode 1)

42
06company-yasnippet.el Normal file
View file

@ -0,0 +1,42 @@
;; Company completion framework configuration
(require 'company); Add completion
;; Company configuration
(setq-default company-minimum-prefix-length 2 ; minimum prefix character number for auto complete.
company-idle-delay 0.3
company-echo-delay 0
;; company-show-numbers t
company-tooltip-align-annotations t ; align annotations to the right tooltip border.
company-tooltip-flip-when-above t
company-tooltip-limit 10 ; tooltip candidates max limit.
company-tooltip-minimum 2 ; minimum candidates limit.
company-tooltip-minimum-width 0 ; The minimum width of the tooltip's inner area.
; This doesn't include the margins and the scroll bar.
company-tooltip-margin 2 ; width of margin columns to show around the tooltip
company-tooltip-offset-display 'scrollbar ; 'lines - how to show tooltip unshown candidates number.
company-show-numbers nil ; t: show quick-access numbers for the first ten candidates.
company-selection-wrap-around t ; loop over candidates
;; company-async-wait 0.03
;; company-async-timeout 2
)
(setq-default company-backends '((company-capf company-keywords
company-yasnippet
)
company-elisp ; Emacs Lisp
;; company-semantic ; C/C++
(company-clang company-cmake) ; C/C++
company-robe
;; company-eclim ; Java
;; company-ropemacs ; Python
company-nxml company-css ; HTML, CSS, XML
;; company-xcode ; for Xcode projects
company-bbdb ; BBDB
(company-dabbrev-code company-dabbrev company-abbrev) ; abbrev
company-files ; files & directory
company-ispell ; Ispell
;; company-oddmuse ; wiki
))
(global-company-mode 1)
(yas-global-mode 1)

17
07projectile.el Normal file
View file

@ -0,0 +1,17 @@
(require 'projectile)
(setq-default projectile-enable-caching t ;; Cache project files
projectile-file-exists-local-cache-expire (* 3 60) ;; keep cache for 3 minutes
projectile-sort-order (quote recently-active) ;; Order by recently active projects
projectile-globally-ignored-directories
(append '("node_modules" ".svn" "_build" "tmp" "log") projectile-globally-ignored-directories)
;; Add certain folders to ignored
)
(projectile-mode t)
(evil-leader/set-key "ps" 'counsel-projectile-switch-project)
(evil-leader/set-key "pt" 'counsel-projectile-find-file)
(evil-leader/set-key "pa" 'counsel-projectile-ag)
(evil-leader/set-key "pc" 'projectile-invalidate-cache)

84
08purpose.el Normal file
View file

@ -0,0 +1,84 @@
;;; windows.el -- summary
;;; Commentary:
;;; Windows management things, mostly with purpose
;;; Code:
(require 'window-purpose)
(purpose-mode t)
;; Set everything to use code window
(add-to-list 'purpose-user-mode-purposes '(fundamental-mode . code))
;; Test
(add-to-list 'purpose-user-regexp-purposes
'("_spec\\.rb\\(<.*>\\)?$" . test)) ;; Rspec
(add-to-list 'purpose-user-regexp-purposes
'("_test\\.rb\\(<.*>\\)?$" . test)) ;; Minitest
(add-to-list 'purpose-user-regexp-purposes
'("_preview\\.rb\\(<.*>\\)?$" . test)) ;; Mailer Previews
(add-to-list 'purpose-user-regexp-purposes
'("_test\\.exs\\(<.*>\\)?$" . test)) ;; ExUnit
(add-to-list 'purpose-user-regexp-purposes
'("test_.*\\.py\\(<.*>\\)?$" . test)) ;; Pytest
(add-to-list 'purpose-user-regexp-purposes
'("tests.rs\\(<.*>\\)?$" . test)) ;; Rust tests
(add-to-list 'purpose-user-regexp-purposes
'("_test.go\\(<.*>\\)?$" . test)) ;; Go tests
(add-to-list 'purpose-user-mode-purposes '(shell-mode . test))
(add-to-list 'purpose-user-mode-purposes '(magit-diff-mode . test))
;; Enumerate through all stuff.
;; Git things
(add-to-list 'purpose-user-regexp-purposes
'("COMMIT_EDITMSG\\(<.*>\\)?$" . code))
(add-to-list 'purpose-user-regexp-purposes
'("git-rebase-todo\\(<.*>\\)?$" . code))
(add-to-list 'purpose-user-mode-purposes '(diff-mode . code))
;; Programming files
(add-to-list 'purpose-user-mode-purposes '(ruby-mode . code))
(add-to-list 'purpose-user-mode-purposes '(elixir-mode . code))
(add-to-list 'purpose-user-mode-purposes '(rust-mode . code))
(add-to-list 'purpose-user-mode-purposes '(haskell-mode . code))
(add-to-list 'purpose-user-mode-purposes '(haskell-cabal-mode . code))
(add-to-list 'purpose-user-mode-purposes '(web-mode . code))
(add-to-list 'purpose-user-mode-purposes '(java-mode . code))
(add-to-list 'purpose-user-mode-purposes '(python-mode . code))
(add-to-list 'purpose-user-mode-purposes '(js-mode . code))
(add-to-list 'purpose-user-mode-purposes '(emacs-lisp-mode . code))
(add-to-list 'purpose-user-mode-purposes '(sql-mode . code))
(add-to-list 'purpose-user-mode-purposes '(go-mode . code))
;; Other files that fall into 'code'
(add-to-list 'purpose-user-mode-purposes '(xml-mode . code))
(add-to-list 'purpose-user-mode-purposes '(markdown-mode . code))
(add-to-list 'purpose-user-mode-purposes '(terraform-mode . code))
(add-to-list 'purpose-user-mode-purposes '(yaml-mode . code))
(add-to-list 'purpose-user-mode-purposes '(dockerfile-mode . code))
;; Tools
(add-to-list 'purpose-user-mode-purposes '(dired-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(magit-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(help-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(helm-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(compilation-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(etags-select-mode . tools))
(add-to-list 'purpose-user-mode-purposes '(reb-mode . tools)) ;; Regexp builder
(setq purpose-use-default-configuration nil)
(purpose-compile-user-configuration)
;; Functions for changing layout
(defun purpose-big-screen ()
"Load coding_with_magit."
(interactive)
(purpose-load-window-layout "coding_with_magit"))
(defun purpose-small-screen ()
"Load small_screen."
(interactive)
(purpose-load-window-layout "small_screen"))
;;; windows.el ends here
(global-set-key (kbd "<f8>") 'purpose-big-screen)
(global-set-key (kbd "<f7>") 'purpose-small-screen)

36
10themes.el Normal file
View file

@ -0,0 +1,36 @@
;; Use smart-mode-line
(require 'smart-mode-line)
(setq-default sml/no-confirm-load-theme t)
(setq-default display-time-format "%H:%M") ;; time format to display on mode line
(sml/setup)
(sml/apply-theme 'respectful)
(load-theme 'base16-mexico-light t t)
(load-theme 'flatui t t)
(defun base16-mexico-light-custom ()
"Additional configuration for Base16 theme."
(set-face-attribute 'mode-line nil :font "Hasklig 15")
(set-face-attribute 'linum nil :font "Hasklig 15"
:slant 'normal))
(if (display-graphic-p)
(progn
(enable-theme 'base16-mexico-light)
(base16-mexico-light-custom))
(progn
(enable-theme 'flatui)))
;; Set font face
(set-face-attribute 'default nil :font "Hasklig 15")
;; Remove ugly black line
(set-face-attribute 'vertical-border nil :foreground
(face-attribute 'fringe :background))
;; Set fringe colors to default, so it does not bother you.
(set-face-attribute 'fringe nil
:foreground (face-foreground 'default)
:background (face-background 'default))

8
20elisp.el Normal file
View file

@ -0,0 +1,8 @@
(add-hook 'emacs-lisp-mode-hook 'flymake-mode)
(defun activate-emacs-lisp-mode ()
"Goodies for editing emacs files."
(set-indent 2) ;; Default indentation of 2 characters
)
(add-hook 'emacs-lisp-mode-hook 'activate-emacs-lisp-mode)

39
20ruby.el Normal file
View file

@ -0,0 +1,39 @@
;; Start rvm before starting robe
(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
(rvm-activate-corresponding-ruby))
(add-hook 'ruby-mode-hook 'enh-ruby-mode)
(add-hook 'enh-ruby-mode-hook 'robe-mode)
(add-hook 'enh-ruby-mode-hook 'ruby-end-mode)
(add-hook 'enh-ruby-mode-hook 'flymake-mode)
(eval-after-load 'company
'(push 'company-robe company-backends))
(defun activate-ruby-mode ()
"All things for ruby mode."
(set-indent 2)
;; Set column enforcement at 80 for normal projects, and at 100 for work
(if (string-match-p "internetee" (buffer-file-name))
(column-enforce-n 100)
(column-enforce-n 80))
;; Do not insert magic encoding comment at the begining of each file
(setq ruby-insert-encoding-magic-comment nil)
;; Start flymake
(flymake-ruby-load))
(add-hook 'enh-ruby-mode-hook 'activate-ruby-mode)
;; Ruby specific key bindings
(evil-leader/set-key-for-mode 'enh-ruby-mode "j" 'robe-jump)
;;; ERB specific things
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(setq web-mode-extra-auto-pairs
'(("erb" . (("<%" "%>")
("beg" "end")))
))
(add-hook 'web-mode-hook 'flymake-mode)

1
20web.el Normal file
View file

@ -0,0 +1 @@
(add-hook 'web-mode-hook 'flymake-mode)

105
init.el
View file

@ -1,25 +1,95 @@
;;; init.el --- Summary ;;; init.el -- Summary
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
;; list the repositories containing them
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
;; Added by Package.el. This must come before configurations of ;; activate all the packages (in particular autoloads)
;; 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.
(package-initialize) (package-initialize)
(load "~/.emacs.d/config/packages.elc") ;; fetch the list of packages available
(load "~/.emacs.d/config/functions.elc") (unless package-archive-contents
(load "~/.emacs.d/config/behaviour.elc") (package-refresh-contents))
(load "~/.emacs.d/config/splash.elc")
(load "~/.emacs.d/config/themes.elc") ;; list the packages you want
(load "~/.emacs.d/config/key-bindings.elc") (setq package-list '(
(load "~/.emacs.d/config/spelling.elc") exec-path-from-shell ;; Allow to execute path from shell
(load "~/.emacs.d/config/languages.elc")
(load "~/.emacs.d/config/windows.elc") evil ;; Behave like VIM
evil-leader ;; Allow to set leader key (usually space)
evil-nerd-commenter ;; Add comments to files
rainbow-delimiters ;; Colorize matching parens
rainbow-mode ;; Make color symbols like #FFF colorfull
magit ;; Git interface for Emacs
diff-hl ;; Highlight diff (also useful for git)
column-enforce-mode ;; Enforce column length of X
window-purpose ;; Make sure that windows are of grouped by
;; purpose.
;;; Helm replacements
ivy
counsel
swiper
;;; Code
dash-at-point
company ;; Code completion framework
yasnippet ;; Code snippets framework
yasnippet-snippets ;; Actual snippets for various languages
;; Project management
projectile
counsel-projectile
;; Themes
smart-mode-line
base16-theme
flatui-theme
;; Ruby
enh-ruby-mode ;; Enhanced Ruby mode
robe ;; Ruby REPL inside emacs
rvm ;; Support rvm usage
ruby-end ;; Insert end for methods automatically
;; Web
web-mode
;; Infrastructure files
yaml-mode
dockerfile-mode
terraform-mode
ansible
)
)
;; install the missing packages
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
;; Additional files
(load "~/.emacs.d/01mac.el")
(load "~/.emacs.d/02evil.el")
(load "~/.emacs.d/03ivy.el")
(load "~/.emacs.d/04magit.el")
(load "~/.emacs.d/05prog-mode.el")
(load "~/.emacs.d/06company-yasnippet.el")
(load "~/.emacs.d/07projectile.el")
(load "~/.emacs.d/08purpose.el")
(load "~/.emacs.d/10themes.el")
;; Actual supported languages
(load "~/.emacs.d/20elisp.el")
(load "~/.emacs.d/20ruby.el")
(load "~/.emacs.d/20web.el")
(provide 'init)
;;; init.el ends here
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
@ -27,8 +97,7 @@
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(package-selected-packages '(package-selected-packages
(quote (quote
(flymake-go go-flymake flycheck-go company-go go-mode expand-region sql-indent json-mode terraform-mode flycheck-rust company-ghc company-ghci scion hlinum etags-select nvm tide yaml-mode window-purpose web-mode ujelly-theme toml-mode smart-mode-line scala-mode rvm ruby-end rspec-mode robe rainbow-mode rainbow-delimiters racer pyenv-mode noctilux-theme monokai-theme markdown-mode less-css-mode json-reformat jade-mode indent-guide helm-themes helm-projectile helm-ag haskell-mode haml-mode groovy-mode flymake-ruby flymake-cursor flycheck flatui-theme exec-path-from-shell evil-nerd-commenter evil-magit evil-leader elpy dumb-jump dockerfile-mode diff-hl dash-at-point company-tern company-racer company-jedi column-enforce-mode color-theme-approximate base16-theme atom-one-dark-theme alchemist aggressive-indent ag))) (window-purpose column-enforce-mode yaml-mode ansible dockerfile-mode evil-nerd-commenter ruby-end web-mode flymake-ruby rvm dash-at-point robe base16-theme exec-path-from-shell evil))))
'(safe-local-variable-values (quote ((encoding . utf-8)))))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View file

2
old/eshell/history Normal file
View file

@ -0,0 +1,2 @@
bundle install
exit

37
old/init.el Normal file
View file

@ -0,0 +1,37 @@
;;; init.el --- Summary
;;; Commentary:
;;; Code:
;; 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.
(package-initialize)
(load "~/.emacs.d/config/packages.elc")
(load "~/.emacs.d/config/functions.elc")
(load "~/.emacs.d/config/behaviour.elc")
(load "~/.emacs.d/config/splash.elc")
(load "~/.emacs.d/config/themes.elc")
(load "~/.emacs.d/config/key-bindings.elc")
(load "~/.emacs.d/config/spelling.elc")
(load "~/.emacs.d/config/languages.elc")
(load "~/.emacs.d/config/windows.elc")
(provide 'init)
;;; init.el ends here
(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
(quote
(flymake-go go-flymake flycheck-go company-go go-mode expand-region sql-indent json-mode terraform-mode flycheck-rust company-ghc company-ghci scion hlinum etags-select nvm tide yaml-mode window-purpose web-mode ujelly-theme toml-mode smart-mode-line scala-mode rvm ruby-end rspec-mode robe rainbow-mode rainbow-delimiters racer pyenv-mode noctilux-theme monokai-theme markdown-mode less-css-mode json-reformat jade-mode indent-guide helm-themes helm-projectile helm-ag haskell-mode haml-mode groovy-mode flymake-ruby flymake-cursor flycheck flatui-theme exec-path-from-shell evil-nerd-commenter evil-magit evil-leader elpy dumb-jump dockerfile-mode diff-hl dash-at-point company-tern company-racer company-jedi column-enforce-mode color-theme-approximate base16-theme atom-one-dark-theme alchemist aggressive-indent ag)))
'(safe-local-variable-values (quote ((encoding . utf-8)))))
(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.
)