Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Plugin completion using VimAwesome API
" ----------------------------------------------------------------------------
" vimawesome.com
" ----------------------------------------------------------------------------
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|
Thread.new do
url = "http://vimawesome.com/api/plugins?page=#{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($/)}
end.compact
end
end.each(&:join).map(&:value).inject(:+)
VIM::command("let cands = #{JSON.dump items}")
EOF
if !empty(cands)
inoremap <buffer> <c-v> <c-n>
augroup _VimAwesomeComplete
autocmd!
autocmd CursorMovedI,InsertLeave * iunmap <buffer> <c-v>
\| autocmd! _VimAwesomeComplete
augroup END
call complete(col('.') - strchars(prefix), cands)
endif
return ''
endfunction
augroup VimAwesomeComplete
autocmd!
autocmd FileType vim inoremap <c-x><c-v> <c-r>=VimAwesomeComplete()<cr>
augroup END
@junegunn

This comment has been minimized.

Show comment Hide comment
@junegunn

junegunn May 15, 2015

Owner

junegunn commented May 15, 2015

@nightire

This comment has been minimized.

Show comment Hide comment
@nightire

nightire May 16, 2015

Love you man~

Love you man~

@starcraftman

This comment has been minimized.

Show comment Hide comment
@starcraftman

starcraftman May 16, 2015

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.

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

This comment has been minimized.

Show comment Hide comment
@junegunn

junegunn 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.

Owner

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.

@starcraftman

This comment has been minimized.

Show comment Hide comment
@starcraftman

starcraftman May 16, 2015

@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 vim.org wasn't great to search against?

@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 vim.org wasn't great to search against?

@junegunn

This comment has been minimized.

Show comment Hide comment
@junegunn

junegunn May 16, 2015

@starcraftman In my opinion, vim.org 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.

Owner

junegunn commented May 16, 2015

@starcraftman In my opinion, vim.org 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

This comment has been minimized.

Show comment Hide comment
@junegunn

junegunn 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.

Owner

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.

@starcraftman

This comment has been minimized.

Show comment Hide comment
@starcraftman

starcraftman May 16, 2015

@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. :/

@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

This comment has been minimized.

Show comment Hide comment
@mhinz

mhinz May 16, 2015

@junegunn Neat! :-)

@starcraftman If it's still working for you, by all means, keep it. Otherwise I enjoy using https://github.com/mbbill/undotree

mhinz commented May 16, 2015

@junegunn Neat! :-)

@starcraftman If it's still working for you, by all means, keep it. Otherwise I enjoy using https://github.com/mbbill/undotree

@jonafato

This comment has been minimized.

Show comment Hide comment
@jonafato

jonafato May 18, 2015

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.

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

This comment has been minimized.

Show comment Hide comment
@craigp

craigp May 18, 2015

This is epic

craigp commented May 18, 2015

This is epic

@unbalancedparentheses

This comment has been minimized.

Show comment Hide comment
@unbalancedparentheses

unbalancedparentheses Sep 9, 2015

Great

@mirzalazuardi

This comment has been minimized.

Show comment Hide comment
@mirzalazuardi

mirzalazuardi Oct 2, 2015

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

u're awesome dude!!

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

u're awesome dude!!

@junegunn

This comment has been minimized.

Show comment Hide comment
@junegunn

junegunn Oct 28, 2015

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

Owner

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