summaryrefslogtreecommitdiffstats
path: root/autoload/db/adapter/ecto.vim
blob: 54ee3396ab2f470cf5600024fd28ad57a8e4f0cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'elixir') != -1
  finish
endif

let s:path = expand('<sfile>:h')
let s:cmd = join(['mix', 'run', '--no-start', '--no-compile', shellescape(s:path.'/get_repos.exs')])

function! s:repo_list() abort
    return map(systemlist(s:cmd), 'split(v:val)')
endfunction

function! db#adapter#ecto#canonicalize(url) abort
    for l:item in s:repo_list()
        let l:name = get(l:item, 0)
        let l:url = get(l:item, 1)
        if !empty(l:name) && 'ecto:'.l:name ==# a:url
            return l:url
        endif
    endfor
endfunction

function! db#adapter#ecto#complete_opaque(url) abort
    return map(s:repo_list(), 'v:val[0]')
endfunction