Change erlang provider to hcs42/vim-erlang-runtime

This commit is contained in:
Adam Stankiewicz 2014-12-11 22:58:14 +01:00
parent 04f868b94a
commit 7f2e366334
8 changed files with 1704 additions and 986 deletions

View File

@ -39,7 +39,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, ftplugin, ftdetect)
- [emberscript](https://github.com/heartsentwined/vim-ember-script) (syntax, indent, ftplugin, ftdetect)
- [emblem](https://github.com/heartsentwined/vim-emblem) (syntax, indent, ftplugin, ftdetect)
- [erlang](https://github.com/oscarh/vimerl) (syntax, indent, compiler, autoload, ftplugin)
- [erlang](https://github.com/hcs42/vim-erlang-runtime) (syntax, indent)
- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin, ftdetect)
- [go](https://github.com/fatih/vim-go) (syntax, indent, ftdetect)
- [haml](https://github.com/tpope/vim-haml) (syntax, indent, compiler, ftplugin, ftdetect)

View File

@ -1,161 +0,0 @@
" ------------------------------------------------------------------------------
" Vim omni-completion script
" Author: Oscar Hellström
" Email: oscar@oscarh.net
" Version: 2010-08-10
" Contributors: kTT (http://github.com/kTT)
" Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" ------------------------------------------------------------------------------
" 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*\(%.*\)\?$'
let s:erlangCompletionPath = expand('<sfile>:p:h') . '/erlang_completion.erl'
if !exists('g:erlangCompletionGrep')
let g:erlangCompletionGrep = 'grep'
endif
if !exists('g:erlangManSuffix')
let g:erlangManSuffix = ''
endif
if !exists('g:erlangManPath')
let g:erlangManPath = '/usr/lib/erlang/man'
endif
if !exists('g:erlangCompletionDisplayDoc')
let g:erlangCompletionDisplayDoc = 1
endif
" 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[:-2], '\<\k*\>$')
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)
" If it's a local module, try to compile it
if filereadable(a:module . '.erl') && !filereadable(a:module . '.beam')
silent execute '!erlc' a:module . '.erl' '>/dev/null' '2>/dev/null'
redraw!
endif
let functions = system(s:erlangCompletionPath . ' ' . a:module)
for element in sort(split(functions, '\n'))
if match(element, a:base) == 0
let function_name = matchstr(element, a:base . '\w\+')
let number_of_args = matchstr(element, '\d\+', len(function_name))
let number_of_comma = max([number_of_args - 1, 0])
let file_path = g:erlangManPath . '/man?/' . a:module . '\.?' . g:erlangManSuffix
" [:-2] cutting some weird characters at the end
" becouse grep doesn't support multilines, we have to filter
" first by .B and next by looking via function name
" if someone have better idea, please change it
let description = ''
" Don't look man pages if the module is present in the current directory
if g:erlangCompletionDisplayDoc != 0 && !filereadable(a:module . '.erl')
let system_command = g:erlangCompletionGrep . ' -A 1 "\.B" ' . file_path . ' | grep -EZo "\<' .
\ function_name . '\>\((\w+, ){' . number_of_comma . '}[^),]*\) -> .*"'
let description = system(system_command)
let description = description[:-2]
endif
if description == ''
let description = element " if function doesn't have description e.g. lists:rmerge, put rmerge/2 instead
endif
let field = {'word': function_name . '(', 'abbr': description, 'kind': 'f', 'dup': 1} " always duplicate functions
call complete_add(field)
endif
endfor
return []
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

2
build
View File

@ -82,7 +82,7 @@ PACKS="
elixir:elixir-lang/vim-elixir
emberscript:heartsentwined/vim-ember-script
emblem:heartsentwined/vim-emblem
erlang:oscarh/vimerl
erlang:hcs42/vim-erlang-runtime
git:tpope/vim-git
go:fatih/vim-go:_BASIC
haml:tpope/vim-haml

View File

@ -1,80 +0,0 @@
" Erlang compiler file
" Language: Erlang
" Maintainer: Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
" URL: http://ktototaki.info
if exists("current_compiler")
finish
endif
let current_compiler = "erlang"
if exists(":CompilerSet") != 2
command -nargs=* CompilerSet setlocal <args>
endif
if !exists('g:erlangCheckFile')
let g:erlangCheckFile = "~/.vim/compiler/erlang_check_file.erl"
endif
if !exists('g:erlangHighlightErrors')
let g:erlangHighlightErrors = 0
endif
let b:error_list = {}
let b:is_showing_msg = 0
function! HighlightErlangErrors()
if match(getline(1), "#!.*escript") != -1
setlocal makeprg=escript\ -s\ %
else
execute "setlocal makeprg=" . g:erlangCheckFile . "\\ \%"
endif
silent make!
call s:clear_matches()
for error in getqflist()
let item = {}
let item['lnum'] = error.lnum
let item['msg'] = error.text
let b:error_list[error.lnum] = item
call matchadd('SpellBad', "\\%" . error.lnum . "l")
endfor
if len(getqflist())
redraw!
endif
call s:show_msg()
setlocal makeprg=erlc\ %
endfunction
function! s:show_msg()
let pos = getpos(".")
if has_key(b:error_list, pos[1])
let item = get(b:error_list, pos[1])
echo item.msg
let b:is_showing_msg = 1
else
if exists("b:is_showing_msg") && b:is_showing_msg == 1
echo
let b:is_showing_msg = 0
endif
endif
endf
function! s:clear_matches()
call clearmatches()
let b:error_list = {}
if exists("b:is_showing_msg") && b:is_showing_msg == 1
echo
let b:is_showing_msg = 0
endif
endfunction
CompilerSet makeprg=erlc\ %
CompilerSet errorformat=%f:%l:\ %tarning:\ %m,%E%f:%l:\ %m
if g:erlangHighlightErrors
autocmd BufLeave *.erl call s:clear_matches()
autocmd BufEnter *.erl call s:clear_matches()
autocmd BufWritePost *.erl call HighlightErlangErrors()
autocmd CursorHold *.erl call s:show_msg()
autocmd CursorMoved *.erl call s:show_msg()
endif

View File

@ -1,154 +0,0 @@
" Vim ftplugin file
" Language: Erlang
" Maintainer: Oscar Hellström <oscar@oscarh.net>
" URL: http://personal.oscarh.net
" Contributor: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" Version: 2010-09-03
" ------------------------------------------------------------------------------
" Usage:
"
" To enable folding put in your vimrc:
" set foldenable
"
" 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 in your vimrc file:
" let g:erlangFoldSplitFunction=1
"
" ------------------------------------------------------------------------------
" Plugin init
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
function s:SetErlangOptions()
compiler erlang
if version >= 700
setlocal omnifunc=erlangcomplete#Complete
endif
setlocal comments=:%%%,:%%,:%
setlocal commentstring=%%s
setlocal foldmethod=expr
setlocal foldexpr=GetErlangFold(v:lnum)
setlocal foldtext=ErlangFoldText()
endfunction
" Define folding functions
if !exists("*GetErlangFold")
" Folding params
let s:ErlangFunBegin = '^\a\w*(.*$'
let s:ErlangFunEnd = '^[^%]*\.\s*\(%.*\)\?$'
let s:ErlangBlankLine = '^\s*\(%.*\)\?$'
" Auxiliary fold functions
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
function GetErlangFold(lnum)
let lnum = a:lnum
let line = getline(lnum)
if line =~ s:ErlangFunEnd
return '<1'
endif
if line =~ s:ErlangFunBegin && foldlevel(lnum - 1) == 1
if exists("g:erlangFoldSplitFunction") && g:erlangFoldSplitFunction
return '>1'
else
return '1'
endif
endif
if line =~ s:ErlangFunBegin
return '>1'
endif
return '='
endfunction
" Erlang fold description (foldtext function)
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()

View File

@ -1,295 +0,0 @@
" Erlang refactor file
" Language: Erlang
" Maintainer: Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
" URL: http://ktototaki.info
if exists("b:did_ftplugin_erlang")
finish
endif
" Don't load any other
let b:did_ftplugin_erlang=1
if !exists('g:erlangRefactoring') || g:erlangRefactoring == 0
finish
endif
if !exists('g:erlangWranglerPath')
let g:erlangWranglerPath = '/usr/share/wrangler/'
endif
if glob(g:erlangWranglerPath) == ""
call confirm("Wrong path to wrangler dir")
finish
endif
autocmd VimLeavePre * call StopWranglerServer()
let s:erlangServerName = "wrangler_vim"
" Starting background erlang session with wrangler on
function! StartWranglerServer()
let wranglerEbinDir = g:erlangWranglerPath . "/ebin"
let command = "erl_call -s -sname " . s:erlangServerName . " -x 'erl -pa " . wranglerEbinDir . "'"
call system(command)
call s:send_rpc('application', 'start', '[wrangler_app]')
endfunction
" Stopping erlang session
function! StopWranglerServer()
echo s:send_rpc('erlang', 'halt', '')
endfunction
" Sending rpc call to erlang session
function! s:send_rpc(module, fun, args)
let command = "erl_call -sname " . s:erlangServerName . " -a '" . a:module . " " . a:fun . " " . a:args . "'"
let result = system(command)
if match(result, 'erl_call: failed to connect to node .*') != -1
call StartWranglerServer()
return system(command)
endif
return result
endfunction
function! ErlangUndo()
echo s:send_rpc("wrangler_undo_server", "undo", "[]")
:e!
endfunction
function! s:trim(text)
return substitute(a:text, "^\\s\\+\\|\\s\\+$", "", "g")
endfunction
function! s:get_msg(result, tuple_start)
let msg_begin = '{' . a:tuple_start . ','
let matching_start = match(a:result, msg_begin)
if matching_start != -1
return s:trim(matchstr(a:result, '[^}]*', matching_start + strlen(msg_begin)))
endif
return ""
endfunction
" Check if there is an error in result
function! s:check_for_error(result)
let msg = s:get_msg(a:result, 'ok')
if msg != ""
return [0, msg]
endif
let msg = s:get_msg(a:result, 'warning')
if msg != ""
return [1, msg]
endif
let msg = s:get_msg(a:result, 'error')
if msg != ""
return [2, msg]
endif
return [-1, ""]
endfunction
" Sending apply changes to file
function! s:send_confirm()
let choice = confirm("What do you want?", "&Preview\n&Confirm\nCa&ncel", 0)
if choice == 1
echo "TODO: Display preview :)"
elseif choice == 2
let module = 'wrangler_preview_server'
let fun = 'commit'
let args = '[]'
return s:send_rpc(module, fun, args)
else
let module = 'wrangler_preview_server'
let fun = 'abort'
let args = '[]'
return s:send_rpc(module, fun, args)
echo "Canceled"
endif
endfunction
" Manually send confirm, for testing purpose only
function! SendConfirm()
echo s:send_confirm()
endfunction
" Format and send function extracton call
function! s:call_extract(start_line, start_col, end_line, end_col, name)
let file = expand("%:p")
let module = 'wrangler'
let fun = 'fun_extraction'
let args = '["' . file . '", {' . a:start_line . ', ' . a:start_col . '}, {' . a:end_line . ', ' . a:end_col . '}, "' . a:name . '", ' . &sw . ']'
let result = s:send_rpc(module, fun, args)
let [error_code, msg] = s:check_for_error(result)
if error_code != 0
call confirm(msg)
return 0
endif
echo "This files will be changed: " . matchstr(msg, "[^]]*", 1)
echo s:send_confirm()
return 1
endfunction
function! ErlangExtractFunction(mode) range
silent w!
let name = inputdialog("New function name: ")
if name != ""
if a:mode == "v"
let start_pos = getpos("'<")
let start_line = start_pos[1]
let start_col = start_pos[2]
let end_pos = getpos("'>")
let end_line = end_pos[1]
let end_col = end_pos[2]
elseif a:mode == "n"
let pos = getpos(".")
let start_line = pos[1]
let start_col = pos[2]
let end_line = pos[1]
let end_col = pos[2]
else
echo "Mode not supported."
return
endif
if s:call_extract(start_line, start_col, end_line, end_col, name)
let temp = &autoread
set autoread
:e
if temp == 0
set noautoread
endif
endif
else
echo "Empty function name. Ignoring."
endif
endfunction
nmap <A-r>e :call ErlangExtractFunction("n")<ENTER>
vmap <A-r>e :call ErlangExtractFunction("v")<ENTER>
function! s:call_rename(mode, line, col, name, search_path)
let file = expand("%:p")
let module = 'wrangler'
let fun = 'rename_' . a:mode
let args = '["' . file .'", '
if a:mode != "mod"
let args = args . a:line . ', ' . a:col . ', '
endif
let args = args . '"' . a:name . '", ["' . a:search_path . '"], ' . &sw . ']'
let result = s:send_rpc(module, fun, args)
let [error_code, msg] = s:check_for_error(result)
if error_code != 0
call confirm(msg)
return 0
endif
echo "This files will be changed: " . matchstr(msg, "[^]]*", 1)
echo s:send_confirm()
return 1
endfunction
function! ErlangRename(mode)
silent w!
if a:mode == "mod"
let name = inputdialog('Rename module to: ')
else
let name = inputdialog('Rename "' . expand("<cword>") . '" to: ')
endif
if name != ""
let search_path = expand("%:p:h")
"let search_path = inputdialog('Search path: ', expand("%:p:h"))
let pos = getpos(".")
let line = pos[1]
let col = pos[2]
let current_filename = expand("%")
let current_filepath = expand("%:p")
let new_filename = name . '.erl'
if s:call_rename(a:mode, line, col, name, search_path)
if a:mode == "mod"
execute ':bd ' . current_filename
execute ':e ' . new_filename
silent execute '!mv ' . current_filepath . ' ' . current_filepath . '.bak'
redraw!
else
let temp = &autoread
set autoread
:e
if temp == 0
set noautoread
endif
endif
endif
else
echo "Empty name. Ignoring."
endif
endfunction
function! ErlangRenameFunction()
call ErlangRename("fun")
endfunction
map <A-r>f :call ErlangRenameFunction()<ENTER>
function! ErlangRenameVariable()
call ErlangRename("var")
endfunction
map <A-r>v :call ErlangRenameVariable()<ENTER>
function! ErlangRenameModule()
call ErlangRename("mod")
endfunction
map <A-r>m :call ErlangRenameModule()<ENTER>
function! ErlangRenameProcess()
call ErlangRename("process")
endfunction
map <A-r>p :call ErlangRenameProcess()<ENTER>
function! s:call_tuple_fun_args(start_line, start_col, end_line, end_col, search_path)
let file = expand("%:p")
let module = 'wrangler'
let fun = 'tuple_funpar'
let args = '["' . file . '", {' . a:start_line . ', ' . a:start_col . '}, {' . a:end_line . ', ' . a:end_col . '}, ["' . a:search_path . '"], ' . &sw . ']'
let result = s:send_rpc(module, fun, args)
if s:check_for_error(result)
return 0
endif
call s:send_confirm()
return 1
endfunction
function! ErlangTupleFunArgs(mode)
silent w!
let search_path = expand("%:p:h")
"let search_path = inputdialog('Search path: ', expand("%:p:h"))
if a:mode == "v"
let start_pos = getpos("'<")
let start_line = start_pos[1]
let start_col = start_pos[2]
let end_pos = getpos("'>")
let end_line = end_pos[1]
let end_col = end_pos[2]
if s:call_tuple_fun_args(start_line, start_col, end_line, end_col, search_path)
let temp = &autoread
set autoread
:e
if temp == 0
set noautoread
endif
endif
elseif a:mode == "n"
let pos = getpos(".")
let line = pos[1]
let col = pos[2]
if s:call_tuple_fun_args(line, col, line, col, search_path)
let temp = &autoread
set autoread
:e
if temp == 0
set noautoread
endif
endif
else
echo "Mode not supported."
endif
endfunction
nmap <A-r>t :call ErlangTupleFunArgs("n")<ENTER>
vmap <A-r>t :call ErlangTupleFunArgs("v")<ENTER>
" vim: set foldmethod=marker:

File diff suppressed because it is too large Load Diff

View File

@ -1,137 +1,271 @@
" Vim syntax file
" Language: Erlang
" Maintainer: Oscar Hellström <oscar@oscarh.net>
" URL: http://oscar.hellstrom.st
" Version: 2010-08-09
" ------------------------------------------------------------------------------
" {{{1
" Options:
"
" Erlang BIFs
" g:erlangHighlightBif - highlight erlang built in functions (default: off)
"
" }}}
" -----------------------------------------------------------------------------
" Language: Erlang (http://www.erlang.org)
" Maintainer: Csaba Hoch <csaba.hoch@gmail.com>
" Contributor: Adam Rutkowski <hq@mtod.org>
" Last Update: 2013-Nov-23
" License: Vim license
" URL: https://github.com/hcs42/vim-erlang
" Acknowledgements: This script was originally created by Kresimir Marzic [1].
" The script was then revamped by Csaba Hoch [2]. During the revamp, the new
" highlighting style and some code was taken from the Erlang syntax script
" that is part of vimerl [3], created by Oscar Hellström [4] and improved by
" Ricardo Catalinas Jiménez [5].
" [1]: Kreąimir Marľić (Kresimir Marzic) <kmarzic@fly.srk.fer.hr>
" [2]: Csaba Hoch <csaba.hoch@gmail.com>
" [3]: https://github.com/jimenezrick/vimerl
" [4]: Oscar Hellström <oscar@oscarh.net> (http://oscar.hellstrom.st)
" [5]: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" Customization:
"
" To use the old highlighting style, add this to your .vimrc:
"
" let g:erlang_old_style_highlight = 1
"
" To highlight further module attributes, add them to
" ~/.vim/after/syntax/erlang.vim:
"
" syn keyword erlangAttribute myattr1 myattr2 contained
" Setup {{{1
" 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
syntax clear
elseif exists("b:current_syntax")
finish
finish
endif
" Erlang is case sensitive
let s:cpo_save = &cpo
set cpo&vim
" Case sensitive
syn case match
" Match groups {{{1
syn match erlangStringModifier /\\./ contained
syn match erlangStringModifier /\~\%(-\?[0-9*]\+\)\?\%(\.[0-9*]\+\..\?\)\?\%(c\|f\|e\|g\|s\|w\|p\|W\|P\|B\|X\|#\|b\|+\|n\|i\)/ contained
syn match erlangModifier /\$\\\?./
syn match erlangInteger /\<\%([0-9]\+#[0-9a-fA-F]\+\|[0-9]\+\)\>/
syn match erlangFloat /\<[0-9]\+\.[0-9]\+\%(e-\?[0-9]\+\)\?\>/
syn keyword erlangTodo TODO FIXME XXX contained
syn match erlangComment /%.*$/ contains=@Spell,erlangTodo
syn keyword erlangKeyword band bor bnot bsl bsr bxor div rem xor
syn keyword erlangKeyword try catch begin receive after cond fun let query
syn keyword erlangConditional case if of end
syn keyword erlangConditional not and or andalso orelse
syn keyword erlangConditional when
syn keyword erlangBoolean true false
syn keyword erlangGuard is_list is_alive is_atom is_binary is_bitstring is_boolean is_tuple is_number is_integer is_float is_function is_constant is_pid is_port is_reference is_record is_process_alive
syn match erlangOperator /\/\|*\|+\|-\|++\|--/
syn match erlangOperator /->\|<-\|||\||\|!\|=/
syn match erlangOperator /=:=\|==\|\/=\|=\/=\|<\|>\|=<\|>=/
syn keyword erlangOperator div rem
syn region erlangString start=/"/ end=/"/ skip=/\\/ contains=@Spell,erlangStringModifier
syn match erlangVariable /\<[A-Z_]\w*\>/
syn match erlangAtom /\%(\%(^-\)\|#\)\@<!\<[a-z][A-Za-z0-9_]*\>\%(\s*[(:]\)\@!/
syn match erlangAtom /\\\@<!'[^']*\\\@<!'/
syn match erlangRecord /#\w\+/
syn match erlangTuple /{\|}/
syn match erlangList /\[\|\]/
syn match erlangAttribute /^-\%(vsn\|author\|copyright\|compile\|deprecated\|module\|export\|import\|behaviour\|export_type\|ignore_xref\) *(\@=/
syn match erlangInclude /^-include\%(_lib\)\?\s*(\@=/
syn match erlangRecordDef /^-record\s*(\@=/
syn match erlangDefine /^-\%(define\|undef\)\s*(\@=/
syn match erlangPreCondit /^-\%(ifdef\|ifndef\|else\|endif\)\%(\s*(\@=\)\?/
syn match erlangType /^-\%(spec\|type\)[( ]\@=/
syn match erlangMacro /\%(-define(\)\@<=\w\+/
syn match erlangMacro /?\w\+/
syn match erlangBitType /\%(\/\|-\)\@<=\%(bits\|bitstring\|binary\|integer\|float\|unit\)\>/
syn match erlangBitSize /:\@<=[0-9]\+/
syn match erlangBinary /<<\|>>/
" BIFS
syn match erlangBIF /\%([^:0-9A-Za-z_]\|\<erlang:\)\@<=\%(abs\|apply\|atom_to_list\|binary_part\|binary_to_list\|binary_to_term\|binary_to_atom\|binary_to_existing_atom\|bitstring_to_list\|check_process_code\|concat_binary\|date\|delete_module\|disconnect_node\|element\|erase\|error\|exit\|float\|float_to_list\|garbage_collect\|get\|get_keys\|group_leader\|halt\|hd\|integer_to_list\|iolist_to_binary\|iolist_size\|length\|link\|list_to_atom\|list_to_binary\|list_to_bitstring\|list_to_existing_atom\|list_to_float\|list_to_integer\|list_to_pid\|list_to_tuple\|load_module\|make_ref\|monitor_node\|node\|nodes\|now\|open_port\|pid_to_list\|port_close\|port_command\|port_connect\|port_control\|pre_loaded\|process_flag\|process_info\|processes\|purge_module\|put\|register\|registered\|round\|self\|setelement\|size\|bit_size\|byte_size\|spawn\|spawn_link\|spawn_opt\|split_binary\|statistics\|term_to_binary\|throw\|time\|tl\|trunc\|tuple_to_list\|unlink\|unregister\|whereis\)\((\|\/[0-9]\)\@=/
syn match erlangBIF /\<\%(erlang:\)\@<=\%(append_element\|bump_reductions\|cancel_timer\|decode_packet\|demonitor\|display\|fault\|fun_info\|fun_to_list\|function_exported\|get_cookie\|get_stacktrace\|hash\|hibernate\|info\|is_builtin\|loaded\|localtime\|localtime_to_universaltime\|localtime_to_universaltime\|make_tuple\|md5\|md5_init\|md5_update\|memory\|monitor\|monitor_node\|phash\|phash2\|port_call\|port_info\|port_to_list\|ports\|process_display\|raise\|read_timer\|ref_to_list\|resume_process\|send\|send_after\|send_nosuspend\|set_cookie\|spawn_monitor\|start_timer\|suspend_process\|system_flag\|system_info\|system_monitor\|trace\|trace_delivered\|trace_info\|trace_pattern\|universaltime\|universaltime_to_localtime\|yield\)(\@=/
syn match erlangGBIF /erlang\(:\w\)\@=/
" }}}
" Link Erlang stuff to Vim groups {{{1
hi link erlangTodo Todo
hi link erlangString String
hi link erlangNoSpellString String
hi link erlangModifier SpecialChar
hi link erlangStringModifier SpecialChar
hi link erlangComment Comment
hi link erlangVariable Identifier
hi link erlangInclude Include
hi link erlangRecordDef Keyword
hi link erlangAttribute Keyword
hi link erlangKeyword Keyword
hi link erlangMacro Macro
hi link erlangDefine Define
hi link erlangPreCondit PreCondit
hi link erlangPreProc PreProc
hi link erlangDelimiter Delimiter
hi link erlangBitDelimiter Normal
hi link erlangOperator Operator
hi link erlangConditional Conditional
hi link erlangGuard Conditional
hi link erlangBoolean Boolean
hi link erlangAtom Constant
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 Keyword
hi link erlangFun Keyword
hi link erlangList Delimiter
hi link erlangTuple Delimiter
hi link erlangBinary Keyword
hi link erlangBitVariable Identifier
hi link erlangBitType Type
hi link erlangType Type
hi link erlangBitSize Number
" }}}
" Optional linkings {{{1
if exists("g:erlangHighlightBif") && g:erlangHighlightBif
hi link erlangGBIF Keyword
if version >= 600
setlocal iskeyword+=$,@-@
endif
" Comments
syn match erlangComment '%.*$' contains=erlangCommentAnnotation,erlangTodo
syn match erlangCommentAnnotation ' \@<=@\%(clear\|docfile\|end\|headerfile\|todo\|TODO\|type\|author\|copyright\|doc\|reference\|see\|since\|title\|version\|deprecated\|hidden\|private\|equiv\|spec\|throws\)' contained
syn match erlangCommentAnnotation /`[^']*'/ contained
syn keyword erlangTodo TODO FIXME XXX contained
" Numbers (minimum base is 2, maximum is 36.)
syn match erlangNumberInteger '\<\d\+\>'
syn match erlangNumberInteger '\<\%([2-9]\|[12]\d\|3[0-6]\)\+#[[:alnum:]]\+\>'
syn match erlangNumberFloat '\<\d\+\.\d\+\%([eE][+-]\=\d\+\)\=\>'
" Strings, atoms, characters
syn region erlangString start=/"/ end=/"/ contains=erlangStringModifier
syn region erlangQuotedAtom start=/'/ end=/'/ contains=erlangQuotedAtomModifier
syn match erlangStringModifier '\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)\|\~\%([ni~]\|\%(-\=\d\+\|\*\)\=\.\=\%(\*\|\d\+\)\=\%(\..\)\=[tl]*[cfegswpWPBX#bx+]\)' contained
syn match erlangQuotedAtomModifier '\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)' contained
syn match erlangModifier '\$\%([^\\]\|\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)\)'
" Operators, separators
syn match erlangOperator '==\|=:=\|/=\|=/=\|<\|=<\|>\|>=\|=>\|:=\|++\|--\|=\|!\|<-\|+\|-\|\*\|\/'
syn keyword erlangOperator div rem or xor bor bxor bsl bsr and band not bnot andalso orelse
syn match erlangBracket '{\|}\|\[\|]\||\|||'
syn match erlangPipe '|'
syn match erlangRightArrow '->'
" Atoms, function calls (order is important)
syn match erlangAtom '\<\l[[:alnum:]_@]*' contains=erlangBoolean
syn keyword erlangBoolean true false contained
syn match erlangLocalFuncCall '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangBIF
syn match erlangLocalFuncRef '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@='
syn match erlangGlobalFuncCall '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangComment
syn match erlangGlobalFuncRef '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@=' contains=erlangComment
" Variables, macros, records, maps
syn match erlangVariable '\<[A-Z_][[:alnum:]_@]*'
syn match erlangMacro '??\=[[:alnum:]_@]\+'
syn match erlangMacro '\%(-define(\)\@<=[[:alnum:]_@]\+'
syn match erlangMap '#'
syn match erlangRecord '#\s*\l[[:alnum:]_@]*'
" Shebang (this line has to be after the ErlangMap)
syn match erlangShebang '^#!.*'
" Bitstrings
syn match erlangBitType '\%(\/\%(\s\|\n\|%.*\n\)*\)\@<=\%(integer\|float\|binary\|bytes\|bitstring\|bits\|binary\|utf8\|utf16\|utf32\|signed\|unsigned\|big\|little\|native\|unit\)\%(\%(\s\|\n\|%.*\n\)*-\%(\s\|\n\|%.*\n\)*\%(integer\|float\|binary\|bytes\|bitstring\|bits\|binary\|utf8\|utf16\|utf32\|signed\|unsigned\|big\|little\|native\|unit\)\)*' contains=erlangComment
" Constants and Directives
syn match erlangUnknownAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\l[[:alnum:]_@]*' contains=erlangComment
syn match erlangAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\%(behaviou\=r\|compile\|export\(_type\)\=\|file\|import\|module\|author\|copyright\|doc\|vsn\|on_load\)\>' contains=erlangComment
syn match erlangInclude '^\s*-\%(\s\|\n\|%.*\n\)*\%(include\|include_lib\)\>' contains=erlangComment
syn match erlangRecordDef '^\s*-\%(\s\|\n\|%.*\n\)*record\>' contains=erlangComment
syn match erlangDefine '^\s*-\%(\s\|\n\|%.*\n\)*\%(define\|undef\)\>' contains=erlangComment
syn match erlangPreCondit '^\s*-\%(\s\|\n\|%.*\n\)*\%(ifdef\|ifndef\|else\|endif\)\>' contains=erlangComment
syn match erlangType '^\s*-\%(\s\|\n\|%.*\n\)*\%(spec\|type\|opaque\|callback\)\>' contains=erlangComment
" Keywords
syn keyword erlangKeyword after begin case catch cond end fun if let of
syn keyword erlangKeyword receive when try
" Build-in-functions (BIFs)
syn keyword erlangBIF abs alive apply atom_to_binary atom_to_list contained
syn keyword erlangBIF binary_part binary_to_atom contained
syn keyword erlangBIF binary_to_existing_atom binary_to_float contained
syn keyword erlangBIF binary_to_integer bitstring_to_list contained
syn keyword erlangBIF binary_to_list binary_to_term bit_size contained
syn keyword erlangBIF byte_size check_old_code check_process_code contained
syn keyword erlangBIF concat_binary date delete_module demonitor contained
syn keyword erlangBIF disconnect_node element erase error exit contained
syn keyword erlangBIF float float_to_binary float_to_list contained
syn keyword erlangBIF garbage_collect get get_keys group_leader contained
syn keyword erlangBIF halt hd integer_to_binary integer_to_list contained
syn keyword erlangBIF iolist_to_binary iolist_size is_alive contained
syn keyword erlangBIF is_atom is_binary is_bitstring is_boolean contained
syn keyword erlangBIF is_float is_function is_integer is_list contained
syn keyword erlangBIF is_number is_pid is_port is_process_alive contained
syn keyword erlangBIF is_record is_reference is_tuple length link contained
syn keyword erlangBIF list_to_atom list_to_binary contained
syn keyword erlangBIF list_to_bitstring list_to_existing_atom contained
syn keyword erlangBIF list_to_float list_to_integer list_to_pid contained
syn keyword erlangBIF list_to_tuple load_module make_ref max min contained
syn keyword erlangBIF module_loaded monitor monitor_node node contained
syn keyword erlangBIF nodes now open_port pid_to_list port_close contained
syn keyword erlangBIF port_command port_connect pre_loaded contained
syn keyword erlangBIF process_flag process_flag process_info contained
syn keyword erlangBIF process purge_module put register registered contained
syn keyword erlangBIF round self setelement size spawn spawn_link contained
syn keyword erlangBIF spawn_monitor spawn_opt split_binary contained
syn keyword erlangBIF statistics term_to_binary throw time tl contained
syn keyword erlangBIF trunc tuple_size tuple_to_list unlink contained
syn keyword erlangBIF unregister whereis contained
" Sync at the beginning of functions: if this is not used, multiline string
" are not always recognized, and the indentation script cannot use the
" "searchpair" (because it would not always skip strings and comments when
" looking for keywords and opening parens/brackets).
syn sync match erlangSync grouphere NONE "^[a-z]\s*("
let b:erlang_syntax_synced = 1
" Define the default highlighting. See ":help group-name" for the groups and
" their colors.
let s:old_style = (exists("g:erlang_old_style_highlight") &&
\g:erlang_old_style_highlight == 1)
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_erlang_inits")
if version < 508
let did_erlang_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" Comments
HiLink erlangComment Comment
HiLink erlangCommentAnnotation Special
HiLink erlangTodo Todo
HiLink erlangShebang Comment
" Numbers
HiLink erlangNumberInteger Number
HiLink erlangNumberFloat Float
" Strings, atoms, characters
HiLink erlangString String
if s:old_style
HiLink erlangQuotedAtom Type
else
HiLink erlangQuotedAtom String
endif
HiLink erlangStringModifier Special
HiLink erlangQuotedAtomModifier Special
HiLink erlangModifier Special
" Operators, separators
HiLink erlangOperator Operator
HiLink erlangRightArrow Operator
if s:old_style
HiLink erlangBracket Normal
HiLink erlangPipe Normal
else
HiLink erlangBracket Delimiter
HiLink erlangPipe Delimiter
endif
" Atoms, functions, variables, macros
if s:old_style
HiLink erlangAtom Normal
HiLink erlangLocalFuncCall Normal
HiLink erlangLocalFuncRef Normal
HiLink erlangGlobalFuncCall Function
HiLink erlangGlobalFuncRef Function
HiLink erlangVariable Normal
HiLink erlangMacro Normal
HiLink erlangRecord Normal
HiLink erlangMap Normal
else
HiLink erlangAtom String
HiLink erlangLocalFuncCall Normal
HiLink erlangLocalFuncRef Normal
HiLink erlangGlobalFuncCall Normal
HiLink erlangGlobalFuncRef Normal
HiLink erlangVariable Identifier
HiLink erlangMacro Macro
HiLink erlangRecord Structure
HiLink erlangMap Structure
endif
" Bitstrings
if !s:old_style
HiLink erlangBitType Type
endif
" Constants and Directives
if s:old_style
HiLink erlangAttribute Type
HiLink erlangMacroDef Type
HiLink erlangUnknownAttribute Normal
HiLink erlangInclude Type
HiLink erlangRecordDef Type
HiLink erlangDefine Type
HiLink erlangPreCondit Type
HiLink erlangType Type
else
HiLink erlangAttribute Keyword
HiLink erlangMacroDef Macro
HiLink erlangUnknownAttribute Normal
HiLink erlangInclude Include
HiLink erlangRecordDef Keyword
HiLink erlangDefine Define
HiLink erlangPreCondit PreCondit
HiLink erlangType Type
endif
" Keywords
HiLink erlangKeyword Keyword
" Build-in-functions (BIFs)
HiLink erlangBIF Function
if s:old_style
HiLink erlangBoolean Statement
HiLink erlangExtra Statement
HiLink erlangSignal Statement
else
HiLink erlangBoolean Boolean
HiLink erlangExtra Statement
HiLink erlangSignal Statement
endif
delcommand HiLink
endif
" }}}
let b:current_syntax = "erlang"
" vim: set foldmethod=marker:
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 et