vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

sshconfig.vim (796B)


      1 " Vim indent file
      2 " Language: ssh config file
      3 " Maintainer: JasonKim <git@jasonk.me>
      4 " Last Change: 2020 May 16
      5 
      6 if exists("b:did_indent")
      7   finish
      8 endif
      9 let b:did_indent = 1
     10 
     11 setlocal autoindent
     12 setlocal indentexpr=GetSshconfigIndent(v:lnum)
     13 setlocal indentkeys=o,O,*<Return>,0=~host\ ,0=~match\ ,0#,!^F
     14 
     15 let b:undo_indent = "setlocal autoindent< indentexpr< indentkeys<"
     16 
     17 if exists("*GetSshconfigIndent")
     18   finish
     19 endif
     20 
     21 function GetSshconfigIndent(lnum)
     22   let sw = shiftwidth()
     23   let prev_lnum = prevnonblank(a:lnum - 1)
     24   let curr_lnum = a:lnum
     25   let prev_line = getline(prev_lnum)
     26   let curr_line = getline(curr_lnum)
     27   if curr_line =~? '^\s*\(host\|match\)\s'
     28     return 0
     29   elseif prev_line =~? '^\s*\(host\|match\)\s'
     30     return sw
     31   else
     32     return indent(prev_lnum)
     33   endif
     34 endfunction