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

Lexer fails to recognize files named CMakeLists.txt #344

Closed
jdumas opened this issue Mar 15, 2020 · 2 comments
Closed

Lexer fails to recognize files named CMakeLists.txt #344

jdumas opened this issue Mar 15, 2020 · 2 comments

Comments

@jdumas
Copy link

jdumas commented Mar 15, 2020

Using a freshly installed version on macOS (installed via go get -u github.com/alecthomas/chroma/cmd/chroma), chroma fails to recognize the CMake language on files named CMakeListst.txt:

make_minimum_required(VERSION 3.1)
project(foo)
~/go/bin/chroma --trace --json CMakeLists.txt
root: pos=0, text="make_minimum_required(VERSION 3.1)\nproject(foo)\n\n"
root: pos=34, text="\nproject(foo)\n\n"
root: pos=35, text="project(foo)\n\n"
root: pos=47, text="\n\n"
root: pos=48, text="\n"
[
  {"type":"Text","value":"make_minimum_required(VERSION 3.1)\nproject(foo)\n\n"}
]

If the file has the .cmake extension it works fine:

~/go/bin/chroma --trace --json foo.cmake
root: pos=0, text="make_minimum_required(VERSION 3.1)\nproject(foo)\n\n"
args: pos=22, text="VERSION 3.1)\nproject(foo)\n\n"
args: pos=29, text=" 3.1)\nproject(foo)\n\n"
args: pos=30, text="3.1)\nproject(foo)\n\n"
args: pos=33, text=")\nproject(foo)\n\n"
root: pos=34, text="\nproject(foo)\n\n"
root: pos=35, text="project(foo)\n\n"
args: pos=43, text="foo)\n\n"
args: pos=46, text=")\n\n"
root: pos=47, text="\n\n"
root: pos=48, text="\n"
[
  {"type":"NameBuiltin","value":"make_minimum_required"},
  {"type":"Punctuation","value":"("},
  {"type":"LiteralString","value":"VERSION"},
  {"type":"Text","value":" "},
  {"type":"LiteralString","value":"3.1"},
  {"type":"Punctuation","value":")"},
  {"type":"Error","value":"\n"},
  {"type":"NameBuiltin","value":"project"},
  {"type":"Punctuation","value":"("},
  {"type":"LiteralString","value":"foo"},
  {"type":"Punctuation","value":")"},
  {"type":"Error","value":"\n\n"}
]

Looking at the code it seems that chroma should recognize file named CMakeListst.txt, so I'm not sure why this doesn't work here.

@alecthomas
Copy link
Owner

This was because typoscript (whatever that is) and plaintext both match *.txt and had the same priority as cmake.

@jdumas
Copy link
Author

jdumas commented Mar 15, 2020

Awesome, thanks for the quick fix!

mrsdizzie pushed a commit to mrsdizzie/chroma that referenced this issue Jul 15, 2020
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

No branches or pull requests

2 participants