comparison src/testdir/test_syntax.vim @ 7687:61354fabf8a2 v7.4.1142

commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 19 22:29:28 2016 +0100 patch 7.4.1142 Problem: Cannot define keyword characters for a syntax file. Solution: Add the ":syn iskeyword" command. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jan 2016 22:30:07 +0100
parents
children da4f6e238374
comparison
equal deleted inserted replaced
7686:fad587cb360a 7687:61354fabf8a2
1 " Test for syntax and syntax iskeyword option
2
3 if !has("syntax")
4 finish
5 endif
6
7 func GetSyntaxItem(pat)
8 let c = ''
9 let a = ['a', getreg('a'), getregtype('a')]
10 0
11 redraw!
12 call search(a:pat, 'W')
13 let synid = synID(line('.'), col('.'), 1)
14 while synid == synID(line('.'), col('.'), 1)
15 norm! v"ay
16 " stop at whitespace
17 if @a =~# '\s'
18 break
19 endif
20 let c .= @a
21 norm! l
22 endw
23 call call('setreg', a)
24 0
25 return c
26 endfunc
27
28 func Test_syn_iskeyword()
29 new
30 call setline(1, [
31 \ 'CREATE TABLE FOOBAR(',
32 \ ' DLTD_BY VARCHAR2(100)',
33 \ ');',
34 \ ''])
35
36 syntax on
37 set ft=sql
38 syn match SYN /C\k\+\>/
39 hi link SYN ErrorMsg
40 call assert_equal('DLTD_BY', GetSyntaxItem('DLTD'))
41 /\<D\k\+\>/:norm! ygn
42 call assert_equal('DLTD_BY', @0)
43 redir @c
44 syn iskeyword
45 redir END
46 call assert_equal("\nsyntax iskeyword not set", @c)
47
48 syn iskeyword @,48-57,_,192-255
49 redir @c
50 syn iskeyword
51 redir END
52 call assert_equal("\nsyntax iskeyword @,48-57,_,192-255", @c)
53
54 setlocal isk-=_
55 call assert_equal('DLTD_BY', GetSyntaxItem('DLTD'))
56 /\<D\k\+\>/:norm! ygn
57 let b2=@0
58 call assert_equal('DLTD', @0)
59
60 syn iskeyword clear
61 redir @c
62 syn iskeyword
63 redir END
64 call assert_equal("\nsyntax iskeyword not set", @c)
65
66 quit!
67 endfunc