コード例 #1
0
    def _add_source(self, path):
        source = None
        try:
            Source = import_plugin(path, 'source', 'Source')
            if not Source:
                return

            source = Source(self._vim)
            name = os.path.splitext(os.path.basename(path))[0]
            source.name = getattr(source, 'name', name)
            source.path = path
            if source.name in self._loaded_sources:
                # Duplicated name
                error_tb(self._vim, 'Duplicated source: %s' % source.name)
                error_tb(
                    self._vim, 'path: "%s" "%s"' %
                    (path, self._loaded_sources[source.name]))
                source = None
        except Exception:
            error_tb(self._vim, 'Could not load source: %s' % path)
        finally:
            if source:
                self._loaded_sources[source.name] = path
                self._sources[source.name] = source
                self.debug('Loaded Source: %s (%s)', source.name, path)
コード例 #2
0
ファイル: deoplete.py プロジェクト: N0hbdy/.dotfiles
    def load_filters(self, context):
        # Load filters from runtimepath
        for path in find_rplugins(context, 'filter'):
            if path in self._ignored_filters or path in self._loaded_paths:
                continue
            self._loaded_paths.add(path)

            name = os.path.splitext(os.path.basename(path))[0]

            f = None
            try:
                Filter = import_plugin(path, 'filter', 'Filter')
                if not Filter:
                    continue

                f = Filter(self._vim)
                f.name = getattr(f, 'name', name)
                f.path = path
                self._filters[f.name] = f
            except Exception:
                # Exception occurred when loading a filter.  Log stack trace.
                error_tb(self._vim, 'Could not load filter: %s' % name)
            finally:
                if f:
                    self._filters[f.name] = f
                    self.debug('Loaded Filter: %s (%s)', f.name, path)
コード例 #3
0
    def _add_filter(self, path):
        f = None
        try:
            Filter = import_plugin(path, 'filter', 'Filter')
            if not Filter:
                return

            f = Filter(self._vim)
            name = os.path.splitext(os.path.basename(path))[0]
            f.name = getattr(f, 'name', name)
            f.path = path
            if f.name in self._loaded_filters:
                # Duplicated name
                error_tb(self._vim, 'Duplicated filter: %s' % f.name)
                error_tb(
                    self._vim,
                    'path: "%s" "%s"' % (path, self._loaded_filters[f.name]))
                f = None
        except Exception:
            # Exception occurred when loading a filter.  Log stack trace.
            error_tb(self._vim, 'Could not load filter: %s' % path)
        finally:
            if f:
                self._loaded_filters[f.name] = path
                self._filters[f.name] = f
                self.debug('Loaded Filter: %s (%s)', f.name, path)
コード例 #4
0
    def load_sources(self, context):
        # Load sources from runtimepath
        for path in find_rplugins(context, 'source'):
            if path in self._loaded_paths:
                continue
            self._loaded_paths.add(path)

            name = os.path.splitext(os.path.basename(path))[0]

            source = None
            try:
                Source = import_plugin(path, 'source', 'Source')
                if not Source:
                    continue

                source = Source(self._vim)
                source.name = getattr(source, 'name', name)
                source.path = path
            except Exception:
                error_tb(self._vim, 'Could not load source: %s' % name)
            finally:
                if source:
                    self._sources[source.name] = source
                    self.debug('Loaded Source: %s (%s)', source.name, path)

        self.set_source_attributes(context)
        self._custom = context['custom']
コード例 #5
0
    def load_filters(self, context):
        # Load filters from runtimepath
        for path in find_rplugins(context, 'filter'):
            if path in self._ignored_filters or path in self._loaded_paths:
                continue
            self._loaded_paths.add(path)

            name = os.path.splitext(os.path.basename(path))[0]

            f = None
            try:
                Filter = import_plugin(path, 'filter', 'Filter')
                if not Filter:
                    continue

                f = Filter(self._vim)
                f.name = getattr(f, 'name', name)
                f.path = path
                self._filters[f.name] = f
            except Exception:
                # Exception occurred when loading a filter.  Log stack trace.
                error_tb(self._vim, 'Could not load filter: %s' % name)
            finally:
                if f:
                    self._filters[f.name] = f
                    self.debug('Loaded Filter: %s (%s)', f.name, path)
コード例 #6
0
    def _add_source(self, path: str) -> None:
        # Resolve symbolic link
        path = str(Path(path).resolve())

        source = None
        try:
            Source = import_plugin(path, 'source', 'Source')
            if not Source:
                return

            source = Source(self._vim)
            name = Path(path).stem
            source.name = getattr(source, 'name', name)
            source.path = path
            loaded_path = self._loaded_sources.get(source.name, '')
            if source.name in self._loaded_sources and path != loaded_path:
                # Duplicated name
                error_tb(self._vim, 'Duplicated source: %s' % source.name)
                error_tb(self._vim, 'path: "%s" "%s"' %
                         (path, loaded_path))
                source = None
        except Exception:
            error_tb(self._vim, 'Could not load source: %s' % path)
        finally:
            if source:
                self._loaded_sources[source.name] = path
                self._sources[source.name] = source
                self.debug(  # type: ignore
                    f'Loaded Source: {source.name} ({path})')
コード例 #7
0
    def _add_filter(self, path: str) -> None:
        # Resolve symbolic link
        path = str(Path(path).resolve())

        f = None
        try:
            Filter = import_plugin(path, 'filter', 'Filter')
            if not Filter:
                return

            f = Filter(self._vim)
            name = Path(path).stem
            f.name = getattr(f, 'name', name)
            f.path = path
            loaded_path = self._loaded_filters.get(f.name, '')
            if f.name in self._loaded_filters and path != loaded_path:
                # Duplicated name
                error_tb(self._vim, 'Duplicated filter: %s' % f.name)
                error_tb(self._vim, 'path: "%s" "%s"' %
                         (path, loaded_path))
                f = None
        except Exception:
            # Exception occurred when loading a filter.  Log stack trace.
            error_tb(self._vim, 'Could not load filter: %s' % path)
        finally:
            if f:
                self._loaded_filters[f.name] = path
                self._filters[f.name] = f
                self.debug(  # type: ignore
                    f'Loaded Filter: {f.name} ({path})')
コード例 #8
0
ファイル: child.py プロジェクト: noahgamboa/vim_runtime
    def _add_filter(self, path):
        f = None
        try:
            Filter = import_plugin(path, 'filter', 'Filter')
            if not Filter:
                return

            f = Filter(self._vim)
            name = os.path.splitext(os.path.basename(path))[0]
            f.name = getattr(f, 'name', name)
            f.path = path
            if f.name in self._loaded_filters:
                # Duplicated name
                error_tb(self._vim, 'Duplicated filter: %s' % f.name)
                error_tb(self._vim, 'path: "%s" "%s"' %
                         (path, self._loaded_filters[f.name]))
                f = None
        except Exception:
            # Exception occurred when loading a filter.  Log stack trace.
            error_tb(self._vim, 'Could not load filter: %s' % path)
        finally:
            if f:
                self._loaded_filters[f.name] = path
                self._filters[f.name] = f
                self.debug('Loaded Filter: %s (%s)', f.name, path)
コード例 #9
0
ファイル: deoplete.py プロジェクト: pbt001/neovim-config
    def load_filters(self, context):
        # Load filters from runtimepath
        loaded_paths = [filter.path for filter in self.__filters.values()]
        for path in find_rplugins(context, 'filter'):
            if path in self.__ignored_filters:
                continue
            if path in loaded_paths:
                continue
            name = os.path.splitext(os.path.basename(path))[0]

            filter = None
            try:
                Filter = import_plugin(path, 'filter', 'Filter')
                if Filter is None:
                    continue

                filter = Filter(self.__vim)
                filter.name = getattr(filter, 'name', name)
                filter.path = path
                self.__filters[filter.name] = filter
            except Exception:
                # Exception occurred when loading a filter.  Log stack trace.
                error_tb(self.__vim, 'Could not load filter: %s' % name)
            finally:
                if filter is not None:
                    self.__filters[filter.name] = filter
                    self.debug('Loaded Filter: %s (%s)', filter.name, path)
コード例 #10
0
ファイル: deoplete.py プロジェクト: plotnikovanton/dotfiles
    def load_filters(self, context):
        # Load filters from runtimepath
        for path in find_rplugins(context, 'filter'):
            name = os.path.splitext(os.path.basename(path))[0]
            if name in self.__filters:
                continue

            filter = None

            try:
                Filter = import_plugin(path, 'filter', 'Filter')
                if Filter is None:
                    continue

                filter = Filter(self.__vim)

                filter.name = getattr(filter, 'name', name)
                self.__filters[filter.name] = filter
            except Exception:
                # Exception occurred when loading a filter.  Log stack trace.
                error_tb(self.__vim, 'Could not load filter: %s' % name)
            finally:
                if filter is not None:
                    self.__filters[filter.name] = filter
                    self.debug('Loaded Filter: %s (%s)', filter.name, path)
コード例 #11
0
ファイル: deoplete.py プロジェクト: pocari/deoplete.nvim
    def load_sources(self, context):
        # Load sources from runtimepath
        for path in find_rplugins(context, 'source'):
            name = os.path.splitext(os.path.basename(path))[0]
            if name in self.__sources:
                continue

            source = None

            try:
                Source = import_plugin(path, 'source', 'Source')
                if Source is None:
                    continue
                source = Source(self.__vim)
                source.name = getattr(source, 'name', name)

                source.min_pattern_length = getattr(
                    source, 'min_pattern_length',
                    context['vars']['deoplete#auto_complete_start_length'])
                source.max_abbr_width = getattr(
                    source, 'max_abbr_width',
                    context['vars']['deoplete#max_abbr_width'])
                source.max_menu_width = getattr(
                    source, 'max_menu_width',
                    context['vars']['deoplete#max_menu_width'])

            except Exception:
                error_tb(self.__vim, 'Could not load source: %s' % name)
            finally:
                if source is not None:
                    self.__sources[source.name] = source
                    self.debug('Loaded Source: %s (%s)', source.name, path)

        self.set_source_attributes(context)
        self.__custom = context['custom']
コード例 #12
0
ファイル: child.py プロジェクト: noahgamboa/vim_runtime
    def _add_source(self, path):
        source = None
        try:
            Source = import_plugin(path, 'source', 'Source')
            if not Source:
                return

            source = Source(self._vim)
            name = os.path.splitext(os.path.basename(path))[0]
            source.name = getattr(source, 'name', name)
            source.path = path
            if source.name in self._loaded_sources:
                # Duplicated name
                error_tb(self._vim, 'Duplicated source: %s' % source.name)
                error_tb(self._vim, 'path: "%s" "%s"' %
                         (path, self._loaded_sources[source.name]))
                source = None
        except Exception:
            error_tb(self._vim, 'Could not load source: %s' % path)
        finally:
            if source:
                self._loaded_sources[source.name] = path
                self._sources[source.name] = source
                self.debug('Loaded Source: %s (%s)', source.name, path)