GCalc.vimに超絶簡易補完機能を追加した
もとのGCalc.vimはこちら→VimでGoogleの電卓機能を使うプラグインGCalc.vim書いた - ほとんど欄外
scriptencoding utf-8 function! GCalc(...) let word = a:1 let res = webapi#http#get('http://www.google.co.jp/complete/search?output=toolbar&q='.webapi#http#escape(word)).content if match(res, 'calculator_suggestion') == -1 echohl ErrorMsg | echo '答えが出せませんでした' | echohl None return endif let dom = webapi#xml#parse(res) echo dom.find('calculator_suggestion').attr['data'] endfunction function! GCalcComp(ArgLead, CmdLine, CursorPos) return " \binary\n \octal\n \decimal\n \hexdecimal\n \" endfunction command! -nargs=+ -complete=custom,GCalcComp GCalc call GCalc(<q-args>)
具体的にはGCalcComp関数を追加して、コマンドの定義行に少し書き足した。GoogleCalc関数には変更はない。補完出来るのはbinary、octal、decimal、hexdecimalの4語のみ。feetとかmileとかpoundとか他にも追加しようと思ったけれど複数形の事考えると面倒になってやめた。必要と有らば適当にいじってやってください。補完をもっと拡張したいなら:help :command-completion-customあたりを見ればいいんじゃないかな。
追記2011-04-10:
思うところあって名称変更。GoogleCalcからGCalcへ