- New themes in `$BAT_CONFIG_DIR/themes` are now loaded *in addition* to
the default themes (they may also override).
- The `Default.tmTheme` symlink is not necessary anymore.
This relates to #172
This changes the output color of the grid and the line numbers to use
the "gutter" foreground color defined in the Sublime `.tmTheme` files.
Sublime Text does the same.
Note: we could go one step further and also extract the "GitGutter"
colors from the themes. These could be used instead of red/green/yellow
to signify Git modifications. The problem is that they are quite a bit
harder to extract from the syntect `Theme` object.
closes#178
This commit separates the handling of syntax sets and theme sets. It
also changes the way how new syntax definitions are loaded from `bat`'s
configuration folder. New syntax definitions are now loaded *in
addition* to the ones that are stored in the `bat` binary by default.
This fixes#172
The `--theme` command line option stills takes precedence and this
change preserves how errors are handled when it's used: If a theme name
that doesn't exist is specified using the argument, this error is fatal.
However, if a theme that doesn't exist is specified using the environment
variable, the error is logged to `stderr` and the "Default" theme is
loaded as a fallback.
Before this patch:
$ bat cache --init
[bat error]: Could not load themes from '{}'
After:
$ bat cache --init
[bat error]: Could not load themes from '/home/user/.config/bat/themes'
This changes a few things:
- All syntaxes and themes are now stored (as submodules) under
assets/syntaxes and assets/themes
- The default directories for syntaxes and themes are "syntaxes"
and "themes" (used to be "syntax" and "themes")
- The "bat cache" command can now take a `--source <dir>` and
`--target <dir>` option.
- The cached files have been renamed to "themes.bin" and "syntaxes.bin"
This commit tries to simply the change. Instead of separating an
`OutputComponent` and a `PredefinedStyle`, I have combined the two into
just `OutputComponent`.
To still have the styles work, I added an impl to `OutputComponent` with
a function `components` which returns the components related to the
specified component.
For a simple output component this is trivial, but for the predefined
styles this is a list of other components.
The evaluating of the command-line parameter simplified significantly,
making use of Claps `values_t!` macro to parse the supplied parameters
into a `Vec<OutputComponent>`. After that it is simply a task of
combining all supplied output components into one vector.
Important: this means that the styles are now additive, rather than one
of the predefined styles overruling other parameters supplied.
The `--style` parameter now accepts a comma-separated list of strings,
where every element defines either a single output component (`changes`,
`grid`, `header`, `numbers`) or a predefined style (`full`,
`line-numbers`, `plain`).
If available, bat picks the first predefined style in the user-supplied
style-list and ignores everything else. If no predefined style was
requested, the other parameters that are simple output components will
be used.
Examples:
--style changes,full,numbers
Will internally be reduced to only the predefined style `full`.
--style plain,full
Will internally be reduced to only the predefined style `plain`.
--style changes,numbers
Will not be reduced, because the list does not contain any predefined
styles.
(Note: if `grid` is requested but no other parameters, bat still creates
the left-most column with a width of `PANEL_WIDTH`. I didn't want to
introduce further logic in this PR that drops or adapts the width of the
left column.)
* Adds separator.length() to calculation for desired width.
* Replaces use of term_width with options.term_width.
* Adds the comma and space separator to calculation for line-wrapping.
* removes redundant `.takes_value(false)`.
* changes Arg name to "list-languages" to be consistent with long-form.
* replaces unnecessary match statement with is_present().
* replaces unnecessary match statement on iter and uses unwrap_or()
instead.
* replaces for-loop with a call to join().
* Remove the old `init-cache` subcommand
* Introduce a new `cache` subcommand that can be used like this:
* `bat cache -h` - Show help
* `bat cache --init` - Initialize cache from config dir
* `bat cache --clear` - Reset the cache
* `bat cache --config-dir` - Show config directory
* Update README
closes#44