Skip to content

Commit

Permalink
Merge pull request #32 from Symmettry/master
Browse files Browse the repository at this point in the history
Actual .java implementation, make js.lua better, json.lua
  • Loading branch information
face-hh authored Mar 22, 2024
2 parents 9965c10 + 60151a4 commit 1389d6e
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 4 deletions.
134 changes: 134 additions & 0 deletions Lua/Plugins/java.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
highlight("package", "reserved")
highlight("import", "reserved")

highlight("public", "reserved")
highlight("private", "reserved")
highlight("protected", "reserved")

highlight("class", "reserved")
highlight("enum", "reserved")
highlight("record", "reserved")
highlight("interface", "reserved")

highlight("extends", "reserved")
highlight("implements", "reserved")
highlight("module", "reserved")

highlight("super", "reserved")
highlight("this", "reserved")

highlight("void", "reserved")
highlight("boolean", "reserved")
highlight("int", "reserved")
highlight("double", "reserved")
highlight("long", "reserved")
highlight("float", "reserved")
highlight("char", "reserved")
highlight("byte", "reserved")
highlight("short", "reserved")

-- which mf actually uses these
highlight("const", "reserved")
highlight("goto", "reserved")
highlight("strictfp", "reserved")

highlight("instanceof", "reserved")
highlight("native", "reserved")
highlight("new", "reserved")

highlight("return", "reserved")

highlight("final", "reserved")
highlight("static", "reserved")
highlight("transient", "reserved")
highlight("volatile", "reserved")

highlight_region("\"", "\"", "string")
highlight_region("//", "", "comments", true)
highlight_region("/*", "*/", "comments")

-- annotation but ofc griddy doesn't let me set keywords outside of default ones
highlight_region("@", "", "comments", true)

highlight("if", "reserved")
highlight("else", "reserved")

highlight("do", "reserved")
highlight("while", "reserved")
highlight("for", "reserved")
highlight("continue", "reserved")
highlight("default", "reserved")
highlight("break", "reserved")

highlight("switch", "reserved")
highlight("case", "reserved")

highlight("try", "reserved")
highlight("catch", "reserved")
highlight("finally", "reserved")
highlight("throw", "reserved")
highlight("throws", "reserved")

highlight("false", "binary")
highlight("true", "binary")
highlight("null", "binary")

highlight("synchronized", "reserved")

highlight("assert", "reserved")

highlight("exports", "reserved")
highlight("module", "reserved")
highlight("non-sealed", "reserved")
highlight("open", "reserved")
highlight("opens", "reserved")
highlight("permits", "reserved")
highlight("provides", "reserved")
highlight("requires", "reserved")
highlight("sealed", "reserved")
highlight("to", "reserved")
highlight("transitive", "reserved")
highlight("uses", "reserved")
highlight("var", "reserved")
highlight("when", "reserved")
highlight("with", "reserved")
highlight("yield", "reserved")

add_comment("boiler plate alert!!!")
add_comment("public static volatile transient transitive synchronized class type language 🗣️🔥")
add_comment("another semicolon please")
add_comment("use a lambda you dumbass")

function detect_functions(content)
local functionNames = {}

for line in content:gmatch("[^\r\n]+") do
local pattern = "[%a_][%a%d_<>]*%s+([%a_][%a%d_]*)%s*%("
local functionName = line:match(pattern)
if functionName then
table.insert(functionNames, functionName);
end
end

return functionNames
end

function detect_variables(content)
local variable_names = {
"this",
"super",
"System",
"Object",
"Math",
"Thread",
"Runtime"
}
for line in content:gmatch("[^\r\n]+") do
local pattern = "%f[%a_][%a_][%a%d_<>]*%s+([%a_][%a%d_<>]*)%s*=%s*[^;]+;"
local match = line:match(pattern)
if match then
table.insert(variable_names, match)
end
end
return variable_names
end
19 changes: 15 additions & 4 deletions Lua/Plugins/js.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ add_comment("tip: decrease your chance at errors: Number.MAX_SAFE_INTEGER += Num
--- autocomplete

function detect_functions(content)
local functionNames = {}
local functionNames = {
"require"
}

local lines = {}
for line in content:gmatch("[^\r\n]+") do
table.insert(lines, line)
end

for _, line in ipairs(lines) do
if (string.find(line, "function ") or string.find(line, "async ")) and string.find(line, "%(") then
if trim(line):find("^function ") or trim(line):find("^async function ") and string.find(line, "%(") then
local functionName =
string.match(trim(line):gsub("{", ""), "function%s+(.-)%s*%(") or
string.match(trim(line):gsub("{", ""), "async%s+(.-)%s*%(")
Expand All @@ -120,11 +122,20 @@ function detect_functions(content)
end

function detect_variables(content)
local variable_names = {}
local variable_names = {
"global",
"process",
"console",
"Buffer",
"__dirname",
"__filename",
"module",
"exports"
}
local lines = content:gmatch("[^\r\n]+")

for line in lines do
if line:find("let ") or line:find("var ") or line:find("const ") then
if trim(line):find("^let ") or trim(line):find("^var ") or trim(line):find("^const ") then
local parts = splitstr(line, "=")
if #parts > 0 then
local variable_name = trim(splitstr(trim(parts[1]), " ")[2])
Expand Down
7 changes: 7 additions & 0 deletions Lua/Plugins/json.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
highlight_region('"', '"', "string")

add_comment("object notation 💯🔥")
add_comment("lower that scope")
add_comment("🗣️🗣️🗣️ { \"i'm\": \"suiciding\" }")

-- json doesn't have variables or functions

0 comments on commit 1389d6e

Please sign in to comment.