Skip to content

Commit

Permalink
Build OTP tags and add to vim tags path
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Oct 26, 2019
1 parent 4b332f4 commit 8da16d2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ Or within Vim by executing the following command:
Note that for the latter command, the current working directory will be used
(`:help pwd` to find out more).

### Generate OTP tags

Often, you might be curious about the implementation of that function from the
OTP libraries, but `CTRL-t` is not taking you there. We have a solution for
this:

call AsyncBuildOtpTags()

This command will find the path to your otp installation, and inside its `lib/`
folder, it will build a tags file called `otptags`. The next thing you need, is
to make vim aware of this. That's where the next function comes in place:

call GetOtpTagsPath()

This will return the path to the generated `otptags` file, wherever this file
lives. Extract it, and add it to your tags by doing

let &tags.="," . otptags_path

Where otptags\_path is the expanded path returned previously.

### Options

#### `g:erlang_tags_ignore`
Expand Down
14 changes: 13 additions & 1 deletion plugin/vim-erlang-tags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif
autocmd FileType erlang call VimErlangTagsDefineMappings()

let s:exec_script = expand('<sfile>:p:h') . "/../bin/vim_erlang_tags.erl"
let s:otppath_cmd = 'erl -noinput -eval ''io:format("~ts", [code:lib_dir()]), init:stop().'''

function! s:GetExecuteCmd()
let script_opts = ""
Expand All @@ -42,6 +43,17 @@ function! s:GetExecuteCmd()
return s:exec_script . script_opts
endfunction

function! GetOtpTagsPath()
let otppath = system(s:otppath_cmd)
let otptags = otppath . "/otptags"
return otptags
endfunction

function! AsyncBuildOtpTags()
let cmd = '(OTPPATH=`' . s:otppath_cmd . '` && ' . s:exec_script . ' -i $OTPPATH -o $OTPPATH/otptags)'
call system(cmd . " &")
endfunction

function! VimErlangTags(...)
let param = join(a:000, " ")
let exec_cmd = s:GetExecuteCmd()
Expand Down Expand Up @@ -104,7 +116,7 @@ if !exists("s:os")
endif

" https://vim.fandom.com/wiki/Autocmd_to_update_ctags_file
function! DelTagOfFile(file)
function! s:DelTagOfFile(file)
let fullpath = a:file
let cwd = getcwd()
let tagfilename = cwd . "/tags"
Expand Down

0 comments on commit 8da16d2

Please sign in to comment.