Ⅰ. 插件描述
A plugin for Vim that completes words from your browserⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'thalesmello/webcomplete-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'thalesmello/webcomplete-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'thalesmello/webcomplete-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/thalesmello/webcomplete.vim
Ⅳ. 文档说明
# webcomplete.vim
A Vim plugin that completes words from the currently open web page in your
browser.
Currently only works on Mac OS and Chrome. There is a fork that works with Firefox.

Installation
With vim-plug:
Plug 'thalesmello/webcomplete.vim'Using with deoplete
deoplete is an awesome asynchronous
completion engine for Neovim. webcomplete works with deoplete out of the box.
Just start typing to see suggestions of words comming from your browser.
g:deoplete#sources#webcomplete#script: Execute this command-line string
to get a list of words instead of default internalsh/webcomplete. You may
add arguments to the string, e.g. cat /tmp/words.txt.
Using with ncm2
ncm2 is also supported. Once ncm2 is configured
in your configuration files, the completions for webcomplete should be enabled by
default.
g:ncm2_webcomplete_script: Same as option for deoplete, but for ncm2.
Using with coc
coc is also supported. Once coc is configured
in your configuration files, the completions for webcomplete should be enabled by
default.
g:coc_webcomplete_script: Same as option for deoplete, but for coc.
Using with completefunc or omnifunc
Vim allows you to define a completefunc or an omnifunc to give you
completions during insert mode. webcomplete provides you with a function that
you can plug into these built in features.
To set it up, use either of the two lines below:
" Use <C-X><C-U> in insert mode to get completions
set completefunc=webcomplete#complete
" Use <C-X><C-O> in insert mode to get completions
set omnifunc=webcomplete#completeUsing with Google Chrome
Currently this plugin only supports Google Chrome on Mac OS.
To use it, you must enable "Allow JavaScript from Apple Events" in View >
Developer submenu.
Using with Firefox
Currently there is no official support for Firefox, but there is a
fork with Firefox support
Limitations
- Currently works on Mac OS because of the
osascriptcommand line utility,
which is used to fetch text from the page - Assumes you have only one browser window opened. If there is more than one
window open, it picks the most recently used. - Currently works only on Chrome, but it's possible to use with other browsers.
Contributing
If you would like to contribute to the project by supporting your browser or
operating system, I would be happy to accept pull requests.
Inspiration
The project was only possible with the help of Reddit user 18252
and by looking at tmux-complete.vim as reference when implementing this plugin.