summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-06-06 22:27:20 +0100
committerw0rp <devw0rp@gmail.com>2017-06-06 22:27:20 +0100
commite4d886d4a798208d2c5dd10816cd3f47a8f5f431 (patch)
tree83e30da5f6d27c98670fc7b7acc02015df08a09a /autoload
parenteeea72e16740bb1dfa5bd554a927e6bbee76a9b5 (diff)
downloadale-e4d886d4a798208d2c5dd10816cd3f47a8f5f431.zip
Add a function for computing the number of arguments for a function
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/util.vim15
1 files changed, 15 insertions, 0 deletions
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 03abacb7..90e052a7 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -123,3 +123,18 @@ function! ale#util#GetMatches(lines, patterns) abort
return l:matches
endfunction
+
+" Given the name of a function, a Funcref, or a lambda, return the number
+" of named arguments for a function.
+function! ale#util#FunctionArgCount(function) abort
+ let l:Function = ale#util#GetFunction(a:function)
+
+ redir => l:output
+ silent function Function
+ redir END
+
+ let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2]
+ let l:arg_list = filter(split(l:match, ', '), 'v:val !=# ''...''')
+
+ return len(l:arg_list)
+endfunction