Example #1
0
    def on_init(self, context):  # called by deoplete

        try:
            self.merlin_binary = self.vim.eval("merlin#SelectBinary()")
        except nvim.NvimError:
            util.debug(
                self.vim,
                "Merlin not found, make sure ocamlmerlin is in your path"
                " and merlin's vim plugin is installed.")
            self.merlin_binary = None
            return

        self.merlin_completion_with_doc = self._is_set(
            "g:merlin_completion_with_doc")
        self.merlin_binary_flags = self.vim.eval("g:merlin_binary_flags")
        self.buffer_merlin_flags = self._list_if_set("b:merlin_flags")
        self.merlin_extensions = concat_map(
            lambda ext: ("-extension", ext),
            self._list_if_set("b:merlin_extensions"))
        self.merlin_packages = concat_map(
            lambda pkg: ("-package", pkg),
            self._list_if_set("b:merlin_packages"))
        self.merlin_dot_merlins = concat_map(
            lambda dm: ("-dot-merlin", dm),
            self._list_if_set("b:merlin_dot_merlins"))

        if self._is_set("g:merlin_debug"):
            log_errors = ["-log-file", "-"]
        else:
            log_errors = []
        self.merlin_log_errors = log_errors
    def _access_control_candidates(self, context, matched):
        debug(self.vim, ("f2", matched))
        if matched == "":
            return (self.__access_controls, "")
        words = re.sub(r"\s+", "", matched).split(",")
        last_word = words[-1]
        word_set = set(words)

        def gather(a, b):
            word = b["word"]
            include_set = set(b.get("_include", []))
            if word in word_set:
                a.add(word)
                a |= include_set
            elif len(include_set) > 0 and include_set <= word_set:
                a.add(word)
            return a

        selected = reduce(gather, self.__access_controls, set())
        debug(self.vim, ("f3", last_word, selected))
        if last_word == "":
            return (
                [
                    x for x in self.__access_controls
                    if x["word"] not in selected
                ],
                last_word,
            )
        return (
            [
                x for x in self.__access_controls if x["word"] == last_word or
                (x["word"].startswith(last_word) and x["word"] not in selected)
            ],
            last_word,
        )
 def _search_candidates(self, context):
     allow_match = re.search(r"allow\s+([a-z\s,]*)$", context["input"])
     if allow_match:
         (candidates, input_str) = self._access_control_candidates(
             context, allow_match.group(1))
         debug(self.vim, ("f4", candidates))
         if candidates:
             return (candidates, input_str)
     method_match = re.search(r".+\.\w*$", context["input"])
     if method_match:
         (candidates,
          input_str) = self._method_candidates(context,
                                               method_match.group(0))
         if candidates:
             return (candidates, input_str)
     global_match = re.search(r"[^.]\b([a-zA-Z]*)$", context["input"])
     if global_match:
         (candidates,
          input_str) = self._top_candidates(context, global_match.group(1))
         if candidates:
             return (candidates, input_str)
     return ([], "")
Example #4
0
File: base.py Project: s0la/orw_bak
 def print(self, expr):
     if not self.is_silent:
         debug(self.vim, expr)
Example #5
0
 def print(self, expr):
     debug(self.vim, expr)
Example #6
0
 def print(self, expr: typing.Any) -> None:
     if not self.is_silent:
         debug(self.vim, expr)
Example #7
0
 def print(self, expr):
     debug(self.vim, expr)
Example #8
0
 def print(self, expr):
     if not self.is_silent:
         debug(self.vim, expr)