1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-02-13 13:28:27 +02:00

521 Commits

Author SHA1 Message Date
Siavash Askari Nasr
22fac1fc0f Raku: Fix Match hash access, $<variable><key> 2021-08-29 07:10:23 +10:00
Siavash Askari Nasr
2535d1a99e Raku: Fix operators that come after < 2021-08-29 07:10:23 +10:00
Siavash Askari Nasr
bb38ae204f Raku: Fix detecting adverbs, plus a little cleanup 2021-08-29 07:10:23 +10:00
Stefan kruger
2eba3ce9a1 Update APL lexer to cope with current Dyalog APL
* Names can start with underscore
* Missing APL primitive ops: ⍥@⌺⌶⍢
* Missing APL primitive funcs: ⊆⍸
2021-08-20 08:28:03 +10:00
Siavash Askari Nasr
b71f4c6607 Raku: Fix incorrectly matching closing brackets as opening 2021-08-15 21:39:18 +10:00
Alec Thomas
7966c29526
Update README.md 2021-08-01 21:51:06 +10:00
Alec Thomas
61cfd7d7a7
Update README.md 2021-08-01 21:50:36 +10:00
Alec Thomas
594e3117f8
Update README.md 2021-08-01 21:49:50 +10:00
Siavash Askari Nasr
f4ffd6cea9 Fix Raku colon pair, function adverb and POD declaration 2021-08-01 21:48:42 +10:00
Alec Thomas
2cff0c9b1f Switch from Circle to GHA. 2021-08-01 14:38:38 +10:00
Nelo Mitranim
fb1dd01cfb [kotlin] expensive char list -> char classes
This reduces the lexer's init time by about x1000, from ≈350ms to ≈350μs
on my machine.
2021-07-31 19:07:24 +10:00
Nelo Mitranim
eafea0d771 replace expensive char lists with char classes
Huge hardcoded character lists have a cost. In some current lexers, such
as Haskell and JavaScript, this bloats lexer init time to 60-80ms on
some current systems, as opposed to sub-ms for many others.

Replacing them with character classes such as `\p{L}` seems to
eliminate this cost, reducing lexer init time to the norm (around 1ms).
In addition, this significantly reduces and simplifies the code.

The current tests pass, but there may be inaccuracies not covered by
tests. This requires a review.

This change is likely to cause edge case regressions, as the sets of
characters considered "letters" vary between languages. However, Chroma
lexers don't aim to be perfectly accurate. Performance should be just as
much a goal as accuracy. I believe this tradeoff to be justified.

This commit leaves at least two lexers unfixed: Julia and Kotlin.
Judging by the code, they might have the same issue, and should also be
addressed.
2021-07-27 22:04:33 +10:00
Koki Fukuda
f09329ae62 Add lexer for Meson build system
Ported pygments' lexer using pygments2chroma.py.
2021-07-23 07:31:47 +10:00
Kyle Baldwin
a0e9618fbc
ARM ASM (#531) 2021-07-18 08:24:23 +10:00
Phil Hagelberg
d402102976
Support Fennel. (#530)
This adds support for the Fennel programming language: https://fennel-lang.org

I couldn't find much explanation for what the different lexer rules
meant, so I based it off of Clojure's lexer since the two languages
share a very similar syntax.

I also included a program to generate a list of keywords from Fennel's
own listing, which will make it easier to update in the future.
2021-07-16 11:56:03 +10:00
David McClure
21a1750dc2 Remove go get for installation from README
Per: https://github.com/alecthomas/chroma/issues/528#issuecomment-866370115

> Use the release binaries. go get is not supported anymore.
2021-06-24 08:22:35 +10:00
Alec Thomas
6a6cf1764d Fix some buggy number patterns.
Fixes #507.
2021-06-22 16:41:06 +09:30
Alec Thomas
d4eaef361b Release arm64 builds. 2021-06-21 15:34:57 +09:30
Alec Thomas
54fd3bc12f Clean up imports and make cmd/chroma its own module. 2021-06-18 16:56:50 +10:00
Siavash Askari Nasr
9df8bd4f92 fish: Fix incorrect tokenisation of command arguments containing dash
Command line arguments containing dash/hyphen were incorrectly
tokenised as command line options.
2021-06-17 18:13:46 +10:00
Dan Bennett
841c391b98
Basic lexer for Microsoft Power Query M (#462) v0.9.2 2021-06-15 12:56:00 +10:00
ktprograms
d13f838b25 Added uint8_t to c lexer.
Copied the KeywordType rule from the c++ lexer (but removed wchar_t since it doesn't exist in c).
2021-06-10 17:41:00 +10:00
Siavash Askari Nasr
402a150d3e SCSS fixes and modifications, fixes #451 2021-06-09 21:44:22 +10:00
Siavash Askari Nasr
3ec045529f Some Raku modifications and making use of #519 and #518 2021-06-09 09:50:19 +10:00
Siavash Askari Nasr
10329f849e
Add ByGroupNames function, same as ByGroups but use named groups (#519)
For named groups that are not given, an Error will be emitted anyway.

This also handles the case when an Emitter for group `0` is provided
or not. Since numbers can also be used for names.
But it might be over-doing, because why would anyone use ByGroupNames
if they wanted to assign a token to the whole match?!
2021-06-08 22:26:59 +10:00
Siavash Askari Nasr
22cbca546a Allow skipping group's emitter, via passing nil as emitter 2021-06-07 22:45:39 +10:00
Ville Skyttä
4b989ea3b2 feat(styles/dracula): use official green and red for inserted and deleted
Green and red are the de facto colors used to represent inserted and
deleted lines. This changes the red that was already used for deleted to
use the official Dracula red, getting rid of an unofficial color, and
changes the inserted color from foreground white to green, to make
insertions stand out from headings and such.
2021-05-27 08:55:14 +10:00
rhymes
c8581d47ee Add tabindex="0" to default <pre> wrapper 2021-05-24 07:16:54 +10:00
Soubik Bhui
8513d9997e
Add new style - "hr" (#513) 2021-05-22 21:49:56 +10:00
Alec Thomas
99e66962d8 Use Hermit (https://github.com/cashapp/hermit) to manage build tools. 2021-05-21 16:46:55 +10:00
Carlos Henrique Guardão Gandarez
a566061e65 Add set text analyser for MySQL lexer 2021-05-19 08:20:08 +10:00
Ville Skyttä
d964e7c774
pygments2chroma updates (#509) 2021-05-19 08:15:25 +10:00
Vukašin Manojlović
9391121b92 Add Metal lexer 2021-05-19 08:14:24 +10:00
Ville Skyttä
b5d03c0079 feat(regexlexer): compile in RE2 compatibility mode
To better match vanilla Go regexps and support some additional
constructs that might be present in Pygments rules.

https://github.com/dlclark/regexp2#re2-compatibility-mode
2021-05-17 14:09:19 +10:00
Ville Skyttä
4d45300557 feat(lexers/c): associate with XBM and XPM 2021-05-13 09:58:16 +10:00
Ville Skyttä
14a8abad48 feat(lexers): match filenames ignoring trailing .in
The .in suffix is often assiociated with build system input/template
files, for example in autotools ones.
2021-05-13 09:57:52 +10:00
Siavash Askari Nasr
2bcdf19ee2 [doom-one] Change style of NameAttribute
it was close to operator's color
2021-05-11 22:51:48 +10:00
Siavash Askari Nasr
33faf5576d Improve fish lexer. Add syntax highlighting for commands
- Commands are syntax highlighted as functions
- Command options are highlighted as attributes
- Added more built-ins and operators
- Added Hashbang
- Added and improved syntax highlighting for function, variable and
keywords
- Added test files
2021-05-11 22:51:06 +10:00
Alec Thomas
35539cf059 gofmt 2021-05-11 13:06:37 +10:00
Ville Skyttä
465a27c08a
cmd: --fail earlier without reading entire input files (#502) 2021-05-11 11:03:16 +10:00
Ville Skyttä
e87e5b2208 cmd: add optional silent fail mode on no specific lexer
Makes use of chroma easier in/as less(1) preprocessors.

https://manpages.debian.org/less#INPUT_PREPROCESSOR
  export LESSOPEN='| p() { chroma --fail "$1" || cat "$1"; }; p "%s"'

https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS
  ln -s ~/go/bin/chroma ~/.lessfilter
2021-05-09 08:46:49 +10:00
Siavash Askari Nasr
2e23e7f215 regexp2 uses number of group as its name so name check isn't needed 2021-05-08 18:48:49 +10:00
mlpo
1b7d2dd620 Update Python lexers and add tests for them 2021-05-08 18:18:27 +10:00
mlpo
ff6eedba72
Fix: sort words in descending order of length before regex generation (#496)
* Fix: sort words in descending order of length before regex generation

* Avoid code duplication in Raku lexer
2021-05-08 09:10:18 +10:00
Siavash Askari Nasr
225e1862d3 Pass *LexerState as context to emitters
Useful for accessing named capture groups and context set by
`mutators` and other field and methods LexerState provides.
2021-05-07 22:55:54 +10:00
Yang Zhang
2cc8645d62 Add FortranFixedLexer 2021-05-07 08:47:10 +10:00
mlpo
312be634e4 Allow several tests for a same lexer 2021-05-07 08:42:53 +10:00
Siavash Askari Nasr
dcfd826b25 Add support for named capture groups 2021-05-06 21:34:28 +10:00
Ville Skyttä
15f2498398 lexers: add one for groff
Generated from Pygments one, some filename extensions added.
2021-05-06 10:08:01 +10:00
mlpo
8bba42c1ff Update mimetypes in Python lexers 2021-05-05 16:59:58 +10:00