Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom extension and file name mappings #169

Closed
eproxus opened this issue Jun 7, 2018 · 4 comments · Fixed by #361
Closed

Support custom extension and file name mappings #169

eproxus opened this issue Jun 7, 2018 · 4 comments · Fixed by #361
Labels
feature-request New feature or request

Comments

@eproxus
Copy link

eproxus commented Jun 7, 2018

I would like to add custom file name and extension mappings to a language. For example, Erlang often uses .config as an extension for configuration files, and some canonical files like rebar.lock in the project root folder should also be highlighted as Erlang.

It would be nice to be able to assign custom extension mappings to languages, and additionally complete file name mappings (could also be abused as extensions).

@sharkdp sharkdp added feature-request New feature or request help wanted Extra attention is needed question Further information is requested labels Jun 7, 2018
@sharkdp
Copy link
Owner

sharkdp commented Jun 7, 2018

The file extensions and filenames that should be highlighted are specified in the respective sublime-syntax files. See the one for Erlang, for example. If something like rebar.lock is common for Erlang projects (and not used by other languages), it could probably be added in sublimehq/Packages.

However, they will probably not accept something generic like .config. One option that should work already is to use bat's customization features, which would allow you to modify the Erlang.sublime-syntax file for yourself. It's not a super-convenient way, though.

I'm inclined to say that this feature would be a useful addition to bat. However, we would first need to figure out a way to add a configuration file. We would probably put a YAML/JSON file somewhere in ~/.config/bat.

(by the way, I hope that you already know that you can always use something like bat -lerl rebar.lock to highlight a file in Erlang mode)

@epitron
Copy link

epitron commented Jun 15, 2018

This is a great idea. From a usability perspective, it would be ideal if bat users weren't even aware that bat was using sublime syntax files under the hood -- if it supported the syntax of every programming language under the sun, a user would only have to learn bat's simple config syntax to meet their every need.

Regarding the config file's format, I think INI and TOML are a bit nicer than YAML and JSON. They're less pedantic about syntax (i.e. INIs don't care about quoting strings, or about structuring dictionaries and arrays properly, while a typo in a large JSON file can result in very frustrating error messages, and an empty YAML file won't even parse).

@eproxus
Copy link
Author

eproxus commented Jun 18, 2018

My 2 cents is that power users will always have a need to override default configuration (in this case, the Sublime syntax definitions). They might find that using a specific highlight syntax for a custom file works better, they want to add common but not standard extensions (my case), or they are working on a system that doesn't use the standard extensions for some reason.

@sharkdp sharkdp removed help wanted Extra attention is needed question Further information is requested labels Jul 3, 2018
sharkdp added a commit that referenced this issue Oct 17, 2018
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
sharkdp added a commit that referenced this issue Oct 17, 2018
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
@sharkdp
Copy link
Owner

sharkdp commented Oct 17, 2018

Released in v0.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants