More readable sign initialisation code.
authorIain Patterson <me@iain.cx>
Tue, 28 Jan 2014 17:50:44 +0000 (17:50 +0000)
committerIain Patterson <me@iain.cx>
Mon, 3 Feb 2014 14:09:50 +0000 (14:09 +0000)
Not much more, admittedly.

.vimrc

diff --git a/.vimrc b/.vimrc
index 65e88b3..c2705ed 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -942,12 +942,30 @@ fun! <SID>Cycle_Signs(resize) "{{{2
     while strlen(l:signs)
       let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=-][^ ]\+')
 
-      let l:sign = substitute(l:sign, ':.', "", "")
-      let l:sign = substitute(l:sign, '=', " texthl=MarkSign text=", "")
-      let l:sign = substitute(l:sign, '\.', " texthl=MarkDot text=", "")
-      let l:sign = substitute(l:sign, '-', " texthl=MarkLine linehl=MarkLine text=", "")
+      let l:name = substitute(l:sign, '[:.=-].*', "", "")
+      let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "")
+      let l:ascii = matchstr(l:sign, '^:.')
+      let l:mark = substitute(l:sign, '^\(:.\)*[.=-]', "", "")
+      if strlen(l:ascii)
+        let l:ascii = substitute(l:ascii, '^:', "", "")
+        let l:ascii = matchstr(l:ascii, '^.')
+      else
+        let l:ascii = l:mark
+      endif
+      let l:ascii = substitute(l:ascii, '"', '\\"', "")
+      let l:type = substitute(l:sign, '^:.', "", "")
+      let l:type = matchstr(l:type, '^.')
+
+      let l:hl = ""
+      if l:type == "="
+        let l:hl = "texthl=MarkSign text="
+      elseif l:type == "."
+        let l:hl = "texthl=MarkDot text="
+      elseif l:type == "-"
+        let l:hl = "texthl=MarkLine text="
+      endif
 
-      exe "sign define Mark" . l:sign
+      exe "sign define Mark" . l:name . " " . l:hl . l:mark
 
       let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
     endwhile