~reykjalin/fonn_extensions

231d957ee60f8da8b17ea8adea5e134f9a2c408e — KristoĢfer R 3 months ago b8bb610
remove lua and cpp extensions since fonn now has builtin support for syntax highlighting
17 files changed, 0 insertions(+), 689 deletions(-)

D cpp/build_command
D cpp/c-highlights.scm
D cpp/extension.lua
D cpp/highlights-2.scm
D cpp/highlights-preproc.scm
D cpp/highlights.scm
D cpp/injections.scm
D cpp/libtree-sitter-cpp.so
D cpp/tags.scm
D cpp/tree-sitter-cpp
D lua/arguments.scm
D lua/extension.lua
D lua/folds.scm
D lua/highlights.scm
D lua/libtree-sitter-lua.so
D lua/symbols.scm
D lua/tree-sitter-lua
D cpp/build_command => cpp/build_command +0 -1
@@ 1,1 0,0 @@
cc src/parser.c src/scanner.c -O3 -o libtree-sitter-cpp.so -shared -fPIC -fno-exceptions -Isrc/tree_sitter

D cpp/c-highlights.scm => cpp/c-highlights.scm +0 -81
@@ 1,81 0,0 @@
"break" @keyword
"case" @keyword
"const" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"static" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword

"#define" @keyword
"#elif" @keyword
"#else" @keyword
"#endif" @keyword
"#if" @keyword
"#ifdef" @keyword
"#ifndef" @keyword
"#include" @keyword
(preproc_directive) @keyword

"--" @operator
"-" @operator
"-=" @operator
"->" @operator
"=" @operator
"!=" @operator
"*" @operator
"&" @operator
"&&" @operator
"+" @operator
"++" @operator
"+=" @operator
"<" @operator
"==" @operator
">" @operator
"||" @operator

"." @delimiter
";" @delimiter

(string_literal) @string
(system_lib_string) @string

(null) @constant
(number_literal) @number
(char_literal) @number

(call_expression
  function: (identifier) @function)
(call_expression
  function: (field_expression
    field: (field_identifier) @function))
(function_declarator
  declarator: (identifier) @function)
(preproc_function_def
  name: (identifier) @function.special)

(field_identifier) @property
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type
(sized_type_specifier) @type

((identifier) @constant
 (#match? @constant "^[A-Z][A-Z\\d_]*$"))

(identifier) @variable

(comment) @comment

D cpp/extension.lua => cpp/extension.lua +0 -36
@@ 1,36 0,0 @@
function activate()
end

function queries()
  return {
    workspace.path .. "/highlights-2.scm",
    workspace.path .. "/highlights-preproc.scm"
  }
end

function parser()
  return {
    ["path"] = workspace.path .. "/libtree-sitter-cpp.so",
    ["function"] = "tree_sitter_cpp",
  }
end

function activates_for(file_name)
  return string.match(file_name, ".cpp$") ~= nil
    or string.match(file_name, ".cc$") ~= nil
    or string.match(file_name, ".cxx$") ~= nil
    or string.match(file_name, ".h$") ~= nil
    or string.match(file_name, ".hpp$") ~= nil
    or string.match(file_name, ".hxx$") ~= nil
    or string.match(file_name, ".hh$") ~= nil
end

function provides_parser_for_file(file_name)
  return string.match(file_name, ".cpp$") ~= nil
    or string.match(file_name, ".cc$") ~= nil
    or string.match(file_name, ".cxx$") ~= nil
    or string.match(file_name, ".h$") ~= nil
    or string.match(file_name, ".hpp$") ~= nil
    or string.match(file_name, ".hxx$") ~= nil
    or string.match(file_name, ".hh$") ~= nil
end
\ No newline at end of file

D cpp/highlights-2.scm => cpp/highlights-2.scm +0 -198
@@ 1,198 0,0 @@
[ "." ";" ":" "," ] @punctuation.delimiter
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket

; Preprocessor
(preproc_if
  [
    "#if"
    "#endif"
  ] @processing.directive
  condition: (identifier) @processing.directive)
(preproc_elif
  "#elif" @processing.directive
  condition: (identifier) @processing.directive)
(preproc_else
  "#else" @processing.directive)
(preproc_ifdef
  [
    "#ifdef"
    "#ifndef"
  ] @processing.directive
  name: (identifier) @processing.directive)
(preproc_ifdef
  "#endif" @processing.directive)
(preproc_def
  "#define" @processing.directive
  name: (identifier) @processing.directive)
(preproc_call
  directive: (preproc_directive) @processing.directive
  argument: (preproc_arg) @processing.directive)

; Functions

(call_expression
  function: (qualified_identifier
    name: (identifier) @identifier.function))
(call_expression
  function: (qualified_identifier
    name: (qualified_identifier
      name: (identifier) @identifier.function)))
(call_expression
  function: (qualified_identifier
    name: (qualified_identifier
      name: (qualified_identifier
        name: (identifier) @identifier.function))))
(call_expression
  function: (identifier) @identifier.function)
(call_expression
  function: (field_expression
    field: (field_identifier) @identifier.function))
(field_expression
  argument: (field_expression
    field: (field_identifier) @identifier.property))

(template_function
  name: (identifier) @identifier.function)

(template_method
  name: (field_identifier) @identifier.function)

(template_function
  name: (identifier) @identifier.function)

; Types

(qualified_identifier 
  scope: (namespace_identifier) @identifier.type)

(type_descriptor
  (qualified_identifier 
    name: (type_identifier) @identifier.type))

((namespace_identifier) @identifier.type
 (#match? @identifier.type "^[A-Z]"))

(type_identifier) @identifier.type
(primitive_type) @identifier.type
(sized_type_specifier) @identifier.type

(auto) @keyword.modifier
(type_qualifier) @keyword.modifier
(storage_class_specifier) @keyword.modifier

(template_argument_list (identifier) @identifier.type)

; Literals

(number_literal) @value.number
[
  (true)
  (false)
] @value.boolean
(this) @keyword.self
(null) @value.null
[ "nullptr" ] @value.null

; Operators

[
  "~"
  ":"
  "::"
  "--"
  "-"
  "-="
  "->"
  "="
  "!="
  "*"
  "&"
  "&&"
  "+"
  "++"
  "+="
  "<"
  "=="
  ">"
  "||"
  "<="
  ">="
  "<<"
  ">>"
  "!"
  "."
  "?"
] @operator

; Keywords

[
 "catch"
 "class"
 "co_await"
 "co_return"
 "co_yield"
 "constexpr"
 "constinit"
 "consteval"
 "delete"
 "explicit"
 "final"
 "friend"
 "mutable"
 "namespace"
 "noexcept"
 "new"
 "override"
 "private"
 "protected"
 "public"
 "template"
 "throw"
 "try"
 "typename"
 "using"
 "virtual"
 "concept"
 "requires"
 "return"
 "do"
 "if"
 "else"
 "while"
 "for"
 "struct"
 "union"
 "enum"
 "typedef"
 "switch"
 "case"
 "default"
 "break"
 "continue"
 "extern"
 "sizeof"
] @keyword

; Preprocessor

(preproc_include) @declaration.include

; Strings

(string_literal) @string
(raw_string_literal) @string
(char_literal) @value.number

; Declarations

(class_specifier name: (type_identifier) @identifier.type.declare)
(namespace_definition name: (_) @identifier.type.declare)
(struct_specifier name: (type_identifier) @identifier.type.declare)
(union_specifier name: (type_identifier) @identifier.type.declare)
(enum_specifier name: (type_identifier) @identifier.type.declare)
(type_definition declarator: (type_identifier) @identifier.type.declare)

; Comments

(comment) @comment

D cpp/highlights-preproc.scm => cpp/highlights-preproc.scm +0 -48
@@ 1,48 0,0 @@
; Preprocessor
(preproc_if
  [
    "#if"
    "#endif"
  ] @processing.directive
  condition: (_) @processing.argument)
(preproc_elif
  "#elif" @processing.directive
  condition: (_) @processing.argument)
(preproc_else
  "#else" @processing.directive)
(preproc_if
  "#endif" @processing.directive)
(preproc_ifdef
  [
    "#ifdef"
    "#ifndef"
  ] @processing.directive
  name: (identifier) @processing.argument)
(preproc_ifdef
  "#endif" @processing.directive)
(preproc_def
  "#define" @processing.directive
  name: (identifier) @processing.argument
  value: (preproc_arg)? @processing.argument)
(preproc_include
  "#include" @processing.directive
  path: (_) @string)
(preproc_function_def
  "#define" @processing.directive
  name: (identifier) @processing.argument
  parameters: (preproc_params) @processing.argument
  value: (preproc_arg)? @processing.argument)
(preproc_call
  directive: (preproc_directive) @processing.directive
  argument: (preproc_arg)? @processing.argument
  (#not-eq? @processing.directive "#pragma"))
(preproc_call
  directive: (preproc_directive) @processing.directive
  argument: (preproc_arg)? @processing.argument
  (#eq? @processing.directive "#pragma")
  (#not-match? @processing.argument "^\\s+mark\\s+"))
(preproc_call 
  directive: (preproc_directive) @_directive
  argument: (preproc_arg) @_argument @comment.doctag
  (#eq? @_directive "#pragma")
  (#match? @_argument "^\\s+mark\\s+")) @comment

D cpp/highlights.scm => cpp/highlights.scm +0 -74
@@ 1,74 0,0 @@
; Functions

(call_expression
  function: (qualified_identifier
    name: (identifier) @function))

(template_function
  name: (identifier) @function)

(template_method
  name: (field_identifier) @function)

(template_function
  name: (identifier) @function)

(function_declarator
  declarator: (qualified_identifier
    name: (identifier) @function))

(function_declarator
  declarator: (qualified_identifier
    name: (identifier) @function))

(function_declarator
  declarator: (field_identifier) @function)

; Types

((namespace_identifier) @type
 (#match? @type "^[A-Z]"))

(auto) @type

; Constants

(this) @variable.builtin
(null "nullptr" @constant)

; Keywords

[
 "catch"
 "class"
 "co_await"
 "co_return"
 "co_yield"
 "constexpr"
 "constinit"
 "consteval"
 "delete"
 "explicit"
 "final"
 "friend"
 "mutable"
 "namespace"
 "noexcept"
 "new"
 "override"
 "private"
 "protected"
 "public"
 "template"
 "throw"
 "try"
 "typename"
 "using"
 "virtual"
 "concept"
 "requires"
] @keyword

; Strings

(raw_string_literal) @string

D cpp/injections.scm => cpp/injections.scm +0 -3
@@ 1,3 0,0 @@
(raw_string_literal
  delimiter: (raw_string_delimiter) @injection.language
  (raw_string_content) @injection.content)

D cpp/libtree-sitter-cpp.so => cpp/libtree-sitter-cpp.so +0 -0
D cpp/tags.scm => cpp/tags.scm +0 -15
@@ 1,15 0,0 @@
(struct_specifier name: (type_identifier) @name body:(_)) @definition.class

(declaration type: (union_specifier name: (type_identifier) @name)) @definition.class

(function_declarator declarator: (identifier) @name) @definition.function

(function_declarator declarator: (field_identifier) @name) @definition.function

(function_declarator declarator: (qualified_identifier scope: (namespace_identifier) @scope name: (identifier) @name)) @definition.method

(type_definition declarator: (type_identifier) @name) @definition.type

(enum_specifier name: (type_identifier) @name) @definition.type

(class_specifier name: (type_identifier) @name) @definition.class

D cpp/tree-sitter-cpp => cpp/tree-sitter-cpp +0 -1
@@ 1,1 0,0 @@
Subproject commit a90f170f92d5d70e7c2d4183c146e61ba5f3a457

D lua/arguments.scm => lua/arguments.scm +0 -2
@@ 1,2 0,0 @@
(parameter_list
  (identifier) @name @subtree)

D lua/extension.lua => lua/extension.lua +0 -23
@@ 1,23 0,0 @@
function activate()
end

function queries()
  return {
    workspace.path .. "/highlights.scm",
  }
end

function parser()
  return {
    ["path"] = workspace.path .. "/libtree-sitter-lua.so",
    ["function"] = "tree_sitter_lua",
  }
end

function activates_for(file_name)
  return string.match(file_name, ".lua$") ~= nil
end

function provides_parser_for_file(file_name)
  return string.match(file_name, ".lua$") ~= nil
end
\ No newline at end of file

D lua/folds.scm => lua/folds.scm +0 -69
@@ 1,69 0,0 @@
(local_function_definition_statement
  name: (_) @start
  ")"? @start
  "end" @end
 (#set! scope.byLine)
 (#set! role function)
)

(function_definition_statement
  name: (_) @start
  ")"? @start
  "end" @end
 (#set! scope.byLine)
 (#set! role function)
)

(if_statement
  "then" @start
  consequence: (_)?
  .
  alternative: [(elseif_clause) (else_clause)]? @end
  "end" @end
 (#set! scope.byLine)
)
(elseif_clause
  "then" @start
  consequence: (_)?
  .
  alternative: [(elseif_clause) (else_clause)]? @end
 (#set! scope.byLine)
) @end.after
(else_clause
  "else" @start
  (#set! scope.byLine)
) @end.after

(while_statement
  "do" @start
  "end" @end
 (#set! scope.byLine)
)

(for_generic_statement
  "do" @start
  "end" @end
 (#set! scope.byLine)
)

(for_numeric_statement
  "do" @start
  "end" @end
 (#set! scope.byLine)
)

(repeat_statement
  "repeat" @start
  "until" @end
 (#set! scope.byLine)
)

(do_statement
  "do" @start
  "end" @end
 (#set! scope.byLine)
)

(table
  "{" @start
  "}" @end)

D lua/highlights.scm => lua/highlights.scm +0 -112
@@ 1,112 0,0 @@
(comment) @comment

(number) @value.number
(string) @string
(nil) @value.null
[
  (true)
  (false)
] @value.boolean

(identifier) @identifier

(call
  function: (variable
    name: (identifier) @identifier.function))
    
(call
  function: (variable
    field: (identifier) @identifier.method))
        
(call
  function: (variable
    method: (identifier) @identifier.method))

(variable
  field: (identifier) @identifier.property)

(variable
  (identifier) @identifier.constant
 (#match? @identifier.constant "^[A-Z][A-Z0-9_]*$")
)

(function_definition_statement
  name: (variable
    table: (identifier) @identifier.type
    method: (identifier) @identifier.method))

(parameter_list
  (identifier) @identifier.argument)

(table
  (field_list
    (field
      key: (identifier) @identifier.key)))

[ "." ";" ":" "," ] @punctuation.delimiter
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket

[
  ; "import"
  "return"
  "local"
  "function"
  "end"
  "for"
  "in"
  "do"
  "if"
  "then"
  "elseif"
  "else"
  "repeat"
  "until"
  "while"
  "goto"
  "and"
  "or"
  "not"
] @keyword

((identifier) @keyword
 (#eq? @keyword "self")
)

(break_statement) @keyword

((attribute
  name: (identifier) @keyword.modifier)
 (#eq? @keyword.modifier "const")
)

[
  "="
  ; "+="
  ; "-="
  ; "*="
  ; "/="
  ; "//="
  ; "%="
  ; "<<="
  ; ">>="
  ; "&="
  ; "|="
  ; "^="
  "=="
  "~="
  "<"
  ">"
  "<="
  ">="
  "|"
  "~"
  "&"
  "<<"
  ">>"
  "+"
  "-"
  "*"
  "/"
  "//"
  "%"
] @operator

D lua/libtree-sitter-lua.so => lua/libtree-sitter-lua.so +0 -0
D lua/symbols.scm => lua/symbols.scm +0 -25
@@ 1,25 0,0 @@
(local_function_definition_statement
  name: [
    (identifier) @name
    (variable
      field: (identifier) @name)
    (variable
      method: (identifier) @name)
  ] @start @displayname
  parameters: (parameter_list)? @arguments.target
 (#set! role function)
 (#set! arguments.query "arguments.scm")
) @subtree

(function_definition_statement
  name: [
    (identifier) @name
    (variable
      field: (identifier) @name)
    (variable
      method: (identifier) @name)
  ] @start @displayname
  parameters: (parameter_list)? @arguments.target
 (#set! role function)
 (#set! arguments.query "arguments.scm")
) @subtree

D lua/tree-sitter-lua => lua/tree-sitter-lua +0 -1
@@ 1,1 0,0 @@
Subproject commit 6b02dfd7f07f36c223270e97eb0adf84e15a4cef