From 06a5d45c859df68da6a93ecc0eb1001d559f9efd Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sat, 13 Jul 2024 12:16:44 -0400 Subject: [PATCH 1/4] Add fn/end and do/end as brackets in language configuration --- eex-language-configuration.json | 8 ++++++-- elixir-language-configuration.json | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/eex-language-configuration.json b/eex-language-configuration.json index 6326d68..6a24c21 100644 --- a/eex-language-configuration.json +++ b/eex-language-configuration.json @@ -9,12 +9,16 @@ ["<", ">"], ["{", "}"], ["(", ")"], - ["[", "]"] + ["[", "]"], + ["do", "end"], + ["fn", "end"] ], "colorizedBracketPairs": [ ["{", "}"], ["[", "]"], - ["(", ")"] + ["(", ")"], + ["do", "end"], + ["fn", "end"] ], "autoClosingPairs": [ ["{", "}"], diff --git a/elixir-language-configuration.json b/elixir-language-configuration.json index dd8b1d5..eaca253 100644 --- a/elixir-language-configuration.json +++ b/elixir-language-configuration.json @@ -5,7 +5,9 @@ "brackets": [ ["{", "}"], ["[", "]"], - ["(", ")"] + ["(", ")"], + ["do", "end"], + ["fn", "end"] ], "surroundingPairs": [ ["{", "}"], From 202b0802f989686c9ddc0574ce867c734de8b133 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 21 Jul 2024 20:04:10 -0400 Subject: [PATCH 2/4] Remove do/end from eex language config --- eex-language-configuration.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/eex-language-configuration.json b/eex-language-configuration.json index 6a24c21..6326d68 100644 --- a/eex-language-configuration.json +++ b/eex-language-configuration.json @@ -9,16 +9,12 @@ ["<", ">"], ["{", "}"], ["(", ")"], - ["[", "]"], - ["do", "end"], - ["fn", "end"] + ["[", "]"] ], "colorizedBracketPairs": [ ["{", "}"], ["[", "]"], - ["(", ")"], - ["do", "end"], - ["fn", "end"] + ["(", ")"] ], "autoClosingPairs": [ ["{", "}"], From 3a278bb4205949dcbfd6350fda5ae054e815a3b5 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 21 Jul 2024 20:06:59 -0400 Subject: [PATCH 3/4] Exclude constant symbols from bracket matching Fixes issues with things like :end atoms and do: keyword lists --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a12fb9e..a973e1c 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,10 @@ { "language": "elixir", "scopeName": "source.elixir", - "path": "./syntaxes/elixir.json" + "path": "./syntaxes/elixir.json", + "unbalancedBracketScopes": [ + "constant.language.symbol.elixir" + ] }, { "language": "eex", From 13589bd7bb76ee5a26ea924b032e59ada53109c8 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 21 Jul 2024 20:19:15 -0400 Subject: [PATCH 4/4] Document bracket configuration --- CHANGELOG.md | 7 +++++++ README.md | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a829be9..0964169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [Unreleased] + +### Added + +- Added support for `do`/`end` and `fn`/`end` as brackets for VSCode, enabling + bracket colorization and bracket navigation features. + ## [0.0.16] ### Added diff --git a/README.md b/README.md index 86b4b7c..309e90f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,28 @@ The path should look something like Controls whether notifications are shown after automatic installs of new Lexcial versions. Defaults to `true`. +### Editor Configuration + +The extension provides a language configuration for Elixir which marks +`do`/`end` and `fn`/`end` as brackets. Among other things, this enables +colorization of `do`/`end` and `fn`/`end` with VSCode's +`editor.bracketPairColorization.enabled` setting. While this can be helpful when +searching for a `do`'s corresponding `end`, some users may prefer to use the +standard keyword coloring, while still highlighting parenthesis and other +brackets. This can be achieved by adding the following to your VSCode +configuration. + +```jsonc +"editor.bracketPairColorization.enabled": true, +"[elixir]": { + "editor.language.colorizedBracketPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ] +} +``` + ### Erlang and Elixir version compatibility #### Erlang