# -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base register_source( name='cm-jedi', priority=9, abbreviation='Py', scoping=True, scopes=['python'], # The last two patterns is for displaying function signatures [r'\(\s?(\w*)$',r',(\s?\w*)$'] cm_refresh_patterns=[ r'^(import|from).*?\s(\w*)$', r'\.\w*$', r'\(\s?(\w*)$', r',\s?(\w*)$' ], ) import re import jedi logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) self._snippet_engine = nvim.vars['cm_completed_snippet_engine'] def cm_refresh(self, info, ctx, *args):
# -*- coding: utf-8 -*- # For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source(name='cm-gocode', priority=9, abbreviation='Go', word_pattern=r'[\w/]+', scoping=True, scopes=['go'], cm_refresh_patterns=[r'\.(\w*)$'],) import re import subprocess import json logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super(Source,self).__init__(nvim)
# -*- coding: utf-8 -*- # For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source(name='cm-gocode', priority=9, abbreviation='Go', word_pattern=r'[\w/]+', early_cache=1, scoping=True, scopes=['go'], cm_refresh_patterns=[r'\.'],) import re import subprocess import json logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super(Source,self).__init__(nvim)
#!/usr/bin/env python # -*- coding: utf-8 -*- from cm import register_source, get_src register_source(name='cm-php-language-server', abbreviation='PHP', priority=9, scopes=['php'], detach=1) # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim import os import json import base64 import subprocess import sys import logging import threading import os import re import logging import tempfile from neovim.api import Nvim logger = logging.getLogger(__name__) directory = os.path.abspath(os.path.dirname(__file__))
# -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # clang python bindings only supports python2 # https://github.com/llvm-mirror/clang/commit/abdad67b94ad4dad2d655d48ff5f81d6ccf3852e from __future__ import absolute_import from cm import register_source, getLogger, Base register_source( name='clang_complete', priority=9, abbreviation='c', scoping=True, scopes=['c', 'cpp'], events=['BufEnter'], cm_refresh_patterns=[r'(-\>|\.|::)'], ) import sys import os import libclang logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim)
# -*- coding: utf-8 -*- import re import json import urllib import urllib.request import urllib.parse from cm import register_source, Base, getLogger register_source(name='Omnisharp CS', abbreviation='CS', scopes=['cs'], word_pattern=r'\w+', early_cache=1, cm_refresh_patterns=[r'\.'], priority=8) logger = getLogger(__name__) class Source(Base): def __init__(self, vim): super(Source, self).__init__(vim) self.go = False self.vim = vim # Can we get completions ( i.e. is the server alive ) def am_i_allowed(self): if self.go: return True try: if self.vim.eval("g:deoplete_omnisharp_finished_loading"):
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base register_source(name='cm-bufkeyword', priority=5, abbreviation='Key', events=['InsertEnter', 'BufEnter'],) import re import cm_default logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super(Source,self).__init__(nvim) self._words = set() self._last_ctx = None self.refresh_keyword(nvim.eval('cm#context()')) def cm_event(self,event,ctx,*args): if self._last_ctx and (self._last_ctx['changedtick'] == ctx['changedtick']): return self._last_ctx = ctx self.refresh_keyword(ctx)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Stefan Haller <*****@*****.**> from cm import register_source register_source(name='cm-otherbuf', priority=4, abbreviation='Bufs', events=['BufAdd', 'BufDelete', 'BufLeave'],) from cm import getLogger, Base import re import cm_default logger = getLogger(__name__) class Source(Base): class BufferData: __sltos__ = ('changed', 'changedtick', 'deleted', 'words') def __init__(self): self.changed = False self.changedtick = None self.deleted = False self.words = set() def __init__(self, nvim): super(Source,self).__init__(nvim) self._compiled = re.compile(r'\w+') self._buffers = {}
# -*- coding: utf-8 -*- from cm import register_source, getLogger, Base register_source(name='rct-complete', priority=9, abbreviation='rb', scoping=True, scopes=['ruby'], sort=0, cm_refresh_patterns=[r'\.', r'::'],) import subprocess logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super(Source,self).__init__(nvim) try: from distutils.spawn import find_executable # echoe does not work here if not find_executable("rct-complete"): self.message('error', "Can't find [rct-complete] binary. Please install rcodetools https://rubygems.org/gems/rcodetools") except: pass def cm_refresh(self,info,ctx,*args):
# -*- coding: utf-8 -*- from cm import register_source, getLogger, Base register_source( name='rct-complete', priority=9, abbreviation='rb', scoping=True, scopes=['ruby'], sort=0, cm_refresh_patterns=[r'\.', r'::'], ) import subprocess logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) try: from distutils.spawn import find_executable # echoe does not work here if not find_executable("rct-complete"): self.message( 'error', "Can't find [rct-complete] binary. Please install rcodetools https://rubygems.org/gems/rcodetools" )
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base import os register_source(name='cm-tmux', abbreviation='Tmux', priority=4, enable= 'TMUX' in os.environ, events=['CursorHold','CursorHoldI','FocusGained','BufEnter'],) import os import re import logging import subprocess logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super().__init__(nvim) self._words = set() self._split_pattern = r'[^\w]+' self._kw_pattern = r'\w'
from cm import register_source, Base, getLogger register_source(name='github-repo', abbreviation='repo', scopes=['gitcommit', 'markdown', 'magit'], word_pattern = r'[\w.\-]+', cm_refresh_length=-1, cm_refresh_patterns=[r'\b(\w+)\/'], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json import re logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim) def cm_refresh(self, info, ctx): typed = ctx['typed'] base = ctx['base'] txt = typed[0 : len(typed)-len(base)] # `.*` greedy match, push to the the end match = re.search(r'.*\b(\w+)\/$', txt) if not match:
from cm import register_source, Base, getLogger register_source(name='github-link', abbreviation='link', scopes=['markdown'], word_pattern = r'[^)(]+', cm_refresh_length=-1, cm_refresh_patterns=[r'\[(\w+\/)?[\w.\-]+\]\('], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json import re from .api import create_request logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim) def cm_refresh(self, info, ctx): # `.*` greedy match, push to the the end typed = ctx['typed'] base = ctx['base'] txt = typed[0 : len(typed)-len(base)] match = re.search(r'.*\[((\w+)\/)?([\w.\-]+)\]\($', txt)
from cm import register_source, Base, getLogger register_source(name='github-user', abbreviation='user', scopes=['gitcommit', 'markdown', 'magit'], word_pattern = r'\w+', cm_refresh_length=-1, cm_refresh_patterns=[r'github.com\/', r'@'], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json from .api import create_request logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): Base.__init__(self, nvim) def cm_refresh(self,info,ctx): query = { 'q': ctx['base'] + ' in:login', } url = 'https://api.github.com/search/users?' + urlencode(query) req = create_request(url) logger.debug("url: %s", url) matches = []
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger register_source( name='cm-tags', priority=6, abbreviation='Tag', events=['WinEnter'], ) import os import re import logging import sys logger = getLogger(__name__) class Source: def __init__(self, nvim): self._nvim = nvim self._files = self._nvim.call('tagfiles') def cm_event(self, event, ctx, *args): if event == "WinEnter": self._files = self._nvim.call('tagfiles')
# -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base register_source( name='cm-tern', priority=9, abbreviation='Js', scoping=True, scopes=['javascript', 'javascript.jsx'], early_cache=1, word_pattern=r'[\w$\-]+', cm_refresh_patterns=[r'\.'], ) import os import re import logging from neovim import attach, setup_logging import re import subprocess import logging from urllib import request import json import cm import platform logger = getLogger(__name__)
# For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source( name='clang', priority=9, abbreviation='', scoping=True, scopes=['cpp', 'c'], early_cache=1, cm_refresh_patterns=[r'-\>', r'::', r'\.'], ) import subprocess import re from os import path from ncm_clang import args_from_cmake, args_from_clang_complete logger = getLogger(__name__) class Source(Base): def __init__(self, nvim):
# -*- coding: utf-8 -*- from cm import register_source, Base import subprocess register_source(name='gtags', priority=6, abbreviation='gtags', word_pattern=r'\w+', scoping=True, scopes=['c', 'cpp', 'php', 'java']) class Source(Base): GTAGS_DB_NOT_FOUND_ERROR = 3 def __init__(self, nvim): super().__init__(nvim) self._checked = False def is_word_valid_for_search(self, word): FORRBIDDEN_CHARACTERS = [ '^', '$', '{', '}', '(', ')', '.', '*', '+', '[', ']', '?', '\\' ] for forbbiden_char in FORRBIDDEN_CHARACTERS: if forbbiden_char in word: return False return True
# # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base # A completion source with CTRL-X CTRL-N like feature # # sort=0 for not using NCM's builtin sorting # auto_popup=0, this source is kinkd of heavy weight (scan all buffers) register_source( name='cm-keyword-continue', priority=5, abbreviation='', word_pattern=r'\w+', cm_refresh_length=0, auto_popup=0, sort=0, ) import re import copy logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): super().__init__(nvim)
from cm import register_source, Base, getLogger register_source(name='github-link', abbreviation='link', scopes=['markdown'], word_pattern=r'[^)(]+', cm_refresh_length=-1, cm_refresh_patterns=[r'\[(\w+\/)?[\w.\-]+\]\('], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json import re logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim) def cm_refresh(self, info, ctx): # `.*` greedy match, push to the the end typed = ctx['typed'] base = ctx['base'] txt = typed[0:len(typed) - len(base)] match = re.search(r'.*\[((\w+)\/)?([\w.\-]+)\]\($', txt) if not match: logger.debug("match pattern failed: %s", txt)
py = 'python3' # detect python2 if 'VIRTUAL_ENV' in os.environ: py2 = os.path.join(os.environ['VIRTUAL_ENV'], 'bin', 'python2') if os.path.isfile(py2): py = 'python2' from cm import register_source, getLogger, Base register_source( name='cm-jedi', priority=9, abbreviation='Py', scoping=True, scopes=['python'], multi_thread=0, # disable early cache to minimize the issue of #116 # early_cache=1, # The last two patterns is for displaying function signatures r'\(\s?', r',\s?' cm_refresh_patterns=[r'^(import|from).*\s', r'\.', r'\(\s?', r',\s?'], python=py, ) import re import jedi logger = getLogger(__name__) class Source(Base): def __init__(self, nvim):
# -*- coding: utf-8 -*- # For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source(name='cm-filepath', abbreviation='path', word_pattern=r'''([^\W]|[-.~%$])+''', cm_refresh_patterns=[ r'''(\.[/\\]+|[a-zA-Z]:\\+|~\/+)''', r'''([^\W]|[-.~%$]|[/\\])+[/\\]+'''], options=dict(path_pattern=r'''(([^\W]|[-.~%$]|[/\\])+)'''), sort=0, priority=6,) import os import re from neovim.api import Nvim class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) def cm_refresh(self, info, ctx):
# -*- coding: utf-8 -*- from cm import register_source, getLogger, Base register_source(name='fireplace', abbreviation='🔥', scopes=['clojure'], word_pattern=r'[\w!$%&*+/:<=>?@\^_~\-\.#]+', cm_refresh_patterns=[r'/'], priority=9) import sys import os basedir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.normpath(os.path.join(basedir, "../../rplugin/python3/deoplete/sources/vim_nrepl_python_client"))) from async_clj_omni import fireplace import re class Source(Base): def __init__(self,nvim): super(Source,self).__init__(nvim) self._nvim = nvim self._cider_completion_manager = fireplace.CiderCompletionManager(getLogger(__name__), nvim) def cm_refresh(self,info,ctx): getLogger(__name__).debug('Running a refresh…') matches = self._cider_completion_manager.gather_candidates(ctx['base']) self._nvim.call('cm#complete', info['name'], ctx, ctx['startcol'], matches, False, async=True)
# # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=DEBUG nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module import subprocess from cm import register_source, getLogger, Base register_source(name='mail', abbreviation='mail', scopes=['mail'], priority=9, scoping=True, early_cache=True, word_pattern=r'[\w/]+', cm_refresh_patterns=[ r'^(Bcc|Cc|From|Reply-To|To):\s*', r'^(Bcc|Cc|From|Reply-To|To):.*,\s*' ], cm_refresh_length=-1) LOGGER = getLogger(__name__) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) # dependency check try:
# -*- coding: utf-8 -*- import json import os import re import subprocess from pathlib import Path from cm import Base, getLogger, register_source register_source( name='eclim', priority=9, abbreviation='java', word_pattern=r'\w+', scoping=True, scopes=['java'], early_cache=1, cm_refresh_patterns=[r'\.'], ) logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) self.home_directory = os.path.join( str(Path.home()), '.eclim', )
# -*- coding: utf-8 -*- from cm import register_source, getLogger, Base register_source(name='acid', abbreviation='acid', scopes=['clojure'], word_pattern=r'[\w!$%&*+/:<=>?@\^_~\.#]+', cm_refresh_patterns=[r'/'], priority=9) import os import sys import re class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) # TODO Why is this necessary when it isn't in deoplete sources? sys.path.append( os.path.join( nvim.eval('globpath(&rtp,"rplugin/python3/acid",1)').split( "\n")[0], "..")) from async_clj_omni import acid self._nvim = nvim self._acid_manager = acid.AcidManager(getLogger(__name__), nvim) self._acid_manager.on_init() def cm_refresh(self, info, ctx): getLogger(__name__).debug('Running a refresh…') matches = self._acid_manager.gather_candidates(ctx['base'])
from cm import register_source, Base, getLogger register_source(name='github-issue', abbreviation='issue', scopes=['gitcommit', 'markdown', 'magit'], word_pattern = r'((?<!^)#\d*|#\d+)', cm_refresh_length=1, priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json import subprocess import re from os.path import dirname from .api import create_request logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim) def _get_repo_user(self, cwd): args = ['git', 'remote', '-v'] try: proc = subprocess.Popen(args=args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, cwd=cwd) result, errs = proc.communicate('', 10) result = result.decode('utf-8')
# -*- coding: utf-8 -*- # For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source( name='flow', abbreviation='', priority=9, scopes=['javascript'], word_pattern=r'[\w$\-]+', cm_refresh_patterns=[r'\.'], ) import json import subprocess import os from os import path from sys import stdout, platform logger = getLogger(__name__) class Source(Base): def __init__(self, nvim):
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base register_source( name='cm-bufkeyword', priority=5, abbreviation='Key', events=['InsertEnter', 'BufEnter'], ) import re import cm_default logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) self._words = set() self._last_ctx = None self.refresh_keyword(nvim.eval('cm#context()')) def cm_event(self, event, ctx, *args): if self._last_ctx and (self._last_ctx['changedtick'] == ctx['changedtick']): return
""" An ncm source for vim-minisnip """ from os import listdir, path from cm import register_source, Base, getLogger register_source(name='vim-minisnip', abbreviation='minisnip', priority=9) LOGGER = getLogger(__name__) class Source(Base): """ The primary class: fetches, processes and returns snippets """ def __init__(self, nvim): self.nvim = nvim self.minisnip_dir = nvim.eval('get(g:, "minisnip_dir")') self.snippets = listdir(path.expanduser(self.minisnip_dir)) LOGGER.info('minisnip snippets: %s', self.snippets) def process_matches(self, filetypes): """ Process and return snippet names""" matches = [] for filetype in filetypes: for snippet in self.snippets: if filetype in snippet: matches.append(snippet.split(filetype)[1]) LOGGER.info('minisnip matches: %s', matches) return matches def cm_refresh(self, info, ctx): """ Refresh NCM with matches """ split_filetypes = ctx['filetype'].split('.') filetypes = ['_' + filetype + '_' for filetype in split_filetypes]
# -*- coding: utf-8 -*- # For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source( name='cm-filepath', abbreviation='path', word_pattern=r'[^\s,\\\/]+', cm_refresh_patterns=[ r'(\.[\/\\]|[a-zA-Z]:\\|~\/)[0-9a-zA-Z_\-\.\\\/~\$]*$' ], options=dict(path_pattern=r'''[^\s\'\",]+'''), priority=6, ) import os import re from neovim.api import Nvim class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) def cm_refresh(self, info, ctx):
from cm import register_source, Base, getLogger register_source(name='github-user', abbreviation='user', scopes=['gitcommit', 'markdown', 'magit'], word_pattern = r'\w+', cm_refresh_length=-1, cm_refresh_patterns=[r'github.com\/', r'@'], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): Base.__init__(self, nvim) def cm_refresh(self,info,ctx): query = { 'q': ctx['base'] + ' in:login', } url = 'https://api.github.com/search/users?' + urlencode(query) logger.debug("url: %s", url) matches = [] with urlopen(url, timeout=30) as f: rsp = f.read()
#!/usr/bin/env python from cm import register_source, Base, getLogger from neovim.api import Nvim logger = getLogger(__name__) register_source(name='ncm-emoji', abbreviation='emoji', word_pattern=r':[\w+\-]*', cm_refresh_length=2, priority=8) class Source(Base): def __init__(self, nvim): super(Source, self).__init__(nvim) def cm_refresh(self, info, ctx): test = self.nvim.call('emoji#data#dict') logger.info("test: " + str(test['apple'])) matches = [] for name, code in test.items(): if isinstance(code, list): emoji = "".join(map(chr, code)) else: emoji = chr(code) matches += [dict(word=':' + name + ':', menu=emoji)] self.complete(info, ctx, ctx['startcol'], matches)
# For debugging, use this command to start neovim: # # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim # # # Please register source before executing any other code, this allow cm_core to # read basic information about the source without loading the whole module, and # modules required by this module from cm import register_source, getLogger, Base register_source( name='phpactor', priority=9, abbreviation='php', word_pattern=r'[$\w]+', scoping=True, scopes=['php'], early_cache=1, cm_refresh_patterns=[r'-\>', r'::'], ) import json import os import subprocess import glob import re logger = getLogger(__name__) class Source(Base):
from cm import register_source, Base, getLogger register_source(name='github-repo', abbreviation='repo', scopes=['gitcommit', 'markdown', 'magit'], word_pattern=r'[\w.\-]+', cm_refresh_length=-1, cm_refresh_patterns=[r'\b(\w+)\/'], priority=9) from urllib.request import urlopen from urllib.parse import urlencode import json import re logger = getLogger(__name__) class Source(Base): def __init__(self, nvim): Base.__init__(self, nvim) def cm_refresh(self, info, ctx): typed = ctx['typed'] base = ctx['base'] txt = typed[0:len(typed) - len(base)] # `.*` greedy match, push to the the end match = re.search(r'.*\b(\w+)\/$', txt) if not match: logger.debug("match user string failed")
properties_path = os.path.join(script_dir, '../../properties.json') syntaxes_path = os.path.join(script_dir, '../../syntaxes.json') cssProperties = {} cssSyntaxes = {} with open(properties_path) as data_file: cssProperties = json.load(data_file) with open(syntaxes_path) as data_file: cssSyntaxes = json.load(data_file) register_source(name='css', abbreviation='css', scoping=True, scopes=['css', 'sugarss', 'sass', 'scss', 'stylus', 'less'], word_pattern=r'[\w\-]+\s*:\s+', cm_refresh_patterns=[r'[\w\-]+\s*:\s+'], priority=8) def parse(definition, visited=[]): """Return list of css keywords from the syntax.""" values = [] chunks = [''] letters = re.compile('[a-zA-Z-<>()]') for c in definition: if letters.match(c): chunks[-1] += c else: chunks.append('')
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, get_matcher register_source(name='cm-bufkeyword', priority=5, abbreviation='Key', events=['CursorHold','CursorHoldI','BufEnter','BufWritePost','TextChangedI'],) import os import re logger = getLogger(__name__) class Source: def __init__(self,nvim): self._nvim = nvim self._words = set() self._split_pattern = r'[^\w#]+' self._kw_pattern = r'[\w#]' self._last_ctx = None self.refresh_keyword()
py = 'python3' # detect python2 if 'VIRTUAL_ENV' in os.environ: py2 = os.path.join(os.environ['VIRTUAL_ENV'], 'bin', 'python2') if os.path.isfile(py2): py = 'python2' from cm import register_source, getLogger, Base register_source(name='cm-jedi', priority=9, abbreviation='Py', scoping=True, scopes=['python'], multi_thread=0, # disable early cache to minimize the issue of #116 # early_cache=1, # The last two patterns is for displaying function signatures r'\(\s?', r',\s?' cm_refresh_patterns=[r'^(import|from).*\s', r'\.', r'\(\s?', r',\s?'], python=py,) import re import jedi logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): Base.__init__(self, nvim)
#!/usr/bin/env python # -*- coding: utf-8 -*- # For debugging # NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=INFO nvim from cm import register_source, getLogger, Base register_source(name='cm-tags', priority=6, abbreviation='Tag', events=['WinEnter'],) import os import re import logging import sys logger = getLogger(__name__) class Source(Base): def __init__(self,nvim): super().__init__(nvim) self._files = self.nvim.call('tagfiles') def cm_event(self,event,ctx,*args): if event=="WinEnter": self._files = self.nvim.call('tagfiles') def cm_refresh(self,info,ctx):