sxhkd.vim (530B)
1 if exists("b:did_indent") 2 finish 3 endif 4 5 let b:did_indent = 1 6 7 setlocal indentexpr=GetIndentSXHKD() 8 9 " Only define the function once: 10 if exists("*GetIndentSXHKD") 11 finish 12 endif 13 14 function GetIndentSXHKD() 15 " Find a non-blank line above the current line: 16 let lnum = prevnonblank(v:lnum - 1) 17 18 " No indent for the start of the file: 19 if lnum == 0 20 return 0 21 endif 22 23 let prev_line = getline(lnum) 24 if prev_line =~ '^\s*#' 25 return 0 26 elseif prev_line =~ '\v^\s+' 27 return 0 28 else 29 return &sw 30 endif 31 endfunction