Advertisement
Guest User

.vimrc

a guest
Dec 2nd, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.89 KB | None | 0 0
  1. call pathogen#infect()
  2. """"""""""""""""""""""""""""""""""""
  3. " Set shell config on windows
  4. """"""""""""""""""""""""""""""""""""
  5.  
  6. if executable('sh.exe')
  7.   set shell=sh.exe\ -login
  8.   set shellcmdflag=-c
  9.   set shellquote="
  10. endif
  11.  
  12. """"""""""""""""""""""""""""""""""""
  13. " General plugin configurations
  14. """"""""""""""""""""""""""""""""""""
  15.  
  16. """" Syntastic """"
  17. " Disable error display on cursor move
  18. let g:syntastic_echo_current_error = 0
  19.  
  20. """" NeoComplCache """"
  21. " Disable AutoComplPop.
  22. let g:acp_enableAtStartup = 0
  23. " Use neocomplcache.
  24. let g:neocomplcache_enable_at_startup = 1
  25. " Use smartcase.
  26. let g:neocomplcache_enable_smart_case = 1
  27. " Use camel case completion.
  28. let g:neocomplcache_enable_camel_case_completion = 1
  29. " Use underbar completion.
  30. let g:neocomplcache_enable_underbar_completion = 1
  31. " Set minimum syntax keyword length.
  32. let g:neocomplcache_min_syntax_length = 3
  33. let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
  34.  
  35. " Define dictionary.
  36. let g:neocomplcache_dictionary_filetype_lists = {
  37.     \ 'default' : '',
  38.     \ 'vimshell' : $HOME.'/.vimshell_hist',
  39.     \ 'scheme' : $HOME.'/.gosh_completions'
  40.     \ }
  41.  
  42. " Define keyword.
  43. if !exists('g:neocomplcache_keyword_patterns')
  44.   let g:neocomplcache_keyword_patterns = {}
  45. endif
  46. let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
  47.  
  48. " Plugin key-mappings.
  49. " imap <C-k>     <Plug>(neocomplcache_snippets_expand)
  50. " smap <C-k>     <Plug>(neocomplcache_snippets_expand)
  51. inoremap <expr><C-g>     neocomplcache#undo_completion()
  52. inoremap <expr><C-l>     neocomplcache#complete_common_string()
  53.  
  54.  
  55. " Enable code folding for Vimwiki
  56. let g:vimwiki_folding = 1
  57.  
  58. " SuperTab like snippets behavior.
  59. "imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
  60.  
  61. " Recommended key-mappings.
  62. inoremap <expr><CR>  pumvisible() ? neocomplcache#close_popup() : "\<CR>"
  63. " <TAB>: completion.
  64. inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
  65. " <C-h>, <BS>: close popup and delete backword char.
  66. inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
  67. inoremap <expr><C-y>  neocomplcache#close_popup()
  68.  
  69. " AutoComplPop like behavior.
  70. let g:neocomplcache_enable_auto_select = 1
  71.  
  72. " Enable omni completion.
  73. autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  74. autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  75. autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  76. autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  77. autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  78. autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
  79. autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP
  80.  
  81. " Enable heavy omni completion.
  82. if !exists('g:neocomplcache_omni_patterns')
  83.   let g:neocomplcache_omni_patterns = {}
  84. endif
  85. let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
  86. let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
  87. let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
  88.  
  89.  
  90. """" NERDTree """"
  91. "Let NERDTree decide cwd (top of current tree)
  92. let g:NERDTreeChDirMode=2
  93. "Map F8 to NERDTreeToggle
  94. map <F8> :NERDTreeToggle<cr>
  95.  
  96. """" Tagbar """"
  97. "Map F7 to tagbar
  98. nmap <F7> :TagbarToggle<cr>
  99. let g:tagbar_autoclose=1
  100. let g:tagbar_left=1
  101.  
  102. """" CtrlP """"
  103. let g:ctrlp_custom_ignore = 'node_modules'
  104.  
  105.  
  106. """"""""""""""""""""""""""""""""""""
  107. " General setup
  108. """"""""""""""""""""""""""""""""""""
  109. "only javascript indent one level for multiple brackets on same line (jQuery)
  110. let g:SimpleJsIndenter_BriefMode = 1
  111.  
  112. "Syntax highlight sql queries
  113. let g:php_sql_query=1
  114. "Syntax highlight html in strings
  115. let g:php_htmlInStrings=1
  116.  
  117. "Auto generate folds by indent
  118. set foldmethod=indent
  119. "But dont show them by default
  120. set foldlevel=20
  121.  
  122. syntax on
  123. filetype plugin indent on
  124. "Fix indents
  125. set tabstop=2
  126. set softtabstop=2
  127. set shiftwidth=2
  128. set relativenumber
  129.  
  130. "Allow backspace to do its thing
  131. set backspace=indent,eol,start
  132.  
  133. "Expand tabs to spaces
  134. set expandtab
  135.  
  136. "Take a guess
  137. set enc=utf-8
  138.  
  139. "Windows specific configuration
  140. if has('win32') || has('win64')
  141.     "Set font
  142.     set gfn=Consolas:h12
  143.     let g:ruby_path="c:\Ruby193\bin"
  144. endif
  145.  
  146. "Change default folder for ~ and .swp files
  147. if( expand($TEMP) == "" )
  148.     "Default for linux
  149.     let s:tempFolder = "/tmp"
  150. else
  151.     "Default for windows
  152.     let s:tempFolder = expand($TEMP)
  153. endif
  154. let &directory=s:tempFolder
  155. let &backupdir=s:tempFolder
  156.  
  157. "Ignore case on searches, unless search contains uppercase
  158. set ignorecase smartcase
  159. set completeopt=longest,menuone
  160. "Highlight searchresults
  161. set hlsearch
  162. "Display suggestions for commands
  163. set wildmenu wildmode=list:full
  164. set incsearch
  165.  
  166. "Hide files from plugins
  167. set wildignore=*/.git/*
  168.  
  169.  
  170. "Compile .as files using enter
  171. autocmd BufNewFile,BufRead *.as nnoremap <buffer> <CR> !mxmlc %<CR>
  172. autocmd BufNewFile,BufRead *.as set filetype=actionscript
  173.  
  174.  
  175. "Set colorscheme
  176. set background=dark
  177. colorscheme solarized
  178.  
  179. "return the syntax highlight group under the cursor ''
  180. function! StatuslineCurrentHighlight()
  181.     let name = synIDattr(synID(line('.'),col('.'),1),'name')
  182.     if name == ''
  183.         return ''
  184.     else
  185.         return '[' . name . ']'
  186.     endif
  187. endfunction
  188.  
  189. "recalculate the tab warning flag when loading and after writing
  190. autocmd BufReadPost,bufwritepost * unlet! b:statusline_tab_warning
  191.  
  192. "return '[&et]' if &et is set wrong
  193. "return '[mixed-indenting]' if spaces and tabs are used to indent
  194. "return an empty string if everything is fine
  195. function! StatuslineTabWarning()
  196.     if !exists("b:statusline_tab_warning")
  197.         let b:statusline_tab_warning = ''
  198.  
  199.         if !&modifiable
  200.             return b:statusline_tab_warning
  201.         endif
  202.  
  203.         let tabs = search('^\t', 'nw') != 0
  204.  
  205.         "find spaces that arent used as alignment in the first indent column
  206.         let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0
  207.  
  208.         if tabs && spaces
  209.             let b:statusline_tab_warning = '[mixed-indenting]'
  210.         elseif (spaces && !&et) || (tabs && &et)
  211.             let b:statusline_tab_warning = ' [&et]'
  212.         endif
  213.     endif
  214.     return b:statusline_tab_warning
  215. endfunction
  216.  
  217. "statusline setup
  218. set statusline=%f "tail of the filename
  219. set statusline+=\
  220.  
  221. "display a warning if fileformat isnt unix
  222. set statusline+=%#warningmsg#
  223. set statusline+=%{&ff!='unix'?'['.&ff.']':''}
  224. set statusline+=%*
  225.  
  226. "display a warning if file encoding isnt utf-8
  227. set statusline+=%{(&fenc!='')?'['.&fenc.']':''}
  228.  
  229. set statusline+=%h "help file flag
  230. set statusline+=%y "filetype
  231. set statusline+=%r "read only flag
  232. set statusline+=%m "modified flag
  233.  
  234. "display a warning if &et is wrong, or we have mixed-indenting
  235. set statusline+=%#error#
  236. set statusline+=%{StatuslineTabWarning()}
  237. set statusline+=%*
  238.  
  239. set statusline+=%#warningmsg#
  240. set statusline+=%{SyntasticStatuslineFlag()}
  241. set statusline+=%*
  242.  
  243. set statusline+=%= "left/right separator
  244.  
  245. function! SlSpace()
  246.     if exists("*GetSpaceMovement")
  247.         return "[" . GetSpaceMovement() . "]"
  248.     else
  249.         return ""
  250.     endif
  251. endfunc
  252. set statusline+=%{SlSpace()}
  253.  
  254. set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
  255. set statusline+=%c, "cursor column
  256. set statusline+=%l/%L "cursor line/total lines
  257. set statusline+=\ %P "percent through file
  258. set laststatus=2
  259.  
  260. "Remap gd to go to definition
  261. nnoremap gd <C-]>
  262. inoremap kj <ESC>
  263.  
  264. "Insert current time with F5
  265. inoremap <F5> <C-R>=strftime("%H:%M:%S")<CR>
  266.  
  267. nnoremap - :Switch<cr>
  268. let g:detectindent_prefered_indent = 2
  269. let g:detectindent_preferred_expandtab = 1
  270. autocmd BufReadPost * :DetectIndent
  271.  
  272. "Set visual bell
  273. set vb
  274.  
  275. au BufCreate ~/vimwiki/index.wiki silent !cd ~/vimwiki/; git pull origin master
  276. au BufWritePost ~/vimwiki/* silent !start sh -c "cd ~/vimwiki/; git add .; git commit -a -m ' - '"
  277. au BufWritePost ~/vimwiki/* silent !cd ~/vimwiki/;git push origin master
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement