-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_vimrc
157 lines (125 loc) · 4.95 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
" Created 22.12.2006 by Vlad
" Add modeline functionality -- it's disabled by default on some distros
set modeline
filetype plugin on
" Mapping from usenet.
imap jj <Esc>
" Per-filetype settings
autocmd FileType java setlocal tw=78 cin foldmethod=marker
autocmd FileType c,cpp setlocal tw=72 cindent noexpandtab
autocmd FileType python setlocal autoindent expandtab sts=4 sw=4 tw=100
autocmd FileType python setlocal equalprg=autopep8\ --max-line-length=100\ -
autocmd FileType haskell setlocal tw=72 sw=2 sts=2 et
autocmd FileType tex setlocal tw=72 sw=2 sts=2 ai et
autocmd FileType tex so ~/.vim/latex-abbrevs.vim
" 'linebreak' won't work without 'nolist'
autocmd FileType creole setlocal tw=0 fo=t wrap nolist linebreak
autocmd FileType creole so ~/.vim/creole-abbrevs.vim
autocmd FileType mail setlocal tw=72 fo=tql
autocmd FileType lua setlocal sts=4 sw=4 ai et
autocmd FileType rust setlocal cin
autocmd FileType sh setlocal sts=4 sw=4 si et
autocmd FileType beancount setlocal sts=2 sw=2 si et
" Custom filetypes per extension. Not sure this is the recommended way to do it.
autocmd BufRead,BufNewFile *.wiki setlocal ft=creole
autocmd BufRead,BufNewFile *.tex setlocal ft=tex
autocmd BufRead,BufNewFile *.cool setlocal ft=cool
autocmd BufRead,BufNewFile *.cl setlocal ft=cool
autocmd BufRead,BufNewFile *.miC setlocal ft=C
autocmd BufRead,BufNewFile *.g setlocal ft=antlr
autocmd BufRead,BufNewFile *.rkt setlocal ft=scheme
autocmd BufRead,BufNewFile SConstruct* setlocal ft=python tw=0
autocmd BufRead,BufNewFile SConscript* setlocal ft=python tw=0
" This relies on https://github.com/rhysd/vim-clang-format and
" http://github.com/kana/vim-operator-user
" Use clang-format to format code when using =.
autocmd Filetype c,cpp map <buffer> = <Plug>(operator-clang-format)
set autowrite
set dir=/tmp
" Ripped off from Alexandru Mosoi
set statusline=%<%f\ %y%h%m%r%=%-24.(0x%02B,%l/%L,%c%V%)\ %P
set laststatus=2
set wildmenu
" /ripoff
" Ripped off from Cosmin Ratiu, on SO list; 30 Jun 2009
if has("cscope")
" Look for a 'cscope.out' file starting from the current directory,
" going up to the root directory.
let s:dirs = split(getcwd(), "/")
while s:dirs != []
let s:path = "/" . join(s:dirs, "/")
if (filereadable(s:path . "/cscope.out"))
execute "cs add " . s:path . "/cscope.out " . s:path . " -v"
break
endif
let s:dirs = s:dirs[:-2]
endwhile
set csto=0 " Use cscope first, then ctags
set cst " Only search cscope
set csverb " Make cs verbose
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
" Open a quickfix window for the following queries.
set cscopequickfix=s-,c-,d-,i-,t-,e-,g-
endif
" More tabs -- we have enough memory.
set tabpagemax=20
colorscheme zenburn
" Mark tabs and spaces
set list listchars=tab:»\ ,trail:·,extends:»,precedes:«
map Q gq
" Ripped off from Bee on vim_use mailing list
" Space as PageDown like web browser
nmap <Space> <PageDown>
vmap <Space> <PageDown>
" /ripoff
" Highlight current line
set cursorline
" Disable the background color erase; makes the text background the same as
" the terminal background
set t_ut=
" Open new vertical splits to the right of current one.
set splitright
set hidden
set smartcase
set ignorecase
syntax on
nnoremap <Tab> <C-W>w
nnoremap <F9> :cope<CR>
nnoremap <S-F9> :ccl<CR>
nnoremap <F1> 1gt
nnoremap <F2> 2gt
nnoremap <F3> 3gt
nnoremap <F4> 4gt
nnoremap <F5> :cp<CR>
nnoremap <F6> :cn<CR>
" Align subsequent lines to open parantheses in C sources. Via andradaq.
set cinoptions=(0,W4
" Restore position inside previously opened file. From vim.wikia.
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" The main benefit so far is that bullet points are properly formatted when
" autoindent is set.
set autoindent