diff --git a/Lua/Plugins/c.lua b/Lua/Plugins/c.lua index 16ccd96..e5869b4 100644 --- a/Lua/Plugins/c.lua +++ b/Lua/Plugins/c.lua @@ -1,115 +1,173 @@ -- Highlight Keywords -highlight("auto", "reserved") -highlight("break", "reserved") -highlight("case", "reserved") -highlight("char", "reserved") -highlight("const", "reserved") -highlight("continue", "reserved") -highlight("default", "reserved") -highlight("do", "reserved") -highlight("double", "reserved") -highlight("else", "reserved") -highlight("enum", "reserved") -highlight("extern", "reserved") -highlight("float", "reserved") -highlight("for", "reserved") -highlight("goto", "reserved") -highlight("if", "reserved") -highlight("inline", "reserved") -highlight("int", "reserved") -highlight("long", "reserved") -highlight("register", "reserved") -highlight("restrict", "reserved") -highlight("return", "reserved") -highlight("short", "reserved") -highlight("signed", "reserved") -highlight("sizeof", "reserved") -highlight("static", "reserved") -highlight("struct", "reserved") -highlight("switch", "reserved") -highlight("typedef", "reserved") -highlight("union", "reserved") -highlight("unsigned", "reserved") -highlight("void", "reserved") -highlight("volatile", "reserved") -highlight("while", "reserved") -highlight("_Alignas", "reserved") -highlight("_Alignof", "reserved") -highlight("_Atomic", "reserved") -highlight("_Bool", "reserved") -highlight("_Complex", "reserved") -highlight("_Generic", "reserved") -highlight("_Imaginary", "reserved") -highlight("_Noreturn", "reserved") -highlight("_Static_assert", "reserved") -highlight("_Thread_local", "reserved") - --- Arithmetic Operators -highlight("+", "operator") -highlight("-", "operator") -highlight("*", "operator") -highlight("/", "operator") -highlight("%", "operator") -highlight("++", "operator") -highlight("--", "operator") - --- Assignment Operators -highlight("=", "operator") -highlight("+=", "operator") -highlight("-=", "operator") -highlight("*=", "operator") -highlight("/=", "operator") -highlight("%=", "operator") -highlight("&=", "operator") -highlight("^=", "operator") -highlight("|=", "operator") -highlight("<<=", "operator") -highlight(">>=", "operator") - --- Comparison Operators -highlight("==", "operator") -highlight("!=", "operator") -highlight(">", "operator") -highlight("<", "operator") -highlight(">=", "operator") -highlight("<=", "operator") - --- Logical Operators -highlight("&&", "operator") -highlight("||", "operator") -highlight("!", "operator") - --- Bitwise Operators -highlight("&", "operator") -highlight("|", "operator") -highlight("^", "operator") -highlight("~", "operator") -highlight("<<", "operator") -highlight(">>", "operator") - --- Special Characters -highlight("{", "binary") -highlight("}", "binary") -highlight("[", "binary") -highlight("]", "binary") -highlight("(", "binary") -highlight(")", "binary") -highlight(";", "binary") -highlight(",", "binary") - --- Strings -highlight_region("\"", "\"", "string") -highlight_region("'", "'", "string") - --- Comments -highlight_region("//", "", "comments", true) -highlight_region("/*", "*/", "comments", false) - --- Autocomplete - -function detect_functions(content) - local functionNames = {} +local function highlight(word, category) + -- Function to apply highlighting based on word and category + print("Highlighting", word, "as", category) +end + +local function highlight_region(start_delim, end_delim, category, single_line) + -- Function to apply highlighting to regions between start_delim and end_delim + print("Highlighting region from", start_delim, "to", end_delim, "as", category, single_line and "(single line)" or "") +end + +local function highlight_all() + -- Reserved Keywords + local reserved_keywords = { + "auto", "break", "case", "char", "const", "continue", "default", "do", "double", + "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", + "register", "restrict", "return", "short", "signed", "sizeof", "static", "struct", + "switch", "typedef", "union", "unsigned", "void", "volatile", "while", + "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", + "_Noreturn", "_Static_assert", "_Thread_local" + } + + -- Operators + local operators = { + "+", "-", "*", "/", "%", "++", "--", "=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", "|=", + "<<=", ">>=", "==", "!=", ">", "<", ">=", "<=", "&&", "||", "!", "&", "|", "^", "~", "<<", ">>" + } + + -- Special Characters + local special_chars = {"{", "}", "[", "]", "(", ")", ";", ","} + + -- Highlight reserved keywords + for _, keyword in ipairs(reserved_keywords) do + highlight(keyword, "reserved") + end + + -- Highlight operators + for _, operator in ipairs(operators) do + highlight(operator, "operator") + end + + -- Highlight special characters + for _, char in ipairs(special_chars) do + highlight(char, "binary") + end + + -- Highlight strings + highlight_region("\"", "\"", "string") + highlight_region("'", "'", "string") + + -- Highlight comments + highlight_region("//", "", "comments", true) + highlight_region("/*", "*/", "comments", false) +end + +-- Autocomplete Functions + +local function detect_functions(content) + local functionNames = { + -- Standard Library Functions + "abort", "abs", "acos", "asctime", "asin", "atan", "atan2", "atexit", "atof", "atoi", "atol", "atoll", + "bsearch", "btowc", "calloc", "ceil", "clearerr", "clock", "cos", "cosh", "ctime", + "difftime", "div", "exit", "exp", "fabs", "fclose", "fcntl", "fdopen", "feof", "ferror", "fflush", + "fgetc", "fgetpos", "fgets", "floor", "fmod", "fopen", "fprintf", "fputc", "fputs", "fread", + "free", "freopen", "frexp", "fscanf", "fseek", "fsetpos", "ftell", "fwrite", + "getc", "getchar", "getenv", "gets", "gmtime", + "hypot", "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower", "isprint", "ispunct", "isspace", "isupper", "isxdigit", + "labs", "ldexp", "ldiv", "localeconv", "localtime", "log", "log10", "longjmp", "malloc", "mblen", "mbrlen", "mbrtowc", + "mbsinit", "mbsrtowcs", "mbstowcs", "mbtowc", "memchr", "memcmp", "memcpy", "memmove", "memset", "mktime", + "modf", "perror", "pow", "printf", "putc", "putchar", "puts", "qsort", "raise", + "rand", "realloc", "remove", "rename", "rewind", "scanf", "setbuf", "setjmp", "setlocale", "setvbuf", "signal", + "sin", "sinh", "sprintf", "sqrt", "srand", "sscanf", "strcat", "strchr", "strcmp", "strcoll", "strcpy", + "strcspn", "strerror", "strftime", "strlen", "strncat", "strncmp", "strncpy", "strpbrk", "strrchr", "strspn", "strstr", + "strtod", "strtok", "strtol", "strtoul", "strxfrm", "system", "tan", "tanh", "time", + "tmpfile", "tmpnam", "ungetc", "vfprintf", "vprintf", "vsprintf", "wcstombs", "wctomb", + + -- Additional Common Functions + "access", "chdir", "chmod", "chown", "closedir", "dup", "dup2", "execv", "execve", + "fchdir", "fchmod", "fchown", "fork", "fstat", "getcwd", "getpid", "getppid", "getuid", "geteuid", + "getgid", "getegid", "getgrgid", "getgrnam", "gethostname", "getlogin", "getopt", "getpwuid", "getpwnam", "getrlimit", + "getrusage", "getsid", "gettimeofday", "kill", "link", "lseek", "mkdir", "mkfifo", "mknod", "open", + "opendir", "pipe", "read", "readdir", "rename", "rmdir", "select", "setgid", "setuid", + "sleep", "stat", "symlink", "tcdrain", "tcflow", "tcflush", "tcgetattr", "tcsetattr", "tcsendbreak", + "time", "times", "truncate", "umask", "uname", "unlink", "utime", "wait", "waitpid", "write", + -- Math Functions + "acos", "asin", "atan", "atan2", "ceil", "cos", "cosh", "exp", "fabs", "floor", + "fmod", "frexp", "ldexp", "log", "log10", "modf", "pow", "sin", "sinh", "sqrt", "tan", "tanh", + + -- String Functions + "memchr", "memcmp", "memcpy", "memmove", "memset", "strcat", "strchr", "strcmp", + "strcoll", "strcpy", "strcspn", "strdup", "strerror", "strftime", "strlen", + "strncat", "strncmp", "strncpy", "strpbrk", "strrchr", "strspn", "strstr", + "strtod", "strtok", "strtol", "strtoul", "strxfrm", + + -- Input/Output Functions + "clearerr", "fclose", "feof", "ferror", "fflush", "fgetc", "fgetpos", + "fgets", "fopen", "fprintf", "fputc", "fputs", "fread", "freopen", + "fscanf", "fseek", "fsetpos", "ftell", "fwrite", "getc", "getchar", + "gets", "perror", "printf", "putc", "putchar", "puts", "remove", + "rename", "rewind", "scanf", "setbuf", "setvbuf", "sprintf", "sscanf", + "tmpfile", "tmpnam", "ungetc", "vfprintf", "vprintf", "vsprintf", + + -- Memory Management Functions + "calloc", "free", "malloc", "realloc", + + -- Utility Functions + "exit", "getenv", "system", "bsearch", "qsort", "abs", "div", "labs", "ldiv", + + -- Character Classification Functions + "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower", + "isprint", "ispunct", "isspace", "isupper", "isxdigit", "tolower", "toupper", + + -- Date and Time Functions + "asctime", "clock", "ctime", "difftime", "gmtime", "localtime", + "mktime", "strftime", "time", + + -- Signal Handling Functions + "signal", "raise", + + -- Non-standard and POSIX functions + "sleep", "getopt", "strdup", "strlcpy", "strlcat", "mkstemp", "mkdtemp", "mkfifo", + "popen", "pclose", "getline", "getdelim", "strcasestr", "strsep", "strcasecmp", + "strncasecmp", "realpath", "canonicalize_file_name", "readlink", "gethostname", + "getlogin", "getlogin_r", "getpwuid", "getpwnam", "getgrgid", "getgrnam", + "getuid", "geteuid", "getgid", "getegid", "getppid", "getpgid", "getpgrp", + "setuid", "seteuid", "setgid", "setegid", "setpgid", "setpgrp", "fork", + "execv", "execve", "execvp", "execl", "execlp", "exit", "abort", "kill", + "wait", "waitpid", "waitid", "sleep", "usleep", "nanosleep", "alarm", + "pause", "getrlimit", "setrlimit", "getrusage", "times", "clock_gettime", + "clock_settime", "clock_getres", "strftime", "gmtime", "localtime", "mktime", + "timegm", "difftime", "gettimeofday", "settimeofday", "adjtime", "utime", + "utimes", "syscall", "sysctl", "getpagesize", "sysconf", "pathconf", + "fpathconf", "confstr", "realpath", "canonicalize_file_name", "getcwd", + "chdir", "fchdir", "mkdir", "rmdir", "link", "symlink", "readlink", "unlink", + "rename", "chmod", "fchmod", "chown", "fchown", "lchown", "umask", + "mkdir", "mkfifo", "mknod", "mkfifoat", "mknodat", "open", "creat", + "openat", "close", "lseek", "read", "write", "pread", "pwrite", "readv", + "writev", "preadv", "pwritev", "fcntl", "ioctl", "dup", "dup2", "pipe", + "pipe2", "socket", "socketpair", "bind", "connect", "listen", "accept", + "accept4", "getsockname", "getpeername", "send", "sendto", "recv", "recvfrom", + "sendmsg", "recvmsg", "getsockopt", "setsockopt", "shutdown", "close", + "dup", "dup2", "fcntl", "ioctl", "getfd", "setfd", "getpid", "getppid", + "getuid", "geteuid", "getgid", "getegid", "getpgrp", "setpgrp", "getpgid", + "setpgid", "getsid", "setsid", "fork", "vfork", "execv", "execve", + "execvp", "execvpe", "execl", "execlp", "execle", "getenv", "putenv", + "setenv", "unsetenv", "clearenv", "syslog", "openlog", "closelog", + "setlogmask", "popen", "pclose", "pipe", "mkfifo", "umask", "chmod", + "fchmod", "chown", "fchown", "lchown", "utime", "utimes", "futimes", + "lutimes", "futimens", "utimensat", "stat", "fstat", "lstat", "fstatat", + "truncate", "ftruncate", "mkdir", "rmdir", "readlink", "symlink", + "link", "unlink", "rename", "realpath", "canonicalize_file_name", "getcwd", + "chdir", "fchdir", "chroot", "readdir", "opendir", "closedir", "rewinddir", + "dirfd", "telldir", "seekdir", "scandir", "alphasort", "versionsort", + "getgrnam", "getgrgid", "getpwnam", "getpwuid", "setpwent", "endpwent", + "getpwent", "putpwent", "getgrouplist", "getgrouplist", "getgroups", + "setgroups", "initgroups", "gethostbyname", "gethostbyaddr", "gethostbyname2", + "gethostent", "sethostent", "endhostent", "getnetbyname", "getnetbyaddr", + "getnetent", "setnetent", "endnetent", "getservbyname", "getservbyport", + "getservent", "setservent", "endservent", "getprotoent", "getprotobyname", + "getprotobynumber", "setprotoent", "endprotoent", "getaddrinfo", + "freeaddrinfo", "gai_strerror", "getnameinfo", "gethostbyname", + "gethostbyaddr", "gethostent", "sethostent", "endhostent", "getnetbyname", + "getnetbyaddr", "getnetent", "setnetent", "endnetent", "getservbyname", + "getservbyport", "getservent", "setservent", "endservent", "getprotoent", + "getprotobyname", "getprotobynumber", "setprotoent", "endprotoent", + "if_nameindex", "if_freenameindex", "if_indextoname", "if_nametoindex" + } + + for line in content:gmatch("[^\r\n]+") do -- Match function declarations local functionName = line:match("%s*([%w_]+)%s*%([^%)]*%)%s*%{?") @@ -117,14 +175,65 @@ function detect_functions(content) table.insert(functionNames, functionName) end end - + return functionNames end -function detect_variables(content) - local variable_names = {} - local lines = content:gmatch("[^\r\n]+") +local function detect_variables(content) + local variable_names = { + -- Common loop and iterator variables + "i", "j", "k", "index", "count", "n", "m", "len", "size", + + -- Common general-purpose variables + "temp", "flag", "result", "sum", "total", "average", "min", "max", + + -- Variables for pointers and addresses + "ptr", "p", "q", "address", "buffer", + + -- Common string-related variables + "str", "string", "char", "text", "name", "message", + + -- Variables for file handling + "file", "fp", "filename", "filepath", + -- Variables related to time + "time", "t", "timestamp", "start_time", "end_time", "duration", "elapsed_time", + + -- Variables for dimensions and coordinates + "x", "y", "z", "width", "height", "depth", "radius", "angle", + + -- Flags and status indicators + "is_valid", "is_ready", "is_done", "is_active", "status", "error", "success", "fail", + + -- Counters and indices + "counter", "pos", "position", "offset", + + -- Network-related variables + "socket", "sockfd", "port", "host", "ip", "address", "client", "server", + + -- Data structures and containers + "array", "list", "queue", "stack", "map", "node", "tree", + + -- Variables for numerical values + "value", "num", "val", "factor", "coefficient", "percentage", "rate", + + -- User input/output related + "input", "output", "arg", "argc", "argv", "input_value", "output_value", + + -- Flags and configuration options + "option", "mode", "config", "setting", + + -- Variables for coordinates and points + "coord", "point", "vector", "matrix", + + -- Boolean variables + "is_true", "is_false", "is_enabled", "is_disabled", "enabled", "disabled", + + -- Miscellaneous variables + "key", "value", "data", "info", "details", "id", "index", "id_num", "record", "entry" + } + local lines = content:gmatch("[^\r\n]+") + for line in lines do -- Match variable declarations local variable = line:match("%s*([%w_]+)%s+[%w_]+%s*[=;%(%),]") @@ -133,6 +242,64 @@ function detect_variables(content) table.insert(variable_names, variable) end end - + return variable_names end + +local function highlight_suggestions(input) + local suggestions = {} + + -- Reserved Keywords + local reserved_keywords = { + "auto", "break", "case", "char", "const", "continue", "default", "do", "double", + "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", + "register", "restrict", "return", "short", "signed", "sizeof", "static", "struct", + "switch", "typedef", "union", "unsigned", "void", "volatile", "while", + "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", + "_Noreturn", "_Static_assert", "_Thread_local" + } + + -- Operators + local operators = { + "+", "-", "*", "/", "%", "++", "--", "=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", "|=", + "<<=", ">>=", "==", "!=", ">", "<", ">=", "<=", "&&", "||", "!", "&", "|", "^", "~", "<<", ">>" + } + + -- Special Characters + local special_chars = {"{", "}", "[", "]", "(", ")", ";", ","} + + -- Check for matching reserved keywords + for _, keyword in ipairs(reserved_keywords) do + if keyword:find(input) then + table.insert(suggestions, { type = "keyword", value = keyword }) + end + end + + -- Check for matching operators + for _, operator in ipairs(operators) do + if operator:find(input) then + table.insert(suggestions, { type = "operator", value = operator }) + end + end + + -- Check for matching special characters + for _, char in ipairs(special_chars) do + if char:find(input) then + table.insert(suggestions, { type = "special_char", value = char }) + end + end + + -- Return the list of suggestions + return suggestions +end + +-- Example usage: +local input = "re" +local suggestions = highlight_suggestions(input) + +for _, suggestion in ipairs(suggestions) do + print("Type:", suggestion.type, "Value:", suggestion.value) +end + +-- Run the highlight function +highlight_all() diff --git a/Lua/Plugins/cpp.lua b/Lua/Plugins/cpp.lua index 252e751..11ff450 100644 --- a/Lua/Plugins/cpp.lua +++ b/Lua/Plugins/cpp.lua @@ -1,188 +1,280 @@ ---- Highlight Keywords -highlight("alignas", "reserved") -highlight("alignof", "reserved") -highlight("and", "reserved") -highlight("and_eq", "reserved") -highlight("asm", "reserved") -highlight("atomic_cancel", "reserved") -highlight("atomic_commit", "reserved") -highlight("atomic_noexcept", "reserved") -highlight("auto", "reserved") -highlight("bitand", "reserved") -highlight("bitor", "reserved") -highlight("bool", "reserved") -highlight("break", "reserved") -highlight("case", "reserved") -highlight("catch", "reserved") -highlight("char", "reserved") -highlight("char8_t", "reserved") -highlight("char16_t", "reserved") -highlight("char32_t", "reserved") -highlight("class", "reserved") -highlight("compl", "reserved") -highlight("concept", "reserved") -highlight("const", "reserved") -highlight("consteval", "reserved") -highlight("constexpr", "reserved") -highlight("constinit", "reserved") -highlight("const_cast", "reserved") -highlight("continue", "reserved") -highlight("co_await", "reserved") -highlight("co_return", "reserved") -highlight("co_yield", "reserved") -highlight("decltype", "reserved") -highlight("default", "reserved") -highlight("delete", "reserved") -highlight("do", "reserved") -highlight("double", "reserved") -highlight("dynamic_cast", "reserved") -highlight("else", "reserved") +--#region keywords +highlight("when", "reserved") +highlight("nameof", "reserved") +highlight("unsafe", "reserved") +highlight("stackalloc", "reserved") +highlight("sizeof", "reserved") +highlight("fixed", "reserved") +highlight("await", "reserved") +highlight("async", "reserved") +highlight("null", "reserved") highlight("enum", "reserved") +highlight("interface", "reserved") highlight("explicit", "reserved") -highlight("export", "reserved") -highlight("extern", "reserved") +highlight("implicit", "reserved") highlight("false", "reserved") -highlight("float", "reserved") -highlight("for", "reserved") -highlight("friend", "reserved") -highlight("goto", "reserved") -highlight("if", "reserved") -highlight("import", "reserved") -highlight("inline", "reserved") -highlight("int", "reserved") -highlight("long", "reserved") -highlight("module", "reserved") -highlight("mutable", "reserved") -highlight("namespace", "reserved") -highlight("new", "reserved") -highlight("noexcept", "reserved") -highlight("not", "reserved") -highlight("not_eq", "reserved") -highlight("nullptr", "reserved") +highlight("true", "reserved") highlight("operator", "reserved") -highlight("or", "reserved") -highlight("or_eq", "reserved") +highlight("remove", "reserved") +highlight("add", "reserved") +highlight("set", "reserved") +highlight("get", "reserved") +highlight("params", "reserved") +highlight("override", "reserved") +highlight("virtual", "reserved") +highlight("volatile", "reserved") +highlight("readonly", "reserved") +highlight("struct", "reserved") +highlight("static", "reserved") +highlight("sealed", "reserved") +highlight("abstract", "reserved") highlight("private", "reserved") +highlight("internal", "reserved") highlight("protected", "reserved") highlight("public", "reserved") -highlight("reflexpr", "reserved") -highlight("register", "reserved") -highlight("reinterpret_cast", "reserved") -highlight("requires", "reserved") +highlight("param", "reserved") +highlight("method", "reserved") +highlight("event", "reserved") +highlight("field", "reserved") +highlight("class", "reserved") +highlight("partial", "reserved") +highlight("namespace", "reserved") +highlight("by", "reserved") +highlight("group", "reserved") +highlight("select", "reserved") +highlight("descending", "reserved") +highlight("ascending", "reserved") +highlight("orderby", "reserved") +highlight("into", "reserved") +highlight("equals", "reserved") +highlight("on", "reserved") +highlight("join", "reserved") +highlight("where", "reserved") +highlight("let", "reserved") +highlight("from", "reserved") +highlight("yield", "reserved") +highlight("lock", "reserved") +highlight("finally", "reserved") +highlight("catch", "reserved") +highlight("try", "reserved") +highlight("throw", "reserved") highlight("return", "reserved") -highlight("short", "reserved") -highlight("signed", "reserved") -highlight("sizeof", "reserved") -highlight("static", "reserved") -highlight("static_assert", "reserved") -highlight("static_cast", "reserved") -highlight("struct", "reserved") +highlight("goto", "reserved") +highlight("continue", "reserved") +highlight("break", "reserved") +highlight("in", "reserved") +highlight("foreach", "reserved") +highlight("for", "reserved") +highlight("do", "reserved") +highlight("while", "reserved") +highlight("case", "reserved") highlight("switch", "reserved") -highlight("synchronized", "reserved") -highlight("template", "reserved") +highlight("else", "reserved") +highlight("if", "reserved") +highlight("const", "reserved") +highlight("var", "reserved") +highlight("delegate", "reserved") +highlight("default", "reserved") +highlight("unchecked", "reserved") +highlight("checked", "reserved") +highlight("void", "reserved") +highlight("typeof", "reserved") +highlight("new", "reserved") +highlight("base", "reserved") highlight("this", "reserved") -highlight("thread_local", "reserved") -highlight("throw", "reserved") -highlight("true", "reserved") -highlight("try", "reserved") -highlight("typedef", "reserved") -highlight("typeid", "reserved") -highlight("typename", "reserved") -highlight("union", "reserved") -highlight("unsigned", "reserved") +highlight("out", "reserved") +highlight("ref", "reserved") +highlight("as", "reserved") +highlight("is", "reserved") +highlight("assembly", "reserved") +highlight("string", "reserved") +highlight("dynamic", "reserved") +highlight("object", "reserved") +highlight("double", "reserved") +highlight("float", "reserved") +highlight("char", "reserved") +highlight("ulong", "reserved") +highlight("long", "reserved") +highlight("uint", "reserved") +highlight("int", "reserved") +highlight("ushort", "reserved") +highlight("short", "reserved") +highlight("byte", "reserved") +highlight("sbyte", "reserved") +highlight("decimal", "reserved") +highlight("bool", "reserved") highlight("using", "reserved") -highlight("virtual", "reserved") -highlight("void", "reserved") -highlight("volatile", "reserved") -highlight("wchar_t", "reserved") -highlight("while", "reserved") -highlight("xor", "reserved") -highlight("xor_eq", "reserved") - ---- Arithmetic Operators -highlight("+", "operator") -highlight("-", "operator") -highlight("*", "operator") -highlight("/", "operator") -highlight("%", "operator") -highlight("**", "operator") -highlight("++", "operator") -highlight("--", "operator") - ---- Assignment Operators -highlight("=", "operator") -highlight("+=", "operator") -highlight("-=", "operator") -highlight("*=", "operator") -highlight("/=", "operator") -highlight("%=", "operator") - ---- Comparison Operators -highlight("==", "operator") -highlight("!=", "operator") -highlight(">", "operator") -highlight("<", "operator") -highlight(">=", "operator") -highlight("<=", "operator") - ---- Logical Operators -highlight("&&", "operator") -highlight("||", "operator") -highlight("!", "operator") - ---- Bitwise Operators -highlight("&", "operator") -highlight("|", "operator") -highlight("^", "operator") -highlight("~", "operator") -highlight("<<", "operator") -highlight(">>", "operator") - ---- Special Characters -highlight("{", "binary") -highlight("}", "binary") -highlight("[", "binary") -highlight("]", "binary") -highlight("(", "binary") -highlight(")", "binary") -highlight(";", "binary") -highlight(",", "binary") - ---- Strings -highlight_region("\"", "\"", "string") -highlight_region("'", "'", "string") +highlight("alias", "reserved") +highlight("extern", "reserved") +--#endregion ---- Comments -add_comment("//", "", "comments", true) -add_comment("/*", "*/", "comments", false) +--#region comments +highlight_region("/*", "*/", "comments", false) +highlight_region("//", "", "comments", true) +--#endregion ---- Autocomplete +--#region IDE comments (for CTRL+L) +add_comment("C# Andy detected!") +add_comment("Holy this C# looks like Java") +add_comment("Make your C# roleplay Java, turn that i-- to i++") +add_comment( + "I thought I'd never see a Microsoft product be open source or source available." + .. " If only Windows was the same way." +) +add_comment("Avid Windows user") +add_comment( + "Let's lock you into the Microsoft walled garden even more! " .. "Install Windows and use WPF, UWP, and WinForms." +) +add_comment("Probably using Windows making garbage WinForms or UWP tutorials.") +add_comment("Get locked into the walled garden of Windows with UWP, WinForms, or WPF!") +add_comment( + "UWP? Deprecated. WinForms? Deprecated. WPF? Not deprecated (some people think it's dead). " + .. "Microsoft deprecates everything they start except WPF." +) +add_comment("C#? More like C-hashtag-please-stop-coding!") -- AI generated +add_comment("!!! JAVA CLONE !!!") +add_comment("rewrite in Rust") +add_comment("NoGet") +add_comment( + "I swear if you're writing a WPF, UWP, " + .. "or WinForms app then stop " + .. "and think about why you're making the microsoft walled garden bigger." +) +--#endregion -function detect_functions(content) - local functionNames = {} - - for line in content:gmatch("[^\r\n]+") do - -- Match function declarations - local functionName = line:match("%s*([%w_:]+)%s+[%w_:]+%s*%([^%)]*%)%s*%{?") - if functionName then - table.insert(functionNames, functionName) - end - end +---@param s string +---@return string +local function trim(s) + return s:gsub("%s+", "") +end - return functionNames +if _VERSION ~= "Luau" then + -- Written by Bing Chat, I am using Lua 5.4 against my will... + string.split = function(input, sep) + if sep == nil then + sep = "," -- Default separator is whitespace + end + local t = {} + for str in string.gmatch(input, "([^" .. sep .. "]+)") do + table.insert(t, str) + end + return t + end end +---Detects variables for auto complete +---@param content string +---@return string[] function detect_variables(content) - local variable_names = {} - local lines = content:gmatch("[^\r\n]+") + local variables = { + "bool", + "byte", + "sbyte", + "short", + "ushort", + "int", + "uint", + "long", + "ulong", + "float", + "double", + "char", + "string", + "object", + "dynamic", + "var"} + -- example match: int x = + -- (or: int x;) + -- the reason why there's a 2nd word match + -- is because we only want declarations of variables, + -- we want to match `int x =`, + -- not `x =`, because `x =` is only re-assigning `x`. + local re = "[a-zA-ZA-z0-9]+%s+@?[a-zA-ZA-z0-9]+%s*[=;]" + ---@param match string + for match in content:gmatch(re) do + print(match) + local name = match:split(" ")[2] + if name:sub(-1) == ";" then + name = name:sub(1, -2) + end + table.insert(variables, name) + end - for line in lines do - -- Match variable declarations - local variable = line:match("%s*([%w_:]+)%s+[%w_:]+%s*[=;%(%),]") - if variable then - table.insert(variable_names, variable) - end - end + return variables +end - return variable_names +---Detects functions for auto complete +---@param content string +---@return string[] +function detect_functions(content) + -- example match: typeHere something( + local re = "[a-zA-ZA-z0-9]+%s+[a-zA-ZA-z0-9]+%s*%(" + local functions = { + local methodsList = { + "Console.WriteLine()", + "Console.ReadLine()", + "Console.Read()", + "Console.Clear()", + + "Math.Abs()", + "Math.Pow()", + "Math.Sqrt()", + "Math.Max()", + "Math.Min()", + + "String.Length", + "String.ToUpper()", + "String.ToLower()", + "String.Substring()", + "String.Replace()", + + "List.Add()", + "List.Remove()", + "List.Contains()", + "List.Sort()", + "List.Clear()", + + "Enumerable.Where()", + "Enumerable.Select()", + "Enumerable.ToList()", + "Enumerable.Aggregate()", + "Enumerable.OrderBy()", + + "File.ReadAllText()", + "File.WriteAllText()", + "File.Exists()", + "File.Delete()", + + "Directory.GetFiles()", + "Directory.GetDirectories()", + "Directory.CreateDirectory()", + "Directory.Delete()", + + "Task.Run()", + "Task.Wait()", + "Task.WhenAll()", + "Task.Delay()", + + "Thread.Sleep()", + "Thread.Start()", + "Thread.Abort()", + "Thread.Join()", + + "HttpClient.GetAsync()", + "HttpClient.PostAsync()", + "HttpClient.SendAsync()", + "HttpClient.PutAsync()" + } + + } + ---@param match string + for match in content:gmatch(re) do + print("match=", '"' .. match .. '"') + local a = trim(match:split(" ")[2]) + print("a=", '"' .. a .. '"') + local name = a:split("(")[1] + print("name=", '"' .. name .. '"') + table.insert(functions, name) + end + return functions end diff --git a/Lua/Plugins/css.lua b/Lua/Plugins/css.lua index 4a8e9b8..eea8ca0 100644 --- a/Lua/Plugins/css.lua +++ b/Lua/Plugins/css.lua @@ -485,10 +485,10 @@ local css_keywords = { "writing-mode", "z-index", } -for keyword in css_keywords do - highlight(keyword, "function") -end +for _, variable in ipairs(css_keywords) do + highlight(variable, 'variable'); +end; --- Special Characters highlight("{", "symbol") highlight("#", "symbol") @@ -497,18 +497,376 @@ highlight(".", "symbol") --- Autocomplete function detect_variables(content) - local variable_names = css_keywords + local variable_names = { + "accent-color", + "align-content", + "align-items", + "align-self", + "all", + "animation", + "animation-delay", + "animation-direction", + "animation-duration", + "animation-fill-mode", + "animation-iteration-count", + "animation-name", + "animation-play-state", + "animation-timing-reserved", + "aspect-ratio", + "backdrop-filter", + "backface-visibility", + "background", + "background-attachment", + "background-blend-mode", + "background-clip", + "background-color", + "background-image", + "background-origin", + "background-position", + "background-position-x", + "background-position-y", + "background-repeat", + "background-size", + "block-size", + "border", + "border-block", + "border-block-color", + "border-block-end", + "border-block-end-color", + "border-block-end-style", + "border-block-end-width", + "border-block-start", + "border-block-start-color", + "border-block-start-style", + "border-block-start-width", + "border-block-style", + "border-block-width", + "border-bottom", + "border-bottom-color", + "border-bottom-left-radius", + "border-bottom-right-radius", + "border-bottom-style", + "border-bottom-width", + "border-collapse", + "border-color", + "border-end-end-radius", + "border-end-start-radius", + "border-image", + "border-image-outset", + "border-image-repeat", + "border-image-slice", + "border-image-source", + "border-image-width", + "border-inline", + "border-inline-color", + "border-inline-end", + "border-inline-end-color", + "border-inline-end-style", + "border-inline-end-width", + "border-inline-start", + "border-inline-start-color", + "border-inline-start-style", + "border-inline-start-width", + "border-inline-style", + "border-inline-width", + "border-left", + "border-left-color", + "border-left-style", + "border-left-width", + "border-radius", + "border-right", + "border-right-color", + "border-right-style", + "border-right-width", + "border-spacing", + "border-start-end-radius", + "border-start-start-radius", + "border-style", + "border-top", + "border-top-color", + "border-top-left-radius", + "border-top-right-radius", + "border-top-style", + "border-top-width", + "border-width", + "bottom", + "box-decoration-break", + "box-reflect", + "box-shadow", + "box-sizing", + "break-after", + "break-before", + "break-inside", + "caption-side", + "caret-color", + "@charset", + "clear", + "clip", + "clip-path", + "color", + "column-count", + "column-fill", + "column-gap", + "column-rule", + "column-rule-color", + "column-rule-style", + "column-rule-width", + "column-span", + "column-width", + "columns", + "content", + "counter-increment", + "counter-reset", + "counter-set", + "cursor", + "direction", + "display", + "empty-cells", + "filter", + "flex", + "flex-basis", + "flex-direction", + "flex-flow", + "flex-grow", + "flex-shrink", + "flex-wrap", + "float", + "font", + "@font-face", + "font-family", + "font-feature-settings", + "@font-feature-values", + "font-kerning", + "font-language-override", + "font-size", + "font-size-adjust", + "font-stretch", + "font-style", + "font-synthesis", + "font-variant", + "font-variant-alternates", + "font-variant-caps", + "font-variant-east-asian", + "font-variant-ligatures", + "font-variant-numeric", + "font-variant-position", + "font-weight", + "gap", + "grid", + "grid-area", + "grid-auto-columns", + "grid-auto-flow", + "grid-auto-rows", + "grid-column", + "grid-column-end", + "grid-column-gap", + "grid-column-start", + "grid-gap", + "grid-row", + "grid-row-end", + "grid-row-gap", + "grid-row-start", + "grid-template", + "grid-template-areas", + "grid-template-columns", + "grid-template-rows", + "hanging-punctuation", + "height", + "hyphens", + "hypenate-character", + "image-rendering", + "@import", + "inline-size", + "inset", + "inset-block", + "inset-block-end", + "inset-block-start", + "inset-inline", + "inset-inline-end", + "inset-inline-start", + "isolation", + "justify-content", + "justify-items", + "justify-self", + "@keyframes", + "left", + "letter-spacing", + "line-break", + "line-height", + "list-style", + "list-style-image", + "list-style-position", + "list-style-type", + "margin", + "margin-block", + "margin-block-end", + "margin-block-start", + "margin-bottom", + "margin-inline", + "margin-inline-end", + "margin-inline-start", + "margin-left", + "margin-right", + "margin-top", + "mask", + "mask-clip", + "mask-composite", + "mask-image", + "mask-mode", + "mask-origin", + "mask-position", + "mask-repeat", + "mask-size", + "mask-type", + "max-height", + "max-width", + "@media", + "max-block-size", + "max-inline-size", + "min-block-size", + "min-inline-size", + "min-height", + "min-width", + "mix-blend-mode", + "object-fit", + "object-position", + "offset", + "offset-anchor", + "offset-distance", + "offset-path", + "offset-rotate", + "opacity", + "order", + "orphans", + "outline", + "outline-color", + "outline-offset", + "outline-style", + "outline-width", + "overflow", + "Specifies", + "overflow-anchor", + "Specifies", + "overflow-wrap", + "overflow-x", + "overflow-y", + "overscroll-behavior", + "overscroll-behavior-block", + "overscroll-behavior-inline", + "overscroll-behavior-x", + "overscroll-behavior-y", + "padding", + "padding-block", + "padding-block-end", + "padding-block-start", + "padding-bottom", + "padding-inline", + "padding-inline-end", + "padding-inline-start", + "padding-left", + "padding-right", + "padding-top", + "page-break-after", + "page-break-before", + "page-break-inside", + "paint-order", + "perspective", + "perspective-origin", + "place-content", + "place-items", + "place-self", + "pointer-events", + "position", + "quotes", + "resize", + "right", + "rotate", + "row-gap", + "scale", + "scroll-behavior", + "scroll-margin", + "scroll-margin-block", + "scroll-margin-block-end", + "scroll-margin-block-start", + "scroll-margin-bottom", + "scroll-margin-inline", + "scroll-margin-inline-end", + "scroll-margin-inline-start", + "scroll-margin-left", + "scroll-margin-right", + "scroll-margin-top", + "scroll-padding", + "scroll-padding-block", + "scroll-padding-block-end", + "scroll-padding-block-start", + "scroll-padding-bottom", + "scroll-padding-inline", + "scroll-padding-inline-end", + "scroll-padding-inline-start", + "scroll-padding-left", + "scroll-padding-right", + "scroll-padding-top", + "scroll-snap-align", + "scroll-snap-stop", + "scroll-snap-type", + "scrollbar-color", + "tab-size", + "table-layout", + "text-align", + "text-align-last", + "text-combine-upright", + "text-decoration", + "text-decoration-color", + "text-decoration-line", + "text-decoration-style", + "text-decoration-thickness", + "text-emphasis", + "text-emphasis-color", + "text-emphasis-position", + "text-emphasis-style", + "text-indent", + "text-justify", + "text-orientation", + "text-overflow", + "text-shadow", + "text-transform", + "text-underline-offset", + "text-underline-position", + "top", + "transform", + "transform-origin", + "transform-style", + "transition", + "transition-delay", + "transition-duration", + "transition-property", + "transition-timing-reserved", + "translate", + "unicode-bidi", + "user-select", + "vertical-align", + "visibility", + "white-space", + "widows", + "width", + "word-break", + "word-spacing", + "word-wrap", + "writing-mode", + "z-index", + } + local lines = content:gmatch("[^\r\n]+") for line in lines do - if trim(line):find("^--") then - local parts = splitstr(line, ":") - if #parts > 0 then - local variable_name = trim(parts[1]) - table.insert(variable_names, "--" .. variable_name) - end + -- Check for Python variable assignment syntax + local assignment = line:match("(%w+)%s*=%s*.+") + if assignment then + local variable_name = assignment:match("(%w+)") + table.insert(variable_names, variable_name) end end return variable_names end + diff --git a/Lua/Plugins/html.lua b/Lua/Plugins/html.lua index c111c0c..902c9fa 100644 --- a/Lua/Plugins/html.lua +++ b/Lua/Plugins/html.lua @@ -140,18 +140,51 @@ add_comment("HTML more like hyper text MID language LMFAO") add_comment("please for the love of god use reactjs instead") add_comment("they speak HTML in mexico. HOT TAMALES for MY LADIES πŸ₯πŸ’ƒπŸͺ•πŸ•ΊπŸ₯πŸ’ƒπŸͺ•πŸ«”πŸ«”πŸ«”") + function detect_variables(content) - local variable_names = {} + local variable_names = {"", "", "", "", "
", "", "", "
", + "