Skip to content

Commit

Permalink
README updated, fixed omni completion for local modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jimenezrick authored and Ricardo committed Aug 10, 2010
1 parent d6ded34 commit 71e1aab
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
38 changes: 24 additions & 14 deletions README
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
=== Vim Erlang plugin ===

The indentation plugin is provided by Csaba Hoch and disttributed with his
permission.
Vim plugin for the programming language Erlang. The next features
are implemented:
- Syntax highlight
- Code folding
- Code completion (based on Mod:module_info/0 to use the
Erlang introspection mechanism)
- Auto-indent
- QuickFix

Installation:
The tarball root is vim_erlang-REL/. To remove this part of the package
(e.g., to extract the contents to you .vim dir) use tar --strip-components 1
-xjf vim_erlang-X.X.tar.bz2

== Installation ==

* Unix
- For local installation (one user only) extract the tarball to your
~/.vim directory
- For global installation extract the tarball to your vim runtime
directory (e.g. /usr/share/vim/vimX/)

* Win
- For local installation (one user only) extract the tarball to your
directory
- For local installation (one user only) copy the content of the
tarball to your ~/.vim directory
- For global installation copy the content of the tarball to
your vim runtime directory (e.g. /usr/share/vim/vimX/)


== Omni completion ==

Write the name of a module (e.g. `my_mod:') presh 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 program `escript' is required, the standard Erlang installation
comes with it.


== Settings ==
Expand Down
15 changes: 11 additions & 4 deletions autoload/erlangcomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
" Vim omni-completion script
" Author: Oscar Hellström
" Email: [email protected]
" Version: 2006-06-23
" Version: 2010-08-10
" Contributors: kTT (http://github.com/kTT)
" Ricardo Catalinas Jiménez <[email protected]>
" ------------------------------------------------------------------------------

" Patterns for completions {{{1
Expand All @@ -24,7 +26,7 @@ if !exists('g:erlangManPath')
endif

if !exists('g:erlangCompletionDisplayDoc')
let g:erlangCompletionDisplayDoc = 1
let g:erlangCompletionDisplayDoc = 1
endif

" Main function for completion {{{1
Expand Down Expand Up @@ -110,13 +112,18 @@ function s:erlangFindExternalFunc(module, base)
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

" TODO: try to compile local files first

" [:-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 = ''
if g:erlangCompletionDisplayDoc != 0
let system_command = g:erlangCompletionGrep . ' -A 1 "\.B" ' . file_path . ' | grep -EZo "\<' . function_name . '\>\((\w+, ){' . number_of_comma . '}[^),]*\) -> .*"'
" 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
Expand Down

0 comments on commit 71e1aab

Please sign in to comment.