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

glob-based syntax mapping #877

Merged
merged 5 commits into from
Mar 22, 2020
Merged

glob-based syntax mapping #877

merged 5 commits into from
Mar 22, 2020

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Mar 22, 2020

This PR changes the way --map-syntax works. The option now works like this:

--map-syntax <glob-pattern>:<syntax-name>

(this is a breaking change, users will have to adapt their config files)

This PR also adds a builtin database of syntax mappings to bat to handle cases such as:

  • Glob-based lookups for paths:
    • /proc/cpuinfo => CpuInfo syntax
    • **/.ssh/config => SSHConfig
    • /etc/profile => Bash
    • *.h => C++ (I assume this is a better default than "Objective C")
  • Files named build are no longer mapped to "NAnt Build File" (which should only match *.build files). Instead, we use the first-line detection mechanism on such files.

closes #592, closes #685
see also: #501

@sharkdp sharkdp changed the title Initial implementation of glob-based syntax mapping glob-based syntax mapping Mar 22, 2020
@sharkdp sharkdp merged commit eb2f3dd into master Mar 22, 2020
@sharkdp sharkdp deleted the syntax-detection-glob-patterns branch March 22, 2020 10:02
@cyqsimon
Copy link
Contributor

cyqsimon commented Oct 31, 2023

Hi sharkdp, I'm working on making this system more extensible in #2747. I noticed that in c08d122 you made the match happen in reversed direction (so that mappings inserted later get matched first).

In the spirit of documenting the code behaviour as precisely as possible, I would like to ask you to clarify what your intentions were. My current hypothesis for why this was done is this allows rules inserted by the user at runtime to take precedence; is this correct?

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

Successfully merging this pull request may close these issues.

Files named build don't respect shebang lines Add a dedicated Path => Syntax lookup database
2 participants