on master help sign in
add fortran language (#3025)
commit0cb0c306183be94b9d42c3fae22b805850f87584 authorAusten LeBeau <austenlebeau@gmail.com> dateSun 10 Jul 2022, 11:27 (4 years ago) parente109022
5 files changed+224
book/src/generated/lang-support.md+1 languages.toml+14 runtime/queries/fortran/folds.scm+11 runtime/queries/fortran/highlights.scm+171 runtime/queries/fortran/indents.scm+27
book/src/generated/lang-support.md+1
@@ -22,6 +22,7 @@
2222| erb | ✓ | | | |
2323| erlang | ✓ | ✓ | | `erlang_ls` |
2424| fish | ✓ | ✓ | ✓ | |
25+| fortran | ✓ | | ✓ | `fortls` |
2526| gdscript | ✓ | | ✓ | |
2627| git-attributes | ✓ | | | |
2728| git-commit | ✓ | | | |
languages.toml+14
@@ -1514,3 +1514,17 @@ roots = []
15141514comment-token = "--"
15151515indent = { tab-width = 2, unit = " " }
15161516language-server = { command = "idris2-lsp" }
1517+
1518+[[language]]
1519+name = "fortran"
1520+scope = "source.fortran"
1521+injection-regex = "fortran"
1522+file-types = ["f", "for", "f90", "f95", "f03"]
1523+roots = ["fpm.toml"]
1524+comment-token = "!"
1525+indent = { tab-width = 4, unit = " "}
1526+language-server = { command = "fortls", args = ["--lowercase_intrinsics"] }
1527+
1528+[[grammar]]
1529+name = "fortran"
1530+source = { git = "https://github.com/stadelmanma/tree-sitter-fortran", rev = "f0f2f100952a353e64e26b0fa710b4c296d7af13" }
runtime/queries/fortran/folds.scmnew file+11
@@ -0,0 +1,11 @@
1+;; by @oponkork
2+[
3+ (if_statement)
4+ (where_statement)
5+ (enum_statement)
6+ (do_loop_statement)
7+ (derived_type_definition)
8+ (function)
9+ (subroutine)
10+ (interface)
11+] @fold
runtime/queries/fortran/highlights.scmnew file+171
@@ -0,0 +1,171 @@
1+[
2+ (intrinsic_type)
3+ "dimension"
4+ "intent"
5+ "in"
6+ "out"
7+ "inout"
8+ "type"
9+ "endtype"
10+ "attributes"
11+ "global"
12+ "device"
13+ "host"
14+ "grid_global"
15+ "pointer"
16+] @keyword.storage.modifier
17+
18+[
19+ "contains"
20+ "public"
21+ "private"
22+] @keyword.directive
23+
24+[
25+"implicit"
26+(none)
27+] @attribute
28+
29+[
30+ "function"
31+ "endfunction"
32+ "endprogram"
33+ "subroutine"
34+ "endsubroutine"
35+] @keyword.storage
36+
37+[
38+ "module"
39+ "endmodule"
40+ "bind"
41+ "call"
42+ "class"
43+ "continue"
44+ "cycle"
45+ "enumerator"
46+ "equivalence"
47+ "exit"
48+ "format"
49+ "goto"
50+ "include"
51+ "interface"
52+ "endinterface"
53+ "only"
54+ "parameter"
55+ "procedure"
56+ "print"
57+ "program"
58+ "endprogram"
59+ "read"
60+ "return"
61+ "result"
62+ "stop"
63+ "use"
64+ "write"
65+ "enum"
66+ "endenum"
67+ (default)
68+ (procedure_qualifier)
69+] @keyword
70+
71+[
72+ "if"
73+ "then"
74+ "else"
75+ "elseif"
76+ "endif"
77+ "where"
78+ "endwhere"
79+] @keyword.control.conditional
80+
81+[
82+ "do"
83+ "enddo"
84+ "while"
85+ "forall"
86+] @keyword.control.repeat
87+
88+[
89+ "*"
90+ "**"
91+ "+"
92+ "-"
93+ "/"
94+ "="
95+ "<"
96+ ">"
97+ "<="
98+ ">="
99+ "=="
100+ "/="
101+] @operator
102+
103+[
104+ "\\.and\\."
105+ "\\.or\\."
106+ "\\.lt\\."
107+ "\\.gt\\."
108+ "\\.ge\\."
109+ "\\.le\\."
110+ "\\.eq\\."
111+ "\\.eqv\\."
112+ "\\.neqv\\."
113+] @keyword.operator
114+
115+ ;; Brackets
116+ [
117+ "("
118+ ")"
119+ "["
120+ "]"
121+ ] @punctuation.bracket
122+
123+ ;; Delimiter
124+ [
125+ "::"
126+ ","
127+ "%"
128+ ] @punctuation.delimiter
129+
130+(parameters
131+ (identifier) @variable.parameter)
132+
133+(program_statement
134+ (name) @namespace)
135+
136+(module_statement
137+ (name) @namespace)
138+
139+(function_statement
140+ (name) @function)
141+
142+(subroutine_statement
143+ (name) @function)
144+
145+(end_program_statement
146+ (name) @namespace)
147+
148+(end_module_statement
149+ (name) @namespace)
150+
151+(end_function_statement
152+ (name) @function)
153+
154+(end_subroutine_statement
155+ (name) @function)
156+
157+(subroutine_call
158+ (name) @function)
159+
160+(keyword_argument
161+ name: (identifier) @keyword)
162+
163+(derived_type_member_expression
164+ (type_member) @variable.other.member)
165+
166+(identifier) @variable
167+(string_literal) @string
168+(number_literal) @constant.numeric
169+(boolean_literal) @constant.builtin.boolean
170+(comment) @comment
171+
runtime/queries/fortran/indents.scmnew file+27
@@ -0,0 +1,27 @@
1+[
2+ (module)
3+ (program)
4+ (subroutine)
5+ (function)
6+ ; (interface)
7+ (if_statement)
8+ (do_loop_statement)
9+ (where_statement)
10+ (derived_type_definition)
11+ (enum)
12+] @indent
13+
14+[
15+ (end_module_statement)
16+ (end_program_statement)
17+ (end_subroutine_statement)
18+ (end_function_statement)
19+ ; (end_interface_statement)
20+ (end_if_statement)
21+ (end_do_loop_statement)
22+ (else_clause)
23+ (elseif_clause)
24+ (end_type_statement)
25+ (end_enum_statement)
26+ (end_where_statement)
27+] @outdent