sharkdp / bat

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

New syntax doesn't show up in the list of languages #2320

Open Flurrywinde opened 2 years ago

Flurrywinde commented 2 years ago

I wanted to add a new syntax, so I followed the instructions: I made ~/.config/bat/syntaxes, found a .sublime-syntax file for the language (choicescript) online, git cloned it there, and ran bat cache --build.

"ChoiceScript" doesn't show up when I run bat --list-languages.

I'm running bat 0.22.1 (e5d95796).

Here's the repo for the new syntax I used: https://github.com/fawkesy/choicescript-syntax

sharkdp commented 2 years ago

Can you please tell us the exact commands to reproduce this?

Flurrywinde commented 2 years ago

Pulled from my shell history file:

# mkdir $(bat --config-dir)
# mkdir $(bat --config-dir)/syntaxes
# cp -i ChoiceScript.sublime-syntax $(bat --config-dir)/syntaxes
# bat --generate-config-file
# cd $(bat --config-dir)/syntaxes
# bat cache --build
# bat --list-languages

In case it helps:

Output of ls ~/.config/bat/syntaxes:

ChoiceScript.sublime-syntax
choicescript-syntax/
cs.sublime-syntax
wiki
wiki2.sublime-syntax
w-syntaxes.jpg

(Note: wiki is from me experimenting to see if removing the extension helped. w-syntaxes.jpg is just a screencapture to post in my other issue.)

Output of bat --list-languages | grep 'cs\|choice\|wiki':

C#:cs,csx
CoffeeScript:coffee,Cakefile,coffee.erb,cson
Comma Separated Values:csv,tsv
CSS:css,css.erb,css.liquid
Less:less,css.less
MediaWiki:mediawiki,wikipedia,wiki
SCSS:scss

Note how ChoiceScript isn't there. (Neither is wiki2 or cs.)

More stuff just in case it helps:

Output of head cs.sublime-syntax:

%YAML 1.2
---
name: cs
file_extensions: wiki
scope: plain.cs
contexts:
  main:
    - match: 'kitchen'
      scope: keyword.declaration.end.choicescript
    - match: /\*

Output of head ChoiceScript.sublime-syntax:

%YAML 1.2
---
name: ChoiceScript
file_extensions: txt
scope: plain.cs
contexts:
  main:
    - match: '}}}'
      scope: punctuation.definition.comment.choicescript
      push:
keith-hall commented 2 years ago

https://github.com/sharkdp/bat/issues/2354#issuecomment-1268126736 seems relevant here. Perhaps ChoiceScript didn't show up because you didn't pass the case insensitive option to prep.

Flurrywinde commented 2 years ago

It didn't help. I did:

# cp ChoiceScript.sublime-syntax choicescript.sublime-syntax
# bat cache --build
# bat --list-languages | grep choice

I also changed the choicescript.sublime-syntax file's name: line to name: choicescript.

choicescript still doesn't show up in bat --list-languages. It's in there though. bat -l choicescript ... does work, so there must be some other reason it's not showing up in bat --list-languages.

keith-hall commented 4 months ago

coming back to this a long time later - is it because file_extensions should be an array of strings, and here in both sublime-syntax files it is just a single string? Would changing file_extensions: wiki to file_extensions: [wiki] help?