Skip to content

Commit

Permalink
Update the Vim script functionList
Browse files Browse the repository at this point in the history
 commentExpr
 -----------

 * the UDL targets "legacy" Vim script, in which comments begin with a
   double quote ("), not a hash (#) as in Vim9 script [^1]

 mainExpr, nameExpr
 ------------------

 * allow "namespaced" functions like those encountered in many Vim
   plugins. The conventional pattern is `<vim_script_file_name>#<func_name>`,
   assuming `<vim_script_file_name>` can be found on the file system.
   Any sub-directories must also be part of the name, similar
   to a Java package, e.g.,

    <root_dir>#<sub_dir>#<vim_script_file_name>#<func_name>

   A namespaced function cannot be qualified with `s:` because the
   auto-generated script id of a "private" function makes the name differ
   from the name of the file or directory on disk

 * end the function name pattern with `\w*` instead of `\w+` to allow
   single-letter function names

  ---
  [^1] https://vimhelp.org/vim9.txt.html#vim9-differences
  • Loading branch information
rdipardo committed Aug 31, 2024
1 parent b55699d commit 119637e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"leaves":["build_go_files"],"root":"unitTest"}
{"leaves":["build_go_files","F","Baz","g","H","foo","namespaced#function","Another#namespaced#function"],"root":"unitTest"}
34 changes: 34 additions & 0 deletions UDL-samples/Vimscript_by_rdipardo.vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,38 @@ func! s:build_go_files() abort
endif
endfunc

"""""""""""""""""""
" Tests "
"""""""""""""""""""
function F(x)
echom 'Pass'
endfunction

func Baz(x, y)
echom 'Pass'
endfunc

function! s:g(x)
echom 'Pass'
endfunction

function! s:H(x)
echom 'Pass'
endfunction

func! s:foo(x, y)
echom 'Pass'
endfunc

func! namespaced#function(...)
echom 'Pass'
endfunc

func! Another#namespaced#function(...)
echom 'Pass'
endfunc

" func IgnoreMe()
" endfunc

" vim: syntax=vim
8 changes: 4 additions & 4 deletions functionList/Vimscript_by_rdipardo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<!-- based on rules https://learnvim.irian.to/vimscript/vimscript_functions -->

<parser
id="vimscript_fuunc"
id="vimscript_func"
displayName="Vim Script"
commentExpr="(?-s:#.*)"
commentExpr="(?-s:&quot;.*)"
>
<function
mainExpr="^\h*func(tion)?!?\h+(?-i:\u|s:\l?)\w+"
mainExpr="^\h*func(tion)?!?\h+(?-i:\u|(s:(?!\w+#)|(\w+#)+)\l?)(#?\w)*"
>
<functionName>
<nameExpr expr="^\h*func(tion)?!?\h+\K(?-i:\u|s:\K\l?)\w+" />
<nameExpr expr="^\h*func(tion)?!?\h+\K(?-i:\u|(s:\K|(\w+#)+)\l?)(#?\w)*" />
</functionName>
</function>
</parser>
Expand Down

0 comments on commit 119637e

Please sign in to comment.