Permalink
Browse files

Merge remote branch 'ktt/master' into ktt-merge

  • Loading branch information...
2 parents 78824d2 + ac9b2cf commit f434cf76d623713d075363a974ee204373532755 @jimenezrick jimenezrick committed Sep 2, 2010
Showing with 424 additions and 17 deletions.
  1. +34 −1 README
  2. +0 −8 TODO
  3. +1 −1 autoload/erlangcomplete.vim
  4. +8 −0 compiler/check_file.erl
  5. +82 −0 compiler/erlang.vim
  6. +1 −0 ftplugin/erlang.vim
  7. +295 −0 ftplugin/erlang/refactor.vim
  8. +3 −7 indent/erlang.vim
View
35 README
@@ -21,7 +21,7 @@ are implemented:
== Omni completion ==
-Write the name of a module (e.g. `my_mod:') presh CTRL-X CTRL-O to activate
+Write the name of a module (e.g. `my_mod:') press CTRL-X CTRL-O to activate
the omni completion. The omni completion try to use the man pages to give
the definition for the standard functions. The omni completion try to compile
local modules, if it is possible, in order to call their Mod:module_info/0.
@@ -30,6 +30,25 @@ The program `escript' is required, the standard Erlang installation
comes with it.
+== Refactoring ==
+
+Extract to new function:
+ Select the part of code you want to extract (or point something that
+ can be extracted) and press <Alt-r>e. You will be prompted to put the name
+ of new function. After that you can Preview, Confirm or Cancel this
+ refactoring. (Note: Preview is not currently supported).
+
+Rename variable/function/module:
+ Point on variable/function that name should be changed and press:
+ <Alt-r>f for function
+ <Alt-r>v for variable
+ rename. To rename module, press <Alt-r>m anywere in the buffer.
+
+Tuple function arguments:
+ Select or point on function arguments that should be changed into one tuple and press
+ <Alt-r>t.
+
+
== Settings ==
You can set various variables in your vimrc file to make the plugin behave
@@ -76,3 +95,17 @@ The options expect a string as below is explained.
/ERLANG/PATH/man/man3/lists.3
** In this case, use the default options value **
+
+Compiler options:
+The options is explained.
+
+* Set the location of the Erlang check_file script: (default: "~/.vim/compiler/check_file.erl")
+ g:erlangCheckFile
+* Enable/disable highlighting erlang errors: (default 1)
+ g:erlangHighlightErrors
+
+Refactoring options:
+The options is explained.
+
+* Set the location of the Wrangler: (default: /usr/share/wrangler/)
+ g:WranglerHome
View
8 TODO
@@ -3,11 +3,3 @@
+ I don't actually know what's not working or what's working but a note says it needs to be fixed
+ Folding one-line functions fails, i.e.:
fun(Args) -> body.
-* Fix indent a pattern followed by a guard with `;' because it fails, i.e.:
- receive
- foo when foo == foo; foo != bur ->
- ...
- ...
-* Fix omni completion, fails when omni completion is used twice on the same line with two different modules.
- autoload/erlangcomplete.vim needs fixing because fails to get the target token to be used as the module to
- be completed.
@@ -67,7 +67,7 @@ function! erlangcomplete#Complete(findstart, base)
if a:findstart
return delimiter
else
- let module = matchstr(line, '\(\<\)\@<=[0-9A-Za-z_-]\+:\@=')
+ let module = matchstr(line[:-2], '\<\k*\>$')
return s:erlangFindExternalFunc(module, a:base)
endif
endif
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env escript
+-export([main/1]).
+
+main([File_Name]) ->
+ compile:file(File_Name, [warn_obsolete_guard,
+ warn_unused_import,
+ warn_shadow_vars, warn_export_vars,
+ strong_validation, report]).
View
@@ -0,0 +1,82 @@
+" 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/check_file.erl"
+endif
+
+if !exists('g:erlangHighlightErrors')
+ let g:erlangHighlightErrors = 1
+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 HighlightErlangErrors()
+ autocmd BufWritePost *.erl call HighlightErlangErrors()
+
+ autocmd CursorHold *.erl call s:show_msg()
+ autocmd CursorMoved *.erl call s:show_msg()
+endif
View
@@ -36,6 +36,7 @@ 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
Oops, something went wrong.

0 comments on commit f434cf7

Please sign in to comment.