-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·186 lines (165 loc) · 5.64 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
174
175
176
177
178
179
180
181
182
183
184
185
186
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
" NERDTree related
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" YouCompleteMe
let g:ycm_auto_trigger = 1
syn on " Syntax highlighting on
if has("unix")
colorscheme desert
endif
filetype plugin on
filetype plugin indent on
filetype indent on
autocmd FileType markdown setlocal nocindent
autocmd FileType text setlocal nocindent
autocmd FileType latex setlocal nocindent
autocmd FileType asciidoc setlocal nocindent noautoindent nosmartindent
autocmd FileType asciidoc setlocal fo=want
" autocmd FileType asciidoc hi clear ExtraWhitespace
if version >= 700
set omnifunc=syntaxcomplete#Complete
set completeopt=menuone,menu,longest
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
highlight clear
highlight Pmenu ctermfg=0 ctermbg=2
highlight PmenuSel ctermfg=0 ctermbg=7
highlight PmenuSbar ctermfg=7 ctermbg=0
highlight PmenuThumb ctermfg=0 ctermbg=7
end
if has("gui_running")
if has("macunix")
set guifont=Monaco:h14 " use this font
set lines=70 " height = 50 lines
set columns=90 " width = 100 columns
elseif has("unix")
set guifont=Lucida\ Console:h10 " use this font
set lines=70 " height = 50 lines
set columns=90 " width = 100 columns
endif
endif
set tw=90
set mouse=a
" Tab and indent options =======================================================
set number
set relativenumber
set tabstop=4 " Tab is 4 spaces and NOT the default 8
set shiftwidth=4 " numbers of spaces to (auto)indent
set expandtab " Expand tab to spaces
set cindent " cindent
set smartindent " smart indent
set autoindent " always set autoindenting on
set softtabstop=4 " makes the spaces feel like real tabs. E.g. back deletes all 4 chars
set backspace=indent,eol,start " backspace deletes indent, eol and start lineset hlsearch
set cinoptions=l1
nnoremap H gT
nnoremap L gt
set fo+=mM
" Display options ===============================================================
set cursorline
" hi CursorLine cterm=NONE ctermbg=black guibg=black
set ruler
if exists('+autochdir')
set autochdir
else
autocmd BufEnter * silent! lcd %:p:h:gs/ /\ /
endif
set langmenu=none
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$/
" Tags related ==================================================================
"let Tlist_Ctags_Cmd = "ctags.exe"
set tags=./tags,tags;
set tags+=~/.vim/tags/c
"set tags+=~/.vim/tags/c++
set grepprg=grep\ -nH\ $*
let g:ale_linters = {'rust': ['analyzer']}
let g:ale_linters_explicit = 1
augroup filetype_rust
if tagfiles() == []
au!
au BufRead,BufNewFile *.rs nnoremap K :ALEHover<CR>
au BufRead,BufNewFile *.rs nnoremap <C-]> :ALEGoToDefinition<CR>
endif
augroup END
let g:tex_flavor = "pdftex"
let g:Tex_DefaultTargetFormat = "pdf"
let g:Tex_MultipleCompileFormats="pdf,bib,pdf"
let g:Tex_GotoError = 0
let g:Tex_ShowErrorContext = 0
let g:tex_comment_nospell = 1
if has("macunix")
let g:Tex_TreatMacViewersAsUNIX = 1
let g:Tex_ExecuteUNIXViewerInForeground = 1
let g:Tex_ViewRule_ps = 'open -a Skim'
let g:Tex_ViewRule_pdf = 'open -a /Applications/Skim.app'
let g:Tex_ViewRule_dvi = 'open -a /Applications/Skim.app'
elseif has("unix")
let g:Tex_ViewRule_pdf = "okular"
endif
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
let php_sql_query = 1
let php_htmlInStrings = 1
" File operations ===============================================================
set hidden
set confirm
set nobackup
set hidden
" Search options ================================================================
set incsearch
set hlsearch
" Keymaps =======================================================================
nnoremap <c-l> <c-l>:noh<return>
nnoremap <F12> :TlistToggle<return>
"inoremap ( ()i
"inoremap " ""i
"inoremap ¡® "i
"inoremap [ []i
"inoremap { {}i
" for php:
"imap vv $
"imap .. ->
" Autocmd for different behavior based on filetype==============================
autocmd FileType tex set spell nocindent nosmartindent noautoindent nocursorline tw=90
" Disable logging of the JS indent plugin
let g:js_indent_log = 0
function! LoadCscope()
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
set cscopetag
set cst
set csto=0
endif
endfunction
au BufEnter /* call LoadCscope()
function! UpdateTags()
execute ":!ctags -R --languages=C,C++ --c++-kinds=+p --fields=+iaS --extra=+q ./"
echohl StatusLine | echo "C/C++ tag updated" | echohl None
endfunction
nnoremap <F4> :call UpdateTags()
set csre
" Aligns backslash characters at the end of lines.
" Useful when writing multiline macros or multiline strings.
function AlignBackslash()
:silent! s@\s\+\\$@ \\@
:silent! s/s*\\$/\=repeat(' ', 80-col('.')).'\'
:let @/ = ""
endfunction
function RemoveDuplicateBackslash()
:silent! s/\\\\$/\\/g
endfunction
" In normal mode align the whole file.
nmap \\ mxggVG:call RemoveDuplicateBackslash()<cr>ggVG:call AlignBackslash()<cr>'x
" In visual select mode align selected lines.
vmap \\ :call RemoveDuplicateBackslash()<cr>gv:call AlignBackslash()<cr>
" Insert backslash at the end of current line and align it
nmap <c-\> A\<esc>:call AlignBackslash()<cr>
" Insert backslash at the end of selected lines and align them
vmap <c-\> :norm A\<esc>gv:call AlignBackslash()<cr>