comparison runtime/ftplugin/gdscript.vim @ 29996:e37754a13778

Update runtime files Commit: https://github.com/vim/vim/commit/9b03d3e75b4274493bbe76772d7b92238791964c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 30 20:26:34 2022 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Aug 2022 21:30:04 +0200
parents
children ebed259f919f
comparison
equal deleted inserted replaced
29995:29bc4a7d4995 29996:e37754a13778
1 vim9script
2
3 # Vim filetype plugin file
4 # Language: gdscript (Godot game engine scripting language)
5 # Maintainer: Maxim Kim <habamax@gmail.com>
6
7 if exists("b:did_ftplugin") | finish | endif
8
9 b:did_ftplugin = 1
10 b:undo_ftplugin = 'setlocal cinkeys<'
11 \ .. '| setlocal indentkeys<'
12 \ .. '| setlocal commentstring<'
13 \ .. '| setlocal suffixesadd<'
14 \ .. '| setlocal foldexpr<'
15 \ .. '| setlocal foldignore<'
16
17 setlocal cinkeys-=0#
18 setlocal indentkeys-=0#
19 setlocal suffixesadd=.gd
20 setlocal commentstring=#\ %s
21 setlocal foldignore=
22 setlocal foldexpr=GDScriptFoldLevel()
23
24
25 def GDScriptFoldLevel(): string
26 var line = getline(v:lnum)
27 if line =~? '^\s*$'
28 return "-1"
29 endif
30
31 var sw = shiftwidth()
32 var indent = indent(v:lnum) / sw
33 var indent_next = indent(nextnonblank(v:lnum + 1)) / sw
34
35 if indent_next > indent && line =~ ':\s*$'
36 return $">{indent_next}"
37 else
38 return $"{indent}"
39 endif
40 enddef
41
42
43 # Next/Previous section
44 def NextSection(back: bool, cnt: number)
45 for n in range(cnt)
46 search('^\s*func\s', back ? 'bW' : 'W')
47 endfor
48 enddef
49
50 nnoremap <silent><buffer> ]] <scriptcmd>NextSection(false, v:count1)<CR>
51 nnoremap <silent><buffer> [[ <scriptcmd>NextSection(true, v:count1)<CR>
52 xmap <silent><buffer><expr> ]] "\<esc>" .. v:count1 .. ']]m>gv'
53 xmap <silent><buffer><expr> [[ "\<esc>" .. v:count1 .. '[[m>gv'