Skip to content

Instantly share code, notes, and snippets.

@mmaz
Last active September 26, 2015 05:47
Show Gist options
  • Save mmaz/1048929 to your computer and use it in GitHub Desktop.
Save mmaz/1048929 to your computer and use it in GitHub Desktop.
emacs vimrc and tmux configuration
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize) ;;load all the stuff that doesn't automatically get added into the load-path -> this should not be necessary
(require 'evil)
(evil-mode 1)
(require 'powerline)
(require 'powerline-evil)
(require 'moe-theme)
;;(powerline-evil-vim-color-theme)
;;(powerline-evil-center-color-theme)
(setq moe-theme-mode-line-color 'magenta)
(moe-dark)
(powerline-moe-theme)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
(savehist-mode 1) ;; save minibuffer history
(tool-bar-mode -1) ;; hide tool buttons
;;(load-theme 'wombat t)
;; Apple+T to change font, M-x describe-font to save it here
(set-default-font "-apple-Menlo-medium-normal-normal-*-11-*-*-*-m-0-iso10646-")
;;emacs binary searchpaths for scala and sbt
(setq exec-path (append exec-path (list "/Users/ma23705/scala-2.11.0/bin" "/Users/ma23705/bin" )))
(show-paren-mode t)
(setq show-paren-style 'mixed) ;;http://emacs-fu.blogspot.com/2009/01/balancing-your-parentheses.html
(setq-default indent-tabs-mode nil) ;;http://www.gnu.org/software/emacs/manual/html_node/eintr/Indent-Tabs-Mode.html
(setq inhibit-startup-screen t) ;;don't show the welcome to emacs screen
(require 'protobuf-mode)
(global-linum-mode t) ;;line numbers
;; load the ensime lisp code...
;;(add-to-list 'load-path "/Users/ma23705/bin/ensime_2.10.0-0.9.8.9/elisp/")
;;(require 'ensime)
;; This step causes the ensime-mode to be started whenever
;; scala-mode is started for a buffer. You may have to customize this step
;; if you're not using the standard scala mode.
;;(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
;;semantic highlighting
;;(setq ensime-sem-high-faces
;; '(
;; (var . (:foreground "#ff2222"))
;; (val . (:foreground "#dddddd"))
;; (varField . (:foreground "#ff3333"))
;; (valField . (:foreground "#dddddd"))
;; (functionCall . (:foreground "#84BEE3"))
;; (param . (:foreground "#ffffff"))
;; (class . font-lock-type-face)
;; (trait . (:foreground "#084EA8"))
;; (object . (:foreground "#026DF7"))
;; (package . font-lock-preprocessor-face)
;; ))
;;
;;
(add-hook 'prog-mode-hook 'rainbow-identifiers-mode)
(require 'rainbow-mode)
(require 'rainbow-delimiters)
(global-rainbow-delimiters-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))
(add-to-list 'auto-mode-alist '("\\.pdc\\'" . markdown-mode))
(add-hook 'markdown-mode-hook 'turn-on-pandoc)
(require 'auto-complete)
;;haskell
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(require 'speedbar)
(speedbar-add-supported-extension ".hs")
(eval-after-load "haskell-mode"
'(progn
(define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
(define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)))
(define-key haskell-mode-map (kbd "M-.") 'haskell-mode-jump-to-def-or-tag)
(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.
'(haskell-process-auto-import-loaded-modules t)
'(haskell-process-log t)
'(haskell-process-suggest-remove-import-lines t)
'(haskell-process-type (quote cabal-repl))
'(haskell-tags-on-save t))
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
(define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
(define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
(define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
(define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
(define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
(define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
(define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)
;;(define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring)
;;(define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
;;(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
;;(define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal)
;;evil
(require 'evil)
(evil-mode 1)
;;http://www.emacswiki.org/emacs/Evil
;;start all modes in emacs not vim
;;(setq-default evil-default-state 'emacs)
;;(setq-default evil-insert-state-modes nil evil-motion-state-modes nil)
;;(evil-set-initial-state 'fundamental-mode 'emacs)
;;(evil-set-initial-state 'text-mode 'emacs)
;;(evil-set-initial-state 'ensime-mode 'emacs)
;;(evil-set-initial-state 'scala-mode 'emacs)
;;(evil-set-initial-state 'protobuf-mode 'emacs)
;;(evil-set-initial-state 'Interactive-Haskell-mode 'emacs)
(evil-set-initial-state 'haskell-interactive-mode 'emacs)
(add-hook 'after-init-hook #'global-flycheck-mode)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-haskell-setup))
(require 'flycheck-color-mode-line)
(eval-after-load "flycheck"
'(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
# remap prefix to Control + z
set -g prefix C-z
unbind C-z
bind C-z send-prefix
bind-key C-z last-pane
#yeah, you just lost backgrounding
#https://mutelight.org/practical-tmux
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# tmux/1.9a/share/tmux/examples/vim-keys.conf, v1.2 2010/09/12
# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize panes like vim, by 10 characters at a time
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10
# bind : to command-prompt like vim (this is the default in tmux already)
bind : command-prompt
# vi-style controls for copy mode
setw -g mode-keys vi
"vundle
set nocompatible " be iMproved
filetype on
filetype off "required
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
"https://github.com/tpope/vim-fugitive
Bundle 'tpope/vim-fugitive'
"https://github.com/bling/vim-airline
Bundle 'bling/vim-airline'
"https://github.com/edkolev/promptline.vim
Bundle 'edkolev/promptline.vim'
"https://github.com/edkolev/tmuxline.vim
Bundle 'edkolev/tmuxline.vim'
"https://github.com/Shougo/neocomplete.vim not yet available for apple vim
"https://github.com/Shougo/neocomplcache.vim
Bundle 'Shougo/neocomplcache.vim'
"https://github.com/ervandew/supertab
Bundle 'ervandew/supertab'
"https://github.com/scrooloose/syntastic
Bundle 'scrooloose/syntastic'
"https://github.com/majutsushi/tagbar
Bundle 'majutsushi/tagbar'
"https://github.com/Lokaltog/vim-easymotion
Bundle 'Lokaltog/vim-easymotion'
"https://github.com/scrooloose/nerdtree
Bundle 'scrooloose/nerdtree'
"https://github.com/Shougo/unite.vim
Bundle 'Shougo/unite.vim'
"https://github.com/tpope/vim-surround
Bundle 'tpope/vim-surround'
"https://github.com/vim-pandoc/vim-pandoc
Bundle 'vim-pandoc/vim-pandoc'
"https://github.com/tpope/vim-markdown
Bundle 'tpope/vim-markdown'
"https://github.com/kien/rainbow_parentheses.vim
Bundle 'kien/rainbow_parentheses.vim'
"scala
"https://github.com/derekwyatt/vim-scala
Bundle 'derekwyatt/vim-scala'
"dart
"https://github.com/dart-lang/dart-vim-plugin
Bundle 'dart-lang/dart-vim-plugin'
"haskell
"https://github.com/bitc/vim-hdevtools
"https://github.com/bitc/lushtags
"https://github.com/eagletmt/neco-ghc
"https://github.com/lambdatoast/elm.vim
set ruler "show line and column number
syntax on
"if I need q or z, enable it manually for that session
colorscheme slate
"way better than set showmatch for matching parentheses:
hi MatchParen cterm=bold ctermbg=none ctermfg=red
"Save history and registers in viminfo - for some reason macOS is ignoring ,n~/viminfo.vim
set viminfo='500,<1000,s100,:1000
set history=1000 "matches above setting for : in viminfo
set nocompatible
set autoindent
set smartindent
set wildmenu "tab completion stuff
"expandtab: insert space characters whenever the tab key is pressed
"tabstop: control number of space characters inserted for tab key
"softtabstop: intelligent backspace with 4-spaces instead of tabs
set softtabstop=4
set tabstop=4
set expandtab
"how much visual indenting do you want for tabs
set shiftwidth=4
"autodetect magic
filetype indent on
filetype plugin on
set incsearch "start searching as you type
set number "line numbers
set ignorecase "when searching
set smartcase "if caps used explicitly, search for em
set tabpagemax=30
"change ^M windows line endings to \n
set fileformat=unix
"highlight non-ascii characters
syntax match nonascii "[^\x00-\x7F]"
highlight nonascii guibg=Red ctermbg=2
set visualbell "no beeps in intellij
"gui
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guifont=Inconsolata\ for\ Powerline:h13
"incantations for intelligent 80 width coding and text
set tw=72 fo+=q wm=0
set fo-=t fo-=a fo-=c
"detect trailing whitespace
match Todo /\s\+$/
nmap q <Nop>
nmap Z <Nop>
" Always show statusline
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
" Use 256 colours (Use this setting only if your terminal supports 256 colours)
set t_Co=256
set encoding=utf-8
"set fillchars+=stl:\ ,stlnc:\
"airline
let g:airline_powerline_fonts = 1
"nerdtree
map <C-n> :NERDTreeToggle<CR>
autocmd vimenter * if !argc() | NERDTree | endif
"cheat on buffer and tab exploring
map <C-J> :bnext<CR>
map <C-K> :bprev<CR>
map <C-L> :tabn<CR>
map <C-H> :tabp<CR>
""hdevtools
au FileType haskell nnoremap <buffer> <C-i> :HdevtoolsType<CR>
au FileType haskell nnoremap <buffer> <silent> <C-u> :HdevtoolsClear<CR>
au FileType haskell nnoremap <buffer> <silent> <C-o> :HdevtoolsInfo<CR>
"syntastic
map <silent> <Leader>e :Errors<CR>
map <Leader>s :SyntasticToggleMode<CR>
let g:syntastic_haskell_checkers=['hdevtools']
"let g:syntastic_auto_loc_list=1
"omnicompletes
highlight PmenuSel ctermbg=2 "selected element given green background
" If you prefer the Omni-Completion tip window to close when a selection is
" made, these lines close it on movement in insert mode or when leaving
" insert mode
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"neocomplcache
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Enable omni completion.
highlight PmenuSel ctermbg=2 "selected element given green background
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complete
"neco-ghc
let g:necoghc_enable_detailed_browse = 1
"pandoc
let g:pandoc_no_folding = 1
"tagbar
nmap <leader>= :TagbarToggle<CR>
let g:tagbar_autofocus = 1
"unite
"http://www.codeography.com/2013/06/17/replacing-all-the-things-with-unite-vim.html
"let g:unite_source_history_yank_enable = 1
call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <leader>f :<C-u>Unite -start-insert file<cr>
"nnoremap <leader>t :<C-u>Unite -no-split -buffer-name=files -start-insert file_rec/async:!<cr>
"nnoremap <leader>f :<C-u>Unite -no-split -buffer-name=files -start-insert file<cr>
"nnoremap <leader>r :<C-u>Unite -no-split -buffer-name=mru -start-insert file_mru<cr>
"nnoremap <leader>o :<C-u>Unite -no-split -buffer-name=outline -start-insert outline<cr>
"nnoremap <leader>y :<C-u>Unite -no-split -buffer-name=yank history/yank<cr>
"nnoremap <leader>e :<C-u>Unite -no-split -buffer-name=buffer buffer<cr>
" Custom mappings for the unite buffer
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
" Play nice with supertab
let b:SuperTabDisabled=1
" Enable navigation with control-j and control-k in insert mode
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
endfunction
"http://stackoverflow.com/questions/158968/changing-vim-indentation-behavior-by-file-type
autocmd FileType proto setlocal shiftwidth=2 tabstop=2
autocmd FileType scala setlocal shiftwidth=2 tabstop=2
"ghc-mod
" Reload
"au FileType haskell nnoremap <buffer> te :call GHC_BrowseAll()<CR>
" Type Lookup
"au FileType haskell nnoremap <buffer> tw :call GHC_ShowType(1)<CR>
"pointfree - gq from visual selection
"au FileType haskell set formatprg=pointfree
"let g:vundle_default_git_proto = 'git'
"default is https
"rainbows
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"tmuxline
let g:airline#extensions#tmuxline#enabled = 0
"let g:tmuxline_preset = 'full'
"let g:tmuxline_theme = 'nightly_fox'
auto-complete dart-mode dired-rainbow dired-hacks-utils evil-nerd-commenter evil-terminal-cursor-changer evil-visualstar flycheck-color-mode-line flycheck-haskell flycheck f dash haskell-mode markdown-mode moe-theme pandoc-mode pkg-info epl popup powerline-evil powerline evil goto-chg protobuf-mode rainbow-blocks rainbow-delimiters rainbow-identifiers rainbow-mode s smex undo-tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment