Browse Source

separate syntax file for better combacibility with plugins that reloads

vimrc files(such as perdirvimrc) after BufRead.
George Ang 8 years ago
parent
commit
70ba0d60ec
2 changed files with 183 additions and 95 deletions
  1. 95
    95
      plugin/NERD_tree.vim
  2. 88
    0
      syntax/nerdtree.vim

+ 95
- 95
plugin/NERD_tree.vim View File

@@ -2688,9 +2688,9 @@ function! s:initNerdTreeInPlace(dir)
2688 2688
     call s:bindMappings()
2689 2689
     setfiletype nerdtree
2690 2690
     " syntax highlighting
2691
-    if has("syntax") && exists("g:syntax_on")
2692
-        call s:setupSyntaxHighlighting()
2693
-    endif
2691
+    "if has("syntax") && exists("g:syntax_on")
2692
+        "call s:setupSyntaxHighlighting()
2693
+    "endif
2694 2694
 
2695 2695
     call s:renderView()
2696 2696
 endfunction
@@ -2919,9 +2919,9 @@ function! s:createTreeWin()
2919 2919
     call s:bindMappings()
2920 2920
     setfiletype nerdtree
2921 2921
     " syntax highlighting
2922
-    if has("syntax") && exists("g:syntax_on")
2923
-        call s:setupSyntaxHighlighting()
2924
-    endif
2922
+    "if has("syntax") && exists("g:syntax_on")
2923
+        "call s:setupSyntaxHighlighting()
2924
+    "endif
2925 2925
 endfunction
2926 2926
 
2927 2927
 "FUNCTION: s:dumpHelp  {{{2
@@ -3407,95 +3407,95 @@ function! s:setupStatusline()
3407 3407
     endif
3408 3408
 endfunction
3409 3409
 "FUNCTION: s:setupSyntaxHighlighting() {{{2
3410
-function! s:setupSyntaxHighlighting()
3411
-    "NERDTreeFlags are syntax items that should be invisible, but give clues as to
3412
-    "how things should be highlighted
3413
-    syn match NERDTreeFlag #\~#
3414
-    syn match NERDTreeFlag #\[RO\]#
3415
-
3416
-    "highlighting for the .. (up dir) line at the top of the tree
3417
-    execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
3418
-
3419
-    "highlighting for the ~/+ symbols for the directory nodes
3420
-    syn match NERDTreeClosable #\~\<#
3421
-    syn match NERDTreeClosable #\~\.#
3422
-    syn match NERDTreeOpenable #+\<#
3423
-    syn match NERDTreeOpenable #+\.#he=e-1
3424
-
3425
-    "highlighting for the tree structural parts
3426
-    syn match NERDTreePart #|#
3427
-    syn match NERDTreePart #`#
3428
-    syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
3429
-
3430
-    "quickhelp syntax elements
3431
-    syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
3432
-    syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
3433
-    syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
3434
-    syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
3435
-    syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
3436
-    syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
3437
-    syn match NERDTreeHelp  #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
3438
-
3439
-    "highlighting for readonly files
3440
-    syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
3441
-
3442
-    "highlighting for sym links
3443
-    syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
3444
-
3445
-    "highlighing for directory nodes and file nodes
3446
-    syn match NERDTreeDirSlash #/#
3447
-    syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
3448
-    syn match NERDTreeExecFile  #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
3449
-    syn match NERDTreeFile  #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
3450
-    syn match NERDTreeFile  #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
3451
-    syn match NERDTreeCWD #^[</].*$#
3452
-
3453
-    "highlighting for bookmarks
3454
-    syn match NERDTreeBookmark # {.*}#hs=s+1
3455
-
3456
-    "highlighting for the bookmarks table
3457
-    syn match NERDTreeBookmarksLeader #^>#
3458
-    syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
3459
-    syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
3460
-    syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
3461
-
3462
-    if g:NERDChristmasTree
3463
-        hi def link NERDTreePart Special
3464
-        hi def link NERDTreePartFile Type
3465
-        hi def link NERDTreeFile Normal
3466
-        hi def link NERDTreeExecFile Title
3467
-        hi def link NERDTreeDirSlash Identifier
3468
-        hi def link NERDTreeClosable Type
3469
-    else
3470
-        hi def link NERDTreePart Normal
3471
-        hi def link NERDTreePartFile Normal
3472
-        hi def link NERDTreeFile Normal
3473
-        hi def link NERDTreeClosable Title
3474
-    endif
3475
-
3476
-    hi def link NERDTreeBookmarksHeader statement
3477
-    hi def link NERDTreeBookmarksLeader ignore
3478
-    hi def link NERDTreeBookmarkName Identifier
3479
-    hi def link NERDTreeBookmark normal
3480
-
3481
-    hi def link NERDTreeHelp String
3482
-    hi def link NERDTreeHelpKey Identifier
3483
-    hi def link NERDTreeHelpCommand Identifier
3484
-    hi def link NERDTreeHelpTitle Macro
3485
-    hi def link NERDTreeToggleOn Question
3486
-    hi def link NERDTreeToggleOff WarningMsg
3487
-
3488
-    hi def link NERDTreeDir Directory
3489
-    hi def link NERDTreeUp Directory
3490
-    hi def link NERDTreeCWD Statement
3491
-    hi def link NERDTreeLink Macro
3492
-    hi def link NERDTreeOpenable Title
3493
-    hi def link NERDTreeFlag ignore
3494
-    hi def link NERDTreeRO WarningMsg
3495
-    hi def link NERDTreeBookmark Statement
3496
-
3497
-    hi def link NERDTreeCurrentNode Search
3498
-endfunction
3410
+"function! s:setupSyntaxHighlighting()
3411
+    ""NERDTreeFlags are syntax items that should be invisible, but give clues as to
3412
+    ""how things should be highlighted
3413
+    "syn match NERDTreeFlag #\~#
3414
+    "syn match NERDTreeFlag #\[RO\]#
3415
+
3416
+    ""highlighting for the .. (up dir) line at the top of the tree
3417
+    "execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
3418
+
3419
+    ""highlighting for the ~/+ symbols for the directory nodes
3420
+    "syn match NERDTreeClosable #\~\<#
3421
+    "syn match NERDTreeClosable #\~\.#
3422
+    "syn match NERDTreeOpenable #+\<#
3423
+    "syn match NERDTreeOpenable #+\.#he=e-1
3424
+
3425
+    ""highlighting for the tree structural parts
3426
+    "syn match NERDTreePart #|#
3427
+    "syn match NERDTreePart #`#
3428
+    "syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
3429
+
3430
+    ""quickhelp syntax elements
3431
+    "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
3432
+    "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
3433
+    "syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
3434
+    "syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
3435
+    "syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
3436
+    "syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
3437
+    "syn match NERDTreeHelp  #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
3438
+
3439
+    ""highlighting for readonly files
3440
+    "syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
3441
+
3442
+    ""highlighting for sym links
3443
+    "syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
3444
+
3445
+    ""highlighing for directory nodes and file nodes
3446
+    "syn match NERDTreeDirSlash #/#
3447
+    "syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
3448
+    "syn match NERDTreeExecFile  #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
3449
+    "syn match NERDTreeFile  #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
3450
+    "syn match NERDTreeFile  #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
3451
+    "syn match NERDTreeCWD #^[</].*$#
3452
+
3453
+    ""highlighting for bookmarks
3454
+    "syn match NERDTreeBookmark # {.*}#hs=s+1
3455
+
3456
+    ""highlighting for the bookmarks table
3457
+    "syn match NERDTreeBookmarksLeader #^>#
3458
+    "syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
3459
+    "syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
3460
+    "syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
3461
+
3462
+    "if g:NERDChristmasTree
3463
+        "hi def link NERDTreePart Special
3464
+        "hi def link NERDTreePartFile Type
3465
+        "hi def link NERDTreeFile Normal
3466
+        "hi def link NERDTreeExecFile Title
3467
+        "hi def link NERDTreeDirSlash Identifier
3468
+        "hi def link NERDTreeClosable Type
3469
+    "else
3470
+        "hi def link NERDTreePart Normal
3471
+        "hi def link NERDTreePartFile Normal
3472
+        "hi def link NERDTreeFile Normal
3473
+        "hi def link NERDTreeClosable Title
3474
+    "endif
3475
+
3476
+    "hi def link NERDTreeBookmarksHeader statement
3477
+    "hi def link NERDTreeBookmarksLeader ignore
3478
+    "hi def link NERDTreeBookmarkName Identifier
3479
+    "hi def link NERDTreeBookmark normal
3480
+
3481
+    "hi def link NERDTreeHelp String
3482
+    "hi def link NERDTreeHelpKey Identifier
3483
+    "hi def link NERDTreeHelpCommand Identifier
3484
+    "hi def link NERDTreeHelpTitle Macro
3485
+    "hi def link NERDTreeToggleOn Question
3486
+    "hi def link NERDTreeToggleOff WarningMsg
3487
+
3488
+    "hi def link NERDTreeDir Directory
3489
+    "hi def link NERDTreeUp Directory
3490
+    "hi def link NERDTreeCWD Statement
3491
+    "hi def link NERDTreeLink Macro
3492
+    "hi def link NERDTreeOpenable Title
3493
+    "hi def link NERDTreeFlag ignore
3494
+    "hi def link NERDTreeRO WarningMsg
3495
+    "hi def link NERDTreeBookmark Statement
3496
+
3497
+    "hi def link NERDTreeCurrentNode Search
3498
+"endfunction
3499 3499
 
3500 3500
 "FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2
3501 3501
 "returns the given line with all the tree parts stripped off

+ 88
- 0
syntax/nerdtree.vim View File

@@ -0,0 +1,88 @@
1
+let s:tree_up_dir_line = '.. (up a dir)'
2
+"NERDTreeFlags are syntax items that should be invisible, but give clues as to
3
+"how things should be highlighted
4
+syn match NERDTreeFlag #\~#
5
+syn match NERDTreeFlag #\[RO\]#
6
+
7
+"highlighting for the .. (up dir) line at the top of the tree
8
+execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
9
+
10
+"highlighting for the ~/+ symbols for the directory nodes
11
+syn match NERDTreeClosable #\~\<#
12
+syn match NERDTreeClosable #\~\.#
13
+syn match NERDTreeOpenable #+\<#
14
+syn match NERDTreeOpenable #+\.#he=e-1
15
+
16
+"highlighting for the tree structural parts
17
+syn match NERDTreePart #|#
18
+syn match NERDTreePart #`#
19
+syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
20
+
21
+"quickhelp syntax elements
22
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
23
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
24
+syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
25
+syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
26
+syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
27
+syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
28
+syn match NERDTreeHelp  #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
29
+
30
+"highlighting for readonly files
31
+syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
32
+
33
+"highlighting for sym links
34
+syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
35
+
36
+"highlighing for directory nodes and file nodes
37
+syn match NERDTreeDirSlash #/#
38
+syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
39
+syn match NERDTreeExecFile  #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
40
+syn match NERDTreeFile  #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
41
+syn match NERDTreeFile  #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
42
+syn match NERDTreeCWD #^[</].*$#
43
+
44
+"highlighting for bookmarks
45
+syn match NERDTreeBookmark # {.*}#hs=s+1
46
+
47
+"highlighting for the bookmarks table
48
+syn match NERDTreeBookmarksLeader #^>#
49
+syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
50
+syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
51
+syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
52
+
53
+if exists("g:NERDChristmasTree") && g:NERDChristmasTree
54
+    hi def link NERDTreePart Special
55
+    hi def link NERDTreePartFile Type
56
+    hi def link NERDTreeFile Normal
57
+    hi def link NERDTreeExecFile Title
58
+    hi def link NERDTreeDirSlash Identifier
59
+    hi def link NERDTreeClosable Type
60
+else
61
+    hi def link NERDTreePart Normal
62
+    hi def link NERDTreePartFile Normal
63
+    hi def link NERDTreeFile Normal
64
+    hi def link NERDTreeClosable Title
65
+endif
66
+
67
+hi def link NERDTreeBookmarksHeader statement
68
+hi def link NERDTreeBookmarksLeader ignore
69
+hi def link NERDTreeBookmarkName Identifier
70
+hi def link NERDTreeBookmark normal
71
+
72
+hi def link NERDTreeHelp String
73
+hi def link NERDTreeHelpKey Identifier
74
+hi def link NERDTreeHelpCommand Identifier
75
+hi def link NERDTreeHelpTitle Macro
76
+hi def link NERDTreeToggleOn Question
77
+hi def link NERDTreeToggleOff WarningMsg
78
+
79
+hi def link NERDTreeDir Directory
80
+hi def link NERDTreeUp Directory
81
+hi def link NERDTreeCWD Statement
82
+hi def link NERDTreeLink Macro
83
+hi def link NERDTreeOpenable Title
84
+hi def link NERDTreeFlag ignore
85
+hi def link NERDTreeRO WarningMsg
86
+hi def link NERDTreeBookmark Statement
87
+
88
+hi def link NERDTreeCurrentNode Search

Loading…
Cancel
Save