annotate runtime/ftplugin/gdscript.vim @ 31686:966f1213dd35 v9.0.1175

patch 9.0.1175: the set_ref_in_item() function is too long Commit: https://github.com/vim/vim/commit/ea125393af01ecaf75cee8e085a57f8143f3ae3e Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jan 11 11:46:17 2023 +0000 patch 9.0.1175: the set_ref_in_item() function is too long Problem: The set_ref_in_item() function is too long. Solution: Use a separate function for more complicated types. (Yegappan Lakshmanan, closes #11802)
author Bram Moolenaar <Bram@vim.org>
date Wed, 11 Jan 2023 13:00:05 +0100
parents 0827d3d6d8c0
children 8195572b0b15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29996
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 vim9script
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 # Vim filetype plugin file
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 # Language: gdscript (Godot game engine scripting language)
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 # Maintainer: Maxim Kim <habamax@gmail.com>
30085
ebed259f919f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29996
diff changeset
6 # Website: https://github.com/habamax/vim-gdscript
29996
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 if exists("b:did_ftplugin") | finish | endif
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 b:did_ftplugin = 1
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 b:undo_ftplugin = 'setlocal cinkeys<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 \ .. '| setlocal indentkeys<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 \ .. '| setlocal commentstring<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 \ .. '| setlocal suffixesadd<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 \ .. '| setlocal foldexpr<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 \ .. '| setlocal foldignore<'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 setlocal cinkeys-=0#
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 setlocal indentkeys-=0#
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 setlocal suffixesadd=.gd
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 setlocal commentstring=#\ %s
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 setlocal foldignore=
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 setlocal foldexpr=GDScriptFoldLevel()
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 def GDScriptFoldLevel(): string
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 var line = getline(v:lnum)
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 if line =~? '^\s*$'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 return "-1"
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 endif
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 var sw = shiftwidth()
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 var indent = indent(v:lnum) / sw
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 var indent_next = indent(nextnonblank(v:lnum + 1)) / sw
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 if indent_next > indent && line =~ ':\s*$'
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 return $">{indent_next}"
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 else
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 return $"{indent}"
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 endif
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 enddef
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43
30324
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
44 if !exists("g:no_plugin_maps")
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
45 # Next/Previous section
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
46 def NextSection(back: bool, cnt: number)
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
47 for n in range(cnt)
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
48 search('^\s*func\s', back ? 'bW' : 'W')
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
49 endfor
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
50 enddef
29996
e37754a13778 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51
30324
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
52 nnoremap <silent><buffer> ]] <scriptcmd>NextSection(false, v:count1)<CR>
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
53 nnoremap <silent><buffer> [[ <scriptcmd>NextSection(true, v:count1)<CR>
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
54 xmap <buffer><expr> ]] $'<C-\><C-N>{v:count1}]]m>gv'
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
55 xmap <buffer><expr> [[ $'<C-\><C-N>{v:count1}[[m>gv'
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
56 b:undo_ftplugin ..=
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
57 \ " | silent exe 'unmap <buffer> [['"
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
58 \ .. " | silent exe 'unmap <buffer> ]]'"
0827d3d6d8c0 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30085
diff changeset
59 endif