-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for the Lua language
- Loading branch information
Showing
3 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
" ============================================================================== | ||
" The Lua documentation should follow the 'LDoc' conventions. | ||
" see https://github.com/stevedonovan/LDoc | ||
" ============================================================================== | ||
|
||
let s:save_cpo = &cpoptions | ||
set cpoptions&vim | ||
|
||
let b:doge_patterns = [] | ||
|
||
"" | ||
" ============================================================================== | ||
" Matches regular function expressions and class methods. | ||
" ============================================================================== | ||
" | ||
" {match}: Regex explanation | ||
" \m | ||
" Interpret the pattern as a magic pattern. | ||
" | ||
" ^ | ||
" Matches the position before the first character in the string. | ||
" | ||
" \%(local\s*\)\? | ||
" This should match the 'local' keyword. | ||
" ------------------------------------------------------------------------ | ||
" Matches an optional and non-capturing group, denoted as '\%( ... \)\?', | ||
" that may contain the keyword 'local' followed by 0 or more spaces, denoted | ||
" as '\s*'. | ||
" | ||
" function\s*\%([[:alnum:]_:.]\+[:.]\)\?\([[:alnum:]_]\+\)\s* | ||
" This should match the function name. | ||
" An example scenario it should match would be 'function a.b:c (arg1, arg2)' | ||
" where 'c' is the method name. | ||
" ------------------------------------------------------------------------ | ||
" Matches the 'function' keyword followed by 0 or more spaces, denoted as | ||
" '\s*', followed by an optional and non-capturing group, denoted as | ||
" '\%( ... \)\?', that may contain 1 or more of the following characters | ||
" '[[:alnum:]_:.]', followed by one of the following characters '[:.]', | ||
" followed a captured group, denoted as '\( ... \)', which may contain the | ||
" characters '[[:alnum:]_]', which can finally be followed by 0 or more | ||
" spaces, denoted as '\s*'. | ||
" | ||
" | ||
" (\(.\{-}\)) | ||
" This should match the function parameters. | ||
" ------------------------------------------------------------------------ | ||
" Matches parenthesis, denoted as '( ... )' which contains a captured group, | ||
" denoted as '\( ... \)', which may contain as few as possible characters, | ||
" denoted as '.\{-}'. | ||
" | ||
" {parameters.match}: Regex explanation | ||
" \m | ||
" Interpret the pattern as a magic pattern. | ||
" | ||
" \([^,]\+\) | ||
" This should match the parameter name. | ||
" ------------------------------------------------------------------------ | ||
" Matches a captured group that may contain 1 or more of the following | ||
" characters: '[^,]'. | ||
call add(b:doge_patterns, { | ||
\ 'match': '\m^\%(local\s*\)\?function\s*\%([[:alnum:]_:.]\+[:.]\)\?\([[:alnum:]_]\+\)\s*(\(.\{-}\))', | ||
\ 'match_group_names': ['funcName', 'parameters'], | ||
\ 'parameters': { | ||
\ 'match': '\([^,]\+\)', | ||
\ 'match_group_names': ['name'], | ||
\ 'format': ['@param', '{name}', 'TODO'], | ||
\ }, | ||
\ 'comment': { | ||
\ 'insert': 'above', | ||
\ 'opener': '--[[', | ||
\ 'closer': '--]]', | ||
\ 'trim_comparision_check': 0, | ||
\ 'template': [ | ||
\ '---[[', | ||
\ '-- TODO', | ||
\ '-- {parameters}', | ||
\ '--]]', | ||
\ ], | ||
\ }, | ||
\ }) | ||
|
||
"" | ||
" ============================================================================== | ||
" Matches regular function expressions as a variable value. | ||
" ============================================================================== | ||
" | ||
" {match}: Regex explanation | ||
" \m | ||
" Interpret the pattern as a magic pattern. | ||
" | ||
" ^ | ||
" Matches the position before the first character in the string. | ||
" | ||
" \%(local\s*\)\? | ||
" This should match the 'local' keyword. | ||
" ------------------------------------------------------------------------ | ||
" Matches an optional and non-capturing group, denoted as '\%( ... \)\?', | ||
" that may contain the keyword 'local' followed by 0 or more spaces, denoted | ||
" as '\s*'. | ||
" | ||
" \%([[:alnum:]_:.]\+[:.]\)\?\([[:alnum:]_]\+\)\s*=\s* | ||
" This should match the function name. | ||
" An example scenario it should match would be 'function a.b:c (arg1, arg2)' | ||
" where 'c' is the method name. | ||
" ------------------------------------------------------------------------ | ||
" Matches an optional and non-capturing group, denoted as '\%( ... \)\?', | ||
" that may contain 1 or more of the following characters '[[:alnum:]_:.]', | ||
" followed by one of the following characters '[:.]', followed a captured | ||
" group, denoted as '\( ... \)', which may contain the characters | ||
" '[[:alnum:]_]', which can finally be followed by 0 or more spaces, an | ||
" equal sign, again followed by 0 or more spaces. | ||
" | ||
" \%(\s*function\s*\)\?(\(.\{-}\)) | ||
" This should match the function declaration with its parameters. | ||
" ------------------------------------------------------------------------ | ||
" Matches an optional and non-capturing group, denoted as '\%( ... \)\?', | ||
" that may contain the 'function' keyword, followed by 0 or more spaces, | ||
" denoted as '\s*', followed by parenthesis, denoted as '( ... )' which | ||
" contains a captured group, denoted as '\( ... \)', which should contain as | ||
" few characters as possible, denoted as '.\{-}'. | ||
" | ||
" {parameters.match}: Regex explanation | ||
" \m | ||
" Interpret the pattern as a magic pattern. | ||
" | ||
" \([^,]\+\) | ||
" This should match the parameter name. | ||
" ------------------------------------------------------------------------ | ||
" Matches a captured group that may contain 1 or more of the following | ||
" characters: '[^,]'. | ||
call add(b:doge_patterns, { | ||
\ 'match': '\m^\%(local\s*\)\?\%([[:alnum:]_:.]\+[:.]\)\?\([[:alnum:]_]\+\)\s*=\s*\%(\s*function\s*\)\?(\(.\{-}\))', | ||
\ 'match_group_names': ['funcName', 'parameters'], | ||
\ 'parameters': { | ||
\ 'match': '\([^,]\+\)', | ||
\ 'match_group_names': ['name'], | ||
\ 'format': ['@param', '{name}', 'TODO'], | ||
\ }, | ||
\ 'comment': { | ||
\ 'insert': 'above', | ||
\ 'opener': '--[[', | ||
\ 'closer': '--]]', | ||
\ 'trim_comparision_check': 0, | ||
\ 'template': [ | ||
\ '---[[', | ||
\ '-- TODO', | ||
\ '-- {parameters}', | ||
\ '--]]', | ||
\ ], | ||
\ }, | ||
\ }) | ||
|
||
let &cpoptions = s:save_cpo | ||
unlet s:save_cpo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
-- #! /usr/bin/env lua | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
-- @param arg3 TODO | ||
-- @param arg4 TODO | ||
--]] | ||
function new_function(arg1, arg2, arg3, arg4) | ||
-- ... | ||
end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
-- @param arg3 TODO | ||
--]] | ||
local function new_function(arg1, arg2, arg3) | ||
-- ... | ||
end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
-- @param arg3 TODO | ||
--]] | ||
function BotDetectionHandler:access(arg1, arg2, arg3) | ||
end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
--]] | ||
myprint = function(arg1, arg2) | ||
print("This is my print function - ##",param,"##") | ||
end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
-- @param arg3 TODO | ||
-- @param arg4 TODO | ||
-- @param arg5 TODO | ||
--]] | ||
local myprint = function(arg1, arg2, arg3, arg4, arg5) | ||
print("This is my print function - ##",param,"##") | ||
end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
--]] | ||
function a.b:c (arg1, arg2) body end | ||
|
||
---[[ | ||
-- TODO | ||
-- @param self TODO | ||
-- @param arg1 TODO | ||
-- @param arg2 TODO | ||
--]] | ||
a.b.c = function (self, arg1, arg2) body end | ||
|
||
myobj:foo(n) | ||
myobj.foo(myobj, n) |