Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releasing v3.2.2 #62

Merged
merged 5 commits into from
Jun 27, 2023
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
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Changelog

## [v3.2.2] – 2023-06-28

- Elixir: fixed module function call regression in captures (`&Map.take(&1, @fields)`).
- Elixir: recognize special macro `defmacro (..) do end`.
- Commands: added `mix_test_hide_panel` command.

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

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

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

Expand Down
1 change: 1 addition & 0 deletions commands/Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{ "caption": "Mix Test: Toggle --stale Flag", "command": "mix_test_toggle_stale_flag" },
{ "caption": "Mix Test: Switch to Code or Test", "command": "mix_test_switch_to_code_or_test" },
{ "caption": "Mix Test: Show Panel", "command": "mix_test_show_panel" },
{ "caption": "Mix Test: Hide Panel", "command": "mix_test_hide_panel" },
{ "caption": "Mix Format: File", "command": "mix_format_file" },
{ "caption": "Mix Format: Project / Folder", "command": "mix_format_project" },
{ "caption": "Mix Format: Toggle Auto-Formatting", "command": "mix_format_toggle_auto_format" },
Expand Down
5 changes: 1 addition & 4 deletions commands/mix_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def call_mix_format(window, **kwargs):
cwd = next((reverse_find_root_folder(p) for p in paths if p), None)

if not (cwd or file_path):
print_status_msg(
'Error: could not find a mix.exs file and the _build/ directory! '
+ 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.'
)
print_status_msg(COULDNT_FIND_MIX_EXS)
return

proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand Down
22 changes: 13 additions & 9 deletions commands/mix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ def run(self, **_kwargs):
sublime_NewFileFlags_NONE = 4
self.window.open_file(mix_settings_path, flags=sublime_NewFileFlags_NONE)
else:
sublime.message_dialog(
'Error: could not find a mix.exs file and the _build/ directory!\n' +
'Make sure that you are in a mix project and that `mix do deps.get + compile` has been run.'
)
sublime.message_dialog(COULDNT_FIND_MIX_EXS)

class MixTestCommand(sublime_plugin.WindowCommand):
def description(self):
Expand Down Expand Up @@ -280,7 +277,17 @@ def run(self, **_kwargs):
self.window.run_command('show_panel', {'panel': PANEL_NAME})

def is_enabled(self):
return PANEL_NAME in self.window.panels()
return PANEL_NAME != self.window.active_panel() and PANEL_NAME in self.window.panels()

class MixTestHidePanelCommand(sublime_plugin.WindowCommand):
def description(self):
return 'Hides the output panel if visible.'

def run(self, **_kwargs):
self.window.run_command('hide_panel', {'panel': PANEL_NAME})

def is_enabled(self):
return PANEL_NAME == self.window.active_panel()


# Helper functions:
Expand Down Expand Up @@ -431,10 +438,7 @@ def reverse_find_json_path(window, json_file_path):
paths = [window.active_view().file_name()] + window.folders()
root_dir = next((reverse_find_root_folder(p) for p in paths if p), None)

root_dir or print_status_msg(
'Error: could not find a mix.exs file and the _build/ directory! '
+ 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.'
)
root_dir or print_status_msg(COULDNT_FIND_MIX_EXS)

return root_dir and path.join(root_dir, json_file_path) or None

Expand Down
6 changes: 5 additions & 1 deletion commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

PRINT_PREFIX = 'ElixirSyntax:'

COULDNT_FIND_MIX_EXS = \
'Error: could not find a mix.exs file and the _build/ directory!\n' + \
'Make sure that you are in a mix project and that `mix \'do\' deps.get, compile` has been run.'

def print_status_msg(msg):
print(PRINT_PREFIX, msg)
sublime.status_message(PRINT_PREFIX + ' ' + msg)
Expand Down Expand Up @@ -65,4 +69,4 @@ def load_json_file(file_path):
exists = Path(file_path).exists()
exists and print_status_msg('Error: could not open file: %r\nException: %s' % (file_path, e))

return {}
return {}
10 changes: 7 additions & 3 deletions syntaxes/Elixir.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ contexts:
scope: entity.name.function.elixir
set: function_free_form_header_pop

- match: (\()\s*(\.\.)\s*(\))
captures:
1: punctuation.section.group.begin.elixr
2: entity.name.function.elixir
3: punctuation.section.group.end.elixr
set: function_free_form_header_pop

- include: atom_keyword
- include: func_do_block_pop
- include: block_or_keyword
Expand Down Expand Up @@ -2339,9 +2346,6 @@ contexts:
set:
- include: dot_operator
- include: capture_name_pop
- match: (?={{member}}{{no_id_key_suffix}})
push: id_member_pop
- include: if_closing_token_pop
- include: member_or_call_pop
- include: capture_name_pop
- include: special_form
Expand Down
4 changes: 4 additions & 0 deletions tests/syntax_test_declarations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ def .. a do a end
def ..(a) do a end
# ^ punctuation.section.group.begin
# ^^ keyword.operator.range
defmacro (..) do range(__CALLER__.context, 0, -1, 1) end
# ^ punctuation.section.group.end
# ^^ entity.name.function
# ^ punctuation.section.group.begin
def ... a do a end
# ^^^ entity.name.function
def ...(a) do a end
Expand Down
6 changes: 6 additions & 0 deletions tests/syntax_test_misc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,12 @@ end[]
# ^^^ variable.other.capture
# ^^^^^^^ variable.other.capture

&Module.func(&1)
# ^ punctuation.section.arguments.end
# ^ punctuation.section.arguments.begin
# ^^^^ variable.function
# ^ punctuation.accessor.dot

&Module |> func(&1)
# ^^^^ variable.function
# ^^ keyword.operator.pipe -punctuation.accessor.arity
Expand Down