Exemple #1
0
 def view_pdf(self):
     if not Shell.isinPATH('pdftoppm'):
         self.view_mime()
     else:
         if self.path not in self.tempfile_cache:
             fname = tempfile.mkstemp()[1]
             Shell.touch(fname)
             self.tempfile_cache[self.path] = fname
         fname = self.tempfile_cache[self.path]
         Shell.run(f'pdftoppm -png -f 1 -singlefile "{self.path}" {fname}')
         self.path = self.tempfile_cache[self.path] + '.png'
         self.view_image()
Exemple #2
0
    def list_remotes_in_vim_buffer(self):
        if not Shell.isinPATH('rclone'):
            self.install_rclone()

        remotes = set(self.cmd_listremotes())
        local_remotes = set(super(Rclone, self).ls(self.root_dir))
        for remote in remotes.difference(local_remotes):
            Shell.mkdir(os.path.join(self.root_dir, remote))
        for remote in local_remotes.difference(remotes):
            Shell.rm(os.path.join(self.root_dir, remote))

        if len(remotes) > 0:
            Vim.command(f'NETRTabdrop {self.root_dir}')
        else:
            Vim.ErrorMsg(
                "There's no remote now. Run 'rclone config' in a terminal to "
                "setup remotes and restart vim again.")
Exemple #3
0
 def view_image(self):
     try:
         import ueberzug
     except ModuleNotFoundError:
         Vim.ErrorMsg('Please install ueberzug for image preview')
         self.view_mime()
         return
     path = self.path
     if self.path.endswith('gif') and Shell.isinPATH('convert'):
         if self.path not in self.tempfile_cache:
             dir = tempfile.TemporaryDirectory().name
             Shell.mkdir(dir)
             self.tempfile_cache[self.path] = dir
         dir = self.tempfile_cache[self.path]
         path = dir
         Shell.run(f'convert -deconstruct  "{self.path}" {dir}/a.png')
     Vim.AsyncRun(f'{util.GenNetRangerScriptCmd("image_preview")}\
                     "{path}" {self.total_width} {self.preview_width}',
                  term=True,
                  termopencmd='')
     Vim.command('setlocal nocursorline')
Exemple #4
0
 def __call__(self, fname):
     return Shell.isinPATH(self.args[0])