Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit c18ecb90cc137269d053352d7f0e01475cb008d9 0 parents
@oscarh oscarh authored
4 .hgignore
@@ -0,0 +1,4 @@
+syntax: glob
+
+*~
+.*.swp
2  FIXME
@@ -0,0 +1,2 @@
+ * OmniComplete: local module
+ * OmniComplete: CTags
62 README_erlang
@@ -0,0 +1,62 @@
+Vim Erlang plugin
+
+This is a pre-release!!!
+Treat it as such and please report problems to oscar@oscarh.net
+
+Installation:
+* Unix
+ - For local installation (one user only) extract the vim_erlang.tgz
+ to your ~/.vim directory
+ - For global installation extract the vim_erlang.tgz to your
+ vim runtime directory (e.g. /usr/share/vim/vimX/)
+
+* Win
+ - For local installation (one user only) extract the vim_erlang.tgz
+ to your directory
+ - For global installation extract the vim_erlang.tgz to your
+ to your directory
+
+* Highlighting of Erlang function heads
+ - You need to add the Highlight definition "ErlangFunHead" to your color
+ scheme if you want to use the highlighting of function heads.
+
+Settings:
+You can set various variables in your vimrc file to make the plugin behave
+differently.
+
+Syntax options:
+The options expect a 0 value for disabling and a non-zero (e.g. 1) for enabling.
+
+* Highlight all Erlang bifs as keywords: (default: 0)
+ g:erlangHighlightBif
+* Highlight function heads (you need to edit your color scheme, default: 0)
+ g:erlangHighlightFunHead (default: 0)
+* Highlight words (identifiers, key- / reserved words, default: 1)
+ g:erlangHighLightWords
+* Highlight Erlang operators (default: 1)
+ g:erlangHighLightOperators=0
+
+Folding options:
+The options expect a 0 value for disabling and a non-zero (e.g. 1) for enabling.
+
+* Enable/disable folding: (default: 1)
+ g:erlangFold
+* Splitting functions if a new function head appears: (default: 0)
+ g:erlangFoldSplitFunction
+
+Compiler options:
+Options expect a string.
+
+* Specifying the complier to use
+ g:erlangCompiler (default: "emake")
+ Values:
+ - "emake"
+ Will call erl -make at the directory above the current
+ working directory
+ Expects all erlang sources to exist in src/
+ - "erlc"
+ Calls erlc with the current file as argument
+ Also adds -I ../include
+ - "erlc-debug"
+ Calls erlc with the current file as argument
+ Also adds -I ../include and +debug_info
3  TODO
@@ -0,0 +1,3 @@
+ * Completion for external modules
+ * Omni-completion should match more than functions
+ * Mnemosyne queries
112 autoload/erlangcomplete.vim
@@ -0,0 +1,112 @@
+" ------------------------------------------------------------------------------
+" Vim omni-completion script
+" Author: Oscar Hellström
+" Email: oscar@oscarh.net
+" Version: 2006-06-23
+" ------------------------------------------------------------------------------
+
+" Patterns for completions {{{1
+let s:erlangLocalFuncBeg = '\(\<[0-9A-Za-z_-]*\|\s*\)$'
+let s:erlangExternalFuncBeg = '\<[0-9A-Za-z_-]\+:[0-9A-Za-z_-]*$'
+let s:ErlangBlankLine = '^\s*\(%.*\)\?$'
+
+" Main function for completion {{{1
+function! erlangcomplete#Complete(findstart, base)
+ " 0) Init {{{2
+ let lnum = line('.')
+ let column = col('.')
+ let line = strpart(getline('.'), 0, column - 1)
+
+ " 1) First, check if completion is impossible {{{2
+ if line =~ '[^~\\]%'
+ return -1
+ endif
+
+ "echo "line[col - 1]:" . line[column - 1] . " line[col - 2]:" . line[column - 2] . "\n" . line . "\n"
+
+ " 2) Check if the char to the left of us are part of a function call {{{2
+ "
+ " Nothing interesting is written at the char just before the cursor
+ " This means _anything_ could be started here
+ " In this case, keyword completion should probably be used,
+ " for now we'll only try and complete local functions.
+ " TODO: Examine if we can stare Identifiers end complete on them
+ " Is this worth it? Is /completion/ of a "blank" wanted? Can we consider (
+ " interesting and check if we are in a function call etc.?
+ if line[column - 2] !~ '[0-9A-Za-z:_-]'
+ if a:findstart
+ return column
+ else
+ return s:erlangFindLocalFunc(a:base)
+ endif
+ endif
+
+
+ " 3) Function in external module {{{2
+ if line =~ s:erlangExternalFuncBeg
+ let delimiter = match(line, ':[0-9A-Za-z_-]*$') + 1
+ if a:findstart
+ return delimiter
+ else
+ let module = matchstr(line, '\(\<\)\@<=[0-9A-Za-z_-]\+:\@=')
+ return s:erlangFindExternalFunc(module, a:base)
+ endif
+ endif
+
+ " 4) Local function {{{2
+ if line =~ s:erlangLocalFuncBeg
+ let funcstart = match(line, ':\@<![0-9A-Za-z_-]*$')
+ if a:findstart
+ return funcstart
+ else
+ return s:erlangFindLocalFunc(a:base)
+ endif
+ endif
+
+ " 5) Unhandled situation {{{2
+ if a:findstart
+ return -1
+ else
+ return []
+ endif
+endfunction
+
+" Auxiliary functions for completion {{{1
+" Find the next non-blank line {{{2
+function s:erlangFindNextNonBlank(lnum)
+ let lnum = nextnonblank(a:lnum + 1)
+ let line = getline(lnum)
+ while line =~ s:ErlangBlankLine && 0 != lnum
+ let lnum = nextnonblank(lnum + 1)
+ let line = getline(lnum)
+ endwhile
+ return lnum
+endfunction
+
+" vim: foldmethod=marker:
+" Find external function names {{{2
+function s:erlangFindExternalFunc(module, base)
+ let functions = []
+ return functions
+endfunction
+
+" Find local function names {{{2
+function s:erlangFindLocalFunc(base)
+ " begin at line 1
+ let lnum = s:erlangFindNextNonBlank(1)
+ if "" == a:base
+ let base = '\w' " used to match against word symbol
+ else
+ let base = a:base
+ endif
+ while 0 != lnum && !complete_check()
+ let line = getline(lnum)
+ let function_name = matchstr(line, '^' . base . '[0-9A-Za-z_-]\+(\@=')
+ if function_name != ""
+ call complete_add(function_name)
+ endif
+ let lnum = s:erlangFindNextNonBlank(lnum)
+ endwhile
+ return []
+endfunction
+
47 compiler/erlang.vim
@@ -0,0 +1,47 @@
+" Vim compiler file
+" Compiler: erl -make
+" Maintainer: Oscar Hellström <oscar@oscarh.net>
+" URL: http://personal.oscarh.net
+" Latest Revision: 2006-05-24
+" ------------------------------------------------------------------------------
+" Options:
+" To set compiler to use put ether
+" let g:erlangCompiler="erlc"
+" let g:erlangCompiler="erlc-debug"
+" let g:erlangCompiler="emake"
+" in your vimrc file
+"
+" ------------------------------------------------------------------------------
+
+if exists("current_compiler")
+ finish
+endif
+let current_compiler = "erlang"
+
+if exists(":CompilerSet") != 2 " older Vim always used :setlocal
+ command -nargs=* CompilerSet setlocal <args>
+endif
+
+let s:cpo_save = &cpo
+set cpo-=C
+
+if (! exists("g:erlangCompiler")) || g:erlangCompiler == "emake"
+ set cdpath+="../"
+ CompilerSet makeprg=cd\ ..&&\erl\ -make
+
+ CompilerSet errorformat=%D/%f:%l:\ %m,
+ \%D%f:%l:\ Warning:\ %m,
+elseif g:erlangCompiler == "erlc-debug"
+ CompilerSet makeprg=erlc\ -I\ ../include\ +debug_info\ %
+
+ CompilerSet errorformat=%f:%l:\ %m,
+ \%f:%l:\ Warning:\ %m
+elseif g:erlangCompiler == "erlc"
+ CompilerSet makeprg=erlc\ -I\ ../include\ %
+
+ CompilerSet errorformat=%f:%l:\ %m,
+ \%f:%l:\ Warning:\ %m
+endif
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
194 ftplugin/erlang.vim
@@ -0,0 +1,194 @@
+" Vim ftplugin file
+" Language: Erlang
+" Maintainer: Oscar Hellström <oscar@oscarh.net>
+" URL: http://personal.oscarh.net
+" Version: 2006-06-23
+" ------------------------------------------------------------------------------
+" Usage: {{{1
+"
+" To disable folding put
+" let g:erlangFold=0
+" in your vimrc
+"
+" Folding will make only one fold for a complete function, even though it has
+" more than one function head and body
+" To change this behaviour put
+" let g:erlangFoldSplitFunction=1
+" in your vimrc file
+"
+" }}}
+" ------------------------------------------------------------------------------
+" Plugin init {{{1
+if exists("b:did_ftplugin")
+ finish
+endif
+
+" Don't load any other
+let b:did_ftplugin=1
+
+if exists('s:doneFunctionDefinitions')
+ call s:SetErlangOptions()
+ finish
+endif
+
+let s:doneFunctionDefinitions=1
+" }}}
+
+" Local settings {{{1
+" Run Erlang make instead of GNU Make
+function s:SetErlangOptions()
+ compiler erlang
+ if version >= 700
+ setlocal omnifunc=erlangcomplete#Complete
+ endif
+
+ " {{{2 Settings for folding
+ if (!exists("g:erlangFold")) || g:erlangFold
+ setlocal foldmethod=expr
+ setlocal foldexpr=GetErlangFold(v:lnum)
+ setlocal foldtext=ErlangFoldText()
+ "setlocal fml=2
+ endif
+endfunction
+
+" Define folding functions {{{1
+if !exists("*GetErlangFold")
+ " Folding params {{{2
+ " FIXME: Could these be shared between scripts?
+ let s:ErlangFunEnd = '^[^%]*\.\s*\(%.*\)\?$'
+ let s:ErlangFunHead = '^\a\w*(.*)\(\s+when\s+.*\)\?\s\+->\s*$'
+ let s:ErlangBeginHead = '^\a\w*(.*$'
+ let s:ErlangEndHead = '^\s\+[a-zA-Z-_{}\[\], ]\+)\(\s+when\s+.*\)\?\s\+->\s\(%.*\)\?*$'
+ let s:ErlangBlankLine = '^\s*\(%.*\)\?$'
+
+ " Auxiliary fold functions {{{2
+ function s:GetNextNonBlank(lnum)
+ let lnum = nextnonblank(a:lnum + 1)
+ let line = getline(lnum)
+ while line =~ s:ErlangBlankLine && 0 != lnum
+ let lnum = nextnonblank(lnum + 1)
+ let line = getline(lnum)
+ endwhile
+ return lnum
+ endfunction
+
+ function s:GetFunName(str)
+ return matchstr(a:str, '^\a\w*(\@=')
+ endfunction
+
+ function s:GetFunArgs(str, lnum)
+ let str = a:str
+ let lnum = a:lnum
+ while str !~ '->\s*\(%.*\)\?$'
+ let lnum = s:GetNextNonBlank(lnum)
+ if 0 == lnum " EOF
+ return ""
+ endif
+ let str .= getline(lnum)
+ endwhile
+ return matchstr(str,
+ \ '\(^(\s*\)\@<=.*\(\s*)\(\s\+when\s\+.*\)\?\s\+->\s*\(%.*\)\?$\)\@=')
+ endfunction
+
+ function s:CountFunArgs(arguments)
+ let pos = 0
+ let ac = 0 " arg count
+ let arguments = a:arguments
+
+ " Change list / tuples into just one A(rgument)
+ let erlangTuple = '{\([A-Za-z_,|=\-\[\]]\|\s\)*}'
+ let erlangList = '\[\([A-Za-z_,|=\-{}]\|\s\)*\]'
+
+ " FIXME: Use searchpair?
+ while arguments =~ erlangTuple
+ let arguments = substitute(arguments, erlangTuple, "A", "g")
+ endwhile
+ " FIXME: Use searchpair?
+ while arguments =~ erlangList
+ let arguments = substitute(arguments, erlangList, "A", "g")
+ endwhile
+
+ let len = strlen(arguments)
+ while pos < len && pos > -1
+ let ac += 1
+ let pos = matchend(arguments, ',\s*', pos)
+ endwhile
+ return ac
+ endfunction
+
+ " Main fold function {{{2
+ function GetErlangFold(lnum)
+ let lnum = a:lnum
+ let line = getline(lnum)
+
+ " Function head gives fold level 1 {{{3
+ if line=~ s:ErlangBeginHead
+ while line !~ s:ErlangEndHead
+ if 0 == lnum " EOF / BOF
+ retun '='
+ endif
+ if line =~ s:ErlangFunEnd
+ return '='
+ endif
+ endif
+ let lnum = s:GetNextNonBlank(lnum)
+ let line = getline(lnum)
+ endwhile
+ " check if prev line was really end of function
+ let lnum = s:GetPrevNonBlank(a:lnum)
+ if exists("g:erlangFoldSplitFunction") && g:erlangFoldSplitFunction
+ if getline(lnum) !~ s:ErlangFunEnd
+ return '='
+ endif
+ endif
+ return '1>'
+ endif
+
+ " End of function (only on . not ;) gives fold level 0 {{{3
+ if line =~ s:ErlangFunEnd
+ return '<1'
+ endif
+
+ " Check if line below is a new function head {{{3
+ " Only used if we want to split folds for different function heads
+ " Ignores blank lines
+ if exists("g:erlangFoldSplitFunction") && g:erlangFoldSplitFunction
+ let lnum = s:GetNextNonBlank(lnum)
+
+ if 0 == lnum " EOF
+ return '<1'
+ endif
+
+ let line = getline(lnum)
+
+ " End of prev function head (new function here), ending fold level 1
+ if line =~ s:ErlangFunHead || line =~ s:ErlangBeginHead
+ return '<1'
+ endif
+ endif
+
+ " Otherwise use fold from previous line
+ return '='
+ endfunction
+
+ " Erlang fold description (foldtext function) {{{2
+ function ErlangFoldText()
+ let foldlen = v:foldend - v:foldstart
+ if 1 < foldlen
+ let lines = "lines"
+ else
+ let lines = "line"
+ endif
+ let line = getline(v:foldstart)
+ let name = s:GetFunName(line)
+ let arguments = s:GetFunArgs(strpart(line, strlen(name)), v:foldstart)
+ let argcount = s:CountFunArgs(arguments)
+ let retval = v:folddashes . " " . name . "/" . argcount
+ let retval .= " (" . foldlen . " " . lines . ")"
+ return retval
+ endfunction " }}}
+endif " }}}
+
+call s:SetErlangOptions()
+
+" vim: set foldmethod=marker:
157 indent/erlang.vim
@@ -0,0 +1,157 @@
+" ------------------------------------------------------------------------------
+" Vim indent file
+" Language: Erlang
+" Maintainer: Oscar Hellström <oscar@oscarh.net>
+" URL: http://personal.oscarh.net
+" Version: 2006-05-24
+" ------------------------------------------------------------------------------
+
+" Only load this indent file when no other was loaded {{{1
+"if exists("b:did_indent")
+" finish
+"endif
+"let b:did_indent = 1
+
+" Set up our indention expression and the triggers {{{1
+setlocal indentexpr=GetErlangIndent()
+setlocal indentkeys=o,O,e
+setlocal indentkeys+==end,=after
+
+if exists("*GetErlangIndent")
+ finish
+endif
+
+" 1) Patterns to be used for determining the indentation {{{1
+"
+" Commends are ignored at end of lines
+let s:erlangIgnorePattern = '\(%.*\)\?'
+
+" The following patterns will always get the ignore pattern and
+" the EOL char appended
+" Pattern that add to the indentation
+let s:erlangAddIndentPattern = '\(if\|of\|receive\|after\|catch\|->\)'
+" Pattern that resets indentation
+let s:erlangZeroIndentPattern = '\.'
+" Pattern that will keep the current indentation
+let s:erlangKeepIndentPattern = '\(,\|.\+\s\+->\s\+.\+;\|\<try\>\s\+\w.*\)'
+" Pattern that deletes from the current indentation
+let s:erlangRemoveIndentPattern = ';'
+" end of pattern which get EOL appended
+
+
+" Pattern that should align indentation with block opening line
+let s:erlangAlingIdentPattern = '\(\<after\>\|\<catch\>\|\<after\s\+?\?\w\s\+->\)'
+
+" Pattern that opens blocks
+let s:erlangBlockbegPattern = '.*\%(fun(.*)\s\+\%(when\s\+.\+\s\+\)\?->.*'
+let s:erlangBlockbegPattern .= '\|receive\|if\|query'
+let s:erlangBlockbegPattern .= '\|case\s.\+\sof'
+let s:erlangBlockbegPattern .= '\|try\s.\+\sof'
+let s:erlangBlockbegPattern .= '\|catch\)'
+
+" Pattern that closes block
+let s:erlangBlockendPattern = 'end'
+
+" Empty line
+let s:erlangEmptyLine = '^\s*$'
+
+" 2) Auxiliary functions: {{{1
+
+" Matches the whole string
+function s:Match(line, exp)
+ return a:line =~ a:exp
+endfunction
+
+" Matches the whole string, but only if it is the only thing on that line
+function s:MatchAll(line, exp)
+ return s:MatchEnd(a:line, '^\s*' . a:exp)
+endfunction
+
+" Matches the end of a string
+" Any pattern that should be ignored before a line end is ignored
+function s:MatchEnd(line, exp)
+ return a:line =~ a:exp . '\s*' . s:erlangIgnorePattern . '$'
+endfunction
+
+" Find the previous nonblank line
+" ignoring lines only containing comments
+function s:FindPrevNonBlankNonComment(lnum)
+ let lnum = prevnonblank(a:lnum)
+ let line = getline(lnum)
+ " continue to search above if the current line begins with a '%'
+ while line =~ '^\s*%.*$'
+ let lnum = prevnonblank(lnum - 1)
+ if 0 == lnum
+ return 0
+ endif
+ let line = getline(lnum)
+ endwhile
+ return lnum
+endfunction
+
+" 3) Define the indent function {{{1
+function GetErlangIndent()
+
+ " 1) Check the current line {{{2
+
+ let lnum = v:lnum
+ let line = getline(lnum)
+
+ " At the beginning of the file, zero indentation
+ if 0 == lnum
+ return 0
+ endif
+
+ " If the current line is the end of a block,
+ " find the indentation of the block opener
+ if s:MatchEnd(line, s:erlangBlockendPattern)
+ " FIXME write func find_block_open
+ let begline = searchpair(s:erlangBlockbegPattern, '',
+ \ s:erlangBlockendPattern, 'bW',
+ \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
+ if begline != lnum
+ return indent(begline)
+ endif
+ endif
+
+ if s:MatchAll(line, s:erlangAlingIdentPattern)
+ " FIXME write func find_block_open
+ endif
+
+ " 2) check the previous line(s) {{{2
+
+ " Find a non-blank, non-multi-line string line above the current line.
+ let lnum = s:FindPrevNonBlankNonComment(v:lnum - 1)
+
+ " Read line
+ let line = getline(lnum)
+
+ " Beginning of file
+ if 0 == lnum
+ return 0
+ endif
+
+ " Check for pattern that will add to indentation
+ if s:MatchEnd(line, s:erlangAddIndentPattern)
+ return indent(lnum) + &sw
+ endif
+
+ " Check for patterns that will keep indent
+ if s:MatchEnd(line, s:erlangKeepIndentPattern)
+ return indent(lnum)
+ endif
+
+ " Check for patterns that will decrease indent
+ if s:MatchEnd(line, s:erlangRemoveIndentPattern)
+ return indent(lnum) - &sw
+ endif
+
+ " Check for patterns that will reset indentation
+ if s:MatchEnd(line, s:erlangZeroIndentPattern)
+ return 0
+ endif
+
+ " 3) can't find a pattern, get indent from line before
+ return indent(lnum) + &sw
+endfunction
+" vim: set foldmethod=marker:
213 syntax/erlang.vim
@@ -0,0 +1,213 @@
+" Vim syntax file
+" Language: Erlang
+" Maintainer: Oscar Hellström <oscar@oscarh.net>
+" URL: http://personal.oscarh.net
+" Version: 2006-06-28
+" ------------------------------------------------------------------------------
+" Thanks to Kre¹imir Mar¾iæ (Kresimir Marzic) <kmarzic@fly.srk.fer.hr>,
+" stole some stuff from his syntax for erlang
+" ------------------------------------------------------------------------------
+" {{{1
+" Options:
+"
+" To enable BIF highlighting put
+" let g:erlangHighlightBif=1
+" in your vimrc file
+"
+" To get function head highlighting working, add a definition for
+" "ErlangFunHead" to your color scheme file and also put
+" g:erlangHighlightFunHead=1
+" in your vimrc file.
+"
+" To disable highlighting words (Identifiers / key-/reserved words put
+" g:erlangHighLightWords=0
+" in your vimrc file.
+"
+" To disable highlighting operators put
+" g:erlangHighLightOperators=0
+" in your vimrc file.
+" }}}
+" -----------------------------------------------------------------------------
+
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+" Erlang is case sensitive
+syn case match
+
+" Need to use - in keywords
+setlocal iskeyword+=-
+
+" Comments {{{1
+" TODO / FIXME etc.
+syn keyword erlangTodo TODO FIXME contained
+syn match erlangComment /%.*/ contains=erlangTodo,@Spell
+
+" Preprocessor stuff {{{1
+syn keyword erlangInclude -include -include_lib -import
+syn keyword erlengDefine -define -undef
+syn keyword erlangPreProc -record
+syn keyword erlangPreCondit -ifdef -ifndef -else -endif
+syn match erlangMacro /?[0-9A-Za-z_-]\+/
+
+" Module attributes {{{1
+syn keyword erlangAttribute -compile -module -export -behaviour -author -vsn
+syn keyword erlangAttribute -doc -copyright -file
+
+" String modifiers {{{1
+syn match erlangModifier /\~\a\|\\\a/ contained
+
+" Sparator {{{1
+syn match erlangSeparator /\.\|#/
+
+" Numbers {{{1
+syn match erlangInteger "[a-zA-Z]\@<![+-]\=\d\+[a-zA-Z]\@!" contains=erlangSeparator
+syn match erlangFloat "[a-zA-Z]\@<![+-]\=\d\+.\d\+[a-zA-Z]\@!" contains=erlangSeparator
+syn match erlangFloat "[a-zA-Z]\@<![+-]\=\d\+\(.\d\+\)\=[eE][+-]\=\d\+\(.\d\+\)\=[a-zA-Z]\@!" contains=erlangSeparator
+syn match erlangFloat "[a-zA-Z]\@<![+-]\=\d\+[#]\x\+[a-zA-Z]\@!" contains=erlangSeparator
+syn match erlangFloat "[a-zA-Z]\@<![+-]\=[eE][+-]\=\d\+[a-zA-Z]\@!" contains=erlangSeparator
+syn match erlangHex "[a-zA-Z]\@<!$\x\+[a-zA-Z]\@!" contains=erlangSeparator
+
+" Variables {{{1
+syn match erlangIdentifier /\<\(\u\|_\)\w*\>/
+
+" Atoms {{{1
+syn region erlangAtom start=/'/ end=/'/ contained
+
+" Records {{{1
+syn match erlangRecord /#\a\w*\>/
+
+" String {{{1
+syn region erlangString start=/"/ skip=/\\"/ end=/"/ contains=erlangModifier
+
+" Delimiters {{{1
+syn match erlangDelimiter /:/
+
+" Data structures {{{1
+syn region erlangList matchgroup=Normal start=/\[/ end=/\]/ contained contains=erlangIdentifier,erlangAtom,elangList,erlangTuple
+syn region erlangTuple matchgroup=Normal start=/{/ end=/}/ contained contains=erlangIdentifier,erlangAtom,erlangList,erlangTuple
+
+" Keywords {{{1
+if (!exists("g:erlangHighLightWords")) || g:erlangHighLightWords
+ " Conditions
+ syn keyword erlangContitional if else case of end not andalso orelse and or
+ syn keyword erlangContitional receive after
+
+ " Exceptions
+ syn keyword erlangException try catch begin
+
+ " Funs
+ syn match erlangFun ':\@<!fun(\@='
+
+ " Reserved words
+ syn keyword erlangKeyword cond query let
+endif
+
+" Operators {{{1
+if (!exists("g:erlangHighLightOperators")) || g:erlangHighLightOperators
+ syn match erlangOperator "+\|-\|*\|/"
+ syn match erlangOperator "==\|/=\|=:=\|=/=\|<\|=<\|>\|>="
+ syn match erlangOperator /++\|--\|=\|!\|<-/
+ syn keyword erlangOperator band bnot bor bsl bsr bxor div rem xor
+endif
+
+" All erlang BIF:s (as of R11B) {{{1
+" Not highlighted by default
+if exists("g:erlangHighlightBif") && g:erlangHighlightBif
+" BIF:s
+ syn match erlangBIF ':\@<!\<\(abs\|append_element\|apply\|atom_to_list\)(\@='
+ syn match erlangBIF ':\@<!\<\(binary_to_list\|binary_to_term\|bump_reductions\)(\@='
+ syn match erlangBIF ':\@<!\<\(cancel_timer\|check_process_code\|date\)\>(\@='
+ syn match erlangBIF ':\@<!\<\(delete_module\|demonitor\|disconnect_node\|display\)(\@='
+ syn match erlangBIF ':\@<!\<\(erase\|exit\|fault\|float\|float_to_binary\)(\@='
+ syn match erlangBIF ':\@<!\<\(fun_info\|fun_to_list\|garbage_collect\|get\)(\@='
+ syn match erlangBIF ':\@<!\<\(get_keys\|group_leader\|halt\|hash\|hd\|hibernate\)(\@='
+ syn match erlangBIF ':\@<!\<\(integer_to_list\|is_alive\|is_builtin\)(\@='
+ syn match erlangBIF ':\@<!\<\(length\|link\|list_to_atom\|list_to_binary\|list_to_float\)(\@='
+ syn match erlangBIF ':\@<!\<\(list_to_integer\|list_to_pid\|list_to_tuple\|load_module\)(\@='
+ syn match erlangBIF ':\@<!\<\(loaded\|localtime\|localtime_to_universaltime\|make_ref\)(\@='
+ syn match erlangBIF ':\@<!\<\(make_tuple\|md5\|md5_final\|md5_init\|md5_update\|memory\)(\@='
+ syn match erlangBIF ':\@<!\<\(module_loaded\|monitor\|monitor_node\|node\|nodes\|now\)(\@='
+ syn match erlangBIF ':\@<!\<\(open_port\|phash\|phash2\|pid_to_list\|port_close\)(\@='
+ syn match erlangBIF ':\@<!\<\(port_command\|port_connect\|port_control\|port_call\)(\@='
+ syn match erlangBIF ':\@<!\<\(port_info\|port_to_list\|ports\|pre_loaded\|element\)(\@='
+ syn match erlangBIF ':\@<!\<\(process_flag\|process_info\|processes\|purge_module\)(\@='
+ syn match erlangBIF ':\@<!\<\(put\|read_timer\|ref_to_list\|register\|registered\)(\@='
+ syn match erlangBIF ':\@<!\<\(resume_process\|round\|self\|send\|send_after\|spawn\)(\@='
+ syn match erlangBIF ':\@<!\<\(send_nosuspend\|set_cookie\|setelement\|size\|spawn_link\)(\@='
+ syn match erlangBIF ':\@<!\<\(spawn_opt\|split_binary\|start_timer\|statistics\)(\@='
+ syn match erlangBIF ':\@<!\<\(suspend_process\|system_flag\|system_info\|system_monitor\)(\@='
+ syn match erlangBIF ':\@<!\<\(term_to_binary\|time\|tl\|trace\|trace_info\|trace_pattern\)(\@='
+ syn match erlangBIF ':\@<!\<\(trace_pattern\|trunc\|tuple_to_list\|universaltime\)(\@='
+ syn match erlangBIF ':\@<!\<\(universaltime_to_localtime\|unlink\|unregister\|whereis\)(\@='
+ syn match erlangBIF ':\@<!\<\(yield\|process_display\|send_nosuspend\|binary_to_float\)(\@='
+ syn match erlangBIF ':\@<!\<\(ncat_binary\|loat_to_list\|get_cookie\|info\)(\@='
+ syn match erlangBIF ':\@<!\<\(is_process_alive\)(\@='
+
+endif
+
+" BIF:s used in guards, all contained in guard expressions {{{1
+syn keyword erlangGBIF is_atom is_binary is_constant contained
+syn keyword erlangGBIF is_float is_function is_integer is_list contained
+syn keyword erlangGBIF is_number is_pid is_port is_reference contained
+syn keyword erlangGBIF is_tuple is_record contained
+
+syn keyword erlangGBIF atom binary constant float function contained
+syn keyword erlangGBIF integer list number pid port reference contained
+syn keyword erlangGBIF tuple record contained
+syn keyword erlangGBIF abs element float hd length node contained
+syn keyword erlangGBIF round self size tl trunc contained
+
+
+" Function heads {{{1
+if exists("g:erlangHighlightFunHead") && g:erlangHighlightFunHead
+ "syn region erlangGuardArgs start=/(/ end=/)/ contains=erlangIdentifier contained
+ syn region erlangGuard start=/when/ end=/->/ contains=erlangGBIF,erlangInteger,erlangFloat,erlangIdentifier
+ syn region erlangFunArgs start=/(/ end=/)/ contains=erlangIdentifier,erlangList,erlangTuple,erlangString contained
+ syn region erlangFunHead start='^\a[0-9A-Za-z_-]*(' end=')' contains=erlangFunArgs keepend
+endif
+
+" Link Erlang stuff to Vim groups {{{1
+hi link erlangTodo Todo
+hi link erlangString String
+hi link erlangModifier SpecialChar
+hi link erlangComment Comment
+hi link erlangIdentifier Identifier
+hi link erlangInclude Include
+hi link erlangAttribute Keyword
+hi link erlangGBIF Keyword
+hi link erlangKeyword Keyword
+hi link erlangMacro Macro
+hi link erlengDefine Define
+hi link erlangPreCondit PreCondit
+hi link erlangPreProc PreProc
+hi link erlangDelimiter Delimiter
+hi link erlangOperator Operator
+hi link erlangContitional Conditional
+hi link erlangGuard Conditional
+hi link erlangAtom Structure
+hi link erlangRecord Structure
+hi link erlangInteger Number
+hi link erlangFloat Number
+hi link erlangFloat Number
+hi link erlangFloat Number
+hi link erlangFloat Number
+hi link erlangHex Number
+hi link erlangBIF Function
+hi link erlangFun Keyword
+hi link erlangList Normal
+hi link erlangTuple Normal
+
+" Define new highlight groups {{{1
+hi def link erlangFunHead ErlangFunHead
+" }}}
+
+let b:current_syntax = "erlang"
+
+" vim: set foldmethod=marker:
Please sign in to comment.
Something went wrong with that request. Please try again.