Permalink
Browse files

Braid: Update mirror 'bundle/vimerl' to '4c4d1f0'

  • Loading branch information...
1 parent 2c3c0dc commit fc40ebe65534037ed9088b2dee09fc42c38116ce @baphled committed Feb 9, 2012
View
@@ -226,7 +226,7 @@ bundle/vim-textobj-user:
bundle/vimerl:
branch: master
remote: master/braid/bundle/vimerl
- revision: 3bfce4afb1b3a110ada376be76d165de845125b9
+ revision: 4c4d1f01068bd9e3f8fa84bf882dc474934ff2fe
squashed: true
type: git
url: git://github.com/jimenezrick/vimerl.git
View
@@ -27,7 +27,11 @@ The Erlang plugin for Vim.
Copy the content of the tarball to your `.vim'. Don't forget to run
`:helptags' if you are not using Pathogen.
-Vimerl requires to have Erlang installed in your system.
+Vimerl requires to have a recent version of Erlang installed in your
+system with `escript' in your $PATH.
+
+With a Vim version older than 7.3 syntax checking will be disabled as
+some required features won't be available.
How to use it
View
@@ -1,4 +1,2 @@
-- Fix indentation algorithm to parse correctly:
- `try..of..catch..after..end'
- (see http://github.com/jimenezrick/vimerl/issues/7)
-- Review indent file from branch `experimental-indent-aszlig'.
+- Make the code indenting more similar to the Emacs erlang-mode.
+- Handle code indenting in files like `.app'.
@@ -15,6 +15,8 @@ main([ModName]) ->
Edoc = try
module_edoc(Mod)
catch
+ exit:error ->
+ [];
throw:not_found ->
[]
end,
@@ -27,7 +29,8 @@ main([ModName]) ->
FunSpecs = merge_functions(Edoc, Info),
lists:foreach(fun(Fun) -> print_function(Fun) end, FunSpecs);
main(_) ->
- bad_module.
+ io:format("Usage: ~s <module>~n", [escript:script_name()]),
+ halt(1).
module_edoc(Mod) ->
File = case filename:find_src(Mod) of
@@ -99,8 +102,18 @@ analyze_return(Fun) ->
throw(no_spec)
end.
+simplify_return({typevar, [{name, Name}], _}) ->
+ Name;
simplify_return({type, _, [Type]}) ->
simplify_return(Type);
+simplify_return({abstype, _, [Type]}) ->
+ {erlangName, Attrs, _} = Type,
+ Name = proplists:get_value(name, Attrs),
+ Name ++ "()";
+simplify_return({record, _, [Type]}) ->
+ simplify_return(Type) ++ "()";
+simplify_return({nonempty_list, _, [Type]}) ->
+ "[" ++ simplify_return(Type) ++ "]";
simplify_return({tuple, _, Types}) ->
Elems = lists:map(fun(Type) -> simplify_return(Type) end, Types),
"{" ++ string:join(Elems, ", ") ++ "}";
@@ -115,12 +128,8 @@ simplify_return({union, _, Types}) ->
string:join(Elems, " | ");
simplify_return({atom, [{value, Val}], _}) ->
Val;
-simplify_return({typevar, [{name, Name}], _}) ->
- Name;
-simplify_return({abstype, _, [Type]}) ->
- {erlangName, Attrs, _} = Type,
- Name = proplists:get_value(name, Attrs),
- Name ++ "()".
+simplify_return({nil, _, _}) ->
+ "[]".
get_attribute(Elem, AttrName) ->
[Attr] = xmerl_xpath:string("@" ++ AttrName, Elem),
@@ -3,9 +3,9 @@
" Author: Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
" Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" License: Vim license
-" Version: 2012/01/18
+" Version: 2012/02/08
-if exists("current_compiler")
+if exists("current_compiler") || v:version < 703
finish
else
let current_compiler = "erlang"
@@ -19,15 +19,18 @@ if exists(":CompilerSet") != 2
command -nargs=* CompilerSet setlocal <args>
endif
-if !exists("g:erlang_show_errors")
- let g:erlang_show_errors = 1
-endif
+CompilerSet makeprg=make
+CompilerSet errorformat=%f:%l:\ %tarning:\ %m,%f:%l:\ %m
" Only define functions and script scope variables once
if exists("*s:ShowErrors")
finish
endif
+if !exists("g:erlang_show_errors")
+ let g:erlang_show_errors = 1
+endif
+
let s:erlang_check_file = expand("<sfile>:p:h") . "/erlang_check.erl"
let s:autocmds_defined = 0
@@ -100,9 +103,6 @@ function s:DisableShowErrors()
let s:autocmds_defined = 0
endfunction
-CompilerSet makeprg=make
-CompilerSet errorformat=%W%f:%l:\ Warning:\ %m,%E%f:%l:\ %m
-
if g:erlang_show_errors
call s:EnableShowErrors()
endif
@@ -3,21 +3,24 @@
main([File]) ->
Dir = filename:dirname(File),
Defs = [strong_validation,
- warn_export_all,
- warn_export_vars,
- warn_shadow_vars,
- warn_obsolete_guard,
- warn_unused_import,
- report,
- {i, Dir ++ "/include"},
- {i, Dir ++ "/../include"},
- {d, 'TEST'}, {d, 'DEBUG'}],
+ warn_export_all,
+ warn_export_vars,
+ warn_shadow_vars,
+ warn_obsolete_guard,
+ warn_unused_import,
+ report,
+ {i, Dir ++ "/include"},
+ {i, Dir ++ "/../include"},
+ {d, 'TEST'}, {d, 'DEBUG'}],
case file:consult("rebar.config") of
{ok, Terms} ->
+ RebarDeps = proplists:get_value(deps_dir, Terms, "deps"),
+ code:add_paths(filelib:wildcard(RebarDeps ++ "/*/ebin")),
RebarOpts = proplists:get_value(erl_opts, Terms, []),
compile:file(File, Defs ++ RebarOpts);
_ ->
compile:file(File, Defs)
end;
main(_) ->
- bad_file.
+ io:format("Usage: ~s <file>~n", [escript:script_name()]),
+ halt(1).
@@ -53,6 +53,22 @@ In this section it is explained how to use the features of this plugin.
All the code you write is automatically indented. To reindent a block of code
use the |=| or |v_=| command.
+The code indenting feature it's implemented as an Erlang escript that helps
+Vim parsing code and calculating the indentation level of each line. This
+escript communicates with Vim through a pair of named pipes located in the
+"indent/" folder where Vimerl is installed.
+
+It is recommended to enable the Vim option |'expandtab'|, with it the code
+will be indented more nicely lining up columns when possible.
+
+If Vim freezes while editing an Erlang code file, it's probably caused by a
+bug in the escript which crashed and Vim is waiting for it to respond. So, if
+that happens to you, kill Vim and reopen the file. It also would be nice to
+report the bug to me :-)
+
+Note: indenting a large block of lines with the |=| or |v_=| command will take
+ some time to finish.
+
------------------------------------------------------------------------------
2.2 Code folding *vimerl-folding*
@@ -4,7 +4,7 @@
" Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" Eduardo Lopez (http://github.com/tapichu)
" License: Vim license
-" Version: 2012/01/18
+" Version: 2012/01/25
if exists('b:did_ftplugin')
finish
@@ -27,7 +27,9 @@ if !exists('g:erlang_folding')
let g:erlang_folding = 0
endif
-" Local settings
+let s:erlang_fun_begin = '^\a\w*(.*$'
+let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
+
function s:SetErlangOptions()
compiler erlang
if version >= 700
@@ -47,103 +49,35 @@ function s:SetErlangOptions()
let &l:keywordprg = g:erlang_keywordprg
endfunction
-" Define folding functions
-if !exists('*GetErlangFold')
- " Folding params
- let s:erlang_fun_begin = '^\a\w*(.*$'
- let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
- let s:erlang_blank_line = '^\s*\(%.*\)\?$'
-
- " Auxiliary fold functions
- function s:GetNextNonBlank(lnum)
- let lnum = nextnonblank(a:lnum + 1)
- let line = getline(lnum)
- while line =~ s:erlang_blank_line && 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 erlang_tuple = '{\([A-Za-z_,|=\-\[\]]\|\s\)*}'
- let erlang_list = '\[\([A-Za-z_,|=\-{}]\|\s\)*\]'
-
- " FIXME: Use searchpair?
- while arguments =~ erlang_tuple
- let arguments = substitute(arguments, erlang_tuple, 'A', 'g')
- endwhile
- " FIXME: Use searchpair?
- while arguments =~ erlang_list
- let arguments = substitute(arguments, erlang_list, '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:erlang_fun_end
- return '<1'
- endif
-
- if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1
- return '1'
- endif
-
- if line =~ s:erlang_fun_begin
- 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
+function GetErlangFold(lnum)
+ let lnum = a:lnum
+ let line = getline(lnum)
+
+ if line =~ s:erlang_fun_end
+ return '<1'
+ endif
+
+ if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1
+ return '1'
+ endif
+
+ if line =~ s:erlang_fun_begin
+ return '>1'
+ endif
+
+ return '='
+endfunction
+
+function ErlangFoldText()
+ let line = getline(v:foldstart)
+ let foldlen = v:foldend - v:foldstart + 1
+ let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[ \t]*", '', '')
+ if foldlen < 10
+ let lines = ' ' . lines
+ endif
+ let retval = '+' . v:folddashes . lines
+
+ return retval
+endfunction
call s:SetErlangOptions()
Oops, something went wrong.

0 comments on commit fc40ebe

Please sign in to comment.