Created
May 28, 2014 19:14
-
-
Save MatejLach/3d49c0a907aa2b90a191 to your computer and use it in GitHub Desktop.
Basic emacs setup for almost every programming language in mainstream use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Matej Lach's Emacs config... | |
;; DO NOT BYTE-COMPILE THIS FILE! | |
;; This config is released under the terms of 'MIT' license, but Emacs itself is licensed under the GPLv3. | |
;; For package-specific licenses, see the details for each individual project... | |
;; See the 'LICENSE' file for MIT license text. | |
;; Also see https://gnu.org/licenses/gpl.html for the full text of GPLv3. | |
;; Basics | |
;; General custom key bindings | |
;essential commands | |
(global-set-key "\C-n" 'make-frame); | |
(global-set-key "\C-o" 'find-file); | |
(global-set-key "\C-s" 'save-buffer); | |
(global-set-key "\C-g" 'goto-line); | |
(global-set-key "\C-f" 'search-forward); | |
(global-set-key "\C-q" 'kill-buffer); | |
;;text operation | |
(global-set-key "\C-u" 'undo); | |
(global-set-key "\C-r" 'redo); | |
(global-set-key "\C-t" 'kill-word); | |
(global-set-key "\C-p" 'previous-line); | |
(global-set-key "\C-z" 'backward-word); | |
(global-set-key "\C-a" 'forward-word); | |
(global-set-key "\C-h" 'backward-delete-char-untabify); | |
;;advanced commands | |
(global-set-key "\C-xc" 'compile); | |
(global-set-key "\C-xt" 'text-mode); | |
(global-set-key "\C-xr" 'replace-string); | |
(global-set-key "\C-xa" 'repeat-complex-command); | |
(global-set-key "\C-xm" 'manual-entry); | |
(global-set-key "\C-xw" 'what-line); | |
(global-set-key "\M-e" 'eshell); | |
(global-set-key "\C-x0" 'overwrite-mode); | |
(global-set-key "\C-x\C-r" 'toggle-read-only); | |
(global-set-key "\C-x\C-m" 'not-modified); | |
;; line numbers | |
(global-linum-mode t) | |
(setq linum-format "%5d ") | |
;; set theme | |
(add-to-list 'load-path "~/.emacs.d/themes/") | |
(require 'color-theme-tomorrow) | |
(color-theme-tomorrow-night) | |
;; set font | |
(set-face-attribute 'default nil :font "Source Code Pro-24") | |
(global-font-lock-mode t) | |
;; abbrevs | |
(read-abbrev-file abbrev-file-name) | |
;; enable spellcheck | |
(add-to-list 'load-path "~/.emacs.d/packages/flyspell-1.7p.el") | |
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) | |
;; for programming | |
(mapcar (lambda (mode-hook) (add-hook mode-hook 'flyspell-prog-mode)) | |
'(web-mode-hook)) | |
;; for latex | |
(add-hook 'LaTeX-mode-hook '(flyspell-mode t)) | |
;; for text | |
(mapcar (lambda (mode-hook) (add-hook mode-hook 'flyspell-mode)) | |
'(text-mode-hook)) | |
;; fix X11 clipboard | |
(setq x-select-enable-clipboard t) | |
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value) | |
;; fix Emacs-<Tab> | |
(setq-default indent-tabs-mode nil) | |
(setq-default tab-width 4) | |
(setq indent-line-function 'insert-tab) | |
;; scroll by one line | |
(setq scroll-step 1) | |
;; save sessions | |
(desktop-save-mode 1) | |
;; complete file-name | |
(fset 'my-complete-file-name | |
(make-hippie-expand-function '(try-complete-file-name-partially | |
try-complete-file-name))) | |
(global-set-key "\M-/" 'my-complete-file-name) | |
;; auto save/per minute | |
(setq auto-save-interval 60 | |
auto-save-timeout 60) | |
;; Manage packages | |
;; elpa | |
;; I mostly only require packages outside of elpa explicitly now, or those which require some further customization and need to be called explicitly. | |
;; | |
;; I am also aware of solutions like 'Cask' and 'el-get', which could automate this further. | |
;; These solutions however, are not a part of Emacs and therefore may not keep up with future Emacs versions. | |
;; ELPA is an integral part of Emacs and therefore I will use it everywhere I can. | |
;; | |
(when (>= emacs-major-version 24) | |
(require 'package) | |
(package-initialize) | |
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) | |
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) | |
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")) | |
) | |
;; ELPA PATH | |
(add-to-list 'load-path "~/.emacs.d/elpa/") | |
;; | |
;; flycheck | |
(global-set-key "\C-k" 'flycheck-mode); | |
;; smartparens | |
(require 'smartparens-config) | |
(smartparens-global-mode t) | |
(show-smartparens-global-mode t) | |
;; imenu | |
;;(add-hook 'c-mode-common-hook 'imenu-add-menubar-index) | |
;; CEDET | |
;;(setq cedet-root-path (file-name-as-directory "~/.emacs.d/packages/cedet-bzr/trunk/")) | |
;;(load-file (concat cedet-root-path "cedet-devel-load.el")) | |
;;(add-to-list 'load-path (concat cedet-root-path "contrib")) | |
;; submodes | |
;;(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode) | |
;;(add-to-list 'semantic-default-submodes 'global-semantic-show-parser-state-mode) | |
;; semantic mode | |
;;(semantic-mode 1) | |
;;(require 'semantic/ia) | |
;;(require 'semantic/bovine/gcc) | |
;; C/C++ mode | |
;;(semanticdb-enable-gnu-global-databases 'c-mode t) | |
;;(semanticdb-enable-gnu-global-databases 'c++-mode t) | |
;; C/C++ auto-complete integration | |
;;(defun my-c-mode-cedet-hook () | |
;; (add-to-list 'ac-sources 'ac-source-gtags) | |
;; (add-to-list 'ac-sources 'ac-source-semantic)) | |
;;(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook) | |
;; Java/JDEE | |
;;(add-to-list 'load-path "~/.emacs.d/packages/jdee-dev/lisp") | |
;;(load "jde") | |
;; imenu integration | |
;;(defun my-semantic-hook () | |
;; (imenu-add-to-menubar "TAGS")) | |
;;(add-hook 'semantic-init-hooks 'my-semantic-hook) | |
;; EDE | |
(global-ede-mode t) | |
(ede-enable-generic-projects) | |
;; python-mode | |
(add-to-list 'load-path "~/.emacs.d/packages/python-mode.el-6.1.2") | |
(setq py-install-directory "~/.emacs.d/packages/python-mode.el-6.1.2") | |
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
(require 'python-mode) | |
;; use ipython | |
(setq py-shell-name "/usr/bin/ipython") | |
;; elpy | |
(package-initialize) | |
(elpy-enable) | |
;; go-mode | |
(add-to-list 'load-path "~/.emacs.d/packages/go-mode.el" t) | |
(require 'go-mode-load) | |
(add-hook 'before-save-hook 'gofmt-before-save) | |
;; dart-mode | |
(require 'dart-mode) | |
;; rust-mode | |
(require 'rust-mode) | |
;; web-mode | |
(require '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 '("\\.tpl\\.php\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . 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)) | |
(setq web-mode-enable-current-element-highlight t) | |
(setq web-mode-engines-alist | |
'(("php" . "\\.phtml\\'") | |
("blade" . "\\.blade\\.")) | |
) | |
;; lua-mode | |
(autoload 'lua-mode "lua-mode" "Lua editing mode." t) | |
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode)) | |
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode)) | |
;; markdown mode | |
(add-to-list 'load-path "~/.emacs.d/packages/markdown-mode") | |
(autoload 'markdown-mode "markdown-mode" | |
"Major mode for editing Markdown files" t) | |
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode)) | |
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) | |
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) | |
;; ruby-mode | |
(add-to-list 'auto-mode-alist | |
'("\\.\\(?:gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode)) | |
(add-to-list 'auto-mode-alist | |
'("\\(Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" . ruby-mode)) | |
;; company-mode | |
(load "~/.emacs.d/packages/company-mode/company.el") | |
;; racer (rust autocomplete) | |
(load "~/.emacs.d/packages/racer/editors/racer.el") | |
;; auto-complete-mode | |
(require 'auto-complete) | |
(add-to-list 'load-path "~/.emacs.d/elpa/go-autocomplete-20140102.1333") | |
(require 'go-autocomplete) | |
(global-auto-complete-mode t) | |
(setq ac-auto-start t) | |
(setq ac-delay 0) | |
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20131128.233/dict") | |
(require 'auto-complete-config) | |
(ac-config-default) | |
(add-to-list 'ac-modes 'web-mode) | |
;; ac-mode | |
;; | |
;; ace jump mode major function | |
;; | |
(autoload | |
'ace-jump-mode | |
"ace-jump-mode" | |
"Emacs quick move minor mode" | |
t) | |
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode) | |
;; | |
;; enable a more powerful jump back function from ace jump mode | |
;; | |
(autoload | |
'ace-jump-mode-pop-mark | |
"ace-jump-mode" | |
"Ace jump back:-)" | |
t) | |
(eval-after-load "ace-jump-mode" | |
'(ace-jump-mode-enable-mark-sync)) | |
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark) | |
;; helm | |
(require 'helm-config) | |
(global-set-key (kbd "C-c h") 'helm-mini) | |
;; windata | |
(add-to-list 'load-path "~/.emacs.d/packages/") | |
(require 'windata) | |
(require 'desktop) | |
(add-to-list 'desktop-globals-to-save 'windata-named-winconf) | |
;; dirtree | |
(add-to-list 'load-path "~/.emacs.d/packages/") | |
(require 'dirtree) | |
(autoload 'dirtree "dirtree" "Add directory to tree view" t) | |
(global-set-key "\C-d" 'dirtree-show) | |
;; org-mode | |
(global-set-key "\C-l" 'org-mode); | |
;; yasnippet | |
;;(yas-global-mode t) | |
(setq ac-source-yasnippet nil) | |
;; Automatically added by emacs-options | |
(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. | |
'(cua-mode t nil (cua-base)) | |
'(custom-safe-themes (quote ("5ee12d8250b0952deefc88814cf0672327d7ee70b16344372db9460e9a0e3ffc" "cf08ae4c26cacce2eebff39d129ea0a21c9d7bf70ea9b945588c1c66392578d1" default))) | |
'(initial-buffer-choice t)) | |
(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. | |
) | |
;; END OF EMACS CONFIG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment