diff --git a/languages.toml b/languages.toml index fd6636ade..d7a539c8d 100644 --- a/languages.toml +++ b/languages.toml @@ -2610,7 +2610,7 @@ language-servers = [ "fortls" ] [[grammar]] name = "fortran" -source = { git = "https://github.com/stadelmanma/tree-sitter-fortran", rev = "f0f2f100952a353e64e26b0fa710b4c296d7af13" } +source = { git = "https://github.com/stadelmanma/tree-sitter-fortran", rev = "1b08f4c65fb47c76d3532cd3f7432d03abb9ef69" } [[language]] name = "ungrammar" diff --git a/runtime/queries/fortran/folds.scm b/runtime/queries/fortran/folds.scm index f62d9dd7b..01e24dd6c 100644 --- a/runtime/queries/fortran/folds.scm +++ b/runtime/queries/fortran/folds.scm @@ -7,5 +7,6 @@ (derived_type_definition) (function) (subroutine) + (module_procedure) (interface) -] @fold \ No newline at end of file +] @fold diff --git a/runtime/queries/fortran/highlights.scm b/runtime/queries/fortran/highlights.scm index 0901a4aa7..418e40dfe 100644 --- a/runtime/queries/fortran/highlights.scm +++ b/runtime/queries/fortran/highlights.scm @@ -1,136 +1,155 @@ -[ - (intrinsic_type) - "dimension" - "intent" - "in" - "out" - "inout" - "type" - "endtype" - "attributes" - "global" - "device" - "host" - "grid_global" - "pointer" -] @keyword.storage.modifier - -[ - "contains" - "public" - "private" -] @keyword.directive - -[ -"implicit" -(none) -] @attribute - -[ - "function" - "endfunction" - "endprogram" - "subroutine" - "endsubroutine" -] @keyword.storage - -[ - "module" - "endmodule" - "bind" - "call" - "class" - "continue" - "cycle" - "enumerator" - "equivalence" - "exit" - "format" - "goto" - "include" - "interface" - "endinterface" - "only" - "parameter" - "procedure" - "print" - "program" - "endprogram" - "read" - "return" - "result" - "stop" - "use" - "write" - "enum" - "endenum" - (default) - (procedure_qualifier) -] @keyword - -[ - "if" - "then" - "else" - "elseif" - "endif" - "where" - "endwhere" -] @keyword.control.conditional - -[ - "do" - "enddo" - "while" - "forall" -] @keyword.control.repeat - -[ - "*" - "**" - "+" - "-" - "/" - "=" - "<" - ">" - "<=" - ">=" - "==" - "/=" -] @operator - -[ - "\\.and\\." - "\\.or\\." - "\\.lt\\." - "\\.gt\\." - "\\.ge\\." - "\\.le\\." - "\\.eq\\." - "\\.eqv\\." - "\\.neqv\\." -] @keyword.operator - (identifier) @variable +(string_literal) @string +(number_literal) @number +(boolean_literal) @boolean +(comment) @comment - ;; Brackets - [ - "(" - ")" - "[" - "]" +[ + (intrinsic_type) + "allocatable" + "attributes" + "device" + "dimension" + "endtype" + "global" + "grid_global" + "host" + "import" + "in" + "inout" + "intent" + "optional" + "out" + "pointer" + "type" + "value" + ] @type + +[ + "contains" + "private" + "public" + ] @include + +[ + (none) + "implicit" + ] @attribute + +[ + "endfunction" + "endprogram" + "endsubroutine" + "function" + "procedure" + "subroutine" + ] @keyword.function + +[ + (default) + (procedure_qualifier) + "abstract" + "bind" + "call" + "class" + "continue" + "cycle" + "endenum" + "endinterface" + "endmodule" + "endprocedure" + "endprogram" + "endsubmodule" + "enum" + "enumerator" + "equivalence" + "exit" + "extends" + "format" + "goto" + "include" + "interface" + "intrinsic" + "non_intrinsic" + "module" + "namelist" + "only" + "parameter" + "print" + "procedure" + "program" + "read" + "stop" + "submodule" + "use" + "write" + ] @keyword + +"return" @keyword.return + +[ + "else" + "elseif" + "elsewhere" + "endif" + "endwhere" + "if" + "then" + "where" + ] @conditional + +[ + "do" + "enddo" + "forall" + "while" + ] @repeat + +[ + "*" + "+" + "-" + "/" + "=" + "<" + ">" + "<=" + ">=" + "==" + "/=" + ] @operator + +[ + "\\.and\\." + "\\.or\\." + "\\.lt\\." + "\\.gt\\." + "\\.ge\\." + "\\.le\\." + "\\.eq\\." + "\\.eqv\\." + "\\.neqv\\." + ] @keyword.operator + +;; Brackets +[ + "(" + ")" + "[" + "]" + "<<<" + ">>>" ] @punctuation.bracket - ;; Delimiter - [ - "::" - "," - "%" +;; Delimiter +[ + "::" + "," + "%" ] @punctuation.delimiter (parameters - (identifier) @variable.parameter) + (identifier) @parameter) (program_statement (name) @namespace) @@ -138,35 +157,41 @@ (module_statement (name) @namespace) +(submodule_statement + (module_name) (name) @namespace) + (function_statement (name) @function) (subroutine_statement (name) @function) +(module_procedure_statement + (name) @function) + (end_program_statement (name) @namespace) (end_module_statement (name) @namespace) +(end_submodule_statement + (name) @namespace) + (end_function_statement (name) @function) (end_subroutine_statement (name) @function) +(end_module_procedure_statement + (name) @function) + (subroutine_call - (name) @function) + (identifier) @function) (keyword_argument name: (identifier) @keyword) (derived_type_member_expression - (type_member) @variable.other.member) - -(string_literal) @string -(number_literal) @constant.numeric -(boolean_literal) @constant.builtin.boolean -(comment) @comment - + (type_member) @property) diff --git a/runtime/queries/fortran/indents.scm b/runtime/queries/fortran/indents.scm index daa8bac10..b7881fb45 100644 --- a/runtime/queries/fortran/indents.scm +++ b/runtime/queries/fortran/indents.scm @@ -1,7 +1,9 @@ [ (module) + (submodule) (program) (subroutine) + (module_procedure) (function) ; (interface) (if_statement) @@ -13,8 +15,10 @@ [ (end_module_statement) + (end_submodule_statement) (end_program_statement) (end_subroutine_statement) + (end_module_procedure_statement) (end_function_statement) ; (end_interface_statement) (end_if_statement) @@ -24,4 +28,4 @@ (end_type_statement) (end_enum_statement) (end_where_statement) -] @outdent \ No newline at end of file +] @branch