Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
187 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
deoplete | ||
======== | ||
|
||
Deoplete is the abbreviation of "dark powered neo-completion". It | ||
provides asynchronous keyword completion system in the | ||
current buffer. Deoplete cannot be customized and has not many | ||
features currently. It is provided for testing purpose. | ||
|
||
**Note:** It is still alpha version! It is not for production use. | ||
|
||
## Installation | ||
|
||
**Note:** deoplete requires Neovim(latest is recommended) with Python3 enabled. | ||
See [requirements](#requirements) if you aren't sure whether you have this. | ||
|
||
1. Extract the files and put them in your Neovim directory | ||
(usually `~/.nvim/`). | ||
2. Execute the `:UpdateRemotePlugins` and restart Neovim. | ||
3. Execute the `:DeopleteEnable` command or set `let g:deoplete#enable_at_startup = 1` | ||
in your `.nvimrc` | ||
|
||
## Requirements | ||
|
||
deoplete requires Neovim with if\_python3. | ||
If `:echo has("python3")` returns `1`, then you're done; otherwise, see below. | ||
|
||
You can enable Python3 interface with pip: | ||
|
||
sudo pip3 install neovim | ||
|
||
If you want to read for Neovim-python/python3 interface install documentation, | ||
you should read `:help nvim-python`. | ||
|
||
## Screenshots | ||
|
||
Nothing... | ||
|
||
## Configuration Examples | ||
|
||
```vim | ||
" Use deoplete. | ||
let g:deoplete#enable_at_startup = 1 | ||
``` |
This file contains 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 characters
Empty file.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +0,0 @@ | ||
#============================================================================= | ||
# FILE: deoplete.py | ||
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com> | ||
# License: MIT license {{{ | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# }}} | ||
#============================================================================= | ||
|
||
import neovim | ||
import re | ||
|
||
class Buffer(object): | ||
def __init__(self): | ||
pass | ||
|
||
def get_complete_position(self, vim, context): | ||
m = re.search(context.input, r'[a-zA-Z_][a-zA-Z0-9_]') | ||
if m: | ||
return m.start() | ||
else: | ||
return -1 | ||
|
||
def gather_candidates(self, vim, context): | ||
candidates = [] | ||
p = re.compile('[a-zA-Z_]\w*') | ||
|
||
for l in vim.current.buffer: | ||
candidates += p.findall(l) | ||
return candidates | ||
|
||
class Deoplete(object): | ||
def __init__(self, base_dir): | ||
self.base_dir = base_dir | ||
def gather_candidates(self, vim, context): | ||
buffer = Buffer() | ||
return buffer.gather_candidates(vim, {}) | ||
|
||
@neovim.plugin | ||
class DeopleteHandlers(object): | ||
def __init__(self, vim): | ||
self.vim = vim | ||
|
||
@neovim.command('DeopleteInitializePython', sync=True, nargs=1) | ||
def init_python(self, base_dir): | ||
self.deoplete = Deoplete(base_dir) | ||
self.vim.command('let g:deoplete#_channel_id = ' | ||
+ str(self.vim.channel_id)) | ||
|
||
@neovim.rpc_export('completion_begin') | ||
def completion_begin(self, context): | ||
candidates = self.deoplete.gather_candidates(self.vim, context) | ||
if not candidates: | ||
return | ||
self.vim.command( | ||
'let g:deoplete#_context = {}') | ||
self.vim.command( | ||
'let g:deoplete#_context.complete_position = 0') | ||
self.vim.command( | ||
'let g:deoplete#_context.changedtick = ' | ||
+ str(context[b'changedtick'])) | ||
self.vim.command( | ||
'let g:deoplete#_context.candidates = ' + str(candidates)) | ||
self.vim.command( | ||
'call feedkeys("\<Plug>(deoplete_start_auto_complete)")') | ||
|
||
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#============================================================================= | ||
# FILE: __init__.py | ||
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com> | ||
# License: MIT license {{{ | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# }}} | ||
#============================================================================= | ||
|
||
import neovim | ||
from .deoplete import Deoplete | ||
|
||
@neovim.plugin | ||
class DeopleteHandlers(object): | ||
def __init__(self, vim): | ||
self.vim = vim | ||
|
||
@neovim.command('DeopleteInitializePython', sync=True, nargs=1) | ||
def init_python(self, base_dir): | ||
self.deoplete = Deoplete(base_dir) | ||
self.vim.command('let g:deoplete#_channel_id = ' | ||
+ str(self.vim.channel_id)) | ||
|
||
@neovim.rpc_export('completion_begin') | ||
def completion_begin(self, context): | ||
candidates = self.deoplete.gather_candidates(self.vim, context) | ||
if not candidates: | ||
return | ||
self.vim.command( | ||
'let g:deoplete#_context = {}') | ||
self.vim.command( | ||
'let g:deoplete#_context.complete_position = 0') | ||
self.vim.command( | ||
'let g:deoplete#_context.changedtick = ' | ||
+ str(context[b'changedtick'])) | ||
self.vim.command( | ||
'let g:deoplete#_context.candidates = ' + str(candidates)) | ||
self.vim.command( | ||
'call feedkeys("\<Plug>(deoplete_start_auto_complete)")') | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#============================================================================= | ||
# FILE: deoplete.py | ||
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com> | ||
# License: MIT license {{{ | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# }}} | ||
#============================================================================= | ||
|
||
import neovim | ||
import importlib | ||
from .sources.buffer import Buffer | ||
# from .filters.matcher_head import Filter | ||
from .filters.matcher_fuzzy import Filter | ||
|
||
class Deoplete(object): | ||
def __init__(self, base_dir): | ||
self.base_dir = base_dir | ||
def gather_candidates(self, vim, context): | ||
# Skip completion | ||
if vim.eval('&l:completefunc') != '' \ | ||
and vim.eval('&l:buftype').find('nofile') >= 0: | ||
return [] | ||
|
||
# Encoding conversion | ||
encoding = vim.eval('&encoding') | ||
context = { k.decode(encoding) : | ||
(v.decode(encoding) if isinstance(v, bytes) else v) | ||
for k, v in context.items()} | ||
# debug(vim, context) | ||
|
||
if context['complete_str'] == '': | ||
return [] | ||
|
||
buffer = Buffer() | ||
context['candidates'] = buffer.gather_candidates(vim, context) | ||
|
||
filter = Filter() | ||
context['candidates'] = filter.filter(vim, context) | ||
return context['candidates'] | ||
|
||
def debug(vim, msg): | ||
vim.command('echomsg string(' + str(msg) + ')') |
This file contains 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 characters
This file contains 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 characters
File renamed without changes.