Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
run: pip install "setuptools<81" vim-vint
- name: Lint Vimscript
run: vint ftdetect ftplugin syntax
- name: Test regex highlighting
run: vim -Nu NONE -n -es -S tests/regex_syntax.vim
2 changes: 2 additions & 0 deletions syntax/sema.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ syn keyword semaTodo TODO FIXME XXX HACK NOTE contained

" ---------- Strings & Characters ----------------------------------------

syn region semaRegex start=/#"/ skip=/\\./ end=/"/
syn region semaString start=/"/ skip=/\\./ end=/"/ contains=semaStringEscape
syn match semaStringEscape /\\./ contained

Expand Down Expand Up @@ -496,6 +497,7 @@ hi def link semaComment Comment
hi def link semaBlockComment Comment
hi def link semaTodo Todo
hi def link semaString String
hi def link semaRegex String
hi def link semaStringEscape SpecialChar
hi def link semaNumber Number
hi def link semaBoolean Boolean
Expand Down
27 changes: 27 additions & 0 deletions tests/regex_syntax.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set nocompatible
set runtimepath^=.
syntax on

new
setfiletype sema
call setline(1, '(regex/match? #"\d+" "123")')
call setline(2, '(regex/match? #"\"[^\"]+\"" text)')
call setline(3, '(regex/match? #"\\" text)')

function! AssertGroup(line, column, expected) abort
let actual = synIDattr(synID(a:line, a:column, 1), 'name')
if actual !=# a:expected
echom printf('%d:%d expected %s, got %s', a:line, a:column, a:expected, actual)
cquit 1
endif
endfunction

call AssertGroup(1, 2, 'semaBuiltin')
call AssertGroup(1, 15, 'semaRegex')
call AssertGroup(1, 17, 'semaRegex')
call AssertGroup(2, 15, 'semaRegex')
call AssertGroup(2, 18, 'semaRegex')
call AssertGroup(3, 15, 'semaRegex')
call AssertGroup(3, 17, 'semaRegex')

quitall!
Loading