-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
224 lines (185 loc) · 5.84 KB
/
vimrc
File metadata and controls
224 lines (185 loc) · 5.84 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
" .vimrc
" Load Pathogen
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
" Contine with option setting
set timeoutlen=500 " Shift+O isn't quite so slow, but keep it reasonably long so leader works
set mouse=a " Enable console mouse support
set nocp " Disable vi compatibility
set nohls incsearch " No highlight of search terms, no need to press enter
set autoindent " Autoindent
set tabstop=4 shiftwidth=4 " 4-tabs
set showmatch mat=2 " Switch briefly to opposite (/[/etc for 0.2 sec
set ruler " Show cursor pos.
set novisualbell " Visual bell looks ugly on GUI
set guioptions=ac t_Co=256 " Minimal GUI, 256 colour
set showcmd " Some more info in bottom-right corner
set wildmenu wildmode=list:longest,full " Tab-completion at :
set hid " Change buffer w/o saving
set ignorecase smartcase " Case-insensitive search (when necessary)
set magic " Yay special search chars
set background=dark " It probably will be
set encoding=utf8 " Just in case Unicode gets mucked up.
set nobackup " I don't need x~ everywhere
set directory=~/tmp " Swapfiles are sometimes useful, but keep them out the way
set title " Give terminal a title
set scrolloff=3 " Move down a few lines when reach end of screen
set number " Line numbers
set wrap linebreak textwidth=0 " Default wrapping is weird...
set backspace=indent,eol,start " Fix broken backspace
set cursorline " Highlight current line
set clipboard+=unnamed " Yank to clipboard by default.
set tildeop " Convenient sometimes
set ofu=syntaxcomplete#Complete " Enable omni-completion
set noequalalways " Stop changing my split sizes...
let g:ConqueTerm_Color = 1 " Enable terminal colour
let g:tex_indent_brace = 0 " Turn off buggy LaTeX indentation
let g:gruvbox_italic = 1 " Enable italics in color scheme
let g:ctrlp_extensions = ['tag', 'quickfix', 'line', 'mixed']
set wildignore+=*.o
" Set leader right
let mapleader = ","
" Now %% = path of current file
cabbr <expr> %% expand('%:p:h')
" Toggle hls
nmap <C-K> :set hlsearch!<CR>:set hlsearch?<CR>
" Open tag search
nmap <C-U> :CtrlPTag<CR>
" Open a shell
nmap <leader>bash :ConqueTermVSplit bash<CR>
nmap <leader>py :ConqueTermVSplit python<CR><Esc>:set syntax=python<CR>i
" Press F2 to save quickly in insert mode
imap <F2> <Esc>:w!<CR>a
" Source VimL in buffer
nmap <F9> <Esc>:so %<CR>
" Buffer switch quickly
nnoremap <F1> :bp<CR>
nnoremap <F11> :bn<CR>
nnoremap <F2> <C-W>w
nnoremap <F10> <C-W>W
" Re-indent whole file
nmap <leader>in =%
" Empty file
nmap <leader>em ggdG
" Right margin at 80 cols in Vim 7.3+
function! ToggleRightMargin()
if version >= 703
if &cc != 0
set cc=0
else
set cc=80
endif
endif
endfunction
nnoremap <leader>rm :call ToggleRightMargin()<CR>
" Better % matching
runtime macros/matchit.vim
" Free form FORTRAN source by default
let fortran_free_source=1
let fortran_have_tabs=1
let fortran_more_precise=1
let fortran_do_enddo=1
" Generally better editing
syntax enable
filetype on
filetype plugin on
filetype indent on
" Make whitespace visible
set listchars=tab:➙·,trail:·,eol:¶
nmap <silent> <leader>s :set nolist!<CR>
" Make status bar nicer
function! CurDir()
let curdir = substitute(getcwd(), '/home/lucas/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ \|\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
" Appearance options
if has("gui_running") && !has("nvim")
colors solarized
set bg=light
if has("win32")
set guifont=Monaco:h9
elseif has("gui_athena")
set guifont=fixed
else
set guifont=Monaco\ 9
endif
" I have this habit of doing ^Z to suspend, but by default this minimises the GUI. Ugh. Stop it.
noremap <C-Z> <Esc>
else
colors gruvbox
endif
" Bind Gundo
nmap <C-S-Y> :GundoToggle<CR>
" Make moving around windows easier
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
function! DoPCRE(expr)
let s = 'perldo s' . a:expr
execute s
endfunction
command! -nargs=0 EdVimrc ed $MYVIMRC
command! -nargs=0 SurvivalGuide vs ~/.dotfiles_dir/SurvivalGuide
command! -nargs=* S call DoPCRE('<args>')
command! -nargs=0 MakeExec !chmod +x %
" Load some plugins automatically
function! SetupProgramming()
TlistOpen
NERDTree
syntax on
filetype on
filetype plugin on
filetype indent on
endfunction
nmap <silent> <Leader>p :call SetupProgramming()<CR>
" Bare-bones view mode
function! BareEnable()
setlocal guioptions-=r laststatus=0 noruler nonumber noshowmode noshowcmd nocursorline
highlight NonText guifg=bg ctermfg=0
redraw!
endfunction
function! BareDisable()
setlocal guioptions+=r laststatus=1 ruler number showmode showcmd
endfunction
nmap <silent> <Leader>be :call BareEnable()<CR>
nmap <silent> <Leader>bd :call BareDisable()<CR>
nmap <silent> <Leader>sh :shell<CR>
nmap <silent> <Leader>df :enew<CR>,be
" Activate Powerline
set rtp+=$HOME/.dotfiles_dir/vim/bundle/powerline/powerline/bindings/vim
" Protobuf syntax highlighting
augroup filetype
au! BufRead,BufNewFile *.proto setfiletype proto
augroup end
" Sort out colouring at the right time
function! CheckColors()
if has("nvim") && has("gui_running") && $NVIM_TUI_ENABLE_TRUE_COLOR == "1"
colors solarized
endif
endfunction
augroup colour
au! VimEnter * call CheckColors()
augroup end
" For GAP files
augroup gap
" Remove all gap autocommands
au!
autocmd BufRead,BufNewFile *.g,*.gi,*.gd set filetype=gap comments=b:#
augroup END
" SyncTeX
function! SyncTeXForward()
let execstr = "silent !okular --unique %:p:r.pdf\\#src:".line(".")."%:p &"
exec execstr
endfunction
command! -nargs=0 SyncTeX call SyncTeXForward()
nmap <Leader>f :call SyncTeXForward()<CR>