Advertisement
mikjaer

Untitled

Jul 7th, 2017
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 5.17 KB | None | 0 0
  1.  
  2. " If you prefer the Omni-Completion tip window to close when a selection is
  3. " made, these lines close it on movement in insert mode or when leaving
  4. " insert mode
  5. "autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
  6.  
  7. set nocompatible
  8.  
  9. " :filetype plugin on
  10. autocmd InsertLeave * if pumvisible() == 0|pclose|endif
  11.  
  12. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
  13. function! NERDTreeQuit()
  14.   redir => buffersoutput
  15.   silent buffers
  16.   redir END
  17. "                     1BufNo  2Mods.     3File           4LineNo
  18.   let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
  19.   let windowfound = 0
  20.  
  21.   for bline in split(buffersoutput, "\n")
  22.     let m = matchlist(bline, pattern)
  23.  
  24.     if (len(m) > 0)
  25.       if (m[2] =~ '..a..')
  26.         let windowfound = 1
  27.       endif
  28.     endif
  29.   endfor
  30.  
  31.   if (!windowfound)
  32.     quitall
  33.   endif
  34. endfunction
  35. "autocmd WinEnter * call NERDTreeQuit()
  36.  
  37. function! Smart_TabComplete()
  38.   let line = getline('.')                         " current line
  39.  
  40.   let substr = strpart(line, -1, col('.')+1)      " from the start of the current
  41.                                                   " line to one character right
  42.                                                   " of the cursor
  43.   let substr = matchstr(substr, "[^ \t]*$")       " word till cursor
  44.   if (strlen(substr)==0)                          " nothing to match on empty string
  45.     return "\<tab>"
  46.   endif
  47.   let has_period = match(substr, '\.') != -1      " position of period, if any
  48.   let has_slash = match(substr, '\/') != -1       " position of slash, if any
  49.   if (!has_period && !has_slash)
  50.     return "\<C-X>\<C-P>"                         " existing text matching
  51.   elseif ( has_slash )
  52.     return "\<C-X>\<C-F>"                         " file matching
  53.   else
  54.     return "\<C-X>\<C-O>"                         " plugin matching
  55.   endif
  56. endfunction
  57. "inoremap <tab> <c-r>=Smart_TabComplete()<CR>
  58. :map <F5> :! clear && php5 %<CR>
  59. :map <F6> :! clear && ./build.sh %<CR>
  60. :map! <F5> <ESC> <F5>
  61. :map! <F6> <ESC> <F6>
  62. autocmd FileType php set omnifunc=phpcomplete#CompletePHP
  63. :set omnifunc=phpcomplete#CompletePHP
  64. :set ttyfast
  65. :set scrolloff=3
  66. ":set colorcolumn=85
  67. ":set cursorline
  68. ":set cursorcolumn
  69. :syntax on
  70. :color desert
  71. :set number
  72. :set ai
  73. :set laststatus=2
  74. :set undofile
  75. "autocmd VimEnter * NERDTree
  76. autocmd VimEnter * wincmd p
  77.  
  78. nmap <silent> <F2> :NERDTreeToggle<CR>
  79. :nnoremap <silent> <C-n> :bnext<CR>
  80. :nnoremap <silent> <C-p> :bprevious<CR>
  81. :set hidden
  82.  
  83. " Bclose
  84.  
  85. " Delete buffer while keeping window layout (don't close buffer's windows).
  86. " Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
  87. if v:version < 700 || exists('loaded_bclose') || &cp
  88.   finish
  89. endif
  90. let loaded_bclose = 1
  91. if !exists('bclose_multiple')
  92.   let bclose_multiple = 1
  93. endif
  94.  
  95. " Display an error message.
  96. function! s:Warn(msg)
  97.   echohl ErrorMsg
  98.   echomsg a:msg
  99.   echohl NONE
  100. endfunction
  101.  
  102. " Command ':Bclose' executes ':bd' to delete buffer in current window.
  103. " The window will show the alternate buffer (Ctrl-^) if it exists,
  104. " or the previous buffer (:bp), or a blank buffer if no previous.
  105. " Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
  106. " An optional argument can specify which buffer to close (name or number).
  107. function! s:Bclose(bang, buffer)
  108.   if empty(a:buffer)
  109.     let btarget = bufnr('%')
  110.   elseif a:buffer =~ '^\d\+$'
  111.     let btarget = bufnr(str2nr(a:buffer))
  112.   else
  113.     let btarget = bufnr(a:buffer)
  114.   endif
  115.   if btarget < 0
  116.     call s:Warn('No matching buffer for '.a:buffer)
  117.     return
  118.   endif
  119.   if empty(a:bang) && getbufvar(btarget, '&modified')
  120.     call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
  121.     return
  122.   endif
  123.   " Numbers of windows that view target buffer which we will delete.
  124.   let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
  125.   if !g:bclose_multiple && len(wnums) > 1
  126.     call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
  127.     return
  128.   endif
  129.   let wcurrent = winnr()
  130.   for w in wnums
  131.     execute w.'wincmd w'
  132.     let prevbuf = bufnr('#')
  133.     if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
  134.       buffer #
  135.     else
  136.       bprevious
  137.     endif
  138.     if btarget == bufnr('%')
  139.       " Numbers of listed buffers which are not the target to be deleted.
  140.       let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
  141.       " Listed, not target, and not displayed.
  142.       let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
  143.       " Take the first buffer, if any (could be more intelligent).
  144.       let bjump = (bhidden + blisted + [-1])[0]
  145.       if bjump > 0
  146.         execute 'buffer '.bjump
  147.       else
  148.         execute 'enew'.a:bang
  149.       endif
  150.     endif
  151.   endfor
  152.   execute 'bdelete'.a:bang.' '.btarget
  153.   execute wcurrent.'wincmd w'
  154. endfunction
  155. command! -bang -complete=buffer -nargs=? Bclose call s:Bclose('<bang>', '<args>')
  156. nnoremap <silent> <Leader>bd :Bclose<CR>
  157.  
  158.  
  159.  
  160. set noundofile
  161. "source ~/.vim/php-doc.vim
  162. "inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
  163. "nnoremap <C-P> :call PhpDocSingle()<CR>
  164. "vnoremap <C-P> :call PhpDocRange()<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement