aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/fortran
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/queries/fortran')
-rw-r--r--runtime/queries/fortran/folds.scm11
-rw-r--r--runtime/queries/fortran/highlights.scm319
-rw-r--r--runtime/queries/fortran/indents.scm27
-rw-r--r--runtime/queries/fortran/injections.scm2
4 files changed, 359 insertions, 0 deletions
diff --git a/runtime/queries/fortran/folds.scm b/runtime/queries/fortran/folds.scm
new file mode 100644
index 000000000..cedbdb635
--- /dev/null
+++ b/runtime/queries/fortran/folds.scm
@@ -0,0 +1,11 @@
+; by @oponkork
+[
+ (if_statement)
+ (where_statement)
+ (enum_statement)
+ (do_loop_statement)
+ (derived_type_definition)
+ (function)
+ (subroutine)
+ (interface)
+] @fold
diff --git a/runtime/queries/fortran/highlights.scm b/runtime/queries/fortran/highlights.scm
new file mode 100644
index 000000000..6a6dbba35
--- /dev/null
+++ b/runtime/queries/fortran/highlights.scm
@@ -0,0 +1,319 @@
+; Preprocs
+(preproc_directive) @keyword.directive
+
+; Namespaces
+(program_statement
+ (name) @module)
+
+(end_program_statement
+ (name) @module)
+
+(module_statement
+ (name) @module)
+
+(end_module_statement
+ (name) @module)
+
+(submodule_statement
+ (name) @module)
+
+(end_submodule_statement
+ (name) @module)
+
+; Includes
+[
+ "import"
+ "include"
+ "use"
+] @keyword.import
+
+(import_statement
+ ","
+ [
+ "all"
+ "none"
+ ] @keyword)
+
+; Attributes
+[
+ (none)
+ "implicit"
+ "intent"
+] @attribute
+
+(implicit_statement
+ "type" @attribute)
+
+; Keywords
+[
+ "attributes"
+ "associate"
+ "block"
+ "classis"
+ "contains"
+ "default"
+ "dimension"
+ "endassociate"
+ "endselect"
+ "enumerator"
+ "equivalence"
+ "extends"
+ "goto"
+ "intrinsic"
+ "non_intrinsic"
+ "namelist"
+ "parameter"
+ "quiet"
+ "rank"
+ "save"
+ "selectcase"
+ "selectrank"
+ "selecttype"
+ "sequence"
+ "stop"
+ "target"
+ "typeis"
+] @keyword
+
+[
+ "class"
+ "enum"
+ "endenum"
+ "type"
+ "endtype"
+ "module"
+ "endmodule"
+ "submodule"
+ "endsubmodule"
+ "interface"
+ "endinterface"
+] @keyword.type
+
+(default) @keyword
+
+; Types
+(type_name) @type
+
+(intrinsic_type) @type.builtin
+
+; Qualifiers
+[
+ "abstract"
+ "allocatable"
+ "automatic"
+ "constant"
+ "contiguous"
+ "data"
+ "deferred"
+ "device"
+ "external"
+ "family"
+ "final"
+ "generic"
+ "global"
+ "grid_global"
+ "host"
+ "initial"
+ "local"
+ "local_init"
+ "managed"
+ "nopass"
+ "non_overridable"
+ "optional"
+ "pass"
+ "pinned"
+ "pointer"
+ "private"
+ "property"
+ "protected"
+ "public"
+ "shared"
+ "static"
+ "texture"
+ "value"
+ "volatile"
+ (procedure_qualifier)
+] @keyword.modifier
+
+[
+ "common"
+ "in"
+ "inout"
+ "out"
+] @keyword.modifier
+
+; Labels
+[
+ (statement_label)
+ (statement_label_reference)
+] @label
+
+[
+ "call"
+ "endfunction"
+ "endprogram"
+ "endprocedure"
+ "endsubroutine"
+ "function"
+ "procedure"
+ "program"
+ "subroutine"
+] @keyword.function
+
+[
+ "result"
+ "return"
+] @keyword.return
+
+; Functions
+(function_statement
+ (name) @function)
+
+(end_function_statement
+ (name) @function)
+
+(subroutine_statement
+ (name) @function)
+
+(end_subroutine_statement
+ (name) @function)
+
+(module_procedure_statement
+ (name) @function)
+
+(end_module_procedure_statement
+ (name) @function)
+
+(subroutine_call
+ (identifier) @function.call)
+
+[
+ "character"
+ "close"
+ "bind"
+ "format"
+ "open"
+ "print"
+ "read"
+ "write"
+] @function.builtin
+
+; Exceptions
+"error" @keyword.exception
+
+; Conditionals
+[
+ "else"
+ "elseif"
+ "elsewhere"
+ "endif"
+ "endwhere"
+ "if"
+ "then"
+ "where"
+] @keyword.conditional
+
+; Repeats
+[
+ "do"
+ "concurrent"
+ "enddo"
+ "endforall"
+ "forall"
+ "while"
+ "continue"
+ "cycle"
+ "exit"
+] @keyword.repeat
+
+; Variables
+(identifier) @variable
+
+; Parameters
+(keyword_argument
+ name: (identifier) @variable.parameter)
+
+(parameters
+ (identifier) @variable.parameter)
+
+; Properties
+(derived_type_member_expression
+ (type_member) @variable.member)
+
+; Operators
+[
+ "+"
+ "-"
+ "*"
+ "**"
+ "/"
+ "="
+ "<"
+ ">"
+ "<="
+ ">="
+ "=="
+ "/="
+ "//"
+ (assumed_rank)
+] @operator
+
+[
+ "\\.and\\."
+ "\\.or\\."
+ "\\.eqv\\."
+ "\\.neqv\\."
+ "\\.lt\\."
+ "\\.gt\\."
+ "\\.le\\."
+ "\\.ge\\."
+ "\\.eq\\."
+ "\\.ne\\."
+ "\\.not\\."
+] @keyword.operator
+
+; Punctuation
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "<<<"
+ ">>>"
+] @punctuation.bracket
+
+(array_literal
+ [
+ "(/"
+ "/)"
+ ] @punctuation.bracket)
+
+[
+ ":"
+ ","
+ "/"
+ "%"
+ "::"
+ "=>"
+] @punctuation.delimiter
+
+; Literals
+(string_literal) @string
+
+(number_literal) @number
+
+(boolean_literal) @boolean
+
+(null_literal) @constant.builtin
+
+; Comments
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^!>"))
diff --git a/runtime/queries/fortran/indents.scm b/runtime/queries/fortran/indents.scm
new file mode 100644
index 000000000..86704c4f4
--- /dev/null
+++ b/runtime/queries/fortran/indents.scm
@@ -0,0 +1,27 @@
+[
+ (module)
+ (program)
+ (subroutine)
+ (function)
+ ; (interface)
+ (if_statement)
+ (do_loop_statement)
+ (where_statement)
+ (derived_type_definition)
+ (enum)
+] @indent.begin
+
+[
+ (end_module_statement)
+ (end_program_statement)
+ (end_subroutine_statement)
+ (end_function_statement)
+ ; (end_interface_statement)
+ (end_if_statement)
+ (end_do_loop_statement)
+ (else_clause)
+ (elseif_clause)
+ (end_type_statement)
+ (end_enum_statement)
+ (end_where_statement)
+] @indent.branch
diff --git a/runtime/queries/fortran/injections.scm b/runtime/queries/fortran/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/runtime/queries/fortran/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))