From 2bbbfb1e0eb8e982b31e6a6032376909abcee7fa Mon Sep 17 00:00:00 2001 From: AltCode Date: Sat, 7 Feb 2026 16:29:31 +0100 Subject: [PATCH 1/2] Improve Elixir brackets and indents - Scopes all brackets so that detection only happens where it should - Adds detection for bitstring delimiters - Adds detection for interpolation delimiters - Adds detection for all sigil delimiters - Adds detection for all charlist delimiters - Adds detection for anonymous function delimiters - Adds auto-indents to lists, blocks, tuples, maps, bitstrings, and parentheses - Exclude bracket colorization for interpolations, bitstrings, strings, charlists, and sigils --- languages/elixir/brackets.scm | 59 +++++++++++++++++++++++++++++++---- languages/elixir/config.toml | 4 +++ languages/elixir/indents.scm | 19 +++++++---- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/languages/elixir/brackets.scm b/languages/elixir/brackets.scm index 48f5f25..3f3d884 100644 --- a/languages/elixir/brackets.scm +++ b/languages/elixir/brackets.scm @@ -1,6 +1,53 @@ -("(" @open ")" @close) -("[" @open "]" @close) -("{" @open "}" @close) -("\"\"\"" @open "\"\"\"" @close) -("\"" @open "\"" @close) -("do" @open "end" @close) +(tuple + "{" @open + "}" @close) + +(list + "[" @open + "]" @close) + +(block + "(" @open + ")" @close) + +(map + "{" @open + "}" @close) + +(do_block + "do" @open + "end" @close) + +(call + (arguments + "(" @open + ")" @close)) + +(anonymous_function + "fn" @open + "end" @close) + +(interpolation + "#{" @open + "}" @close + (#set! rainbow.exclude)) + +(bitstring + "<<" @open + ">>" @close + (#set! rainbow.exclude)) + +(string + quoted_start: _ @open + quoted_end: _ @close + (#set! rainbow.exclude)) + +(charlist + quoted_start: _ @open + quoted_end: _ @close + (#set! rainbow.exclude)) + +(sigil + quoted_start: _ @open + quoted_end: _ @close + (#set! rainbow.exclude)) diff --git a/languages/elixir/config.toml b/languages/elixir/config.toml index b528e5f..7539a1b 100644 --- a/languages/elixir/config.toml +++ b/languages/elixir/config.toml @@ -7,8 +7,12 @@ brackets = [ { start = "{", end = "}", close = true, newline = true }, { start = "[", end = "]", close = true, newline = true }, { start = "(", end = ")", close = true, newline = true }, + { start = "do", end = "end", close = false, newline = true, not_in = ["string", "comment"] }, + { start = "fn", end = "end", close = false, newline = true, not_in = ["string", "comment"] }, + { start = "<<", end = ">>", close = false, newline = true }, { start = "\"\"\"", end = "\n\"\"\"", close = true, newline = true, not_in = ["string", "comment"] }, { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, + { start = "'''", end = "\n'''", close = true, newline = true, not_in = ["string", "comment"] }, { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, ] tab_size = 2 diff --git a/languages/elixir/indents.scm b/languages/elixir/indents.scm index 102b1aa..316add5 100644 --- a/languages/elixir/indents.scm +++ b/languages/elixir/indents.scm @@ -1,13 +1,20 @@ +[ + (tuple "}" @end) + (list "]" @end) + (block ")" @end) + (map "}" @end) + (bitstring ">>" @end) + (do_block "end" @end) + (anonymous_function "end" @end) + (call (arguments ")" @end)) +] @indent + +; These have no end delimiter that can be captured, +; as they are usually nested inside `do_block` nodes [ (after_block) - (anonymous_function) (catch_block) - (do_block) (else_block) (rescue_block) (stab_clause) ] @indent - -[ - "end" -] @outdent From 11355c20673512052e1a5351adc9fbed427c616e Mon Sep 17 00:00:00 2001 From: AltCode Date: Sun, 8 Feb 2026 15:29:17 +0100 Subject: [PATCH 2/2] Outdent reserved do-end block keywords --- languages/elixir/config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/languages/elixir/config.toml b/languages/elixir/config.toml index 7539a1b..eacc5be 100644 --- a/languages/elixir/config.toml +++ b/languages/elixir/config.toml @@ -16,6 +16,7 @@ brackets = [ { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, ] tab_size = 2 +decrease_indent_pattern = '^\s*(after|catch|else|rescue)$' scope_opt_in_language_servers = ["tailwindcss-language-server"] [overrides.string]