Azuhmier

.vimrc

Oct 11th, 2019 (edited)
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 27.47 KB | None | 0 0
  1. "" .vimrc
  2. " 2019
  3. " Created by Azuhmier
  4. "-------------------------------------------------------------------------------------------------------------------------------------------"
  5. "==============================================================="
  6. "=========================|| PRESETS ||========================="{{{
  7. "==============================================================="
  8.   execute pathogen#infect()
  9.   set nocompatible
  10.   filetype plugin indent on
  11.   syntax on
  12.   if exists("t:term_win")==1
  13.         unlet t:term_win
  14.   endif
  15.  
  16.   let g:loaded_matchparen=1
  17.   let g:netrw_winsize = 10
  18.   let g:netrw_preview = 1
  19.   let g:netrw_mousemaps = 0
  20.   let g:indentLine_enabled = 0
  21.   let g:netrw_use_errorwindow = 0
  22.   let g:netrw_liststyle= 0
  23.   let g:netrw_keepdir=0
  24.  
  25.   set path=.,/usr/local/Cellar/vim/8.1.2250/share/vim/vim81/**,/Users/Work/Documents/hmofa/**,/Users/Work/.hmofa/**,/Users/Work/.vim/**,/Users/Work
  26.  
  27.  
  28. ""}}}
  29. "============================================================"
  30. "=========================|| AUTO CMDS ||===================="{{{
  31. "============================================================"
  32.   "-------------------"
  33.   "-----| IEL |-----{{{
  34.   "-------------------"
  35.     augroup IEL
  36.       au!
  37.       au InsertEnter  * call s:VVenter()
  38.       au InsertLeave  * call s:VVclose()
  39.     augroup end
  40.  
  41.       "-----| s:VVenter() |-----"
  42.       function s:VVenter()
  43.         hi cursorlineNR    ctermfg=blue       ctermbg=yellow
  44.       endfunction
  45.  
  46.       "-----| s:VVclose() |-----"
  47.       function s:VVclose()
  48.         hi cursorlineNR    ctermfg=white      ctermbg=NONE
  49.       endfunction
  50.   "}}}
  51.   "---------------------"
  52.   "-----| MISC |-----{{{
  53.   "---------------------"
  54.     augroup MISC
  55.       au!
  56.       au BufEnter * silent! :lcd%:p:h " automatically changes Vim's working dir to the current file
  57.       au Filetype perl set commentstring=#%s
  58.       au Filetype perl set shiftwidth=2
  59.       au Filetype perl set tabstop=2
  60.       au SourcePre ~/.vimrc set stl=
  61.       au FileType netrw setl bufhidden=wipe
  62.       au FileType netrw setl bufhidden=wipe
  63.       au FileType * setlocal fo=tcq
  64.       au FileType netrw let g:netrw_bookmarklist= [
  65.             \'/Users/Work/.vim/',
  66.             \'/Users/Work/Documents/hmofa/',
  67.             \'/Users/Work/Documents/hmofa/pastebin/',
  68.             \'/Users/Work/Documents/hmofa/pastebin/code_examples/goto_files/',
  69.             \'/Users/Work/Documents/hmofa/fics/',
  70.             \'/usr/local/',
  71.             \'/usr/local/Cellar/',
  72.             \]
  73.     augroup END
  74.   "}}}
  75. "}}}
  76. "================================================================="
  77. "=========================|| FUNCTIONS ||========================="{{{
  78. "================================================================="
  79.   "-------------------------------------"
  80.   "-----| ReturnHighlightTerm() |-----{{{
  81.   "-------------------------------------"
  82.     function ReturnHighlightTerm(group, term)
  83.       " Store output of group to variable
  84.       let l:output = execute('hi ' . a:group)
  85.       " Find the term we're looking for
  86.       return matchstr(l:output, a:term.'=\zs\S*')
  87.     endfunction
  88.   "}}}
  89. "}}}
  90. "================================================================"
  91. "=========================|| COOMANDS ||========================="{{{
  92. "================================================================"
  93.   "---------------------"
  94.   "-----| :SS |------"{{{
  95.   "---------------------"
  96.     command -nargs=0 SS execute "mks! ~/.vim/sessions/hmofa_tagging.vim | mkview! ~/.vim/views/hmofa_tagging.vim | echo 'saved'"
  97.   "}}}
  98.   "-----------------------"
  99.   "-----| :Foobar |------{{{
  100.   "-----------------------"
  101.     command  -nargs=+ Foobar call Foobar_fun(<q-args>)
  102.     " 1) Makes copy of current buffer to register @+
  103.     " 2) Makes global substitute on register contents of @+
  104.     " 3) Makee line substitutions for every line that matches {pattern}
  105.       "-----| Foobar_fun() |-----"
  106.       function Foobar_fun(ARGS)
  107.         " FUN VARS "
  108.         let l:args = a:ARGS
  109.         "-----| MAIN |-----"
  110.         exe "normal cx"
  111.         let l:reg_contents =  getreg("+")
  112.         let l:reg_array    =  split(l:reg_contents,"\n")
  113.  
  114.         let l:first_done = 0
  115.         for l:line in l:reg_array
  116.             if l:line =~ "^\["
  117.               let l:ops  = matchstr(l:line, '\]\[.*\]\zs.*')
  118.               let l:tags = substitute(l:line, '\V'.l:ops, '', "g")
  119.               let l:tags = substitute(l:tags, ',\s', ',', "g")
  120.               let l:tags = substitute(l:tags, '[^\]\[,]\+', ';&;', "g")
  121.               let l:tags = substitute(l:tags, ',', ' ', "g")
  122.               let l:line = l:tags.l:ops
  123.             endif
  124.             if l:first_done == 0
  125.               let @+ = l:line."\n"
  126.             else
  127.               let @+ .= l:line."\n"
  128.             endif
  129.           let l:first_done = 1
  130.         endfor
  131.       endfunction
  132.   "}}}
  133.   "-----------------------"
  134.   "-----| :Kosher |------{{{
  135.   "-----------------------"
  136.     command -range=% Kosher call Kosher_fun()
  137.     "-----| s:myfun() |-----"
  138.     function Kosher_fun()
  139.       try
  140.         let l:alt_file = expand('%:p')
  141.         %y+ | enew | execute  'normal! "+p ggdd'
  142.         setlocal  bufhidden=wipe nobuflisted noswapfile buftype=nofile
  143.         let l:succeeded = 1
  144.         %s/\c\(post.*\)*virgin?*, \|\c\(post.*\)*virgin?*\|\c, \(post.*\)*virgin?*\|\cexperienced?*, \|\cexperienced?*\|\c, experienced?*//g
  145.       catch
  146.         if !exists('l:succeeded')
  147.           echoerr "something went wrong"
  148.         endif
  149.       finally
  150.       endtry
  151.         let @# = l:alt_file
  152.     endfunction
  153.   "}}}
  154.   "------------------"
  155.   "-----| :R |-----{{{
  156.   "------------------"
  157.     command -complete=shellcmd -nargs=+ R call s:RunShellCommand(<q-args>)
  158.     " run terminal command and return STDOUT to a scratch buffer and....
  159.     " -complete=shellcmd means tab style completion of shell commands.
  160.     " - s:RunShellCommand(cmdline) -"
  161.       "-----| s:RunShellCommand() |-----"
  162.       function s:RunShellCommand(cmdline)
  163.         " DRESSING THE ARGUMENTS FOR SHELL EXECUTION
  164.         let l:cwd_buff = getcwd()
  165.         let l:expanded_cmdline = a:cmdline
  166.         for part in split(a:cmdline, ' ')
  167.           if part[0] =~ '\v[%#<]'
  168.            "let l:expanded_part = fnameescape(expand(part))
  169.            "let l:expanded_cmdline = substitute(l:expanded_cmdline, part, l:expanded_part, '')
  170.           endif
  171.         endfor
  172.  
  173.         "-----| Remeber Prog Window |-----"
  174.         let t:prog_win = win_getid()
  175.  
  176.         "-----| BUFFER CREATION |-----"
  177.         " IF - STDOUT window does not exist
  178.         if exists("t:term_win")==0
  179.           vert bo new
  180.           "exe "normal \<C-W>J"
  181.           let t:term_win = win_getid()
  182.         " ELSEIF - STDOUT window was deleted
  183.         elseif win_gotoid(t:term_win)==0
  184.           vert bo new
  185.           "exe "normal \<C-W>J"
  186.           let t:term_win = win_getid()
  187.         else
  188.           silent execute "call win_gotoid(t:term_win)"
  189.           silent execute "0,$ normal dd"
  190.         endif
  191.         execute "cd ".l:cwd_buff
  192.  
  193.         "-----| BUFFER WRITING |-----"
  194.         setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
  195.         call setline(1,'you entered: ' .  a:cmdline)
  196.         call setline(2,substitute(getline(1),'.','=','g'))
  197.         silent execute '$read! '. l:expanded_cmdline
  198.  
  199.         silent execute "call win_gotoid(t:prog_win)"
  200.  
  201.       endfunction
  202.   "}}}
  203.   "-------------------------"
  204.   "-----| BufOnly |-----{{{
  205.   "-------------------------"
  206.     "
  207.     " Copyright November 2003 by Christian J. Robinson <infynity@onewest.net>
  208.     "
  209.     " Distributed under the terms of the Vim license.  See ":help license".
  210.     "
  211.     " Usage:
  212.     "
  213.     " :Bonly / :BOnly / :Bufonly / :BufOnly [buffer]
  214.     "
  215.     " Without any arguments the current buffer is kept.  With an argument the
  216.     " buffer name/number supplied is kept.
  217.  
  218.     "-----| :Bonly |-----"
  219.     command -nargs=? -complete=buffer -bang Bonly
  220.           \ :call BufOnly('<args>', '<bang>')
  221.     "-----| :BOnly |-----"
  222.     command -nargs=? -complete=buffer -bang BOnly
  223.           \ :call BufOnly('<args>', '<bang>')
  224.     "-----| :Bufonly |-----"
  225.     command -nargs=? -complete=buffer -bang Bufonly
  226.           \ :call BufOnly('<args>', '<bang>')
  227.     "-----| :BufOnly |-----"
  228.     command -nargs=? -complete=buffer -bang BufOnly
  229.           \ :call BufOnly('<args>', '<bang>')
  230.       "-----| :BufOnly() |-----"
  231.       function BufOnly(buffer, bang)
  232.         if a:buffer == ''
  233.           " No buffer provided, use the current buffer.
  234.           let l:buffer = bufnr('%')
  235.         elseif (a:buffer + 0) > 0
  236.           " A buffer number was provided.
  237.           let l:buffer = bufnr(a:buffer + 0)
  238.         else
  239.           " A buffer name was provided.
  240.           let l:buffer = bufnr(a:buffer)
  241.         endif
  242.  
  243.         if l:buffer == -1
  244.           echohl ErrorMsg
  245.           echomsg "No matching buffer for" a:buffer
  246.           echohl None
  247.           return
  248.         endif
  249.  
  250.         let l:last_buffer = bufnr('$')
  251.  
  252.         let l:delete_count = 0
  253.         let l:n = 1
  254.         while l:n <= l:last_buffer
  255.           if l:n != buffer && buflisted(l:n)
  256.             if a:bang == '' && getbufvar(l:n, '&modified')
  257.               echohl ErrorMsg
  258.               echomsg 'No write since last change for buffer'
  259.                     \ n '(add ! to override)'
  260.               echohl None
  261.             else
  262.               silent exe 'bdel' . a:bang . ' ' . l:n
  263.               if ! buflisted(l:n)
  264.                 let l:delete_count = l:delete_count+1
  265.               endif
  266.             endif
  267.           endif
  268.           let l:n = l:n+1
  269.         endwhile
  270.  
  271.         if l:delete_count == 1
  272.           echomsg l:delete_count "buffer deleted"
  273.         elseif l:delete_count > 1
  274.           echomsg l:delete_count "buffers deleted"
  275.         endif
  276.  
  277.       endfunction
  278.  
  279.   "}}}
  280. ""}}}
  281. "==============================================================="
  282. "=========================|| MAPS ||=========================={{{
  283. "==============================================================="
  284.   let mapleader = "-"
  285.   nnoremap K :bn<enter>
  286.   nnoremap gx yiW:!open <cWORD><CR> <C-r>" & <CR><CR>
  287.   nnoremap cx :%y+<Enter>
  288.   nnoremap <leader>p "+p
  289.   nnoremap <leader>gf <C-W><C-f>
  290.   nnoremap <leader>ev :e $MYVIMRC<cr>
  291.   nnoremap <leader>sv :tabdo source $MYVIMRC<cr>
  292.   nnoremap <space> i<space><esc><space>
  293.   nnoremap o o<Esc>
  294.   nnoremap O O<Esc>
  295.   "vim.txt <leader>em
  296.   "protocals <leader>ep
  297.   "note <leader>en
  298.   "journel entry <leader>ej
  299.   noremap <esc>k :tabp<enter>
  300.   noremap <esc>j :tabn<enter>
  301.   noremap <esc>J :tabmove+<enter>
  302.   noremap <esc>K :tabmove-<enter>
  303.   noremap <leader>t :IndentLinesToggle<enter>
  304.  
  305.   vnoremap <leader>y "+y
  306.   vnoremap // y/\V<C-R>"<ESC>
  307.  
  308.   inoremap jj <ESC>
  309.  
  310.   "------------------------------"
  311.   "-----| <F2> |---------------{{{
  312.   "------------------------------"
  313.     nnoremap <F2> :call InsertTime()<enter>
  314.     inoremap <F2> <C-O>:call InsertTime()<enter>
  315.       fun InsertTime()
  316.         let l:CurrentTime = strftime("%a %m/%d/%y %X")
  317.         exe "normal i" . l:CurrentTime
  318.       endfun
  319.  
  320.   "}}}
  321.   "------------------------------"
  322.   "-----| <F3> |---------------{{{
  323.   "------------------------------"
  324.     nnoremap <F3> :call Ins_head()<enter>i
  325.     inoremap <F3> <C-O>:call Ins_head()<enter>
  326.  
  327.       fun Ins_head()
  328.         let l:CurrentTime = strftime("%a %m/%d/%y %X")
  329.         let l:File_Name = getreg("%")
  330.         let l:string = "#===============================================================================\r
  331.                        \#\r
  332.                        \#         FILE: " . l:File_Name . "\r
  333.                        \#\r
  334.                        \#  DESCRIPTION:  \r
  335.                        \#\r
  336.                        \#       AUTHOR: Azuhmier (aka taganon), azuhmier@gmail\.com\r
  337.                        \# ORGANIZATION: HMOFA\r
  338.                        \#      VERSION: 1.0\r
  339.                        \#      Created: " . l:CurrentTime . "\r
  340.                        \#===============================================================================\r"
  341.         exe 'normal i' . l:string . "\<esc>?DESCRIPTION: \\zs \<cr>"
  342.       endfun
  343.   "}}}
  344.   "-------------------------------"
  345.   "-----| <M-D> |---------------{{{
  346.   "-------------------------------"
  347.     nnoremap <esc>d :call Ins_bot()<enter>i
  348.     inoremap <esc>d <C-O>:call Ins_bot()<enter>
  349.  
  350.       fun Ins_bot()
  351.         let l:string = "#-----|  |-----#"
  352.         exe 'normal i' . l:string . "\<esc>?|\<cr>h"
  353.       endfun
  354.   "}}}
  355.   "-------------------------------"
  356.   "-----| <M-S> |---------------{{{
  357.   "-------------------------------"
  358.     nnoremap <esc>s :call Ins_mid()<enter>i
  359.     inoremap <esc>s <C-O>:call Ins_mid()<enter>
  360.  
  361.       fun Ins_mid()
  362.         let l:string = "#----------------------------------------------#\r
  363.                        \#-----|  |---------------#\r
  364.                        \#----------------------------------------------#\r"
  365.         exe 'normal i' . l:string . "\<esc>?|\<cr>h"
  366.       endfun
  367.   "}}}
  368.   "-------------------------------"
  369.   "-----| <M-A> |---------------{{{
  370.   "-------------------------------"
  371.     nnoremap <esc>a :call Ins_top()<enter>i
  372.     inoremap <esc>a <C-O>:call Ins_top()<enter>
  373.  
  374.       fun Ins_top()
  375.         let l:string = "#=============================================================================================#\r
  376.                        \#==================================||  ||===================================#\r
  377.                        \#=============================================================================================#"
  378.         exe 'normal i' . l:string . "\<esc>?|\<cr>nh"
  379.       endfun
  380.   "}}}
  381.   "--------------------"
  382.   "-----| -dp |------{{{
  383.   "--------------------"
  384.   noremap <leader>dp :call FUN_startprofile()<enter>
  385.   fun FUN_startprofile()
  386.     exe 'profile start profile.log'
  387.     exe 'profile func *'
  388.     exe 'profile file *'
  389.     echo 'profiling'
  390.   endfun
  391.   "}}}
  392.   "------------------------------"
  393.   "-----| netrw_mapping |------{{{
  394.   "------------------------------"
  395.     fun! ExampleUserMap(islocal)
  396.       exe 'normal jp'
  397.       let retval= ["refresh"]
  398.       return retval
  399.     endfun
  400.  
  401.     fun! ExampleUserMap_2(islocal)
  402.       exe 'normal kp'
  403.       let retval= ["refresh"]
  404.       return retval
  405.     endfun
  406.  
  407.     fun! ExampleUserMap_3(islocal)
  408.       exe 'Ex ~'
  409.       let retval= ["refresh"]
  410.       return retval
  411.     endfun
  412.  
  413.     let g:Netrw_UserMaps = [["\<esc>h","ExampleUserMap_2"],["\<esc>n","ExampleUserMap"],["~","ExampleUserMap_3"]]
  414.  
  415.   "}}}
  416.   "-----------------------------"
  417.   "-----| -g  |---------------{{{
  418.   "-----------------------------"
  419.     nnoremap <Leader>g :call LoadPerlModule()<CR>
  420.       function! LoadPerlModule()
  421.         execute 'e `perldoc -l ' . expand("<cWORD>") . '`'
  422.       endfunction
  423.   "}}}
  424.   "----------------------------"
  425.   "-----| cd |---------------{{{
  426.   "----------------------------"
  427.   nnoremap cd :e.<enter>
  428.   "}}}
  429.   "-------------------"
  430.   "-----| -cd |------{{{
  431.   "-------------------"
  432.     nnoremap <leader>cd :EXD<enter>
  433.         command EXD call EXBD()
  434.             function EXBD()
  435.                 silent execute ":e."
  436.             try
  437.                 silent execute ":bd#"
  438.             catch
  439.             finally
  440.             endtry
  441.             endfunction
  442.   "}}}
  443.   "------------------"
  444.   "-----| -r |-----{{{
  445.   "------------------"
  446.     nnoremap <leader>r :W<enter> " runs the file of the current buffer in its respective interpretor and/or " ...compiler
  447.       "-----| :W |-----"
  448.       command W call W_run()
  449.         "-----| W_run() |-----{{{
  450.         function W_run()
  451.            let l:file_types = {'perl':'perl','php':'php','vim':'so','python':'python','cpp':'g++','c':'gcc'}
  452.              if has_key(l:file_types,&filetype)
  453.               let l:path = expand('%:p')
  454.  
  455.                if &filetype == 'vim'
  456.                  silent execute  "w ".l:path
  457.                  execute "source ".l:path
  458.  
  459.                elseif &filetype == 'cpp'
  460.                  silent execute  "w ".l:path
  461.                  let l:path_2 = substitute(l:path,'\.cpp','\.out',"")
  462.                  execute "R g++ ".l:path." -o ".l:path_2
  463.                  execute "R ".l:path_2
  464.  
  465.                elseif &filetype == 'c'
  466.                  silent execute  "w ".l:path
  467.                  let l:path_2 = substitute(l:path,'\.c','\.out',"")
  468.                  execute "R gcc ".l:path." -o ".l:path_2
  469.                  execute "R ".l:path_2
  470.  
  471.                else
  472.                silent execute  "w ".l:path
  473.                silent exe  "R ".l:file_types[&filetype]." ".l:path
  474.                endif
  475.  
  476.             else
  477.               echoerr "Not A Executable File!"
  478.  
  479.             endif
  480.  
  481.         endfunction
  482.  
  483.         "}}}
  484.  
  485.   "}}}
  486.   "------------------"
  487.   "-----| -R |-----{{{
  488.   "------------------"
  489.     nnoremap <leader>R :Win<enter>
  490.         "-----| :W_in |-----"
  491.         command Win call W_arg()
  492.           "-----| W_arg() |-----"
  493.           function W_arg()
  494.  
  495.            let l:file_types = {'perl':'perl','php':'php','python':'python'}
  496.              if has_key(l:file_types,&filetype)
  497.               let l:input =  input("Insert ARGS: ")
  498.                       let l:path = expand('%:p')
  499.                       silent execute  "w ".l:path
  500.                       silent execute  "R ".l:file_types[&filetype]." ".l:path." ".l:input
  501.              else
  502.               echoerr "Not A Executable File!"
  503.              endif
  504.           endfunction
  505.  
  506.   "}}}
  507.   "---------------------"
  508.   "-----| <C-k> |-----{{{
  509.   "---------------------"
  510.     nnoremap <C-K> :LSA<enter>
  511.         "-----| :LSA |-----"
  512.         command LSA call s:getLS()
  513.         let w:BH=[] " declare the window variable 'BH' as a list
  514.           "-----| s:getLS() |-----"
  515.           function s:getLS()
  516.  
  517.               " IF STATEMENT - no saving attempts to help files
  518.               if expand('%:p') =~ '/usr/local/Cellar/vim/8.1.1900/share/vim/vim81/doc/.*.txt'
  519.                   setlocal buftype=nofile nobuflisted
  520.               endif
  521.  
  522.             try
  523.               " IF STATEMENT - no saving attempts to buffers of type  'nofile'
  524.               if &buftype !='nofile'
  525.                   execute ':w'
  526.               else
  527.               endif
  528.             catch
  529.             finally
  530.             endtry
  531.               " IF STATEMENT - determins if the current file is a netrw directory (need to change it to unloaded)
  532.               if getftype(expand('%:p')) != 'dir'
  533.                   if &buftype != 'nofile'
  534.                       let l:curbuf=bufnr("%") "get current buffer number as 'curbuf'
  535.                       call add(w:BH, string(l:curbuf)) "add the current buffer number to the end of the list 'BH'
  536.                   endif
  537.               endif
  538.  
  539.               " IF STATEMENTS - keep 'BH' from having duplicates and/or getting too large
  540.               if len(w:BH) > 1
  541.                   if w:BH[0] == w:BH[-1] "checks whether the first and last elements of the list 'BH' are equal
  542.                       let w:BH = [string(l:curbuf)] "set the list 'BH' to the buffer number
  543.                   endif
  544.               endif
  545.  
  546.               " get list of buffer numbers that are non visible
  547.               redir @"|silent execute 'ls'|redir END|enew|put
  548.               setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
  549.  
  550.           " try statment for when there are no non-visible loaded buffers
  551.           try
  552.               " cleaning up the :ls output
  553.               redir @"|silent execute 'g/\_^\s*\d\+\s.[^a]'|redir END|enew|silent put
  554.               setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
  555.               silent execute '%s/\d\+\s*\d\+\zs.*\_$\ze//'
  556.           " if try was sucessful
  557.           let l:succeeded=1
  558.               silent execute '%s/\_^\s*\d*\s\+//'
  559.               silent execute '%g/^$/d'
  560.               let l:buff=getline(1, '$') " sets 'buff' as list of buff numbers of buffers that are not visible
  561.               let l:LL = len(w:BH) " get length of list 'BH'
  562.               let l:LL -= 1 " subtracts the value of LL by one
  563.  
  564.               " FOR LOOP - find the index of every member of 'BH' in the list 'Buff'
  565.               for i in range(0,l:LL)
  566.                   let l:qqq=index(l:buff, w:BH[i]) " returns a -1 if w:BH[i] is not a member of buff
  567.  
  568.                   " IF STATMENT
  569.                   if l:qqq ==-1 " checks if any members of w:BH or visible buffers
  570.                   elseif l:qqq != -1
  571.                        call  remove(l:buff, l:qqq) " removes buffnumbers that are already in 'BH'
  572.                   endif
  573.  
  574.               endfor
  575.  
  576.               " manipulating buff and moving to next buff
  577.               let l:buff = buff + w:BH
  578.               silent execute "b ". l:buff[0]
  579.  
  580.           " Catch statment
  581.            catch
  582.               if !exists('l:succeeded')
  583.                   let w:BH = []
  584.                   execute ':bp' | echom 'ERROR: no non-visible buffers'
  585.               endif
  586.            finally
  587.            endtry
  588.            endfunction
  589.  
  590.         "-----| AU - defines 'w:BH' when new tab |-----"
  591.         augroup LSA"
  592.             au!
  593.             au TabNew * call s:ExistBH()
  594.                 function s:ExistBH()
  595.                     if exists("w:BH")==0
  596.                         let w:BH = []
  597.                     endif
  598.                 endfunction
  599.  
  600.         "-----| AU - defines 'w:BH' when new window |-----"
  601.             au WinNew * call s:ExistBHH()
  602.                 function s:ExistBHH()
  603.                     if exists("w:BH")==0
  604.                         let w:BH = []
  605.                     endif
  606.                 endfunction
  607.         augroup end
  608.  
  609.     "}}}
  610.   "-------------------"
  611.   "-----| -f |------{{{
  612.   "-------------------"
  613.     " Toggles hilighting the entire current line
  614.     nnoremap <leader>f :call WB()<cr>
  615.         function WB()
  616.  
  617.             if ReturnHighlightTerm('CursorLine', 'ctermbg') == 231
  618.  
  619.                 hi CursorLine    cterm=NONE    ctermfg=NONE    ctermbg=NONE
  620.             else
  621.                 hi CursorLine    cterm=NONE    ctermfg=darkgrey    ctermbg=white
  622.             endif
  623.         endfunction
  624.   "}}}
  625.   "------------------"
  626.   "-----| + |------{{{
  627.   "------------------"
  628.     nnoremap + :call HS()<cr>
  629.       function HS()
  630.         if &hlsearch == 1
  631.           set nohlsearch
  632.         else
  633.           set hlsearch
  634.           hi search ctermbg=blue ctermfg=gray
  635.         endif
  636.       endfunction
  637.  
  638.   "}}}
  639.   "------------------"
  640.   "-----| S |------{{{
  641.   "------------------"
  642.     nnoremap S :call VE_toggle()<cr>
  643.       function VE_toggle()
  644.         if &ve == 'onemore'
  645.             set ve=all
  646.         else
  647.             set ve=onemore
  648.         endif
  649.         echo &ve
  650.       endfunction
  651.  
  652.   "}}}
  653. "======================================================================="
  654. "=========================|| OPTIONS/HILIGHTS ||========================"{{{
  655. "======================================================================="
  656.     set ruler                      " ruler d oes not work when statusline is manually set by user
  657.     set wildmenu
  658.     set wildmode=list:longest,full
  659.     set foldmethod=marker
  660.     set report=0
  661.     set ve=onemore
  662.   "------------------------------------------------"
  663.   "-----| MOUSE/KEYBOARD Tabs and Titles |------{{{
  664.   "------------------------------------------------"
  665.     set mouse=a
  666.     set selection=exclusive
  667.     set number
  668.     set tabstop=2
  669.     set shiftwidth=2
  670.     set smarttab
  671.     set expandtab                   " The expandtab property will ensure that when you hit tab it will actually use spaces.
  672.     set autoindent
  673.     set backspace=indent,eol,start  " To allow backspacing over everything in insert mode (including automatically inserted indentation, line breaks and start of insert)
  674.   "}}}
  675.   "------------------------"
  676.   "-----| SESSION |------{{{
  677.   "------------------------"
  678.     set ssop-=options               " do not store global and local values in a session
  679.     set ssop-=folds                 " do not store foldw
  680.   "}}}
  681.   "-----------------------"
  682.   "-----| SEARCH |------{{{
  683.   "-----------------------"
  684.     set shortmess-=S               " shows search count message when searching
  685.   "}}}
  686.   "-----------------------------------"
  687.   "-----| TABS/TITLES/STATUS |------{{{
  688.   "-----------------------------------"
  689.     " tab pages line, where there are no labels
  690.     hi TabLineFill   cterm=NONE         ctermfg=white       ctermbg=black
  691.     hi TabLine       cterm=underline    ctermfg=white       ctermbg=black
  692.     hi TabLineSel    cterm=NONE         ctermfg=white       ctermbg=darkgrey
  693.     hi Title         cterm=NONE         ctermfg=white       ctermbg=NONE
  694.     hi VertSplit                        ctermfg=grey
  695.     set showtabline=2
  696.  
  697.     " the '!' means to treat the following as a expression
  698.     set tabline=%!MyTabLine()
  699.       "-----| MyTabline() |-----{{{
  700.       fun MyTabLine()
  701.         let s = ''
  702.         let t = tabpagenr() " current tab number
  703.         let i = 1
  704.         while i <= tabpagenr('$')
  705.           let buflist = tabpagebuflist(i) " list of buffer numbers
  706.           let winnr = tabpagewinnr(i) " number of windows
  707.           let s .= '%' . i . 'T'
  708.           let s .= (i == t ? '%1*' : '%2*')
  709.  
  710.           let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
  711.  
  712.           let bufnr = buflist[winnr - 1]
  713.           let file = bufname(bufnr)
  714.           let buftype = getbufvar(bufnr, '&buftype')
  715.  
  716.           let nwins = tabpagewinnr(i, '$')
  717.           if nwins > 1
  718.             let s .= ' '.nwins
  719.           endif
  720.  
  721.           "-| filename |-"
  722.           if buftype == 'help'
  723.  
  724.               let file = 'help:' . fnamemodify(file, ':t:r')
  725.  
  726.           elseif buftype == 'quickfix'
  727.               let file = 'quickfix'
  728.  
  729.           elseif buftype == 'nofile'
  730.               let file = '[scratch]'
  731.  
  732.           else
  733.               let file = pathshorten(fnamemodify(file, ':t'))
  734.               if getbufvar(bufnr, '&modified')
  735.                   let file = '+' . file
  736.               endif
  737.  
  738.           endif
  739.  
  740.           if file == '' && buftype != 'nofile'
  741.               let file = '[No Name]'
  742.           endif
  743.  
  744.           let s .= ' ' . file
  745.  
  746.  
  747.           let s .= ' '
  748.           let i = i + 1
  749.  
  750.     endwhile
  751.  
  752.     let s .= '%T%#TabLineFill#%='
  753.     let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
  754.     return s
  755.       endfun
  756.  
  757.       "}}}
  758.  
  759.     " StatusLine
  760.     hi statusline    cterm=NONE    ctermfg=white       ctermbg=darkgrey
  761.     hi StatusLineNC  cterm=NONE    ctermfg=black       ctermbg=darkgrey
  762.     set laststatus=2               " To display the status line always
  763.     set statusline+=%F             " Full path to the file in the buffer.
  764.     set statusline+=%=               " Separation point between left and right aligned items.
  765.     set statusline+=%c/%l/%L       " Evaluate expression between '%{' and '}' and substitute result.
  766.   "}}}
  767.   "---------------------------"
  768.   "-----| CursorLine |------{{{
  769.   "---------------------------"
  770.     set cursorline
  771.     hi LineNr        cterm=NONE    ctermfg=red         ctermbg=NONE
  772.     hi Cursor        cterm=NONE    ctermfg=white       ctermbg=blue
  773.     hi CursorLineNR  cterm=NONE    ctermfg=white       ctermbg=NONE
  774.     hi CursorLine    cterm=NONE    ctermfg=NONE        ctermbg=NONE
  775.   "}}}
  776.   "-------------------------"
  777.   "-----| Spelling |------{{{
  778.   "-------------------------"
  779.     hi SpellLocal ctermbg=blue
  780.   "}}}
  781.   "-----------------------"
  782.   "-----| FORMAT |------{{{
  783.   "-----------------------"
  784.     set fo=tcq
  785.     set wrap
  786.     set linebreak
  787.     set nolist  " list disables linebreak
  788.   "}}}
  789.   "-------------------------"
  790.   "-----| SPELLING |------{{{
  791.   "-------------------------"
  792.     hi SpellBad ctermbg=red
  793.   "}}}
  794.   "-----------------------"
  795.   "-----| SYNTAX |-----{{{
  796.   "-----------------------"
  797.     hi Comment ctermfg = 27
  798.     hi Folded ctermfg=6 ctermbg = 236
  799.   "}}}
  800. "}}}
Add Comment
Please, Sign In to add comment