└── autoload └── googlesuggest.vim /autoload/googlesuggest.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: googlesuggest-complete.vim 3 | " Author: Yasuhiro Matsumoto 4 | " Last Change: 03-Apr-2012. 5 | " Version: 0.2 6 | " WebPage: http://github.com/mattn/googlesuggest-complete-vim 7 | " Usage: 8 | " 9 | " Require: 10 | " 11 | " set completefunc=googlesuggest#Complete 12 | " 13 | " Lesson1: 14 | " 15 | " takasu 16 | " +----------------+ 17 | " takasu|高杉晋作========| 18 | " |高須クリニック | 19 | " |高須 | 20 | " |高鈴 | 21 | " |高鷲スノーパーク| 22 | " |高杉さと美 | 23 | " |高杉良 | 24 | " |高須光聖 | 25 | " |高須克弥 | 26 | " |高須 ブログ | 27 | " +----------------+ 28 | " * perhaps, you can see the candidates above. 29 | " 30 | " Lesson2: 31 | " 32 | " watasinonamaeha 33 | " 34 | " => 私の名前はキムサムスン 35 | " * who is kim samsoon? 36 | " 37 | " Etc: 38 | " 39 | " naitu 40 | " => ナイツ お笑い 41 | " 42 | " www 43 | " => www.yahoo.co.jp 44 | " 45 | " gm 46 | " => gmailへようこそ 47 | " 48 | " vimp 49 | " => vimperator 50 | " 51 | " puri 52 | " => プリキュア 53 | " 54 | 55 | if !exists('g:googlesuggest_language') 56 | let g:googlesuggest_language = 'ja' 57 | endif 58 | 59 | function! googlesuggest#Complete(findstart, base) 60 | if a:findstart 61 | " locate the start of the word 62 | let line = getline('.') 63 | let start = col('.') - 1 64 | while start > 0 && line[start - 1] =~ '\a' 65 | let start -= 1 66 | endwhile 67 | return start 68 | else 69 | " find months matching with "a:base" 70 | let ret = [] 71 | let res = webapi#http#get('https://suggestqueries.google.com/complete/search', {"client" : "youtube", "q" : a:base, "hjson" : "t", "hl" : g:googlesuggest_language, "ie" : "UTF8", "oe" : "UTF8" }) 72 | let arr = webapi#json#decode(res.content) 73 | for m in arr[1] 74 | call add(ret, m[0]) 75 | endfor 76 | return ret 77 | endif 78 | endfunction 79 | 80 | --------------------------------------------------------------------------------