robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
8634bd46b2
master
1" Vim indent file 2" Language: Justfile 3" Maintainer: Peter Benjamin <@pbnj> 4" Last Change: 2025 Jan 19 5" Credits: The original author, Noah Bogart <https://github.com/NoahTheDuke/vim-just/> 6 7" Only load this indent file when no other was loaded yet. 8if exists ( "b:did_indent" ) 9finish 10endif 11let b: did_indent = 1 12 13setlocal indentexpr = GetJustfileIndent () 14setlocal indentkeys = 0},0),!^F,o,O,0=''',0=\"\"\" 15 16let b: undo_indent = "setlocal indentexpr< indentkeys<" 17 18if exists ( "*GetJustfileIndent" ) 19finish 20endif 21 22function GetJustfileIndent () 23if v: lnum < 2 24return 0 25endif 26 27let prev_line = getline ( v: lnum - 1 ) 28let last_indent = indent ( v: lnum - 1 ) 29 30if getline ( v: lnum ) =~ "\\v^\\s+%([})]|'''$|\"\"\"$)" 31return last_indent - shiftwidth () 32elseif prev_line =~ '\V#' 33return last_indent 34elseif prev_line =~ "\\v%([:{(]|^.*\\S.*%([^']'''|[^\"]\"\"\"))\\s*$" 35return last_indent + shiftwidth () 36elseif prev_line =~ '\\$' 37if v: lnum == 2 || getline ( v: lnum - 2 ) !~ '\\$' 38if prev_line =~ '\v:\=@!' 39return last_indent + shiftwidth () + shiftwidth () 40else 41return last_indent + shiftwidth () 42endif 43endif 44elseif v: lnum > 2 && getline ( v: lnum - 2 ) =~ '\\$' 45return last_indent - shiftwidth () 46elseif prev_line =~ '\v:\s*%(\h|\()' && prev_line !~ '\V:=' 47return last_indent + shiftwidth () 48endif 49 50return last_indent 51endfunction