From: Samir Benmendil Date: Tue, 22 Apr 2014 23:49:05 +0000 (+0100) Subject: vim: add syntax and indent files for ros X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/eea5ddf237360145433d8604c13e1633a3315d42 vim: add syntax and indent files for ros --- diff --git a/vim/filetype.vim b/vim/filetype.vim index eca9dc6..ade77b0 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -2,5 +2,6 @@ if exists("did_load_filetypes") finish endif augroup filetypedetect + autocmd! BufNewFile,BufRead *.launch setfiletype roslaunch autocmd! BufNewFile,BufRead PKGBUILD* setfiletype PKGBUILD augroup END diff --git a/vim/indent/roslaunch.vim b/vim/indent/roslaunch.vim new file mode 100644 index 0000000..6a4393b --- /dev/null +++ b/vim/indent/roslaunch.vim @@ -0,0 +1,31 @@ + +" Use XML indentation rules + +if exists("b:did_indent") + finish +endif + +" load the XML indent rules +runtime! indent/xml.vim +runtime! indent/yaml.vim + +" override the vim indent expression (we'll call it ourselves) +setlocal indentexpr=GetRoslaunchIndent(v:lnum) + +" Only define the function once. +if exists("*GetRoslaunchIndent") + finish +endif + +" wiki-indent will return vim indent inside a
 block,
+" and return -1 if not inside a block to trigger auto-indent
+function GetRoslaunchIndent(lnum)
+  return -1
+  if searchpair('','','','bWnm') > 0
+    return GetYAMLIndent(lnum)
+  else
+    return -1
+  endif
+endfunc
+
+
diff --git a/vim/syntax/rosaction.vim b/vim/syntax/rosaction.vim
new file mode 100644
index 0000000..ad86954
--- /dev/null
+++ b/vim/syntax/rosaction.vim
@@ -0,0 +1,18 @@
+" Vim syntax file
+" Language:     rosaction
+" Maintainer:   Sergey Alexandrov 
+" Filenames:    *.action
+
+" Read the rosmsg syntax to start with
+if version < 600
+  so :p:h/rosmsg.vim
+else
+  runtime! syntax/rosmsg.vim
+  unlet b:current_syntax
+endif
+
+syn match rosactionSeparator   "^---$"
+
+hi def link rosactionSeparator Special
+
+let b:current_syntax = "rosaction"
diff --git a/vim/syntax/roslaunch.vim b/vim/syntax/roslaunch.vim
new file mode 100644
index 0000000..c9acdd1
--- /dev/null
+++ b/vim/syntax/roslaunch.vim
@@ -0,0 +1,24 @@
+" Vim syntax file
+" Language: roslaunch XML
+" Maintainer: Jonathan Bohren
+" Latest Revision: 8 July 2013
+"
+" roslaunch xml syntax hilighting with inline yaml support
+"
+" Put the following in your .vimrc:
+"   autocmd BufRead,BufNewFile *.launch setfiletype roslaunch
+
+if exists("b:current_syntax")
+  finish
+endif
+
+runtime syntax/xml.vim
+
+let s:current_syntax=b:current_syntax
+unlet b:current_syntax
+
+syntax include @YAML syntax/yaml.vim
+syntax region ymlSnipInline matchgroup=rosparamTag start="\m<.\{-}rosparam.\{-}>" end="\m" contains=@YAML containedin=xmlEntity
+hi link rosparamTag ModeMsg
+
+let b:current_syntax=s:current_syntax
diff --git a/vim/syntax/rosmsg.vim b/vim/syntax/rosmsg.vim
new file mode 100644
index 0000000..11e4632
--- /dev/null
+++ b/vim/syntax/rosmsg.vim
@@ -0,0 +1,39 @@
+" Vim syntax file
+" Language:     rosmsg
+" Maintainer:   Sergey Alexandrov 
+" Filenames:    *.msg
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn keyword rosmsgBuiltInType      bool
+syn keyword rosmsgBuiltInType      int8
+syn keyword rosmsgBuiltInType      uint8
+syn keyword rosmsgBuiltInType      int16
+syn keyword rosmsgBuiltInType      uint16
+syn keyword rosmsgBuiltInType      int32
+syn keyword rosmsgBuiltInType      uint32
+syn keyword rosmsgBuiltInType      int64
+syn keyword rosmsgBuiltInType      uint64
+syn keyword rosmsgBuiltInType      float32
+syn keyword rosmsgBuiltInType      float64
+syn keyword rosmsgBuiltInType      string
+syn keyword rosmsgBuiltInType      time
+syn keyword rosmsgBuiltInType      duration
+syn keyword rosmsgBuiltInType      Header
+
+syn match   rosmsgType             "\v^\h\w+(/\h\w+)=" nextgroup=rosmsgArray,rosmsgField,rosmsgConstant
+syn match   rosmsgArray            "\[\d*\]"
+syn match   rosmsgField            "\v\s+\h\w*(\w*\s*\=)@!"
+syn match   rosmsgConstant         "\v\s+\u[0-9A-Z_]*(\s*\=)@="
+syn match   rosmsgComment          "\v#.*$"
+
+hi def link rosmsgBuiltInType      Keyword
+hi def link rosmsgType             Type
+hi def link rosmsgArray            Normal
+hi def link rosmsgField            Identifier
+hi def link rosmsgConstant         Constant
+hi def link rosmsgComment          Comment
+
+let b:current_syntax = "rosmsg"
diff --git a/vim/syntax/rossrv.vim b/vim/syntax/rossrv.vim
new file mode 100644
index 0000000..d957915
--- /dev/null
+++ b/vim/syntax/rossrv.vim
@@ -0,0 +1,18 @@
+" Vim syntax file
+" Language:     rossrv
+" Maintainer:   Sergey Alexandrov 
+" Filenames:    *.srv
+
+" Read the rosmsg syntax to start with
+if version < 600
+  so :p:h/rosmsg.vim
+else
+  runtime! syntax/rosmsg.vim
+  unlet b:current_syntax
+endif
+
+syn match rossrvSeparator   "^---$"
+
+hi def link rossrvSeparator Special
+
+let b:current_syntax = "rossrv"