spacevim/bundle/deoplete.nvim/rplugin/python3/deoplete/base/source.py
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

105 lines
3.4 KiB
Python

# ============================================================================
# FILE: source.py
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
# License: MIT license
# ============================================================================
from abc import abstractmethod
from pynvim import Nvim
import re
import typing
from deoplete.logger import LoggingMixin
from deoplete.util import debug, error_vim, UserContext, Candidates
class Base(LoggingMixin):
def __init__(self, vim: Nvim) -> None:
self.vim = vim
self.description = ''
self.mark = ''
self.name = ''
self.max_pattern_length = 80
self.min_pattern_length = -1
self.input_pattern = ''
self.input_patterns: typing.Dict[str, str] = {}
self.matchers = ['matcher_fuzzy']
self.sorters = ['sorter_rank']
self.converters = [
'converter_remove_overlap',
'converter_truncate_abbr',
'converter_truncate_kind',
'converter_truncate_info',
'converter_truncate_menu']
self.filetypes: typing.List[str] = []
self.keyword_patterns: typing.List[str] = []
self.is_debug_enabled = False
self.is_bytepos = False
self.is_initialized = False
self.is_volatile = False
self.is_async = False
self.is_silent = False
self.is_skip_langmap = True
self.rank = 100
self.disabled_syntaxes: typing.List[str] = []
self.events: typing.List[str] = []
self.vars: typing.Dict[str, typing.Any] = {}
self.max_abbr_width = 80
self.max_kind_width = 40
self.max_info_width = 200
self.max_menu_width = 40
self.max_candidates = 500
self.matcher_key = ''
self.dup = False
self.ignore_case = False
self.smart_case = False
self.camel_case = False
def get_complete_position(self, context: UserContext) -> int:
m = re.search('(?:' + context['keyword_pattern'] + ')$|$',
context['input'])
return m.start() if m else -1
def print(self, expr: typing.Any) -> None:
if not self.is_silent:
debug(self.vim, expr)
def print_error(self, expr: typing.Any) -> None:
if not self.is_silent:
error_vim(self.vim, expr)
@abstractmethod
def gather_candidates(self, context: UserContext) -> Candidates:
return []
def on_event(self, context: UserContext) -> None:
pass
def get_var(self, var_name: str) -> typing.Any:
custom_vars = self.vim.call(
'deoplete#custom#_get_source_vars', self.name)
if var_name in custom_vars:
return custom_vars[var_name]
if var_name in self.vars:
return self.vars[var_name]
return ''
def get_filetype_var(self, filetype: str,
var_name: str) -> typing.Optional[typing.Any]:
var = self.get_var(var_name)
if var is None:
return None
ft = filetype if (filetype in var) else '_'
return var.get(ft, '')
def get_input_pattern(self, filetype: str) -> str:
if not self.input_patterns:
return self.input_pattern
ft = filetype if (filetype in self.input_patterns) else '_'
return self.input_patterns.get(ft, self.input_pattern)
def get_buf_option(self, option: str) -> typing.Any:
return self.vim.call('getbufvar', '%', '&' + option)