]> git.r.bdr.sh - rbdr/dotfiles/blob - vimrc
Commit powerline changes, add git signing config
[rbdr/dotfiles] / vimrc
1 set nocompatible
2
3 set number
4 set ruler
5 syntax on
6
7 " Set encoding
8 set encoding=utf-8
9
10 " Whitespace stuff
11 set nowrap
12 set tabstop=2
13 set shiftwidth=2
14 set softtabstop=2
15 set expandtab
16 set list listchars=tab:\ \ ,trail:·
17
18 " Searching
19 set hlsearch
20 set incsearch
21 set ignorecase
22 set smartcase
23
24 " Tab completion
25 set wildmode=list:longest,list:full
26 set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
27
28 " Status bar
29 set laststatus=2
30
31 " NERDTree configuration
32 let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$']
33 map <Leader>n :NERDTreeToggle<CR>
34
35 " CTags
36 map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
37 map <C-\> :tnext<CR>
38
39 " Remember last location in file
40 if has("autocmd")
41 au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
42 \| exe "normal g'\"" | endif
43 endif
44
45 function s:setupWrapping()
46 set wrap
47 set wrapmargin=2
48 set textwidth=72
49 endfunction
50
51 function s:setupMarkup()
52 call s:setupWrapping()
53 map <buffer> <Leader>p :Hammer<CR>
54 endfunction
55
56 " make uses real tabs
57 au FileType make set noexpandtab
58
59 " Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
60 au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
61
62 " md, markdown, and mk are markdown and define buffer-local preview
63 au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
64
65 " add json syntax highlighting
66 au BufNewFile,BufRead *.json set ft=javascript
67
68 au BufRead,BufNewFile *.txt call s:setupWrapping()
69
70 " make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
71 au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
72
73 " snes syntax highlighting
74 au BufNewFile,BufRead *.asm,*.s set filetype=snes"
75
76 " allow backspacing over everything in insert mode
77 set backspace=indent,eol,start
78
79 " load the plugin and indent settings for the detected filetype
80 filetype plugin indent on
81 filetype plugin on
82
83 " Opens an edit command with the path of the currently edited file filled in
84 " Normal mode: <Leader>e
85 map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
86
87 " Opens a tab edit command with the path of the currently edited file filled in
88 " Normal mode: <Leader>t
89 map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
90
91 " Inserts the path of the currently edited file into a command
92 " Command mode: Ctrl+P
93 cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
94
95 " Unimpaired configuration
96 " Bubble single lines
97 nmap <C-Up> [e
98 nmap <C-Down> ]e
99 " Bubble multiple lines
100 vmap <C-Up> [egv
101 vmap <C-Down> ]egv
102
103 " gist-vim defaults
104 if has("mac")
105 let g:gist_clip_command = 'pbcopy'
106 elseif has("unix")
107 let g:gist_clip_command = 'xclip -selection clipboard'
108 endif
109 let g:gist_detect_filetype = 1
110 let g:gist_open_browser_after_post = 1
111
112 " Use modeline overrides
113 set modeline
114 set modelines=10
115
116 " Default color scheme
117 set t_Co=256
118 color molokai
119
120 " Directories for swp files
121 set backupdir=~/.vim/.backup
122 set directory=~/.vim/.backup
123
124 " Turn off jslint errors by default
125 let g:JSLintHighlightErrorLine = 0
126
127 " MacVIM shift+arrow-keys behavior (required in .vimrc)
128 let macvim_hig_shift_movement = 1
129
130 " % to bounce from do to end etc.
131 runtime! macros/matchit.vim
132
133 " Show (partial) command in the status line
134 set showcmd
135
136 " Include user's local vim config
137 if filereadable(expand("~/.vimrc.local"))
138 source ~/.vimrc.local
139 endif
140
141 " Mapping for TagBar
142 nmap <F8> :TagbarToggle<CR>
143 let g:tagbar_ctags_bin="/usr/local/bin/ctags"
144
145 " Color Column
146 let &colorcolumn="80,150"
147
148 " Add Pathogen
149 call pathogen#infect()
150
151 " Folding Settings
152 set foldmethod=syntax
153 set foldnestmax=10
154 set nofoldenable
155 set foldlevel=1
156
157 " powerline stuff
158 python from powerline.vim import setup as powerline_setup
159 python powerline_setup()
160 python del powerline_setup
161
162 " Fix CtrlP root folder and add some ignores
163 let g:ctrlp_working_path_mode = 0
164 let g:ctrlp_custom_ignore = '\v[\/](\.(git|hg|svn)|node_modules|DS_Store)$'
165 let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
166
167 " Relative numbers
168 autocmd FocusLost * :set norelativenumber
169 autocmd InsertEnter * :set norelativenumber
170 autocmd InsertLeave * :set relativenumber
171 autocmd CursorMoved * :set relativenumber
172
173 function! NumberToggle()
174 if(&relativenumber == 1)
175 set norelativenumber
176 else
177 set relativenumber
178 endif
179 endfunction
180
181 nnoremap <C-n> :call NumberToggle()<cr>
182
183 " Syntastic stuff
184 let g:syntastic_javascript_checkers = ['eslint']
185 let g:syntastic_always_populate_loc_list = 1
186 let g:syntastic_check_on_open = 1
187 let g:syntastic_check_on_wq = 1
188 let g:syntastic_error_symbol = "✕"
189 let g:syntastic_warning_symbol = "⚠︎"