From fbf2a646a30597b0e93650752a74483b63ff3d12 Mon Sep 17 00:00:00 2001 From: water Date: Sat, 14 Aug 2021 11:28:02 -0400 Subject: [PATCH] add sublime text config --- scripts/sublime_text/goal.sublime-settings | 6 ++ scripts/sublime_text/goal.sublime-syntax | 92 +++++++++++++++++++ .../sublime_text/lispindent.sublime-settings | 12 +++ scripts/sublime_text/readme.txt | 7 ++ 4 files changed, 117 insertions(+) create mode 100644 scripts/sublime_text/goal.sublime-settings create mode 100644 scripts/sublime_text/goal.sublime-syntax create mode 100644 scripts/sublime_text/lispindent.sublime-settings create mode 100644 scripts/sublime_text/readme.txt diff --git a/scripts/sublime_text/goal.sublime-settings b/scripts/sublime_text/goal.sublime-settings new file mode 100644 index 0000000000..f713b77d90 --- /dev/null +++ b/scripts/sublime_text/goal.sublime-settings @@ -0,0 +1,6 @@ +{ + "extensions": + [ + "gc" + ] +} diff --git a/scripts/sublime_text/goal.sublime-syntax b/scripts/sublime_text/goal.sublime-syntax new file mode 100644 index 0000000000..5c9cd73640 --- /dev/null +++ b/scripts/sublime_text/goal.sublime-syntax @@ -0,0 +1,92 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: goal +file_extensions: + - gc +scope: source.goal +contexts: + main: + + # Important keywords for blocks/control flow/etc + - match: \b(?i:begin|block|return-from|cond|when|if|unless|let|else|while|rlet|countdown|dotimes)\b + scope: keyword.control.goal + + # Less important keywords + - match: \b(?i:the-as|the|logior|logand|ash|cons|car|cdr|new|break|none|method-of-type|method-of-object|declare|and|not)\b + scope: keyword.operator.goal + + # Definition forms like (def thing value) + - match: \b(?i:(defun|defmacro|deftype|define|defconstant|defun-debug|define-extern))\b\s+([\w\-!?<>]*) + scope: meta.function.goal + captures: + 1: keyword.declaration.function.goal + 2: entity.name.function.goal + + # Special case for defmethod + - match: \b(?i:(defmethod))\b\s+([\w\-!?<>]*)\b\s+([\w\-!?<>]*) + scope: meta.function.goal + captures: + 1: keyword.declaration.function.goal + 2: entity.name.function.goal + 3: entity.name.class.lisgoalp + + # Special case for set. Need a special case because of the !, and don't want to match reset! + - match: \b(?i:set!|neq\?|eq\?|zero\?) + scope: keyword.operator.goal + + - match: (?i:->) + scope: keyword.operator.goal + + # Quoted symbols. I abuse these as "parameter" + - match: (?i:'([\w\-!?<>]+)) + scope: variable.parameter.goal + + # Block comments + - match: '#\|' + scope: punctuation.definition.comment.begin.goal + push: + - meta_scope: comment.block.goal + - include: block-comment + - match: '\|#' + scope: punctuation.definition.comment.end.goal + pop: true + + # Normal Comments + - match: (;).*$\n? + scope: comment.line.semicolon.goal + captures: + 1: punctuation.definition.comment.goal + + # Built-in, numeric type + - match: \b(uint128|int128|float|int64|uint64|int32|uint32|int16|uint16|int8|uint8|binteger|int|uint|pointer)\b + scope: storage.type + + - match: (?i:#t|#f|'\(\)) + scope: constant.language.goal + + - match: '(#)(\w|[\\+-=<>''."&#])+' + scope: constant.character.goal + captures: + 1: constant.character.goal # change this to change the color of the prefix. + + - match: (\*)(\S*)(\*) + scope: variable.function.goal + + - match: :(\S*) + scope: variable.function.goal + + + - match: '"' + captures: + 0: punctuation.definition.string.begin.goal + push: + - meta_scope: string.quoted.double.goal + - match: '"' + captures: + 0: punctuation.definition.string.end.goal + pop: true + - match: \\. + scope: constant.character.escape.goal + + diff --git a/scripts/sublime_text/lispindent.sublime-settings b/scripts/sublime_text/lispindent.sublime-settings new file mode 100644 index 0000000000..836528e45f --- /dev/null +++ b/scripts/sublime_text/lispindent.sublime-settings @@ -0,0 +1,12 @@ +{ + "languages": { + "goal": { + "detect": ".*\\.(gc)$", + "default_indent": "function", + "regex": + ["(with-gensyms|defenum|countdown|while|defglobalconstant|desfun|defsmacro|catch|defvar|defclass|defconstant|defcustom|defparameter|defconst|define-condition|define-modify-macro|", + "defsetf|defun|defgeneric|define-setf-method|define-self-expander|defmacro|defsubst|deftype|defmethod|", + "defpackage|defstruct|dolist|dotimes|lambda|let|let\\*|prog1|prog2|unless|when)$"] + } + } +} diff --git a/scripts/sublime_text/readme.txt b/scripts/sublime_text/readme.txt new file mode 100644 index 0000000000..28e5d8fbd3 --- /dev/null +++ b/scripts/sublime_text/readme.txt @@ -0,0 +1,7 @@ +move the goal.sublime-syntax file to your Packages/User directory. To find this, you can go to Preferences -> Browse Packages -> User. + +To enable the syntax highlighting, set the language to goal. It should show up in the "User" category. + +For formatting, install the lispindent plugin and move the lispindent config file to the same User folder. + +