Beispiel #1
0
    def _load_filters(self, context: UserContext) -> None:
        # Load filters from runtimepath
        rplugins = import_rplugins(
            'Filter', context, 'filter',
            [str(Path(x.path).resolve()) for x in self._filters.values()])
        for Filter, path, module_path in rplugins:
            f = Filter(self._vim)
            # NOTE:
            # Previously, kind and filter but source uses
            # module_path as name so modules which does not
            # have proper 'name' may worked.
            # So add 'name' attribute to the class if that
            # attribute does not exist for the backward
            # compatibility
            if not hasattr(f, 'name') or not f.name:
                # Prefer foo/bar instead of foo.bar in name
                setattr(f, 'name', module_path.replace('.', '/'))
            f.path = path
            self._filters[f.name] = f

            if f.name not in self._custom['alias_filter']:
                self._custom['alias_filter'][f.name] = []
            alias_filter = self._custom['alias_filter'][f.name]

            if '/' in f.name:
                alias_filter.append(f.name.replace('/', '_'))

            # Load alias
            for alias in alias_filter:
                self._filters[alias] = Filter(self._vim)
                self._filters[alias].name = alias
                self._filters[alias].path = path
Beispiel #2
0
    def load_sources(self, context):
        # Load sources from runtimepath
        rplugins = import_rplugins(
            'Source', context, 'source',
            [normcase(normpath(x.path)) for x in self._sources.values()])
        for Source, path, _ in rplugins:
            source = Source(self._vim)
            self._sources[source.name] = source
            source.path = path
            syntax_name = 'deniteSource_' + source.name.replace('/', '_')
            if not source.syntax_name:
                source.syntax_name = syntax_name

            if source.name in self._custom['alias_source']:
                # Load alias
                for alias in self._custom['alias_source'][source.name]:
                    self._sources[alias] = Source(self._vim)
                    self._sources[alias].name = alias
                    self._sources[alias].path = path
                    self._sources[alias].syntax_name = syntax_name
        # Update source_names for completion
        self._vim.call(
            'denite#helper#_set_available_sources',
            list(self._sources.keys()),
        )
Beispiel #3
0
    def _load_sources(self, context: UserContext) -> None:
        # Load sources from runtimepath
        # Note: load "denite.source" for old sources compatibility
        import denite.source  # noqa
        rplugins = import_rplugins(
            'Source', context, 'source',
            [str(Path(x.path).resolve()) for x in self._sources.values()])
        for SourceClass, path, _ in rplugins:
            source = SourceClass(self._vim)
            self._sources[source.name] = source
            source.path = path
            syntax_name = 'deniteSource_' + re.sub('[^a-zA-Z0-9_]', '_',
                                                   source.name)
            if not source.syntax_name:
                source.syntax_name = syntax_name

            # Set the source kind attributes.
            if isinstance(source.kind, Kind):
                self._set_custom_attribute('kind', source.kind,
                                           'default_action')

            if source.name in self._custom['alias_source']:
                # Load alias
                for alias in self._custom['alias_source'][source.name]:
                    self._sources[alias] = SourceClass(self._vim)
                    self._sources[alias].name = alias
                    self._sources[alias].path = path
                    self._sources[alias].syntax_name = syntax_name
        # Update source_names for completion
        self._vim.call(
            'denite#helper#_set_available_sources',
            list(self._sources.keys()),
        )
Beispiel #4
0
 def load_filters(self, context):
     # Load filters from runtimepath
     rplugins = import_rplugins('Filter', context, 'filter', [
         normcase(normpath(x.path))
         for x in self._filters.values()
     ])
     for Filter, path, module_path in rplugins:
         f = Filter(self._vim)
         # NOTE:
         # Previously, kind and filter but source uses
         # module_path as name so modules which does not
         # have proper 'name' may worked.
         # So add 'name' attribute to the class if that
         # attribute does not exist for the backward
         # compatibility
         if not hasattr(f, 'name') or not f.name:
             # Prefer foo/bar instead of foo.bar in name
             setattr(f, 'name', module_path.replace('.', '/'))
         f.path = path
         self._filters[f.name] = f
         if f.name in self._custom['alias_filter']:
             # Load alias
             for alias in self._custom['alias_filter'][f.name]:
                 self._filters[alias] = Filter(self._vim)
                 self._filters[alias].name = alias
                 self._filters[alias].path = path
Beispiel #5
0
    def load_sources(self, context):
        # Load sources from runtimepath
        rplugins = import_rplugins('Source', context, 'source', [
            normcase(normpath(x.path))
            for x in self._sources.values()
        ])
        for Source, path, _ in rplugins:
            source = Source(self._vim)
            self._sources[source.name] = source
            source.path = path
            syntax_name = 'deniteSource_' + source.name.replace('/', '_')
            if not source.syntax_name:
                source.syntax_name = syntax_name

            if source.name in self._custom['alias_source']:
                # Load alias
                for alias in self._custom['alias_source'][source.name]:
                    self._sources[alias] = Source(self._vim)
                    self._sources[alias].name = alias
                    self._sources[alias].path = path
                    self._sources[alias].syntax_name = syntax_name
        # Update source_names for completion
        self._vim.call(
            'denite#helper#_set_available_sources',
            list(self._sources.keys()),
        )
Beispiel #6
0
    def _load_sources(self, context):
        # Load sources from runtimepath
        # Note: load "denite.source" for old sources compatibility
        import denite.source  # noqa
        rplugins = import_rplugins(
            'Source', context, 'source',
            [normcase(normpath(x.path)) for x in self._sources.values()])
        for Source, path, _ in rplugins:
            source = Source(self._vim)
            self._sources[source.name] = source
            source.path = path
            syntax_name = 'deniteSource_' + re.sub('[^a-zA-Z0-9_]', '_',
                                                   source.name)
            if not source.syntax_name:
                source.syntax_name = syntax_name

            if source.name in self._custom['alias_source']:
                # Load alias
                for alias in self._custom['alias_source'][source.name]:
                    self._sources[alias] = Source(self._vim)
                    self._sources[alias].name = alias
                    self._sources[alias].path = path
                    self._sources[alias].syntax_name = syntax_name
        # Update source_names for completion
        self._vim.call(
            'denite#helper#_set_available_sources',
            list(self._sources.keys()),
        )
Beispiel #7
0
 def load_kinds(self, context):
     # Load kinds from runtimepath
     rplugins = import_rplugins(
         'Kind', context, 'kind',
         [normcase(normpath(x.path)) for x in self._kinds.values()])
     for Kind, path, module_path in rplugins:
         kind = Kind(self._vim)
         # NOTE:
         # Previously, kind and filter but source uses
         # module_path as name so modules which does not
         # have proper 'name' may worked.
         # So add 'name' attribute to the class if that
         # attribute does not exist for the backward
         # compatibility
         if not hasattr(kind, 'name') or not kind.name:
             # Prefer foo/bar instead of foo.bar in name
             setattr(kind, 'name', module_path.replace('.', '/'))
         kind.path = path
         self._kinds[kind.name] = kind
Beispiel #8
0
 def load_kinds(self, context):
     # Load kinds from runtimepath
     rplugins = import_rplugins('Kind', context, 'kind', [
         normcase(normpath(x.path))
         for x in self._kinds.values()
     ])
     for Kind, path, module_path in rplugins:
         kind = Kind(self._vim)
         # NOTE:
         # Previously, kind and filter but source uses
         # module_path as name so modules which does not
         # have proper 'name' may worked.
         # So add 'name' attribute to the class if that
         # attribute does not exist for the backward
         # compatibility
         if not hasattr(kind, 'name') or not kind.name:
             # Prefer foo/bar instead of foo.bar in name
             setattr(kind, 'name', module_path.replace('.', '/'))
         kind.path = path
         self._kinds[kind.name] = kind
Beispiel #9
0
    def _load_kinds(self, context: UserContext) -> None:
        # Load kinds from runtimepath
        rplugins = import_rplugins(
            'Kind', context, 'kind',
            [str(Path(x.path).resolve()) for x in self._kinds.values()])
        for KindClass, path, module_path in rplugins:
            kind = KindClass(self._vim)
            # NOTE:
            # Previously, kind and filter but source uses
            # module_path as name so modules which does not
            # have proper 'name' may worked.
            # So add 'name' attribute to the class if that
            # attribute does not exist for the backward
            # compatibility
            if not hasattr(kind, 'name') or not kind.name:
                # Prefer foo/bar instead of foo.bar in name
                setattr(kind, 'name', module_path.replace('.', '/'))

            # Set the kind attributes.
            kind.path = path
            self._set_custom_attribute('kind', kind, 'default_action')

            self._kinds[kind.name] = kind