1name = "Shell Script"
2code_fence_block_name = "bash"
3grammar = "bash"
4path_suffixes = ["sh", "bash", "bashrc", "bash_profile", "bash_aliases", "bash_logout", "bats", "profile", "zsh", "zshrc", "zshenv", "zsh_profile", "zsh_aliases", "zsh_histfile", "zlogin", "zprofile", ".env", "PKGBUILD", "APKBUILD"]
5modeline_aliases = ["sh", "shell", "zsh", "fish"]
6line_comments = ["# "]
7first_line_pattern = '^#!.*\b(?:ash|bash|bats|dash|sh|zsh)\b'
8autoclose_before = "}])"
9brackets = [
10 { start = "[", end = "]", close = true, newline = false },
11 { start = "(", end = ")", close = true, newline = true },
12 { start = "{", end = "}", close = true, newline = true },
13 { start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
14 { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
15 { start = "do", end = "done", close = false, newline = true, not_in = ["comment", "string"] },
16 { start = "then", end = "fi", close = false, newline = true, not_in = ["comment", "string"] },
17 { start = "then", end = "else", close = false, newline = true, not_in = ["comment", "string"] },
18 { start = "then", end = "elif", close = false, newline = true, not_in = ["comment", "string"] },
19 { start = "in", end = "esac", close = false, newline = true, not_in = ["comment", "string"] },
20]
21
22auto_indent_using_last_non_empty_line = false
23increase_indent_pattern = "^\\s*(\\b(else|elif)\\b|([^#]+\\b(do|then|in)\\b)|([\\w\\*]+\\)))\\s*$"
24decrease_indent_patterns = [
25 { pattern = "^\\s*elif\\b.*", valid_after = ["if", "elif"] },
26 { pattern = "^\\s*else\\b.*", valid_after = ["if", "elif", "for", "while"] },
27 { pattern = "^\\s*fi\\b.*", valid_after = ["if", "elif", "else"] },
28 { pattern = "^\\s*done\\b.*", valid_after = ["for", "while"] },
29 { pattern = "^\\s*esac\\b.*", valid_after = ["case"] },
30 { pattern = "^\\s*[\\w\\*]+\\)\\s*$", valid_after = ["case_item"] },
31]
32
33# We can't use decrease_indent_patterns simply for elif, because
34# there is bug in tree sitter which throws ERROR on if match.
35#
36# This is workaround. That means, elif will outdents with despite
37# of wrong context. Like using elif after else.
38decrease_indent_pattern = "(^|\\s+|;)(elif)\\b.*$"