Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- uses: actions/checkout@v2
- uses: SublimeText/syntax-test-action@v2
with:
build: 4134
default_packages: v4134
build: 4143
default_packages: v4143
package_name: ElixirSyntax
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [v3.2.1] – 2023-06-24

- Elixir: fixed quoted module name function calls such as `:"Elixir.Kernel".in(1, [1])`
- SQL: recognize `CREATE TYPE`

## [v3.2.0] – 2023-05-02

- Commands: improved/generalized syntax detection for enabling/disabling commands.
Expand Down
106 changes: 50 additions & 56 deletions syntaxes/Elixir.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,9 @@ contexts:
scope: punctuation.accessor.dot.elixir
set:
- include: arguments_paren_param_pop
- include: atom_keyword
- include: module_function_call_param_pop
- include: unquote_call_pop
- include: id_or_operator_call_param_pop
- include: id_member_pop
- include: module_name_pop
- include: arguments_pop
- include: quoted_remote_call_pop
- include: quoted_member_pop
- include: tuple_call_pop
- include: if_non_space_or_eol_pop
- include: member_or_call_pop

function_call_param:
- match: (?=\.(?!\.))
Expand Down Expand Up @@ -1786,38 +1778,31 @@ contexts:
module_name:
- match: '{{module_name}}{{no_key_suffix}}'
scope: constant.other.module.elixir
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
3: constant.other.module.elixir
4: punctuation.definition.constant.end.elixir
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
2: constant.other.module.elixir
- include: atom_module_name

module_name_pop:
- match: '{{module_name}}{{no_key_suffix}}'
scope: constant.other.module.elixir
pop: 1

module_function_call_pop:
- match: ({{module_name}})\s*(\.(?!\.))
- match: ({{module_name}})(?=\s*\.(?!\.))
comment: always a function call after a module
captures:
1: constant.other.module.elixir
2: punctuation.accessor.dot.elixir
set: member_call_pop
scope: constant.other.module.elixir
set: module_member_pop

member_call_pop:
# - include: sql_or_fragment
- include: quoted_remote_call_pop
- include: quoted_member_pop
- include: unquote_call_pop
- match: '{{member}}'
scope: variable.function.elixir
set: arguments_or_pop
- include: tuple_call_pop
- include: if_non_space_or_eol_pop
module_member_pop:
- match: \.(?!\.)
scope: punctuation.accessor.dot.elixir
set:
- match: '{{member}}'
comment: always a function after module name
scope: variable.function.elixir
set: arguments_or_pop
- match: (?=\()
comment: no ".()" style arguments after module name
pop: 1
- include: member_or_call_pop

id_or_operator_call_pop:
- match: ({{member}})(?=\s*\.\s*\(|{{has_arguments}})
Expand Down Expand Up @@ -1872,19 +1857,32 @@ contexts:
captures:
1: constant.character.escape.char.elixir

modules_or_ids_or_calls:
atom_module_name:
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
3: constant.other.module.elixir
4: punctuation.definition.constant.end.elixir
push: member_call_pop
- match: (:)({{atom_symbol}})\s*(\.(?!\.))
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
2: constant.other.module.elixir
3: punctuation.accessor.dot.elixir
push: member_call_pop

atom_module_name_call:
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
3: constant.other.module.elixir
4: punctuation.definition.constant.end.elixir
push: module_member_pop
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
captures:
1: punctuation.definition.constant.begin.elixir
2: constant.other.module.elixir
push: module_member_pop

modules_or_ids_or_calls:
- include: atom_module_name_call
- match: (?={{module_name}}|{{identifier}})
push:
- include: module_function_call_pop
Expand Down Expand Up @@ -1916,18 +1914,19 @@ contexts:
dot_accessor:
- match: \.(?!\.)
scope: punctuation.accessor.dot.elixir
push:
- include: atom_keyword
- include: module_function_call_pop
- include: unquote_call_pop
- include: id_or_operator_call_pop
- include: id_member_pop
- include: module_name_pop
- include: arguments_pop
- include: quoted_remote_call_pop
- include: quoted_member_pop
- include: tuple_call_pop
- include: if_non_space_or_eol_pop
push: member_or_call_pop

member_or_call_pop:
- include: module_function_call_pop
- include: unquote_call_pop
- include: id_or_operator_call_pop
- include: id_member_pop
- include: module_name_pop
- include: arguments_pop
- include: quoted_remote_call_pop
- include: quoted_member_pop
- include: tuple_call_pop
- include: if_non_space_or_eol_pop

## Module attributes

Expand Down Expand Up @@ -2339,16 +2338,11 @@ contexts:
- match: (?=\.(?!\.))
set:
- include: dot_operator
- include: arguments_pop
- include: capture_name_pop
- include: id_or_operator_call_pop
- include: quoted_remote_call_pop
- include: quoted_member_pop
- match: (?={{member}}{{no_id_key_suffix}})
push: id_member_pop
- include: tuple_call_pop
- include: if_closing_token_pop
- include: if_non_space_or_eol_pop
- include: member_or_call_pop
- include: capture_name_pop
- include: special_form
- match: (?={{identifier}}\s*\.(?!\.|\s*\())
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/SQL (Elixir).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contexts:
# Taken from https://www.postgresql.org/docs/current/sql-keywords-appendix.html
all|any|array|analy[sz]e|a?symmetric|authorization|at(?=\s+time\s+zone\b)|binary|both|by
| (?<=\bat\s)time(?=\s+zone\b) | (?<=\btime\s)zone | (?<=\bdo\s)nothing | (?<=\bon\s)conflict | (?<=\bwith\s)ordinality
| cast|cross|column|concurrently|collat(?:e|ion)|create|distinct|(?<!\bas\s)do
| cast|cross|column|concurrently|collat(?:e|ion)|create|(?<=\bcreate\s)type|distinct|(?<!\bas\s)do
| except|excluded(?=\s*\.)|fetch|filter(?=\s+\()|for(?:eign)?|freeze|full|group|intersect|into|inner|isnull
| i[sn]|ilike|lateral|leading|left|natural|not(?:null)?|nullif|on(?:ly)?|offset|order|outer
| over(?:laps)?|primary|recursive|returning|right|similar|some|table(?:sample)?|to|trailing
Expand Down
9 changes: 9 additions & 0 deletions tests/syntax_test_function_calls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ raise"msg"
# ^ punctuation.section.arguments.begin
# ^^^ variable.function

:"Elixir.Kernel".in 1, [1, 2, 3]
# ^^ variable.function
# ^ punctuation.accessor.dot
# ^^^^^^^^^^^^^ constant.other.module
:"Elixir.Kernel"."@" expr
# ^^^^^ meta.function-call.arguments
# ^ variable.function
# ^^^ meta.function-call

%{} |> Kernel.|> Map.put(:key, :value)
# ^ punctuation.section.arguments.end
# ^ punctuation.section.arguments.begin
Expand Down
5 changes: 5 additions & 0 deletions tests/syntax_test_sql_fragments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ fragment("t AT TIME ZONE")
## ^^^^^^ keyword.other.DML.sql
## ^^^^^^ -constant.other.table-name

sql("CREATE TYPE t AS ENUM")
# ^ variable.other
# ^^^^ keyword.other
# ^ -keyword.other

sql("""
SELECT * FROM "table" AS t WHERE t."f i e l d"
# ^^^^^^^^^^^ string.quoted.double.sql
Expand Down