diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 1 | ||||
| -rw-r--r-- | queries/fortran/highlights.scm | 326 |
3 files changed, 237 insertions, 92 deletions
@@ -214,7 +214,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD) - [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z) - [x] [foam](https://github.com/FoamScience/tree-sitter-foam) (experimental, maintained by @FoamScience) -- [ ] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) +- [x] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) (maintained by @amaanq) - [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna) - [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq) - [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 75efd7fca..fa5795335 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -443,6 +443,7 @@ list.fortran = { url = "https://github.com/stadelmanma/tree-sitter-fortran", files = { "src/parser.c", "src/scanner.cc" }, }, + maintainers = { "@amaanq" }, } list.fsh = { diff --git a/queries/fortran/highlights.scm b/queries/fortran/highlights.scm index 95839184a..4604e9a92 100644 --- a/queries/fortran/highlights.scm +++ b/queries/fortran/highlights.scm @@ -1,96 +1,224 @@ -(identifier) @variable -(string_literal) @string -(number_literal) @number -(boolean_literal) @boolean -(comment) @comment +; Preprocs + +(preproc_file_line) @preproc + +; Namespaces + +(program_statement + (name) @namespace) + +(end_program_statement + (name) @namespace) + +(module_statement + (name) @namespace) + +(end_module_statement + (name) @namespace) + +(submodule_statement + (name) @namespace) + +(end_submodule_statement + (name) @namespace) + +; Includes [ - (intrinsic_type) - "pointer" + "import" + "include" + "use" +] @include + +(import_statement + "," + ["all" "none"] @keyword) + +; Attributes + +[ + (none) + "implicit" + "intent" +] @attribute + +(implicit_statement + "type" @attribute) + +; Keywords + +[ + "attributes" + "associate" + "block" + "class" + "classis" + "contains" + "default" + "dimension" + "endassociate" + "endenum" + "endinterface" + "endmodule" + "endselect" + "endsubmodule" + "endtype" + "enum" + "enumerator" + "equivalence" + "extends" + "goto" + "interface" + "intrinsic" + "non_intrinsic" + "module" + "submodule" + "namelist" + "parameter" + "quiet" + "rank" + "save" + "selectcase" + "selectrank" + "selecttype" + "sequence" + "stop" + "target" + "type" + "typeis" +] @keyword + +[ + (default) +] @keyword + +; Types + +[ + (type_name) ] @type [ + (intrinsic_type) +] @type.builtin + +; Qualifiers + +[ + "abstract" "allocatable" - "attributes" + "automatic" + "constant" + "contiguous" + "data" + "deferred" "device" - "dimension" + "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) ] @type.qualifier [ - "endtype" - "type" -] @type.definition - -[ + "common" "in" "inout" "out" ] @storageclass -[ - "contains" - "import" -] @include +; Labels [ - (none) - "implicit" - "intent" -] @attribute + (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" - "call" - "class" - "continue" - "cycle" - "endenum" - "endinterface" - "endmodule" - "endprogram" - "enum" - "enumerator" - "equivalence" - "exit" "format" - "goto" - "include" - "interface" - "module" - "namelist" - "only" - "parameter" + "open" "print" - "program" "read" - "stop" - "use" "write" - (default) - (procedure_qualifier) -] @keyword +] @function.builtin -"return" @keyword.return +; Exceptions + +[ + "error" +] @exception + +; Conditionals [ "else" "elseif" + "elsewhere" "endif" "endwhere" "if" @@ -98,17 +226,44 @@ "where" ] @conditional +; Repeats + [ "do" + "concurrent" "enddo" + "endforall" "forall" "while" + "continue" + "cycle" + "exit" ] @repeat +; Variables + +(identifier) @variable + +; Parameters + +(keyword_argument + name: (identifier) @parameter) + +(parameters + (identifier) @parameter) + +; Properties + +(derived_type_member_expression + (type_member) @property) + +; Operators + [ - "*" "+" "-" + "*" + "**" "/" "=" "<" @@ -117,69 +272,58 @@ ">=" "==" "/=" + "//" + (assumed_rank) ] @operator [ "\\.and\\." "\\.or\\." + "\\.eqv\\." + "\\.neqv\\." "\\.lt\\." "\\.gt\\." - "\\.ge\\." "\\.le\\." + "\\.ge\\." "\\.eq\\." - "\\.eqv\\." - "\\.neqv\\." + "\\.ne\\." + "\\.not\\." ] @keyword.operator - ;; Brackets - [ - "(" - ")" - "[" - "]" - "<<<" - ">>>" - ] @punctuation.bracket +; Punctuation - ;; Delimiter - [ - "::" - "," - "%" - ] @punctuation.delimiter +[ "[" "]" ] @punctuation.bracket -(parameters - (identifier) @parameter) +[ "(" ")" ] @punctuation.bracket -(program_statement - (name) @namespace) +[ "<<<" ">>>" ] @punctuation.bracket -(module_statement - (name) @namespace) +(array_literal + ["(/" "/)"] @punctuation.bracket) -(function_statement - (name) @function) +[ + ":" + "," + "/" + "%" + "::" + "=>" +] @punctuation.delimiter -(subroutine_statement - (name) @function) +; Literals -(end_program_statement - (name) @namespace) +(string_literal) @string -(end_module_statement - (name) @namespace) +(number_literal) @number -(end_function_statement - (name) @function) +(boolean_literal) @boolean -(end_subroutine_statement - (name) @function) +(null_literal) @constant.builtin -(subroutine_call - (identifier) @function.call) +; Comments -(keyword_argument - name: (identifier) @keyword) +(comment) @comment @spell -(derived_type_member_expression - (type_member) @property) +; Errors + +(ERROR) @error |
