· 8 years ago · Jun 16, 2018, 06:40 PM
1"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2" Maintainer: Kessia 'even' Pinheiro - even.archlinux-br.org
3" Version 0.1 - Last change: 19/04/09
4"
5"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
6" General Settings
7" -------------------
8 " My information
9 " --------------
10 iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
11 iab xname Kessia 'even' Pinheiro
12 iab xmaint Maintainer: Kessia 'even' Pinheiro <kessiapinheiro at gmail.com>
13 iab xmail kessiapinheiro
14 iab xgmail at gmail.com
15 iab xarch archlinux-br.org
16
17 " Disable Generation of Backup Files
18 " ----------------------------------
19 set nobackup
20 set nowritebackup
21 set noswapfile
22
23 " Enable Folding
24 " ----------------------------------
25 "Sets leader to ',' and localleader to "\"
26 let mapleader=","
27 let maplocalleader="\\"
28
29 " Some File Type Stuff
30 " --------------------
31 filetype on
32 filetype plugin on
33
34 " Better Navigation
35 " --------------
36 "Set 7 lines to the curors - when moving vertical..
37 set so=5
38
39 " UTF-8 default encoding
40 set enc=utf-8
41
42 "Turn on WiLd menu
43 set wildmenu
44
45 "Always show current position
46 set ruler
47
48 "The commandbar is 2 high
49 set cmdheight=1
50
51 "The commandbar is 2 high
52 set cmdheight=1
53
54 "Show line number
55 set nu
56
57 "Do not redraw, when running macros.. lazyredraw
58 set lz
59
60 "Change buffer - without saving
61 set hid
62
63 "Set backspace
64 set backspace=eol,start,indent
65
66 "Bbackspace and cursor keys wrap to
67 set whichwrap+=<,>,h,l
68
69 "Ignore case when searching
70 set ignorecase
71 set incsearch
72
73 " Use case, if it contains
74 set smartcase
75
76 "Set magic on
77 set magic
78
79 "No sound on errors.
80 set noerrorbells
81 set novisualbell
82 set t_vb=
83
84 "Show matching bracets
85 set showmatch
86
87 "How many tenths of a second to blink
88 set mat=2
89
90 "Highlight search things
91 set hlsearch
92
93 " We don't want vi compatibility.
94 set nocompatible
95
96 "Set bash
97 set shell=/bin/bash
98
99
100" User Interface
101" --------------
102 "Include toobar in gui mode
103" set guioptions-=m
104
105 "Highlight current line
106 if has("gui_running")
107 set cursorline
108 endif
109 "don't used in terminal
110 "set cursorline
111
112 "Extra information about selected completion
113 set completeopt=menuone,longest,preview
114 imap <silent> <expr> <buffer> <CR> pumvisible() ?
115 \ "<CR><C-R>=(col('.')-1&&match(getline(line('.')), '\\.',
116 \ col('.')-2) == col('.')-2)?\"\<lt>C-X>\<lt>C-O>\":\"\"<CR>"
117 \ : "<CR>"
118
119 inoremap pumvisible() ? "\" : "\u\"
120 inoremap pumvisible() ? "\c-n>" : "\c-n>\c-r>=pumvisible() ? \"\\down>\" : \"\"\cr>"
121 inoremap pumvisible() ? "\c-n>" : "\c-x>\c-o>\c-n>\ c-p>\c-r>=pumvisible() ? \"\\down>\" : \"\"\cr>"
122
123 " make the popupmenu's colours less ugly (default bright pink is horrible)
124 highlight Pmenu ctermfg=0 ctermbg=2 gui=NONE
125 highlight PmenuSel ctermfg=0 ctermbg=7 gui=NONE
126 highlight PmenuSbar ctermfg=7 ctermbg=0 gui=NONE
127 highlight PmenuThumb ctermfg=0 ctermbg=7 gui=NONE
128
129
130 "Fast saving
131 nmap <leader>w :w!<cr>
132
133 "Make case insensitive for save and quit
134 cab W w
135 cab Q q
136 cab Wq wq
137 cab wQ wq
138 cab WQ wq
139
140 "Find a file in path and edit it
141 nmap <leader>f :find<cr>
142
143 "Fast reloading of the .vimrc
144 map <leader>s :source ~/.vim/vimrc<cr>
145
146 "Fast editing of .vimrc
147 map <leader>e :e! ~/.vim/vimrc<cr>
148
149 "When .vimrc is edited, reload it
150 autocmd! BufWritePost .vimrc source ~/.vimrc
151
152 " Colors and Fonts
153 " ---------
154 "Omni Menu Colors
155 " ---------
156 hi Pmenu guibg=#1a293f
157 hi PmenuSel guibg=#54657d guifg=#ffffff
158
159 " Enable Syntax Color
160 " -------------------
161 syntax on
162 set background=dark
163 set t_Co=256
164 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
165 "If using gui, change colorscheme and font.
166 if has("gui_running")
167 "tell the term has 256 colors
168 set guifont=Consolas\ 12
169 set lines=40
170 set columns=115
171 colorscheme vibrantink
172 else
173 "let g:CSApprox_loaded = 0
174 colorscheme vibrantink
175 endif
176
177 "Format the statusline
178 " Nice statusbar
179 set laststatus=2
180 set statusline=
181 set statusline+=%2*%-3.3n%0*\ " buffer number
182 set statusline+=%f\ " file name
183 set statusline+=%h%1*%m%r%w%0* " flags
184 set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype
185 set statusline+=%{&encoding}, " encoding
186 set statusline+=%{&fileformat}] " file format
187 set statusline+=%2*0x%-8B\ " current char
188 set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
189
190 set statusline=[%l\,%c\ %P%M]\ %f\ %r%h%w
191
192 " Set Better Indention
193 " --------------------
194 set smartindent
195 set autoindent
196
197 "set cindent
198 set wrap
199
200 "Indent with tab in visual
201 vnoremap < <gv
202 vnoremap > >gv
203 vmap <TAB> >
204 vmap <S-TAB> <
205 imap <S-TAB> <ESC><<i
206
207 " Tab Settings
208 " ------------
209 set smarttab
210 set tabstop=4
211 set softtabstop=4
212 set shiftwidth=4
213 set tw=500
214 set expandtab
215 set lbr
216
217 " Tab Configuration
218 " ----------
219 map <leader>tN :tabnew %<cr>
220 map <leader>tn :tabnext<cr>
221 map <leader>tp :tabprevious<cr>
222 map <leader>te :tabedit
223 map <leader>tc :tabclose<cr>
224 map <leader>tm :tabmove
225
226 " File Browser
227 " ------------
228 "Split vertically
229 let g:explVertical=1
230
231 "Window size
232 let g:explWinSize=35
233
234 let g:explSplitLeft=1
235 let g:explSplitBelow=1
236
237 "Hide some files
238 let g:explHideFiles='^\.,.*\.class$,.*\.sw[po]$,.*\.pyc$,.*\.swo$,\.DS_Store$'
239
240 "Hide the help thing..
241 let g:explDetailedHelp=0
242
243
244" MISC
245" ----------
246"Remove the Windows ^M
247noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
248
249"Paste toggle - when pasting something in, don't indent.
250set pastetoggle=<F3>
251
252"Remove indenting on empty lines
253map <F2> :%s/\s*$//g<cr>:noh<cr>''
254
255"Opens NerdTree
256nmap <silent> <Leader>p :NERDTreeToggle<CR>
257
258"make <c-l> clear the highlight as well as redraw
259nnoremap <C-L> :nohls<CR><C-L>
260
261"make cmdline tab completion similar to bash
262set wildmode=list:longest
263
264"enable ctrl-n and ctrl-p to scroll thru matches
265set wildmenu
266
267"stuff to ignore when tab completing
268set wildignore=*.o,*.obj,*~
269
270"Tab completion
271if has("eval")
272 function! CleverTab()
273 if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$'
274 return "\<Tab>"
275 else
276 return "\<C-N>"
277 endif
278 endfun
279 inoremap <Tab> <C-R>=CleverTab()<CR>
280 inoremap <S-Tab> <C-P>
281endif
282
283"Bracket Handling
284inoremap ( ()<Esc>i
285inoremap [ []<Esc>i
286inoremap { {<CR>}<Esc>O
287autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
288inoremap ) <c-r>=ClosePair(')')<CR>
289inoremap ] <c-r>=ClosePair(']')<CR>
290inoremap } <c-r>=CloseBracket()<CR>
291
292"Super paste
293inoremap <C-v> <esc>:set paste<cr>mui<C-R>+<esc>mv'uV'v=:set nopaste<cr>
294
295" Plugin Configuration
296" ----------
297 " Tag list (ctags)
298 " ----------
299 "Look documentation in plugins/
300 let Tlist_Sort_Type = "name"
301 let Tlist_Show_Menu = 1
302 let Tlist_Close_On_Select = 1
303 let Tlist_GainFocus_On_ToggleOpen = 1
304 let Tlist_Show_Menu = 1
305 "let Tlist_Use_Right_Window = 1
306
307 "Open/close taglist
308 map <F8> :TlistToggle<cr>
309 "Adding files to taglist
310 map <F9> :TlistAddFiles<cr>
311 "Making a update in your tags
312 map <F10> :TlistUpdate<cr>
313
314" Omni Complete Functions
315" ----------------------
316autocmd FileType python set omnifunc=pythoncomplete#Complete
317autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
318autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
319autocmd FileType css set omnifunc=csscomplete#CompleteCSS
320autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
321autocmd FileType php set omnifunc=phpcomplete#CompletePHP
322autocmd FileType c set omnifunc=ccomplete#Complete
323
324" Filetypes
325" ----------------------
326 " VIM
327 " ----------------------
328 autocmd FileType vim map <buffer> <leader><space> :w!<cr>:source %<cr>
329
330 " Python support
331 " --------------
332 autocmd FileType python set expandtab shiftwidth=4 tabstop=4 softtabstop=4
333 autocmd BufRead,BufNewFile *.py syntax on
334 autocmd BufRead,BufNewFile *.py set ai
335 autocmd BufRead,BufNewFile *.py set foldmethod=indent
336 autocmd BufRead,BufNewFile *.py set syntax=python
337 autocmd BufRead,BufNewFile *.py set smartindent
338 autocmd BufRead,BufNewFile *.py set cinwords=class,def,elif,else,except,finally,for,if,try,while
339 autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
340 let python_highlight_all=1
341
342 "Run the current buffer in python - ie. on leader+space
343 au FileType python so ~/.vim/syntax/python.vim
344 autocmd FileType python map <buffer> <leader><space> :w!<cr>:!python %<cr>
345 autocmd FileType python so ~/.vim/plugin/python_fold.vim
346
347 "Set some bindings up for 'compile' of python
348 autocmd FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
349 autocmd FileType python set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
350
351 "Run in the Python interpreter
352 function! Python_Eval_VSplit() range
353 let src = tempname()
354 let dst = tempname()
355 execute ": " . a:firstline . "," . a:lastline . "w " . src
356 execute ":!python " . src . " > " . dst
357 execute ":pedit! " . dst
358 endfunction
359 au FileType python vmap <F7> :call Python_Eval_VSplit()<cr>
360
361 " Ruby support
362 " ------------
363 autocmd FileType ruby setlocal shiftwidth=2 tabstop=2 softtabstop=2
364 autocmd FileType ruby map <buffer> <leader><space> :w!<cr>:!ruby %<cr>
365
366 " Content creation
367 if has("autocmd")
368 augroup content
369 autocmd!
370
371 autocmd BufNewFile *.py
372 \ 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
373 \ 0put ='#!/usr/bin/env python' |
374 \ 1put ='# -*- coding: utf-8 -*-' |
375 \ set sw=4 sts=4 et tw=80 |
376 \ norm G
377
378 autocmd BufNewFile *.rb
379 \ 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
380 \ 0put ='#!/usr/bin/ruby' |
381 \ 1put ='# -*- coding: utf-8 -*-' |
382 \ set sw=4 sts=4 et tw=80 |
383 \ norm G
384
385 autocmd BufNewFile *.cc
386 \ 0put ='/* vim: set sw=4 sts=4 et foldmethod=syntax : */' |
387 \ 1put ='' | 2put ='' | call setline(3, '#include "' .
388 \ substitute(expand("%:t"), ".cc$", ".hh", "") . '"') |
389 \ set sw=4 sts=4 et tw=80 | norm G
390
391 autocmd BufNewFile *.sh
392 \ 0put ='#!/usr/bin/env bash' |
393 \ 1put ='# vim: set sw=4 sts=4 et tw=80 :' |
394 \ set sw=4 sts=4 et tw=80 |
395 \ norm gg=Ggg
396
397 augroup END
398 endif