-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
173 lines (146 loc) · 6.48 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"Don't bother with vi compatibility"
set nocompatible
"Use pathogen to manage plugins"
call pathogen#infect() "Run pathogen to install plugins"
call pathogen#helptags() "Run pathogen to generate helpfiles for plugins"
filetype plugin indent on "Enable loading indent file for filetype"
set softtabstop=4 "Make spaces feel like tabs (like deleting)"
set sr
set gfn=Monaco\ Arial\ Monospaced\ 9
set lsp=1
set ghr=160 "GUI headroom"
set number "Always show line numbers"
syntax on "Syntax highlighting"
set t_Co=256 "Enable 256 colours in vim"
colorscheme wombat256mod "Enable the wombat theme"
set expandtab "Expand tabs to spaces"
set tabstop=4 "Set tab width to 4 spaces"
set shiftwidth=4 "Normal mode indentation commands use 4 spaces"
set laststatus=2 "Always show status line"
set autoindent "Automatically indent text"
set smartindent
set ruler "Always show where you are"
set makeprg=php\ -l\ %
set errorformat=%m\ in\ %f\ on\ line\ %l
set tags=./tags,tags; "Make use of exuberant ctags"
match Error /\t\|\s\+$/ "Show trailing whitespace as ugly red blocks"
set backspace=indent,eol,start "Fix this weird backspace issue deleting lines"
set wildmenu "Enable a menu at the bottom of the window"
set wildmode=list:longest,full "Something to do with completion in command line"
set mouse=a "Turn on mouse support"
set completeopt=longest,menuone "Completion menu matches longest and shows even 1"
set encoding=utf-8 "Make vim use utf8"
"Statusline setup"
set statusline=%{fugitive#statusline()} "Current git branch"
set statusline+=%f "Full filepath"
set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, "File encoding"
set statusline+=%{&ff}] "File format"
set statusline+=%h "Help file flag"
set statusline+=%m "Modified flag"
set statusline+=%r "Read only flag"
set statusline+=%y "Filetype"
set statusline+=%= "Left/right separator"
set statusline+=%c, "Cursor column"
set statusline+=%l/%L "Cursor line/total lines"
set statusline+=\ %P "Percent through file"
"Keyboard shortcuts"
let mapleader = ','
"Code folding"
let php_folding=1
set foldmethod=syntax
set foldlevel=99
map <leader>f za<CR>
"CTRL-P stuff"
"Toggle ctrl-p"
map <leader>p :CtrlP<CR>
map <leader>b :CtrlPBuffer<CR>
" Seach recursively from the ancestor containing .git
let g:ctrlp_working_path_mode = 'ra'
"NERDTree stuff"
"Automatically load nerdtree when we open vim and no files are specified"
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"Toggle nerdtree with keypress"
map <leader>n :NERDTreeToggle<CR>
"Close vim when only nerdtree is left"
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"Fix weird chars"
let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"
"For easier buffers, this maps ` to show buffers"
nnoremap ` :buffers<CR>:buffer<Space>
"Strip extra whitespace"
nmap <leader><space> :call whitespace#strip_trailing()<CR>
"Setup syntastic code checker"
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_css_checkers = ['stylelint']
let g:syntastic_scss_checkers = ['stylelint']
let g:syntastic_enable_signs=1
let g:syntastic_php_phpcs_args="--standard=moodle --extensions=php"
let g:syntastic_php_phpmd_post_args = "~/.vim/phpmdruleset.xml"
let g:syntastic_aggregate_errors=1
let g:syntastic_always_populate_loc_list=1
let g:syntastic_auto_loc_list=1
"Vdebug stuff"
let g:vdebug_options = {
\ 'server': '0.0.0.0',
\ 'port': '9000',
\ 'on_close': 'detach'
\}
let g:vdebug_options['path_maps'] = {
\ '/var/www/site' : '/home/marcus/workspace/monash/elms/site'
\}
nmap <leader>sb :Breakpoint<CR>
nmap <leader>rb :BreakpointRemove *<CR>
"Autocompletion"
filetype plugin on
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
let g:SuperTabDefaultCompletionType = "context"
let php_sql_query=1
let php_htmlInstrings=1
"Tagbar"
let g:tagbar_usearrows=1
let g:tagbar_autofocus=1
let g:tagbar_autoclose=1
nnoremap <leader>l :TagbarToggle<CR>
"Gundo stuff"
nnoremap <leader>u :GundoToggle<CR>
"Update tags"
nnoremap <leader>t :silent execute "!~/.vim/ctaggify &>/dev/null &"\|redraw!<CR>
"List all matching tags, their location and type"
"nnoremap <C-]> :tselect <C-R><C-W><CR>
"Change settings based on path.
function! SetCommon()
setlocal tabstop=2 shiftwidth=2 softtabstop=2
let g:syntastic_php_phpcs_args="--standard=Zend --extensions=php"
endfunction
au BufNewFile,BufRead **/common* call SetCommon()
" Change the highlight colour
let g:vawahl="ctermbg=239 guibg=#4e4e4e gui=bold"
"Close the location list if its the only thing open
aug QFClose
au!
au WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&buftype") == "quickfix"|q|endif
aug END
"Setup for snipmate
let g:snips_author = 'Marcus Boon<[email protected]>'
let g:snipMate = {}
let g:snipMate.snippet_version = 1
" Syntax for ruby files
au FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Jump to definition if there is only one, or else show list of definitions to
" choose from if there are multiple.
nnoremap <c-]> g<c-]>
" Shortcut for git blame
nnoremap gb :Git blame<CR>
" Shortcut for gitv
nnoremap gv :Gitv<CR>
nnoremap gfv :Gitv!<CR>
" Shortcuts for threeway-merge resolution
nnoremap gd :Gdiffsplit!<CR>
nnoremap gdt :diffget //2<CR>
nnoremap gtm :diffget //3<CR>
nnoremap gu :diffupdate<CR>