Commit graph

22 commits

Author SHA1 Message Date
Dmytro Maluka
b2a428f1cd Restore header instead of signature in most syntax files
Turning `header` patterns into `signature` patterns in all syntax files
was a mistake. The two are different things. In almost all syntax files
those patterns are things like shebangs or <?xml ... ?> or
<!DOCTYPE html5> i.e. things that:

1. can be (and should be) used for detecting the filetype when there is
   no `filename` match (and that is actually the purpose of those
   patterns, so it's a regression that it doesn't work anymore).

2. should only occur in the first line of the file, not in the first
   100 lines or so.

In other words, the old `header` semantics was exactly what was needed
for those filetypes, while the new `signature` semantics makes little
sense for them.

So replace `signature` back with `header` in most syntax files. Keep
`signature` only in C++ and Objective-C syntax files, for which it was
actually introduced.
2024-03-24 04:47:04 +01:00
Jöran Karl
433879046e Improve file detection with signature check capabilities
This allows more complex detection upon regex rules for a certain amount of
lines.
2023-10-26 20:20:02 +02:00
Andrew Geng
2a9a5afbb2
Fix python decorator syntax. (#2827)
1. Python decorators begin a compound statement, so they only appear
   at the start of a line. So match at the line start to avoid giving
   decorator colors to matrix multiplication (@) expressions. Source:
   https://docs.python.org/3/reference/compound_stmts.html#function-definitions

2. Python decorators go to the end of the line and might not include
   parentheses (for example @functools.cache). So instead of matching
   everything until an `(`, just match as many non-`(` characters
   as possible---which both catches the @functools.cache example and
   allows decorator parameters to fall back to the default color.

3. Instead of hardcoding `brightgreen` (which railscast.micro also
   complains about), color decorators as `preproc` (otherwise unused
   by the python syntax files, and arguably the right colorscheme
   group to be using for syntactic sugars anyway). Note this will
   change decorator colors---for example from bright green to kinda
   brown on monokai, and from yellow to more of a light orange on
   railscast.
2023-10-16 11:08:37 +02:00
john-batch
c226779aca Case-insensitive highlighting of hexadecimal constants 2022-07-24 14:03:53 -07:00
abaldota
d023aef6b5
Python syntax: multiline string should be constant.string, not comment (#2268)
* Python syntax: multiline string should be comment.string, not comment 

''' delimits multiline strings, not comments

* Python syntax: multiline string should be comment.string, not comment 

''' delimits multiline strings, not comments

* Update python3.yaml for python3.10 keywords
2021-11-14 21:54:56 -08:00
a11ce
1e5f8c020e Highlight 0 as a constant number in python3 2020-12-15 18:57:28 -05:00
Zachary Yedidia
cfcb2e4577 Update runtime 2020-10-06 17:39:20 -04:00
ThatXliner
c0907bb58e
✏️ : Added more Code tags (#1875)
I added more syntax highlighting for python comment code tags. Though this should be implemented for all languages...
2020-10-06 16:56:08 -04:00
Peder B. Sundt
5bee7272e9
Add improvements to the python3 syntax definitions (#1833)
* Python3: Add built-in object 'cls'

* Python3: Add the bitwise negation operator ~

* Python3: Add support for hexadeximal and binary numerical literals

* Python3: Rewrite '(__foo__|__bar__)' as '__(foo|bar)__', add known '__i.*__' methods

* Python3: Add __iter__ as a magic method, sort the list of magic methods

* Python3: Numerical literals: Add support for '_', disallow leading 0 for decimals

* fixup! Python3: Numerical literals: Add support for '_', disallow leading 0 for decimals

hex oct and bin have different sets of allowed digits

* Python3: Add support for floating point numbers with optional scientific notation

* Python3: stop single-line strings at EOL

* Python3: Add support for TODO and FIXME in comments

* Python3: Add support for the ^ bitwise xor operator
2020-08-23 15:46:27 -04:00
Ryan Westlund
006165230d
python.yaml: add async as a keyword (#1713)
await is already a keyword, but async is not.
2020-06-08 13:45:05 -04:00
Zachary Yedidia
1cf9537340 Fix python3 syntax file and make python3 default
The python3 syntax had "filename" instead of "filetype"
as the header. This commit also makes standard py extensions
use the python3 highlighting and requires .py2 or a python2
env to use python2 highlighting because python3 is the standard
python now.

Fixes #1592
2020-03-24 11:42:23 -04:00
Dull Bananas
9ec07b595b
Add missing keywords for Python syntax 2019-07-03 16:53:53 -07:00
Zachary Yedidia
5c2fc92332
Merge pull request #1205 from kylebarron/python-syntax-fixes
Use symbol.operator and symbol.brackets scopes correctly in Python syntax file
2018-12-10 14:28:21 -05:00
Kyle Barron
fd48a3841e Python syntax: docstring should be string, not comment 2018-11-04 12:36:39 -05:00
Kyle Barron
e0ce419357 Use symbol.operator and symbol.brackets scopes correctly 2018-10-02 13:54:29 -04:00
Zachary Yedidia
47ef864295 Add skip statements to all strings 2017-03-29 09:45:16 -04:00
Zachary Yedidia
299712ead3 Add support for skipping and remove need for lookbehind 2017-03-27 20:53:08 -04:00
Zachary Yedidia
1655fde09b Fix precedence for python multi-comments 2017-03-26 17:24:02 -04:00
Zachary Yedidia
87f54be13a Add support for lookbehind in region regexes
Use the 'regexp2' library for lookahead and lookbehind in region
start and end regular expressions to support things like closing quotes
that aren't preceded by backslashes.
2017-03-22 19:03:06 -04:00
Zachary Yedidia
54bb99d758 Improve new syntax files and fix a region glitch 2017-03-21 15:07:39 -04:00
Zachary Yedidia
b977bf5cca Add converted syntax files 2017-03-21 14:55:22 -04:00
Zachary Yedidia
2fcb40d5a9 Use new syntax highlighting engine from zyedidia/highlight
This changes all the syntax files in the runtime directory and also
changes how syntax highlighting is done from inside micro.
2017-02-26 11:14:35 -05:00