install.fairie/dotfiles/.vim/plugged/vim-devicons/rplugin/python3/denite/filter/devicons_denite_converter.py
Git E2E Dev Test Username e30fca43b3 git subrepo clone (merge) https://github.com/ryanoasis/vim-devicons.git ./dotfiles/.vim/plugged/vim-devicons
subrepo:
  subdir:   "dotfiles/.vim/plugged/vim-devicons"
  merged:   "71f239af2"
upstream:
  origin:   "https://github.com/ryanoasis/vim-devicons.git"
  branch:   "master"
  commit:   "71f239af2"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2022-10-18 10:37:31 -04:00

31 lines
896 B
Python

# -*- coding: utf-8 -*-
# vim:se fenc=utf8 noet:
from .base import Base
from os.path import isdir
class Filter(Base):
def __init__(self, vim):
super().__init__(vim)
self.name = 'devicons_denite_converter'
self.description = 'add devicons in front of candidates'
def filter(self, context):
for candidate in context['candidates']:
if 'bufnr' in candidate:
bufname = self.vim.funcs.bufname(candidate['bufnr'])
filename = self.vim.funcs.fnamemodify(bufname, ':p:t')
elif 'word' in candidate and 'action__path' in candidate:
filename = candidate['word']
icon = self.vim.funcs.WebDevIconsGetFileTypeSymbol(
filename, isdir(filename))
# Customize output format if not done already.
if icon not in candidate.get('abbr', '')[:10]:
candidate['abbr'] = ' {} {}'.format(
icon, candidate.get('abbr', candidate['word']))
return context['candidates']