Skip to content

Allow function name which starts with underscore #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoload/vimlparser.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ function! s:VimLParser.parse_cmd_function()
if left.type == s:NODE_IDENTIFIER
let s = left.value
let ss = split(s, '\zs')
if ss[0] !=# '<' && !s:isupper(ss[0]) && stridx(s, ':') == -1 && stridx(s, '#') == -1
if ss[0] !=# '<' && ss[0] !=# '_' && !s:isupper(ss[0]) && stridx(s, ':') == -1 && stridx(s, '#') == -1
throw s:Err(printf('E128: Function name must start with a capital or contain a colon: %s', s), left.pos)
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion js/vimlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ VimLParser.prototype.parse_cmd_function = function() {
if (left.type == NODE_IDENTIFIER) {
var s = left.value;
var ss = viml_split(s, "\\zs");
if (ss[0] != "<" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
if (ss[0] != "<" && ss[0] != "_" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
throw Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos);
}
}
Expand Down
2 changes: 1 addition & 1 deletion py/vimlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def parse_cmd_function(self):
if left.type == NODE_IDENTIFIER:
s = left.value
ss = viml_split(s, "\\zs")
if ss[0] != "<" and not isupper(ss[0]) and viml_stridx(s, ":") == -1 and viml_stridx(s, "#") == -1:
if ss[0] != "<" and ss[0] != "_" and not isupper(ss[0]) and viml_stridx(s, ":") == -1 and viml_stridx(s, "#") == -1:
raise VimLParserException(Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos))
# :function {name}
if self.reader.peekn(1) != "(":
Expand Down
3 changes: 3 additions & 0 deletions test/test_funcname.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function (_F))
(function (s:SID))
(function (<SID>SID))
8 changes: 8 additions & 0 deletions test/test_funcname.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function _F()
endfunction

function s:SID()
endfunction

function <SID>SID()
endfunction