e30fca43b3
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: "???"
31 lines
896 B
Python
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']
|