sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
49.46k stars 1.25k forks source link

Can bat support tmLanguage? #2351

Closed Freed-Wu closed 2 years ago

Freed-Wu commented 2 years ago

http://www.sublimetext.com/docs/syntax.html

Sublime Text can use both .sublime-syntax and .tmLanguage files for syntax highlighting. This document describes .sublime-syntax files.

Can bat support *.tmLanguage? I notice https://github.com/wuub/requirementstxt/ only provide *.tmLanguage not *.sublime-syntax. It seems bat don't support it. Thanks!

keith-hall commented 2 years ago

The upstream issue tracking tmLanguage support in the syntax highlighting library we use is https://github.com/trishume/syntect/issues/418

Freed-Wu commented 2 years ago

Thanks, I have followed https://forum.sublimetext.com/t/trying-to-convert-tmlanguage-syntax-to-sublime-syntax/53427 to convert https://github.com/wuub/requirementstxt/blob/master/requirementstxt.tmLanguage to *.sublime-syntax. However, it highlights seems to have some bugs. I'll take a look at it.

%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: requirements.txt
scope: source.requirementstxt
file_extensions:
  - requirements.txt
contexts:
  main:
    - match: (#).*$\n?
      scope: comment.line.requirementstxt
      captures:
        1: punctuation.definition.comment.requirementstxt
    - match: '(?i)^[a-z0-9_\-\.]+'
      scope: string.package_name.requirementstxt
    - match: (?i)==|<|<=|>=|>
      scope: keyword.operator.logical.punctuation.requirementstxt
    - match: '(?i)\d+\.[\da-z\-_\.]*'
      scope: constant.numeric.verions.requirementstxt

https://github.com/raimon49/requirements.txt.vim/blob/master/examples/requirements.txt

Screenshot from 2022-10-06 13-33-16