Skip to content

Commit f1605e2

Browse files
committed
Build OTP tags and add to vim tags path
1 parent 31b3f29 commit f1605e2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ Or within Vim by executing the following command:
6262
Note that for the latter command, the current working directory will be used
6363
(`:help pwd` to find out more).
6464

65+
### Generate OTP tags
66+
67+
Often, you might be curious about the implementation of that function from the
68+
OTP libraries, but `CTRL-t` is not taking you there. We have a solution for
69+
this:
70+
71+
call AsyncBuildOtpTags()
72+
73+
This command will find the path to your otp installation, and inside its `lib/`
74+
folder, it will build a tags file called `otptags`. The next thing you need, is
75+
to make vim aware of this. That's where the next function comes in place:
76+
77+
call GetOtpTagsPath()
78+
79+
This will return the path to the generated `otptags` file, wherever this file
80+
lives. Extract it, and add it to your tags by doing
81+
82+
let &tags.="," . otptags_path
83+
84+
Where otptags\_path is the expanded path returned previously.
85+
6586
### Options
6687

6788
#### `g:erlang_tags_ignore`

plugin/vim-erlang-tags.vim

+13-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endif
2222
autocmd FileType erlang call VimErlangTagsDefineMappings()
2323

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

2627
function! s:GetExecuteCmd()
2728
let script_opts = ""
@@ -42,6 +43,17 @@ function! s:GetExecuteCmd()
4243
return s:exec_script . script_opts
4344
endfunction
4445

46+
function! GetOtpTagsPath()
47+
let otppath = system(s:otppath_cmd)
48+
let otptags = otppath . "/otptags"
49+
return otptags
50+
endfunction
51+
52+
function! AsyncBuildOtpTags()
53+
let cmd = '(OTPPATH=`' . s:otppath_cmd . '` && ' . s:exec_script . ' -i $OTPPATH -o $OTPPATH/otptags)'
54+
call system(cmd . " &")
55+
endfunction
56+
4557
function! VimErlangTags(...)
4658
let param = join(a:000, " ")
4759
let exec_cmd = s:GetExecuteCmd()
@@ -104,7 +116,7 @@ if !exists("s:os")
104116
endif
105117

106118
" https://vim.fandom.com/wiki/Autocmd_to_update_ctags_file
107-
function! DelTagOfFile(file)
119+
function! s:DelTagOfFile(file)
108120
let fullpath = a:file
109121
let cwd = getcwd()
110122
let tagfilename = cwd . "/tags"

0 commit comments

Comments
 (0)