diff --git a/queries/highlights.scm b/queries/highlights.scm index c9841d3..ea6df34 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -94,15 +94,30 @@ ; Calls -; * function call +; * local function call (call - target: [ - ; local - (identifier) @function - ; remote - (dot - right: (identifier) @function) - ]) + target: (identifier) @function) + +; * remote function call +(call + target: (dot + right: (identifier) @function)) + +; * field without parentheses or block +(call + target: (dot + right: (identifier) @property) + .) + +; * remote call without parentheses or block (overrides above) +(call + target: (dot + left: [ + (alias) + (atom) + ] + right: (identifier) @function) + .) ; * definition keyword (call @@ -140,6 +155,13 @@ right: (identifier) @variable)) (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) +; * pipe into field without parentheses (function call) +(binary_operator + operator: "|>" + right: (call + target: (dot + right: (identifier) @function))) + ; Operators ; * capture operand diff --git a/test/highlight/calls.ex b/test/highlight/calls.ex index eb51f23..ea0e03e 100644 --- a/test/highlight/calls.ex +++ b/test/highlight/calls.ex @@ -88,3 +88,37 @@ end) # ^ operator # ^ number # ^ punctuation.bracket + +map.key1 +# ^ variable +# ^ property + +map.key1.key2 +# ^ variable +# ^ property +# ^ property + +DateTime.utc_now.day +# ^ module +# ^ function +# ^ property + +arg |> mod.func +# ^ variable +# ^ operator +# ^ variable +# ^ function + +Mod.fun do +# ^ module +# ^ function +# ^ keyword +end +# ^ keyword + +mod.fun do +# ^ variable +# ^ function +# ^ keyword +end +# ^ keyword diff --git a/test/highlight/kernel.ex b/test/highlight/kernel.ex index c2d188a..9c4a9de 100644 --- a/test/highlight/kernel.ex +++ b/test/highlight/kernel.ex @@ -92,7 +92,7 @@ case __ENV__.line do # ^ keyword # ^ constant.builtin # ^ operator -# ^ function +# ^ property # ^ keyword x when is_integer(x) -> x # <- variable