├── .gitignore ├── README.md ├── autoload ├── neocomplcache │ └── sources │ │ └── look.vim └── neocomplete │ └── sources │ └── look.vim ├── doc └── neco-look.txt ├── neco-look.vimup └── rplugin └── python3 └── deoplete └── sources └── look.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | doc/tags 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # neco-look: look completion for deoplete/neocomplete/neocomplcache 2 | 3 | A deoplete/neocomplete/neocomplcache plugin for `/usr/bin/look` for completing words in English. 4 | 5 | ## install 6 | 7 | * Install one of the following comprehensive Vim auto-completion plugins 8 | * deoplete.nvim (recommended) 9 | * neocomplete.vim (its development has been discontinued) 10 | * neocomplcache.vim (its development has been discontinued) 11 | * Make sure if you already have `look` command 12 | * Mac: this should be preinstalled 13 | * ArchLinux: https://www.archlinux.org/packages/core/x86_64/util-linux/ 14 | * Windows: https://github.com/ujihisa/neco-look/wiki 15 | * Use your favourite Vim plugin manager to install neco-look itself as well 16 | * e.g. [dein.vim](https://github.com/Shougo/dein.vim) 17 | * `call dein#add('ujihisa/neco-look')` in your ~/.vimrc 18 | 19 | ## Authors 20 | 21 | * Tatsuhiro Ujihisa 22 | * Shougo Matsushita 23 | 24 | ## License 25 | 26 | GPL-3 or later 27 | -------------------------------------------------------------------------------- /autoload/neocomplcache/sources/look.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | let s:source = { 5 | \ 'name': 'look', 6 | \ 'kind': 'plugin', 7 | \ 'mark': '[look]', 8 | \ 'max_candidates': 15, 9 | \ 'min_pattern_length' : 4, 10 | \ 'is_volatile' : 1, 11 | \ } 12 | 13 | function! s:source.get_keyword_list(cur_keyword_str) 14 | if !(&spell || neocomplcache#is_text_mode() 15 | \ || neocomplcache#within_comment()) 16 | \ || a:cur_keyword_str !~ '^[[:alpha:]]\+$' 17 | return [] 18 | endif 19 | 20 | let list = split(neocomplcache#util#system( 21 | \ 'look ' . a:cur_keyword_str), "\n") 22 | if neocomplcache#util#get_last_status() 23 | return [] 24 | endif 25 | 26 | return map(list, "substitute(v:val, 27 | \ '^' . tolower(a:cur_keyword_str), a:cur_keyword_str, '')") 28 | endfunction 29 | 30 | function! neocomplcache#sources#look#define() 31 | return executable('look') ? s:source : {} 32 | endfunction 33 | 34 | let &cpo = s:save_cpo 35 | unlet s:save_cpo 36 | -------------------------------------------------------------------------------- /autoload/neocomplete/sources/look.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | let s:source = { 5 | \ 'name': 'look', 6 | \ 'kind': 'plugin', 7 | \ 'mark': '[look]', 8 | \ 'max_candidates': 15, 9 | \ 'min_pattern_length' : 4, 10 | \ 'is_volatile' : 1, 11 | \ } 12 | 13 | function! s:source.gather_candidates(context) 14 | if neocomplete#is_auto_complete() && 15 | \ !(&spell || neocomplete#is_text_mode() 16 | \ || neocomplete#within_comment()) 17 | \ || a:context.complete_str !~ '^[[:alpha:]]\+$' 18 | return [] 19 | endif 20 | 21 | let list = split(neocomplete#util#system( 22 | \ 'look ' . a:context.complete_str), "\n") 23 | if neocomplete#util#get_last_status() 24 | return [] 25 | endif 26 | 27 | return map(list, "substitute(v:val, 28 | \ '^' . tolower(a:context.complete_str), 29 | \ a:context.complete_str, '')") 30 | endfunction 31 | 32 | function! neocomplete#sources#look#define() 33 | return executable('look') ? s:source : {} 34 | endfunction 35 | 36 | let &cpo = s:save_cpo 37 | unlet s:save_cpo 38 | -------------------------------------------------------------------------------- /doc/neco-look.txt: -------------------------------------------------------------------------------- 1 | *neco-look.txt* A neocomplcache.vim/neocomplete.vim plugin to complete English 2 | words. 3 | 4 | Author: ujihisa 5 | Licence: GPL-3 or later 6 | 7 | ============================================================================== 8 | INTRODUCTION *neco-look-introduction* 9 | 10 | Requirements: 11 | - One of 12 | - neocomplcache.vim; 13 | - neocomplete.vim; or 14 | - deoplete.nvim 15 | - `look` command 16 | - Arch Linux: `sudo pacman -S words` 17 | 18 | Latest version: 19 | https://github.com/ujihisa/neco-look 20 | 21 | ============================================================================== 22 | VARIABLES neco-look-variables 23 | 24 | g:deoplete#look#words 25 | g:deoplete#look#words 26 | Change the words source for the look command. This should be a 27 | file with a word on each line in sorted order. Currently only 28 | supported for the deoplete source. 29 | 30 | ============================================================================== 31 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 32 | -------------------------------------------------------------------------------- /neco-look.vimup: -------------------------------------------------------------------------------- 1 | "script_name": neco-look 2 | "script_id": "3440" 3 | "script_type": utility 4 | "script_package": "{script_name}-{version}.zip" 5 | "required_vim_version": '7.3' 6 | "summary": A neocomplcache plugin for `/usr/bin/look` for completing words in English. 7 | "detailed_description": | 8 | A neocomplcache plugin for `/usr/bin/look` for completing English. 9 | 10 | http://gyazo.com/c21c8201fa7a571c7665bc7455d88631.png 11 | "install_details": | 12 | * install the latest neocomplcache.vim 13 | * make sure if you already have `look` command 14 | * Unarchive neco-look and put it into a dir of your &rtp. 15 | "versions": 16 | - '1.3': Works also with neocomplete.vim besides neocomplcache. (patches from Shougo) 17 | - '1.2': Works also in comment area of of arbitrary programming languages. (patches from ypresto) 18 | - '1.1': Bugfix. It doesn't crash when you input a multibyte word 19 | - '1.0': Initial release in vim.org 20 | # vim: filetype=yaml 21 | -------------------------------------------------------------------------------- /rplugin/python3/deoplete/sources/look.py: -------------------------------------------------------------------------------- 1 | #============================================================================= 2 | # FILE: look.py 3 | # AUTHOR: Shougo Matsushita 4 | #============================================================================= 5 | 6 | from os.path import expanduser, expandvars 7 | import re 8 | import subprocess 9 | from .base import Base 10 | 11 | class Source(Base): 12 | def __init__(self, vim): 13 | Base.__init__(self, vim) 14 | 15 | self.name = 'look' 16 | self.mark = '[look]' 17 | self.min_pattern_length = 4 18 | 19 | def get_look_var(shortname, default): 20 | name = 'deoplete#look#{}'.format(shortname) 21 | if name not in vim.vars: 22 | return default 23 | return vim.vars[name] 24 | 25 | self.is_volatile = True 26 | 27 | self.executable_look = self.vim.call('executable', 'look') 28 | self.words = get_look_var('words', None) 29 | if self.words: 30 | self.words = expandvars(expanduser(self.words)) 31 | 32 | def _query_look(self, querystring): 33 | command = ['look', '--', querystring] 34 | 35 | if self.words is not None: 36 | command.append(self.words) 37 | 38 | return subprocess.check_output(command).splitlines() 39 | 40 | def gather_candidates(self, context): 41 | if not self.executable_look: 42 | return [] 43 | 44 | try: 45 | # We're adding :2 here to support head prefixed fuzzy search 46 | # "look" will return some results and deoplete will fuzzy search in 47 | # the rest. 48 | words = [ 49 | x.decode(context['encoding'], errors='ignore') 50 | for x in self._query_look(context['complete_str'][:2]) 51 | ] 52 | except subprocess.CalledProcessError: 53 | return [] 54 | if re.match('[A-Z][a-z0-9_-]*$', context['complete_str']): 55 | words = [x[0].upper() + x[1:] for x in words] 56 | elif re.match('[A-Z][A-Z0-9_-]*$', context['complete_str']): 57 | words = [x.upper() for x in words] 58 | 59 | return [{ 'word': x } for x in words] 60 | --------------------------------------------------------------------------------