name = "Shell Script"
code_fence_block_name = "bash"
grammar = "bash"
path_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"]
modeline_aliases = ["sh", "shell", "zsh", "fish"]
line_comments = ["# "]
first_line_pattern = '^#!.*\b(?:ash|bash|bats|dash|sh|zsh)\b'
autoclose_before = "}])"
brackets = [
    { start = "[", end = "]", close = true, newline = false },
    { start = "(", end = ")", close = true, newline = true },
    { start = "{", end = "}", close = true, newline = true },
    { start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
    { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
    { start = "do", end = "done", close = false, newline = true, not_in = ["comment", "string"] },
    { start = "then", end = "fi", close = false, newline = true, not_in = ["comment", "string"] },
    { start = "then", end = "else", close = false, newline = true, not_in = ["comment", "string"] },
    { start = "then", end = "elif", close = false, newline = true, not_in = ["comment", "string"] },
    { start = "in", end = "esac", close = false, newline = true, not_in = ["comment", "string"] },
]

auto_indent_using_last_non_empty_line = false
increase_indent_pattern = "^\\s*(\\b(else|elif)\\b|([^#]+\\b(do|then|in)\\b)|([\\w\\*]+\\)))\\s*$"
decrease_indent_patterns = [
  { pattern = "^\\s*elif\\b.*",    valid_after = ["if", "elif"] },
  { pattern = "^\\s*else\\b.*",    valid_after = ["if", "elif", "for", "while"] },
  { pattern = "^\\s*fi\\b.*",      valid_after = ["if", "elif", "else"] },
  { pattern = "^\\s*done\\b.*",    valid_after = ["for", "while"] },
  { pattern = "^\\s*esac\\b.*",    valid_after = ["case"] },
  { pattern = "^\\s*[\\w\\*]+\\)\\s*$", valid_after = ["case_item"] },
]

# We can't use decrease_indent_patterns simply for elif, because
# there is bug in tree sitter which throws ERROR on if match.
#
# This is workaround. That means, elif will outdents with despite
# of wrong context. Like using elif after else.
decrease_indent_pattern = "(^|\\s+|;)(elif)\\b.*$"
