diff options
| author | qiu-x <alex@alexslomka.xyz> | 2022-06-29 07:56:51 +0200 |
|---|---|---|
| committer | Felix Van der Jeugt <felix.vanderjeugt@posteo.net> | 2022-11-29 21:57:18 +0100 |
| commit | 8a420ecc4c1ed50111464ec66901bd983eaf2dbd (patch) | |
| tree | f31d2186cafaee6e7f18d32fe99144c3e8148c00 /lua/lexers/README.md | |
| parent | 981b90a203484182feace48471fe2b53dae7676f (diff) | |
| download | vis-8a420ecc4c1ed50111464ec66901bd983eaf2dbd.tar.gz vis-8a420ecc4c1ed50111464ec66901bd983eaf2dbd.tar.xz | |
Resync the lexers with Scintillua
- Resync the lexers with Scintillua
- Update the lexer readme
- Update `zenburn` theme to fix some highlighting issues
- lexers: redirect print function to vis:info()
- Fix support for custom style names
- As per error message "lexer.delimited_range() is deprecated, use lexer.range()".
- Remove remaining `lexer.delimited_range()` call
- Set syntax to `nil` if the file type has no matching lexer
- Updated Go lexer for Go 1.18.
- lexers/dsv: convert to new lexer format
(cherry picked from commit 9edbc3cd9ea1d7142b1305840432a3d2739e755a)
- lexers/gemini: disable legacy gemini lexer
This reverts commit 468f9ee1b027a7ce98b1a249fa1af5888feeb989.
It is in legacy format and of questionable quality. Ideally it
should be contributed upstream from where it will eventually
trickle down to us.
- lexers/git-rebase: convert to new lexer format
(cherry picked from commit 4000a4cc9ac4a4c2869dfae772b977a82aee8d8c)
- lexers/strace: convert to new lexer format
(cherry picked from commit e420451320d97eb164f5629c1bcfab0b595be29d)
- lexers/typescript: add new upstream lexer revision 28e2b60
(cherry picked from commit 7326e6deecdaa75fa94ae9ebdb653f9f907b33f2)
- use `package.searchpath` instead of a local `searchpath` function
- Restore `filetype: support filetype detection via hashbang`
- Remove redundant comment
- Restore gemini lexer
Diffstat (limited to 'lua/lexers/README.md')
| -rw-r--r-- | lua/lexers/README.md | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/lua/lexers/README.md b/lua/lexers/README.md index e97ea1f..1d74a8c 100644 --- a/lua/lexers/README.md +++ b/lua/lexers/README.md @@ -2,8 +2,7 @@ Lua LPeg lexers for vis ======================= Vis reuses the [Lua](http://www.lua.org/) [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) -based lexers from the [Scintillua](http://foicica.com/scintillua/) project -which is now part of the [Scintilla 3.x branch](https://foicica.com/hg/scintilla/file/tip/lexlua). +based lexers from the [Scintillua](https://orbitalquark.github.io/scintillua/index.html) project. # Vis integration @@ -26,13 +25,13 @@ where `<name>` corresponds to the filename without the `.lua` extension. To add a new lexer, start with the template quoted below or a lexer of a similiar language. Read the -[lexer module documentation](http://foicica.com/scintillua/api.html#lexer). +[lexer module documentation](https://orbitalquark.github.io/scintillua/api.html#lexer). The [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) introduction might also be useful. For development purposes it is recommended to test the lexers from a lua script as described in the -[Scintillua manual](http://foicica.com/scintillua/manual.html#Using.Scintillua.as.a.Lua.Library). +[Scintillua manual](https://orbitalquark.github.io/scintillua/manual.html#Using.Scintillua.as.a.Lua.Library). To enable auto syntax highlighting when opening a file you can associate your new lexer with a set of file extensions by adding a corresponding entry into @@ -42,35 +41,57 @@ Changes to existing lexers should also be sent upstream for consideration. A template for new lexers: -``` +```lua +-- Copyright 2006-2021 Mitchell. See LICENSE. -- ? LPeg lexer. -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, S = lpeg.P, lpeg.S -local M = {_NAME = '?'} +local lex = lexer.new('?') -- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + keyword1 keyword2 keyword3 +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +local sq_str = lexer.range("'") +local dq_str = lexer.range('"') +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#'))) -M._rules = { - {'whitespace', ws}, -} +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.number)) -M._tokenstyles = { +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%^=<>,.{}[]()'))) -} +-- Fold points. +lex:add_fold_point(lexer.KEYWORD, 'start', 'end') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, lexer.fold_consecutive_lines('#')) -return M +return lex ``` # Color Themes -The `../themes` directory contains the color schemes. Depending on the -number of colors supported by your terminal, vis will start with either -the `default-16` or `default-256` theme. Symlink it to your prefered -style or add a command like the following one to your `visrc.lua`: +The [`../themes directory`](../themes) contains the color +schemes. Depending on the number of colors supported by your terminal, +vis will start with either the [`default-16`](../themes/default-16.lua) +or [`default-256`](../themes/default-256.lua) theme. Symlink it to +your prefered style or add a command like the following one to your +`visrc.lua`: ``` vis:command("set theme solarized") @@ -79,4 +100,4 @@ vis:command("set theme solarized") # Dependencies * [Lua](http://www.lua.org/) 5.1 or greater - * [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) 0.12 or greater + * [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/) 1.0.0 or greater |
