robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
7945732ed7
master
1" Vim filetype plugin file 2" Language: gdscript (Godot game engine scripting language) 3" Maintainer: Maxim Kim <habamax@gmail.com> 4" Website: https://github.com/habamax/vim-gdscript 5" 6" This file has been manually translated from Vim9 script. 7 8if exists ( "b:did_ftplugin" ) |finish |endif 9 10let s: save_cpo = & cpo 11set cpo & vim 12 13let b: did_ftplugin = 1 14let b: undo_ftplugin = 'setlocal cinkeys<' 15 \.. '| setlocal indentkeys<' 16 \.. '| setlocal commentstring<' 17 \.. '| setlocal suffixesadd<' 18 \.. '| setlocal foldexpr<' 19 \.. '| setlocal foldignore<' 20 21setlocal cinkeys -= 0# 22setlocal indentkeys -= 0# 23setlocal suffixesadd = .gd 24setlocal commentstring = #\ %s 25setlocal foldignore = 26setlocal foldexpr = s :GDScriptFoldLevel() 27 28if get ( g:, 'gdscript_recommended_style' , get ( g:, 'filetype_recommended_style' , 1 )) 29setlocal noexpandtab tabstop = 4 softtabstop = 0 shiftwidth = 0 30let b: undo_ftplugin ..= ' | setlocal expandtab< tabstop< softtabstop< shiftwidth<' 31endif 32 33 34function s: GDScriptFoldLevel () abort 35let line = getline ( v: lnum ) 36if line =~? '^\s*$' 37return "-1" 38endif 39 40let sw = shiftwidth () 41let indent = indent ( v: lnum ) / sw 42let indent_next = indent ( nextnonblank ( v: lnum + 1 )) / sw 43 44if indent_next > indent && line =~# ':\s*$' 45return $ ">{indent_next}" 46else 47return $ "{indent}" 48endif 49endfunction 50 51 52if ! exists ( "g:no_plugin_maps" ) 53" Next/Previous section 54function s: NextSection ( back , cnt ) abort 55for n in range ( a: cnt ) 56call search ( '^\s*func\s' , a: back ? 'bW' : 'W' ) 57endfor 58endfunction 59 60" Nvim: <scriptcmd> hasn't been ported yet. 61" nnoremap <silent><buffer> ]] <scriptcmd>NextSection(false, v:count1)<CR> 62" nnoremap <silent><buffer> [[ <scriptcmd>NextSection(true, v:count1)<CR> 63nnoremap <silent><buffer> ]]<Cmd> call <SID> NextSection ( v: false , v: count1 ) <CR> 64nnoremap <silent><buffer> [[<Cmd> call <SID> NextSection ( v: true , v: count1 ) <CR> 65 xmap<buffer><expr> ]]$ '<C-\><C-N>{v:count1}]]m>gv' 66 xmap<buffer><expr> [[ $ '<C-\><C-N>{v:count1}[[m>gv' 67let b: undo_ftplugin ..= 68 \" | silent exe 'unmap <buffer> [['" 69 \.. " | silent exe 'unmap <buffer> ]]'" 70endif 71 72let & cpo = s: save_cpo 73unlet s: save_cpo