Skip to content

Commit

Permalink
Improve VimL regex highlighting
Browse files Browse the repository at this point in the history
**NOTES:**
- PR is not yet merged in upstream repository (SalGnt/Sublime-VimL#12),
but sublime-syntax file is already updated with changes.
- Updated syntax test files are added as well

This fixes #1064
  • Loading branch information
esensar authored and sharkdp committed Dec 28, 2020
1 parent 171d215 commit 29ea396
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Binary file modified assets/syntaxes.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions assets/syntaxes/02_Extra/VimL.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ contexts:
- match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
scope: string.quoted.single.viml
string_regex:
- match: '/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
- match: '[gvs]{1}/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
scope: string.regexp.viml
support_function:
- match: \b(set(local|global)?|let|command|filetype|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
- match: \b(set(local|global)?|let|command|filetype|syntax|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
scope: support.function.viml
support_type:
- match: <.*?>
Expand Down
13 changes: 10 additions & 3 deletions tests/syntax-tests/highlighted/VimL/source.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

command! -nargs=? Echo :call EchoFunc(<args>)

" TODO test stuff
let g:global = "global var"
let s:script_var = "script var"
let w:window_var = "window war"
Expand All @@ -67,19 +68,25 @@
echo "Hello" == "Hello2"
echo "Hello" is "Hello2"
echo "Hello" isnot "Hello2"
[38;2;102;217;239mecho[0m[38;2;248;248;242m [0m[38;2;230;219;116m"Hello"[0m[38;2;248;248;242m [0m[38;2;249;38;114m=~[0m[38;2;248;248;242m [0m[38;2;230;219;116m"Hello2"[0m
[38;2;102;217;239mecho[0m[38;2;248;248;242m [0m[38;2;230;219;116m"Hello"[0m[38;2;248;248;242m [0m[38;2;249;38;114m=~[0m[38;2;248;248;242m [0m[38;2;230;219;116m'xx*'[0m
echo "Hello" !~ "Hello2"
echo "Hello" !~ "Hello2"

echo "/This/should/not/be/a/regex"

" Error case from issue #1604 (https://github.com/sharkdp/bat/issues/1064)
set runtimepath=~/foo/bar
set runtimepath=~/foo/bar

silent g/Aap/p

let g:dict = {}
let g:dict.item = ['l1', 'l2']

let g:dict2 = {'dict_item': ['l1', 'l2'], 'di2': 'x'}

silent g/regex/
silent v/regex/
silent %s/regex/not_regex/

filetype plugin indent on
[38;2;248;248;242msyntax enable[0m
[38;2;102;217;239msyntax[0m[38;2;248;248;242m enable[0m
9 changes: 8 additions & 1 deletion tests/syntax-tests/source/VimL/source.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ imap <C-h> <C-r>=HelloWorld("World")<CR>
command! -nargs=? Echo :call EchoFunc(<args>)

" TODO test stuff
let g:global = "global var"
let s:script_var = "script var"
let w:window_var = "window war"
Expand All @@ -67,7 +68,7 @@ echo "Hello" ==? "Hello2"
echo "Hello" == "Hello2"
echo "Hello" is "Hello2"
echo "Hello" isnot "Hello2"
echo "Hello" =~ "Hello2"
echo "Hello" =~ 'xx*'
echo "Hello" !~ "Hello2"
echo "Hello" !~ "Hello2"

Expand All @@ -76,10 +77,16 @@ echo "/This/should/not/be/a/regex"
" Error case from issue #1604 (https://github.com/sharkdp/bat/issues/1064)
set runtimepath=~/foo/bar

silent g/Aap/p

let g:dict = {}
let g:dict.item = ['l1', 'l2']

let g:dict2 = {'dict_item': ['l1', 'l2'], 'di2': 'x'}

silent g/regex/
silent v/regex/
silent %s/regex/not_regex/

filetype plugin indent on
syntax enable

0 comments on commit 29ea396

Please sign in to comment.