Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Plugin completion using VimAwesome API
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
function! VimAwesomeComplete() abort
let prefix = matchstr(strpart(getline('.'), 0, col('.') - 1), '[.a-zA-Z0-9_/-]*$')
echohl WarningMsg
echo 'Downloading plugin list from VimAwesome'
echohl None
ruby << EOF
require 'json'
require 'open-uri'
query = VIM::evaluate('prefix').gsub('/', '%20')
items = 1.upto(max_pages = 3).map do |page| do
url = "{page}&query=#{query}"
data = open(url).read
json = JSON.parse(data, symbolize_names: true)
json[:plugins].map do |info|
pair = info.values_at :github_owner, :github_repo_name
next if pair.any? { |e| e.nil? || e.empty? }
{word: pair.join('/'),
menu: info[:category].to_s,
info: info.values_at(:short_desc, :author).compact.join($/)}
VIM::command("let cands = #{JSON.dump items}")
if !empty(cands)
inoremap <buffer> <c-v> <c-n>
augroup _VimAwesomeComplete
autocmd CursorMovedI,InsertLeave * iunmap <buffer> <c-v>
\| autocmd! _VimAwesomeComplete
augroup END
call complete(col('.') - strchars(prefix), cands)
return ''
augroup VimAwesomeComplete
autocmd FileType vim inoremap <c-x><c-v> <c-r>=VimAwesomeComplete()<cr>
augroup END

junegunn commented May 15, 2015

Love you man~

Very cool. You at all interested in putting that into plug.vim to toggle on? Though it might be a bit more useful as a perhaps a search command in left pane? If not, we can at least put this in the wiki faq I guess.


junegunn commented May 16, 2015

@starcraftman Well, I'd like to avoid making vim-plug dependent on external services, and the result of VimAwesome API doesn't seem flawless; missing plugins, duplicate results, etc. Moreover, I'm not convinced if the site is being actively maintained: divad12/vim-awesome#61

Yeah, we should put this on the wiki page (a link on "Home" page or maybe a separate page?) since this compensates for the missing :PluginSearch from Vundle.

@junegunn Ah damn, seems their main dev(s) got busy. Should probably give em a hand, do love that site. The duping problem is a real bummer.

Separately, have you ruled out ever adding PlugSearch or just didn't because wasn't great to search against?


junegunn commented May 16, 2015

@starcraftman In my opinion, no longer functions as the central repository. I don't even publish my plugins there anymore. Regarding the command, I know that some people want PluginSearch equivalent in vim-plug, but I personally don't see the point of it. Don't we all have web browsers? :) Also I don't think it has to be a part of vim-plug, it can be a separate plugin.


junegunn commented May 16, 2015

Yeah, I think it should be a plugin of its own, doesn't have to be limited to a specific plugin manager.

@junegunn I guess your right. Separate plugin makes most sense, searching isn't really part of plugin management.

Do hope VimAwesome isn't abandoned. Only just realized Gundo hadn't gotten a patch in a year. Sad when good software falls by wayside. :/

mhinz commented May 16, 2015

@junegunn Neat! :-)

@starcraftman If it's still working for you, by all means, keep it. Otherwise I enjoy using

VimAwesome isn't dead, though the main developer (@divad12) does seem to be busy. There was a bit of activity a couple of months ago, and he was quick to respond to pull requests. I can't speak for the project or its maintainers, but I'd guess that pull requests would be well received based on my limited experience with it.

craigp commented May 18, 2015

This is epic

where should i put the file (vimawesome.vim) in case to combine with my vundle ?
is there a for installing this ?

u're awesome dude!!


junegunn commented Oct 28, 2015

@mirzalazuardi Place the file in ~/.vim/plugin directory or simply paste the code onto your .vimrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment