Skip to content

Instantly share code, notes, and snippets.

@fzerorubigd
Created April 18, 2015 19:54
Show Gist options
  • Select an option

  • Save fzerorubigd/05baa33c489a5a68d6ea to your computer and use it in GitHub Desktop.

Select an option

Save fzerorubigd/05baa33c489a5a68d6ea to your computer and use it in GitHub Desktop.
/home/f0rud/.emacs.d/init.el
;; emacs kicker --- kick start emacs setup
;; Copyright (C) 2010 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <[email protected]>
;; URL: https://github.com/dimitri/emacs-kicker
;; Created: 2011-04-15
;; Keywords: emacs setup el-get kick-start starter-kit
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
(require 'cl) ; common lisp goodies, loop
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil t)
(with-current-buffer
(url-retrieve-synchronously
"https://github.com/dimitri/el-get/raw/master/el-get-install.el")
(end-of-buffer)
(eval-print-last-sexp)))
;; now either el-get is `require'd already, or have been `load'ed by the
;; el-get installer.
;; set local recipes
(setq
el-get-sources
'((:name buffer-move ; have to add your own keys
:after (progn
(global-set-key (kbd "<C-S-up>") 'buf-move-up)
(global-set-key (kbd "<C-S-down>") 'buf-move-down)
(global-set-key (kbd "<C-S-left>") 'buf-move-left)
(global-set-key (kbd "<C-S-right>") 'buf-move-right)))
(:name smex ; a better (ido like) M-x
:after (progn
(setq smex-save-file "~/.emacs.d/.smex-items")
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)))
(:name magit ; git meet emacs, and a binding
:after (progn
(global-set-key (kbd "C-x C-z") 'magit-status)))
(:name goto-last-change ; move pointer back to last change
:after (progn
;; when using AZERTY keyboard, consider C-x C-_
(global-set-key (kbd "C-x C-/") 'goto-last-change)))))
;; now set our own packages
(setq
my:el-get-packages
'(el-get ; el-get is self-hosting
escreen ; screen for emacs, C-\ C-h
php-mode-improved ; if you're into php...
switch-window ; takes over C-x o
auto-complete ; complete as you type with overlays
yasnippet ; powerful snippet mode
zencoding-mode ; http://www.emacswiki.org/emacs/ZenCoding
color-theme ; nice looking emacs
color-theme-solarized ; check out color-theme-solarized
helm
helm-cmd-t
helm-project
git-gutter
fringe-helper
git-gutter-fringe
helm-ls-git
go-autocomplete
flycheck
multi-term
jinja2-mode
mingus
rainbow-delimiters
projectile
powerline
web-mode
;; evil
;; evil-nerd-commenter
dockerfile-mode
yaml-mode
go-oracle
go-rename
git-commit-mode
yasnippet
sr-speedbar
twittering-mode
toml-mode
;; solarized-emacs
))
;;
;; Some recipes require extra tools to be installed
;;
;; Note: el-get-install requires git, so we know we have at least that.
;;
(when (ignore-errors (el-get-executable-find "cvs"))
(add-to-list 'my:el-get-packages 'emacs-goodies-el)) ; the debian addons for emacs
(when (ignore-errors (el-get-executable-find "svn"))
(loop for p in '(psvn ; M-x svn-status
)
do (add-to-list 'my:el-get-packages p)))
(setq my:el-get-packages
(append
my:el-get-packages
(loop for src in el-get-sources collect (el-get-source-name src))))
;; install new packages and init already installed packages
(el-get 'sync my:el-get-packages)
;; on to the visual settings
(setq inhibit-splash-screen t) ; no splash screen, thanks
(line-number-mode 1) ; have line numbers and
(column-number-mode 1) ; column numbers in the mode line
(tool-bar-mode -1) ; no tool bar with icons
(scroll-bar-mode -1) ; no scroll bars
(unless (string-match "apple-darwin" system-configuration)
;; on mac, there's always a menu bar drown, don't have it empty
(menu-bar-mode -1))
;; choose your own fonts, in a system dependant way
(if (string-match "apple-darwin" system-configuration)
(set-face-font 'default "Inconsolata-14")
(set-default-font "Inconsolata-14"))
(global-hl-line-mode) ; highlight current line
(global-linum-mode 1) ; add line numbers on the left
;; avoid compiz manager rendering bugs
(add-to-list 'default-frame-alist '(alpha . 100))
;; copy/paste with C-c and C-v and C-x, check out C-RET too
(cua-mode)
;; under mac, have Command as Meta and keep Option for localized input
(when (string-match "apple-darwin" system-configuration)
(setq mac-allow-anti-aliasing t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'none))
;; Use the clipboard, pretty please, so that copy/paste "works"
(setq x-select-enable-clipboard t)
;; Navigate windows with M-<arrows>
(windmove-default-keybindings 'meta)
(setq windmove-wrap-around t)
; winner-mode provides C-<left> to get back to previous window layout
(winner-mode 1)
;; whenever an external process changes a file underneath emacs, and there
;; was no unsaved changes in the corresponding buffer, just revert its
;; content to reflect what's on-disk.
(global-auto-revert-mode 1)
;; M-x shell is a nice shell interface to use, let's make it colorful. If
;; you need a terminal emulator rather than just a shell, consider M-x term
;; instead.
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; If you do use M-x term, you will notice there's line mode that acts like
;; emacs buffers, and there's the default char mode that will send your
;; input char-by-char, so that curses application see each of your key
;; strokes.
;;
;; The default way to toggle between them is C-c C-j and C-c C-k, let's
;; better use just one key to do the same.
(require 'term)
(define-key term-raw-map (kbd "C-'") 'term-line-mode)
(define-key term-mode-map (kbd "C-'") 'term-char-mode)
;; Have C-y act as usual in term-mode, to avoid C-' C-y C-'
;; Well the real default would be C-c C-j C-y C-c C-k.
(define-key term-raw-map (kbd "C-y") 'term-paste)
;; use ido for minibuffer completion
(require 'ido)
(ido-mode t)
(setq ido-save-directory-list-file "~/.emacs.d/.ido.last")
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point 'guess)
(setq ido-show-dot-for-dired t)
(setq ido-default-buffer-method 'selected-window)
;; default key to switch buffer is C-x b, but that's not easy enough
;;
;; when you do that, to kill emacs either close its frame from the window
;; manager or do M-x kill-emacs. Don't need a nice shortcut for a once a
;; week (or day) action.
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)
;;(global-set-key (kbd "C-x C-c") 'ido-switch-buffer)
(global-set-key (kbd "C-x B") 'ibuffer)
;; have vertical ido completion lists
(setq ido-decorations
'("\n-> " "" "\n " "\n ..." "[" "]"
" [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]"))
;; C-x C-j opens dired with the cursor right on the file you're editing
(require 'dired-x)
;; full screen
(defun fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(global-set-key [f11] 'fullscreen)
;; bind C-h to <backspace>
(define-key key-translation-map [?\C-h] [?\C-?])
;; bind C-M-h to M-<backspace>
(define-key key-translation-map [?\C-\M-h] [?\C-\M-?])
(global-set-key (kbd "C-M-h") 'ido-delete-backward-word-updir)
(defun djcb-gtags-create-or-update ()
"create or update the gnu global tag file"
(interactive)
(if (not (= 0 (call-process "global" nil nil nil " -p"))) ; tagfile doesn't exist?
(let ((olddir default-directory)
(topdir (read-directory-name
"gtags: top of source tree:" default-directory)))
(cd topdir)
(shell-command "gtags && echo 'created tagfile'")
(cd olddir)) ; restore
;; tagfile already exists; update it
(shell-command "global -u && echo 'updated tagfile'")))
(add-hook 'gtags-mode-hook
(lambda()
(local-set-key (kbd "M-7") 'gtags-find-tag) ; find a tag, also M-.
(local-set-key (kbd "M-8") 'gtags-find-rtag))) ; reverse tag
(add-hook 'php-mode-hook
(lambda ()
(require 'gtags)
(gtags-mode t)
(djcb-gtags-create-or-update)))
;;; My settings
(add-hook 'php-mode-hook 'my-php-mode-hook)
(defun my-php-mode-hook ()
"My PHP mode configuration."
(setq indent-tabs-mode nil
tab-width 4
c-basic-offset 4))
;; Run evil mode globally
;;(evil-mode t)
;; Solarized
;;(color-theme-solarized-dark t)
;; Some helm related and gofmt binding
(global-set-key (kbd "C-c h") 'helm-cmd-t)
(global-set-key (kbd "M-g") 'helm-projectile)
(global-set-key (kbd "M-t") 'helm-mini)
(global-set-key (kbd "C-x C-a") 'gofmt)
(global-set-key (kbd "C-<f6>") 'helm-ls-git-ls)
(global-set-key (kbd "C-x C-d") 'helm-browse-project)
(global-set-key (kbd "C-c C-f") 'helm-project)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(add-hook 'before-save-hook #'gofmt-before-save)
;; Prevent backup file generation
;; store all backup and autosave files in the tmp dir
;;(setq backup-directory-alist
;; '((".*" . ,temporary-file-directory)))
;;(setq auto-save-file-name-transforms
;; '((".*" ,temporary-file-directory t)))
;; Global helm mode
(helm-mode)
(add-hook 'prog-mode-hook 'rainbow-delimiters-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 '("\\.[gj]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 '("\\.gohtml\\'" . web-mode))
(setq web-mode-engines-alist '(("razor" . "\\.gohtml\\'")))
(add-hook 'after-init-hook #'global-flycheck-mode)
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
(powerline-default-theme)
(require 'git-gutter-fringe)
(defun xah-clean-whitespace (p1 p2)
"Delete trailing whitespace, and replace sequence of newlines into just 2.
Work on text selection or whole buffer."
(interactive
(if (region-active-p)
(list (region-beginning) (region-end))
(list 1 (point-max))))
(save-excursion
(save-restriction
(narrow-to-region p1 p2)
(progn
(goto-char (point-min))
(while (search-forward-regexp "[ \t]+\n" nil "noerror")
(replace-match "\n")))
(progn
(goto-char (point-min))
(while (search-forward-regexp "\n\n\n+" nil "noerror")
(replace-match "\n\n"))))))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq yas-snippet-dirs
'("~/.emacs.d/snippets" ;; personal snippets
"~/.emacs.d/el-get/yasnippet/yasmate/snippets" ;; the yasmate collection
"~/.emacs.d/el-get/yasnippet/snippets" ;; the default collection
))
(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.
(global-set-key (kbd "C-x C-g") 'go-rename)
;;Setup sr-speedbar binding
(require 'sr-speedbar)
(global-set-key (kbd "<f11>") 'sr-speedbar-toggle)
(setq speedbar-show-unknown-files t)
(setq speedbar-use-images nil)
;(setq sr-speedbar-right-side nil)
;; Twittering mode
(setq twittering-use-master-password t)
(load-theme 'solarized t)
(setq background-mode 'dark)
(setq frame-background-mode 'dark)
;; Setup GTAGS
(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.
'(ansi-color-names-vector
["#073642" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#657b83"])
'(backup-directory-alist (quote ((".*" . "/tmp"))))
'(compilation-message-face (quote default))
'(cua-global-mark-cursor-color "#2aa198")
'(cua-normal-cursor-color "#839496")
'(cua-overwrite-cursor-color "#b58900")
'(cua-read-only-cursor-color "#859900")
'(fci-rule-color "#073642")
'(flycheck-go-errcheck-executable "/home/f0rud/gospace/bin/errcheck")
'(flycheck-go-golint-executable "/home/f0rud/gospace/bin/golint")
'(flycheck-phpcs-standard "Vada")
'(git-gutter-fr:side (quote left-fringe))
'(global-git-gutter-mode t)
'(go-oracle-command "/home/f0rud/gospace/bin/oracle")
'(gofmt-command "goimports")
'(helm-projectile-sources-list
(quote
(helm-source-projectile-files-list helm-source-projectile-buffers-list helm-source-projectile-projects helm-source-projectile-recentf-list)))
'(magit-diff-use-overlays nil)
'(pos-tip-background-color "#073642")
'(pos-tip-foreground-color "#93a1a1")
'(projectile-global-mode t)
'(show-paren-delay 0)
'(show-paren-mode t)
'(sr-speedbar-default-width 20)
'(sr-speedbar-max-width 25)
'(term-default-bg-color "#002b36")
'(term-default-fg-color "#839496")
'(twittering-http-proxy-port 7072)
'(twittering-http-proxy-server "127.0.0.1")
'(twittering-proxy-port 7072)
'(twittering-proxy-server "127.0.0.1")
'(twittering-proxy-use t)
'(twittering-use-profile-image-api t)
'(twittering-username "fzerorubigd")
'(vc-annotate-background nil)
'(vc-annotate-color-map
(quote
((20 . "#dc322f")
(40 . "#c85d17")
(60 . "#be730b")
(80 . "#b58900")
(100 . "#a58e00")
(120 . "#9d9100")
(140 . "#959300")
(160 . "#8d9600")
(180 . "#859900")
(200 . "#669b32")
(220 . "#579d4c")
(240 . "#489e65")
(260 . "#399f7e")
(280 . "#2aa198")
(300 . "#2898af")
(320 . "#2793ba")
(340 . "#268fc6")
(360 . "#268bd2"))))
'(vc-annotate-very-old-color nil)
'(weechat-color-list
(quote
(unspecified "#002b36" "#073642" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#839496" "#657b83"))))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment