Commit Graph

76 Commits

Author SHA1 Message Date
sharkdp 10965a6122 Implement syntax mapping
This adds a `-m`/`--map-syntax` option that allows users to (re)map
certain file extensions or file names to an existing syntax.

For example:
```
bat --map-syntax .config:json
```

The option can be use multiple times. Note that you can easily make
these mappings permanent by using `bat`s new configuration file.

closes #169
2018-10-17 23:08:19 +02:00
sharkdp 1ae02c65fb Fix include 2018-10-16 22:09:15 +02:00
sharkdp 8275b0436d Add simple configuration file
This allows users to create simple configuration file
(`~/.config/bat/config` on Linux) that has the following format:

    ```bash
    --flag1
    --flag2
    --option1=value1
    # lines beginning with '#' are ignored
    --option2=value2
    # empty lines and trailing whitespace are also ignored

    --option3=value3
    ```
2018-10-16 22:09:15 +02:00
sharkdp 5842d58c01 Updates for syntect 3.0 2018-10-09 22:04:51 +02:00
sharkdp e97095b724 Use first-line detection for STDIN 2018-10-07 15:34:37 +02:00
sharkdp f98fc5f06a Simplify access to first line 2018-10-07 15:34:37 +02:00
sharkdp 0502a3bd4a Add first-line detection for all input types
closes #205
2018-10-07 15:34:37 +02:00
sharkdp 860f3e9006 Move InputFile to separate module 2018-10-07 15:34:37 +02:00
sharkdp 8cacd9b432 Include theme_preview file in binary 2018-08-28 20:24:13 +02:00
sharkdp 9316f2a758 Major refactoring and cleanup 2018-08-22 22:29:12 +02:00
sharkdp 052425b12f Load customized themes in addition to defaults
- 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
2018-08-20 21:39:21 +02:00
sharkdp 2df3305b94 Add new '--blank' option for 'bat cache --init'
closes #206
2018-08-20 21:34:08 +02:00
sharkdp 1dddce3aa1 Separate syntax set and theme set
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
2018-08-19 11:08:23 +02:00
sharkdp 5b421b455d Update dependencies 2018-08-18 20:44:25 +02:00
sharkdp 28397b8f78 Always show a warning when theme is unknown 2018-07-23 21:51:49 +02:00
Armando Perez c68aa0f424 Allow specifying the theme via the `BAT_THEME` environment variable
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.
2018-07-23 21:51:49 +02:00
sharkdp a348a9f68e Handle syntax-set loading errors 2018-05-25 22:42:06 +02:00
Gert Hulselmans 65bb4c7ee6 Print themes directory in error message if no themes could be loaded from it.
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'
2018-05-24 09:09:23 +02:00
Ezinwa Okpoechi 2712d63a4b Move asset clearing to assets module 2018-05-21 23:20:45 +02:00
sharkdp 2a9f5a24ed Permissive error handling, closes #17 2018-05-19 12:50:41 +02:00
Ezinwa Okpoechi 247dfbee83 Extract syntax finding to assets module 2018-05-18 16:45:59 +02:00
sharkdp c826c2a438 Better error handling 2018-05-16 22:55:37 +02:00
sharkdp 145b99f01c Include syntaxes and themes in repository
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"
2018-05-16 22:04:12 +02:00
Ryan Leung 22c8978fca add theme option (#95)
closes #89
2018-05-11 13:53:17 +02:00
sharkdp e2ac6de783 Fix clippy warnings 2018-05-10 13:15:59 +02:00
Ezinwa Okpoechi 25cee002f9 Split modules (#86)
* Split diffing to separate module
* Split assets to separate module
2018-05-10 12:36:09 +02:00