summaryrefslogtreecommitdiffstats
path: root/vim
diff options
context:
space:
mode:
authorjistone <jistone>2005-12-21 00:44:16 +0000
committerjistone <jistone>2005-12-21 00:44:16 +0000
commit0dd17aeffbbe7e704cfb297a35a569bbe74aff2d (patch)
treebc191167d4b4ed14b7403506b59841b12ad30f9b /vim
parent0b2cecb78ce5c0dcef980124d7155263f39edd10 (diff)
downloadsystemtap-steved-0dd17aeffbbe7e704cfb297a35a569bbe74aff2d.tar.gz
systemtap-steved-0dd17aeffbbe7e704cfb297a35a569bbe74aff2d.tar.xz
systemtap-steved-0dd17aeffbbe7e704cfb297a35a569bbe74aff2d.zip
2005-12-20 Josh Stone <joshua.i.stone@intel.com>
* vim/filetype.vim: defines *.stp files as SystemTap scripts * vim/ftplugin/stap.vim: sets the comment styles * vim/indent/stap.vim: enables simple auto-indenting * vim/syntax/stap.vim: defines syntax highlighting
Diffstat (limited to 'vim')
-rw-r--r--vim/filetype.vim10
-rw-r--r--vim/ftplugin/stap.vim25
-rw-r--r--vim/indent/stap.vim35
-rw-r--r--vim/syntax/stap.vim97
4 files changed, 167 insertions, 0 deletions
diff --git a/vim/filetype.vim b/vim/filetype.vim
new file mode 100644
index 00000000..8c1fdfbd
--- /dev/null
+++ b/vim/filetype.vim
@@ -0,0 +1,10 @@
+" Vim support file to detect file types
+" Language: SystemTap
+" Maintainer: Josh Stone <joshua.i.stone@intel.com>
+" Last Change: 2005 Dec 16
+" Note: this overrides the default *.stp mapping to "Stored Procedures"
+" It would be nice to find a way to intelligently detect this.
+
+" SystemTap scripts
+au BufNewFile,BufRead *.stp setf stap
+
diff --git a/vim/ftplugin/stap.vim b/vim/ftplugin/stap.vim
new file mode 100644
index 00000000..de49a4f1
--- /dev/null
+++ b/vim/ftplugin/stap.vim
@@ -0,0 +1,25 @@
+" Vim filetype plugin file
+" Language: SystemTap
+" Maintainer: Josh Stone <joshua.i.stone@intel.com>
+" Last Change: 2005 Dec 15
+
+" Only do this when not done yet for this buffer
+if exists("b:did_ftplugin")
+ finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+set cpo-=C
+
+let b:undo_ftplugin = "setl cin< fo< com<"
+
+setlocal cindent
+
+" Set 'formatoptions' to break comment lines but not other lines,
+" and insert the comment leader when hitting <CR> or using "o".
+setlocal fo-=t fo+=croql
+
+" Set 'comments' to format dashed lists in comments.
+setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://,:#
diff --git a/vim/indent/stap.vim b/vim/indent/stap.vim
new file mode 100644
index 00000000..16658d6c
--- /dev/null
+++ b/vim/indent/stap.vim
@@ -0,0 +1,35 @@
+" Vim indent file
+" Language: SystemTap
+" Maintainer: Josh Stone <joshua.i.stone@intel.com>
+" Last Change: 2005 Dec 15
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" SystemTap indenting works *mostly* the same as C, so this gets things pretty
+" close. For 'real' SystemTap indenting, we would have to write a custom
+" indentexpr function.
+
+" indenting is similar to C, so start there...
+setlocal cindent
+
+" Statements don't require a ';', so don't indent following lines
+setlocal cino=+0
+
+" Known issues:
+" - need to detect when following lines are a continuation of the previous
+" statement, and indent appropriately.
+" - one-liners with control flow try to indent the next line if there's no
+" ';'. For example:
+" if (my_condition) break
+" do_work()
+" The second line should not be indented.
+" - The embedded-C braces do not line up correctly
+" - Preprocessor braces don't line up correctly, and internals of the
+" preprocessor aren't getting any special handling.
+" - Embedded-C statements across multiple lines don't indent
+" - '#' comments don't maintain indenting (they get treated like C
+" preprocessor statements)
diff --git a/vim/syntax/stap.vim b/vim/syntax/stap.vim
new file mode 100644
index 00000000..39947179
--- /dev/null
+++ b/vim/syntax/stap.vim
@@ -0,0 +1,97 @@
+" Vim syntax file
+" Language: SystemTap
+" Maintainer: Josh Stone <joshua.i.stone@intel.com>
+" Last Change: 2005 Dec 20
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+ syn clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+syn keyword stapStatement contained break continue return next containedin=stapBlock
+syn keyword stapRepeat contained while for foreach in containedin=stapBlock
+syn keyword stapConditional contained if else containedin=stapBlock
+syn keyword stapDeclaration global probe function
+syn keyword stapType string long
+
+syn region stapProbeDec start="\<probe\>"lc=5 end="{"me=s-1 contains=stapString,stapNumber
+syn match stapProbe contained "\<\w\+\>" containedin=stapProbeDec
+
+syn region stapFuncDec start="\<function\>"lc=8 end=":\|("me=s-1 contains=stapString,stapNumber
+syn match stapFuncCall contained "\<\w\+\ze\(\s\|\n\)*(" containedin=stapBlock
+syn match stapFunc contained "\<\w\+\>" containedin=stapFuncDec,stapFuncCall
+
+syn match stapStat contained "@\<\w\+\ze\(\s\|\n\)*(" containedin=stapBlock
+
+" decimal number
+syn match stapNumber "\<\d\+\>" containedin=stapBlock
+" octal number
+syn match stapNumber "\<0\o\+\>" contains=stapOctalZero containedin=stapBlock
+" Flag the first zero of an octal number as something special
+syn match stapOctalZero contained "\<0"
+" flag an octal number with wrong digits
+syn match stapOctalError "\<0\o*[89]\d*" containedin=stapBlock
+" hex number
+syn match stapNumber "0x\x\+\>" containedin=stapBlock
+
+syn region stapString oneline start=+"+ skip=+\\"+ end=+"+ containedin=stapBlock
+
+syn region stapPreProc fold start="%(" end="%)" contains=stapNumber,stapString containedin=ALL
+syn keyword stapPreProcCond contained kernel_v kernel_vr arch containedin=stapPreProc
+
+syn include @C syntax/c.vim
+syn keyword stapCMacro contained THIS CONTEXT containedin=@C,stapCBlock
+syn region stapCBlock fold matchgroup=stapCBlockDelims start="%{"rs=e end="%}"re=s contains=@C
+
+syn region stapBlock fold matchgroup=stapBlockEnds start="{"rs=e end="}"re=s containedin=stapBlock
+
+syn keyword stapTodo contained TODO FIXME XXX
+
+syn match stapComment "#.*" contains=stapTodo containedin=stapBlock
+syn match stapComment "//.*" contains=stapTodo containedin=stapBlock
+syn region stapComment matchgroup=stapComment start="/\*" end="\*/" contains=stapTodo,stapCommentBad containedin=stapBlock
+syn match stapCommentBad contained "/\*"
+
+" treat ^#! as special
+syn match stapSharpBang "^#!.*"
+
+
+" define the default highlighting
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlightling yet
+if version >= 508 || !exists("did_stap_syn_inits")
+ if version < 508
+ let did_stap_syn_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink stapNumber Number
+ HiLink stapOctalZero PreProc " c.vim does it this way...
+ HiLink stapOctalError Error
+ HiLink stapString String
+ HiLink stapTodo Todo
+ HiLink stapComment Comment
+ HiLink stapCommentBad Error
+ HiLink stapSharpBang PreProc
+ HiLink stapCBlockDelims Special
+ HiLink stapCMacro Macro
+ HiLink stapStatement Statement
+ HiLink stapConditional Conditional
+ HiLink stapRepeat Repeat
+ HiLink stapType Type
+ HiLink stapProbe Function
+ HiLink stapFunc Function
+ HiLink stapStat Function
+ HiLink stapPreProc PreProc
+ HiLink stapPreProcCond Special
+ HiLink stapDeclaration Typedef
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "stap"