I made Deoplete sources for the package and option lists.
It’s unlikely that anybody else would use them but I’ll post the file.
You need to change the file paths in the script and obviously put it in the proper subfolder of your vim-confs.
As an added note, this is basically the first time I’ve touched Python, so there is probably some room for improvement here; but this works.
Ideally this this would be expanded to source more information. Deoplete can easily show things like a preview of the current configuration settings for instance just like the FZF script does, but this’ll do for now.
# ${NVIMCONFS}/rplugin/python3/deoplete/sources/nix.py
import re
from .base import Base
from deoplete.util import (convert2list, parse_file_pattern, set_pattern)
class Source(Base):
def __init__(self, vim):
super().__init__(vim)
self.name = 'nix'
self.filetypes = ['nix']
self.min_pattern_length = 0
self.rank = 500
self._object_pattern = r'[a-zA-Z_]\w*(?:\(\)?)?'
self.prefix = ''
def get_complete_position(self, context):
m = re.search(self._object_pattern + r'\.\w*$', context['input'])
if m is None:
return -1
self._prefix = re.sub(r'\w*$', '', m.group(0))
return re.search(r'\w*$', context['input']).start()
def gather_candidates(self, context):
# Run Packages
with open("/etc/nixos/packages.txt") as packs:
pkgs = [{'word': x, 'menu': 'NxP'} for x in
parse_file_pattern(
packs,
r'(?<=' + re.escape(self._prefix) + r')\w+'
)
if x != context['complete_str']]
# Run Options
with open("/etc/nixos/options.txt") as opts:
opts = [{'word': x, 'menu': 'NxO'} for x in
parse_file_pattern(
opts,
r'(?<=' + re.escape(self._prefix) + r')\w+'
)
if x != context['complete_str']]
return pkgs + opts