Commits

jb55 committed d67b5a5

Added plugin for vim

Comments (0)

Files changed (4)

misc/vim/ftdetect/roy.vim

+au BufRead,BufNewFile *.roy,*.lroy set ft=roy

misc/vim/indent/roy.vim

+" Vim indent file
+" Language:	Roy
+" Maintainer:	Bill Casarin <bill@casarin.ca>
+" Last Change:	April 24, 2012
+" Notes:        based on Bram Moneaar's indent file for vim
+
+"set nocindent
+"set smartindent
+set autoindent
+
+setlocal indentexpr=GetRoyIndent()
+setlocal indentkeys+==end,=else,=catch,=}
+
+" Only define the function onceo
+if exists("*GetRoyIndent")
+endif
+
+function! GetRoyIndent()
+  " Find a non-blank line above the current line.
+  let lnum = prevnonblank(v:lnum - 1)
+
+  " At the start of the file use zero indent.
+  if lnum == 0
+    return 0
+  endif
+
+  " Add a 'shiftwidth' after matched strings
+  let ind = indent(lnum)
+  let line = getline(lnum)
+
+  let i = match(line, '\.*\(if\)\.*') 
+  if i >= 0
+    let ind = i + &sw
+  endif
+
+  if match(line, '\.*{\s*$') >= 0
+    let ind += &sw
+  endif
+
+  if match(line, '\.*=\s*$') >= 0
+    let ind += &sw
+  endif
+
+  let i = match(line, '^\s*\(where\|else\|do\)')
+  if i >= 0
+    let ind += &sw
+  endif
+
+  " Subtract a 'shiftwidth' on a end, catch, else and elseif
+  if getline(v:lnum) =~ '^\s*\(else\|}\)'
+    let ind -= &sw
+  endif
+
+  return ind
+endfunction

misc/vim/plugin/roy.vim

+" Vim filetype plugin file
+" Language:	Roy
+" Maintainer:	Bill Casarin <bill@casarin.ca>
+" Last Change: April 24, 2012  
+
+if exists("b:did_ftplugin")
+	finish
+endif
+
+let b:did_ftplugin = 1
+
+setlocal include="^\s*import\>"
+setlocal suffixesadd=.lroy,.roy,.roym
+setlocal comments=://
+setlocal commentstring=//%s
+setlocal define="^\s*macro\>"
+
+" Uncomment the following two lines to force julia source-code style
+set shiftwidth=2
+set expandtab
+
+if has("gui_win32")
+	let b:browsefilter = "Roy Source Files (*.roy)\t*.lroy\n"
+endif

misc/vim/syntax/roy.vim

+" Vim syntax file
+" Language: Roy (http://roy.brianmckenna.org/)
+" Maintainer: Shigeo Esehara, Bill Casarin <bill@casarin.ca>
+" Last Change: 2011.11.29
+
+if version < 600
+    syn clear
+elseif exists("b:current_syntax")
+    finish
+endif
+
+"keywords
+syn keyword royStatement bind
+syn keyword royStatement case
+syn keyword royStatement data
+syn keyword royStatement do 
+syn keyword royStatement else
+syn keyword royStatement if
+syn keyword royStatement macro 
+syn keyword royStatement match
+syn keyword royStatement return 
+syn keyword royStatement then
+syn keyword royStatement type
+syn keyword royStatement typeclass
+syn keyword royStatement instance
+syn keyword royStatement where
+syn keyword royStatement with
+
+syn keyword royConstant true false
+syn keyword royImport import export
+syn keyword royMacro macro
+
+" Types {{{
+syn keyword royType Boolean
+syn keyword royType Either
+syn keyword royType Function
+syn keyword royType Maybe
+syn keyword royType Native
+syn keyword royType Number
+syn keyword royType String
+" }}}
+
+"defined type or data
+syn keyword roySymbol let nextgroup=roySymbol skipwhite
+syn match   roySymbol  "\%(\%(let\s\)\s*\)\@<=\%([a-zA-Z0-9$_]\)*" contained
+syn match   royLiteralTok "[<>!=/\%\+\*\-&←λ→\\⇒]"
+syn match   royNumber "\<\d\+\>"
+syn match   royTypeVariable "#[a-zA-Z]\+"
+
+"Braces,Parens
+syn match   roySurround "[{}]"
+syn match   roySurround  "[()]"
+
+"Comment
+syn match  royComment "//.*$" display contains=royTodo,@Spell
+syn keyword royTodo   FIXME NOTE NOTES TODO XXX contained
+
+"String
+syn region  royStringD	       start=+"+  skip=+\\\\\|\\"+  end=+"\|$+
+syn region  royStringS	       start=+'+  skip=+\\\\\|\\'+  end=+'\|$+
+
+if version >= 508 || !exists("did_roy_syn_inits")
+  if version <= 508
+    let did_roy_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+  
+  HiLink royComment   Comment
+  HiLink royStringD    String
+  HiLink royStringS    String
+  HiLink royStatement Statement
+  HiLink roySymbol    Function
+  HiLink roySurround  Nothing
+  HiLink royConstant  Constant
+  HiLink royTodo      Todo
+  HiLink royType      Type
+  HiLink royImport    Include
+  HiLink royMacro     Macro
+  HiLink royLiteralTok Operator
+  HiLink royNumber       Number
+  HiLink royTypeVariable Type
+
+  delcommand HiLink
+endif
+
+
+let b:current_syntax = "roy"