Skip to content

Instantly share code, notes, and snippets.

@marioidival marioidival/init.el
Last active Feb 11, 2018

Embed
What would you like to do?
my emacs config
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(require 'go-eldoc)
(add-hook 'go-mode-hook 'go-eldoc-setup)
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
;; (add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")
(defconst private-dir (expand-file-name "private" user-emacs-directory))
(defconst temp-dir
(format "%s/cache" private-dir)
"Hostname-based elisp temp directories")
(use-package yasnippet
:bind
("C-c y s" . yas-insert-snippet)
("C-c y v" . yas-visit-snippet-file)
:config
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")
(yas-global-mode 1))
;; configs
(use-package ace-jump-mode
:bind
("C-c SPC" . ace-jump-mode))
(use-package anzu
:config
(global-anzu-mode +1)
(global-set-key [remap query-replace] 'anzu-query-replace)
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp))
(use-package company
:bind
("M-TAB" . company-complete) ;; ALT-TAB ???????
:config
(add-hook 'after-init-hook 'global-company-mode))
(use-package hungry-delete
:config
(global-hungry-delete-mode))
(use-package hlinum
:config
(hlinum-activate))
(use-package linum
:config
(setq linum-format " %3d ")
(global-linum-mode nil))
(use-package ido
:config
(ido-mode 'both)
(ido-everywhere t)
(setq ido-auto-merge-delay-time 4
ido-enable-flex-matching t
ido-max-window-height 1
ido-use-virtual-buffers t
ido-use-filename-at-point 'guess
ido-create-new-buffer 'always
ido-file-extensions-order '(".org" ".txt" ".py" ".emacs" ".xml" ".el"
".ini" ".cfg" ".cnf" ".conf" ".go" ".sh")
ido-ignore-extensions t
ido-ignore-files '("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./"
"\\.orig$")))
(use-package ibuffer
:bind
("C-x C-b" . ibuffer))
(use-package ido-grid-mode
:ensure t
:init
(ido-grid-mode 1)
:config
(setq ido-grid-mode-max-rows 4
ido-grid-mode-min-rows 4)
(setq ido-max-window-height (+ ido-grid-mode-max-rows 1)))
(use-package flx-ido
:ensure t
:config
(flx-ido-mode t)
(setq ido-enable-flex-matching t))
(use-package rotate
:bind
("C-c C-r w" . rotate-window)
("C-c C-r l" . rotate-layout))
(use-package smartparens)
(use-package smex
:ensure t
:config
(setq smex-save-file (expand-file-name "smex-items" temp-dir))
:bind
("M-x" . smex)
("M-X" . smex-major-mode-commands)
;; if you want to be able to M-x without meta
("C-x C-m" . smex)
;; default Emacs M-x
("C-c C-c M-x" . execute-extended-command)
:init
(smex-initialize))
(use-package syntax-subword
:config
(syntax-subword-mode)
:bind
("M-j" . syntax-subword-backward)
("M-l" . syntax-subword-forward))
(use-package undo-tree
:config
(global-undo-tree-mode 1)
;; Remember undo history
(setq undo-tree-auto-save-history nil
undo-tree-history-directory-alist `(("." . ,(concat temp-dir "/undo/")))))
(use-package which-key
:config
(which-key-mode))
(use-package windmove
:bind
("C-c i" . windmove-up)
("C-c k" . windmove-down)
("C-c j" . windmove-left)
("C-c l" . windmove-right))
(use-package recentf
:config
(setq recentf-exclude '("/elpa/" ;; ignore all files in elpa directory
".*?autoloads.el$"
"/tmp/" ;; ignore temporary files
)
recentf-save-file (recentf-expand-file-name "~/.emacs.d/private/cache/recentf"))
(recentf-mode 1))
(use-package neotree
:config
(setq neo-theme 'arrow
neotree-smart-optn t
neo-window-fixed-size nil)
(neotree-projectile-action)
;; Disable linum for neotree
(add-hook 'neo-after-create-hook 'disable-neotree-hook)
:bind
("C-x C-t" . neotree-toggle))
(use-package web-mode
:config
(setq web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-enable-current-element-highlight t)
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tmpl\\'" . 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 '("\\.jsx$" . web-mode))
(add-hook 'web-mode-hook 'jsx-flycheck))
(use-package typescript-mode)
(use-package powerline)
;; colorscheme
;;(use-package rebecca-theme)
(use-package github-modern-theme)
;; (load-theme github-modern)
(use-package ediff
:config
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq-default ediff-highlight-all-diffs 'nil)
(setq ediff-diff-options "-w"))
;; Custom line number stuff
(set-face-attribute 'fringe nil)
(set-face-foreground 'linum-highlight-face "#00B3EF")
(set-face-background 'linum-highlight-face "#1f252b")
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
(use-package go-mode
:config
; Use goimports instead of go-fmt
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook 'company-mode)
;; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook 'setup-go-mode-compile)
(add-hook 'go-mode-hook #'smartparens-mode)
;; (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode)
(add-hook 'go-mode-hook (lambda ()
(setq tab-width 4)
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)
(local-set-key (kbd "C-c C-g") 'go-goto-imports)
(set (make-local-variable 'company-backends) '(company-go))
(company-mode))))
;; end configs
;; Core settings
;; UTF-8 please
(set-charset-priority 'unicode)
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
(fset 'yes-or-no-p 'y-or-n-p)
(global-auto-revert-mode t)
(setq
confirm-kill-emacs 'y-or-n-p
confirm-nonexistent-file-or-buffer t
save-interprogram-paste-before-kill t
mouse-yank-at-point t
require-final-newline nil
visible-bell nil
ring-bell-function 'ignore
custom-file "~/.emacs.d/.custom.el"
;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
minibuffer-prompt-properties
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; persistent bookmarks
bookmark-save-flag t
bookmark-default-file (concat temp-dir "/bookmarks")
;; Disable backups (that's what git/dropbox are for)
history-length 1000
auto-save-default nil
auto-save-list-file-name (concat temp-dir "/autosave")
make-backup-files nil
create-lockfiles nil
backup-directory-alist `((".*" . ,(concat temp-dir "/backup/")))
auto-save-file-name-transforms `((".*" ,(concat temp-dir "/auto-save-list/") t))
;; Disable non selected window highlight
cursor-in-non-selected-windows nil
highlight-nonselected-windows nil
;; PATH
exec-path (append exec-path '("/usr/local/bin/"))
;; Backups disabled
backup-inhibited t
make-backup-files nil
indent-tabs-mode nil
inhibit-startup-message t
fringes-outside-margins t
x-select-enable-clipboard t
use-package-always-ensure t
vc-follow-symlinks t
auto-revert-check-vc-info nil
frame-resize-pixelwise t)
;; Disable toolbar & menubar
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when ( fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(show-paren-mode 1)
(desktop-save-mode 0)
(set-default-font "Hack 10")
;; Delete trailing whitespace before save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-to-list 'auto-mode-alist '("\\.psql$" . sql-mode))
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.