-
-
Save lf-wxp/4c849fc4351b7aa7aeb764a5170bd2a8 to your computer and use it in GitHub Desktop.
Revisions
-
junegunn renamed this gist
May 22, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
junegunn revised this gist
May 16, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ " 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 -
junegunn revised this gist
May 16, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,9 +13,9 @@ ruby << EOF 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? } -
junegunn created this gist
May 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ " ---------------------------------------------------------------------------- " 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