浏览代码

utils/misc: added vim syntax and auto-detect scripts

Daniel-Constantin Mierla 15 年之前
父节点
当前提交
4e46984428
共有 3 个文件被更改,包括 89 次插入0 次删除
  1. 14 0
      utils/misc/vim/README
  2. 21 0
      utils/misc/vim/ftdetect/ser.vim
  3. 54 0
      utils/misc/vim/syntax/ser.vim

+ 14 - 0
utils/misc/vim/README

@@ -0,0 +1,14 @@
+Vim scripts to auto-detect SER and Kamailio configuration files and
+enable syntax highlighting for them.
+
+Install:
+
+- copy ftdetect/ser.vim to ~/.vim/ftdetect/ser.vim
+- copy syntax/ser.vim to ~/.vim/syntax/ser.vim
+
+Usage:
+
+- autodetection is based on .cfg extension and match of #!SER,
+#!KAMAILIO (and other variants), modparam or route keywords in
+first 400 lines of file. You can enable syntax highlighting for files
+not auto-detected with vim command: "setf ser".

+ 21 - 0
utils/misc/vim/ftdetect/ser.vim

@@ -0,0 +1,21 @@
+" Copy this file to $HOME/.vim/ftdetect/ser.vim
+
+func! s:cfgType() 
+   let max = line("$") > 400 ? 400 : line("$") 
+   for n in range(1, max) 
+      if getline(n) =~ '^\s*#!\(KAMAILIO\|OPENSER\|SER\|ALL\|MAXCOMPAT\)' 
+         set filetype=ser 
+         return 
+	 elseif getline(n) =~ '^\s*modparam\s*(\s*"[^"]\+"' 
+         set filetype=ser 
+         return 
+      elseif getline(n) =~ '^\s*route\s*{\s*' 
+         set filetype=ser 
+         return 
+      endif 
+   endfor 
+   setf cfg 
+endfunc
+
+au BufNewFile,BufRead *.cfg   call s:cfgType() 
+

文件差异内容过多而无法显示
+ 54 - 0
utils/misc/vim/syntax/ser.vim


部分文件因为文件数量过多而无法显示