From eeccf630eb4b2e62430f68f076ef25863a2e896f Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Wed, 10 Jul 2024 18:22:07 -0400 Subject: [PATCH] missing schemes, elixir queries --- Edit.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/Elixir.xcscheme | 97 +++++++++ .../xcshareddata/xcschemes/Go.xcscheme | 97 +++++++++ .../Elixir/queries/highlights.scm | 201 ++++++++++++++++++ .../Elixir/queries/injections.scm | 7 + .../LanguageData/Elixir/queries/tags.scm | 54 +++++ 6 files changed, 458 insertions(+), 2 deletions(-) create mode 100644 Edit.xcodeproj/xcshareddata/xcschemes/Elixir.xcscheme create mode 100644 Edit.xcodeproj/xcshareddata/xcschemes/Go.xcscheme create mode 100644 Edit/Resources/LanguageData/Elixir/queries/highlights.scm create mode 100644 Edit/Resources/LanguageData/Elixir/queries/injections.scm create mode 100644 Edit/Resources/LanguageData/Elixir/queries/tags.scm diff --git a/Edit.xcodeproj/project.pbxproj b/Edit.xcodeproj/project.pbxproj index 3ada9d3..01a582a 100644 --- a/Edit.xcodeproj/project.pbxproj +++ b/Edit.xcodeproj/project.pbxproj @@ -136,6 +136,7 @@ C9818AD52C3F2CA70032899D /* Gopls.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD12C3F2CA70032899D /* Gopls.swift */; }; C9818AD82C3F2D350032899D /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; }; C9818AD92C3F2DB90032899D /* Gopls.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD12C3F2CA70032899D /* Gopls.swift */; }; + C9818ADA2C3F40B00032899D /* ElixirStandaloneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AB62C3EF68B0032899D /* ElixirStandaloneExtension.swift */; }; C986F2492C3ED60800A62879 /* ClojureExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C986F2472C3ED60800A62879 /* ClojureExtension.swift */; }; C986F24A2C3ED67900A62879 /* ClojureExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C986F2472C3ED60800A62879 /* ClojureExtension.swift */; }; C9891AF82AFE996300C8F393 /* NSParagraphStyle+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9891AF72AFE996300C8F393 /* NSParagraphStyle+Helpers.swift */; }; @@ -3353,6 +3354,7 @@ buildActionMask = 2147483647; files = ( C9818ABA2C3EF6E80032899D /* ElixirExtension.swift in Sources */, + C9818ADA2C3F40B00032899D /* ElixirStandaloneExtension.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4582,7 +4584,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = C92673282B04046700B3CE2F /* Edit-Debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; }; name = Debug; }; @@ -4590,7 +4591,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = C9FE52CC2A752B4D00CACA1A /* Edit.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; }; name = Release; }; diff --git a/Edit.xcodeproj/xcshareddata/xcschemes/Elixir.xcscheme b/Edit.xcodeproj/xcshareddata/xcschemes/Elixir.xcscheme new file mode 100644 index 0000000..950e5e7 --- /dev/null +++ b/Edit.xcodeproj/xcshareddata/xcschemes/Elixir.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Edit.xcodeproj/xcshareddata/xcschemes/Go.xcscheme b/Edit.xcodeproj/xcshareddata/xcschemes/Go.xcscheme new file mode 100644 index 0000000..6d1373d --- /dev/null +++ b/Edit.xcodeproj/xcshareddata/xcschemes/Go.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Edit/Resources/LanguageData/Elixir/queries/highlights.scm b/Edit/Resources/LanguageData/Elixir/queries/highlights.scm new file mode 100644 index 0000000..c9841d3 --- /dev/null +++ b/Edit/Resources/LanguageData/Elixir/queries/highlights.scm @@ -0,0 +1,201 @@ +; Punctuation + +[ + "%" +] @punctuation + +[ + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<<" + ">>" +] @punctuation.bracket + +; Literals + +[ + (boolean) + (nil) +] @constant + +[ + (integer) + (float) +] @number + +(char) @constant + +; Identifiers + +; * regular +(identifier) @variable + +; * unused +( + (identifier) @comment.unused + (#match? @comment.unused "^_") +) + +; * special +( + (identifier) @constant.builtin + (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$") +) + +; Comment + +(comment) @comment + +; Quoted content + +(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded + +(escape_sequence) @string.escape + +[ + (string) + (charlist) +] @string + +[ + (atom) + (quoted_atom) + (keyword) + (quoted_keyword) +] @string.special.symbol + +; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters + +(sigil + (sigil_name) @__name__ + quoted_start: _ @string.special + quoted_end: _ @string.special) @string.special + +(sigil + (sigil_name) @__name__ + quoted_start: _ @string + quoted_end: _ @string + (#match? @__name__ "^[sS]$")) @string + +(sigil + (sigil_name) @__name__ + quoted_start: _ @string.regex + quoted_end: _ @string.regex + (#match? @__name__ "^[rR]$")) @string.regex + +; Calls + +; * function call +(call + target: [ + ; local + (identifier) @function + ; remote + (dot + right: (identifier) @function) + ]) + +; * definition keyword +(call + target: (identifier) @keyword + (#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$")) + +; * kernel or special forms keyword +(call + target: (identifier) @keyword + (#match? @keyword "^(alias|case|cond|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$")) + +; * just identifier in function definition +(call + target: (identifier) @keyword + (arguments + [ + (identifier) @function + (binary_operator + left: (identifier) @function + operator: "when") + ]) + (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) + +; * pipe into identifier (function call) +(binary_operator + operator: "|>" + right: (identifier) @function) + +; * pipe into identifier (definition) +(call + target: (identifier) @keyword + (arguments + (binary_operator + operator: "|>" + right: (identifier) @variable)) + (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) + +; Operators + +; * capture operand +(unary_operator + operator: "&" + operand: (integer) @operator) + +(operator_identifier) @operator + +(unary_operator + operator: _ @operator) + +(binary_operator + operator: _ @operator) + +(dot + operator: _ @operator) + +(stab_clause + operator: _ @operator) + +; * module attribute +(unary_operator + operator: "@" @attribute + operand: [ + (identifier) @attribute + (call + target: (identifier) @attribute) + (boolean) @attribute + (nil) @attribute + ]) + +; * doc string +(unary_operator + operator: "@" @comment.doc + operand: (call + target: (identifier) @comment.doc.__attribute__ + (arguments + [ + (string) @comment.doc + (charlist) @comment.doc + (sigil + quoted_start: _ @comment.doc + quoted_end: _ @comment.doc) @comment.doc + (boolean) @comment.doc + ])) + (#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$")) + +; Module + +(alias) @module + +(call + target: (dot + left: (atom) @module)) + +; Reserved keywords + +["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword diff --git a/Edit/Resources/LanguageData/Elixir/queries/injections.scm b/Edit/Resources/LanguageData/Elixir/queries/injections.scm new file mode 100644 index 0000000..16069ce --- /dev/null +++ b/Edit/Resources/LanguageData/Elixir/queries/injections.scm @@ -0,0 +1,7 @@ +; Phoenix HTML template +((sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content) + (#eq? @_sigil_name "H") + (#set! injection.language "heex") + (#set! injection.combined)) diff --git a/Edit/Resources/LanguageData/Elixir/queries/tags.scm b/Edit/Resources/LanguageData/Elixir/queries/tags.scm new file mode 100644 index 0000000..3408b7f --- /dev/null +++ b/Edit/Resources/LanguageData/Elixir/queries/tags.scm @@ -0,0 +1,54 @@ +; Definitions + +; * modules and protocols +(call + target: (identifier) @ignore + (arguments (alias) @name) + (#match? @ignore "^(defmodule|defprotocol)$")) @definition.module + +; * functions/macros +(call + target: (identifier) @ignore + (arguments + [ + ; zero-arity functions with no parentheses + (identifier) @name + ; regular function clause + (call target: (identifier) @name) + ; function clause with a guard clause + (binary_operator + left: (call target: (identifier) @name) + operator: "when") + ]) + (#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function + +; References + +; ignore calls to kernel/special-forms keywords +(call + target: (identifier) @ignore + (#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defmodule|defprotocol|defimpl|defstruct|defexception|defoverridable|alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$")) + +; ignore module attributes +(unary_operator + operator: "@" + operand: (call + target: (identifier) @ignore)) + +; * function call +(call + target: [ + ; local + (identifier) @name + ; remote + (dot + right: (identifier) @name) + ]) @reference.call + +; * pipe into function call +(binary_operator + operator: "|>" + right: (identifier) @name) @reference.call + +; * modules +(alias) @name @reference.module