robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
5f23ce732d
master
1" Vim indent file 2" Language: Nushell 3" Maintainer: El Kasztano 4" URL: https://github.com/elkasztano/nushell-syntax-vim 5" License: MIT <https://opensource.org/license/mit> 6" Last Change: 2025 Sep 05 7 8" Only load if no other indent file is loaded 9if exists ( "b:did_indent" ) 10finish 11endif 12let b: did_indent = 1 13 14setlocal cindent 15setlocal cinoptions = L0,(s,Ws,J1,j1,+0,f5,m1,i0 16setlocal cinkeys = 0{,0},!^F,o,O,0[,0],0),0# 17 18setlocal autoindent 19setlocal indentkeys = 0{,0},!^F,o,O,0[,0],0),0# 20 21setlocal shiftwidth = 2 22setlocal softtabstop = 2 23setlocal expandtab 24 25setlocal indentexpr = GetNuIndent (v:lnum) 26 27let b: undo_indent = "setl ai< cin< cink< cino< et< inde< indk< sts< sw<" 28 29" only define once 30if exists ( "*GetNuIndent" ) 31finish 32endif 33 34let s: save_cpo = & cpo 35set cpo & vim 36 37function GetNuIndent ( lnum ) 38let prevlnum = prevnonblank ( v: lnum - 1 ) "get number of last non blank line 39let line = getline ( a: lnum ) 40let synname = synIDattr ( synID ( a: lnum , 1 , 1 ), "name" ) 41if ( synname == "nuString" ) || ( synname == "nuComment" ) 42return -1 43endif 44if getline ( prevlnum ) =~ '\%(^.*[$\|^.*[\s*#.*$\)' 45return ( prevlnum > 0 ) * indent ( prevlnum ) + shiftwidth () 46endif 47if getline ( v: lnum ) =~ "^\s*]\>" 48return ( prevlnum > 0 ) * indent ( prevlnum ) - shiftwidth () 49endif 50return cindent ( a: lnum ) 51endfunction 52 53let & cpo = s: save_cpo 54unlet s: save_cpo