Skip to content

Commit 67cead6

Browse files
committed
Add comments about public API as vital-module
1 parent 62dad18 commit 67cead6

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.mkd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This parser provide same feature for following languages.
1414

1515
* Vim script
1616
* Python
17-
* Javascript
17+
* JavaScript
1818

1919
## Example
2020

autoload/vital/__vimlparser__/VimLParser.vim

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44
"
55
" License: This file is placed in the public domain.
66

7+
" s:import is only public API and you can access this script-local function via
8+
" vital.vim. See https://github.com/vim-jp/vital.vim for more detail.
9+
"
10+
" Historically, vimlparser.vim is not vital module and there are other exported
11+
" functions as vital-module, but they are not expected to be used.
12+
" The one reason we didn't make them as private function (add `_` prefix to
13+
" script local function) is that this file will be translated into other
14+
" languages like Python and JavaScript. Also, vimlparser developers have no
15+
" need to learn vital.vim convention and develop vimlparser same as before as
16+
" much as possible.
17+
"
18+
" Example:
19+
" call extend(s:, vital#vital#import('VimLParser').import())
20+
"
21+
" function! s:run() abort
22+
" let code = [
23+
" \ 'let s:message = printf("hello %d", 1+(2*3))'
24+
" \ ]
25+
" let r = s:StringReader.new(code)
26+
" let p = s:VimLParser.new()
27+
" let c = s:Compiler.new()
28+
" echo join(c.compile(p.parse(r)), "\n")
29+
" endfunction
30+
"
31+
" call s:run()
732
function! s:import() abort
833
return s:
934
endfunction
@@ -906,7 +931,7 @@ function! s:VimLParser.find_command()
906931
endif
907932
endfor
908933

909-
if self.neovim
934+
if self.neovim
910935
for x in self.neovim_additional_commands
911936
if stridx(x.name, name) == 0 && len(name) >= x.minlen
912937
unlet cmd
@@ -923,7 +948,7 @@ function! s:VimLParser.find_command()
923948
endif
924949
endfor
925950
endif
926-
951+
927952
" FIXME: user defined command
928953
if (cmd is s:NIL || cmd.name ==# 'Print') && name =~# '^[A-Z]'
929954
let name .= self.reader.read_alnum()

0 commit comments

Comments
 (0)