Skip to content

Commit

Permalink
Change: Export keyword JSON for VSCode (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Aug 29, 2022
1 parent fa5b89b commit ea27c4a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions nml/editors/visualstudiocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
with nmlL; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""

import json
from nml.editors import extract_tables

output_file = "newgrfml.tmLanguage.json"

text1 = """\
{
"name": "newgrfml",
Expand Down Expand Up @@ -168,18 +167,22 @@
"""


# Build VS .tmLanguage file
def write_file(fname):
def run():
line = r"(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))("
lineend = r")(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))"
with open(fname, "w") as file:
with open("newgrfml.tmLanguage.json", "w") as file:
file.write(text1)
file.write(text2.replace("blocks", line + "|".join(extract_tables.block_names_table) + lineend))
file.write(text3.replace("variables", line + "|".join(extract_tables.variables_names_table) + lineend))
file.write(text4.replace("features", line + "|".join(extract_tables.feature_names_table) + lineend))
file.write(text5.replace("callbacks", line + "|".join(extract_tables.callback_names_table) + lineend))
file.write(text6)


def run():
write_file(output_file)
# Simple JSON that contains all keywords for suggestion purposes.
with open("providers.json", "w") as file:
output = {}
output["block"] = extract_tables.block_names_table
output["variables"] = extract_tables.variables_names_table
output["features"] = extract_tables.feature_names_table
output["callbacks"] = extract_tables.callback_names_table
file.write(json.dumps(output, separators=(",", ":")))

0 comments on commit ea27c4a

Please sign in to comment.