diff --git a/plugin/webdevicons.vim b/plugin/webdevicons.vim index dbf94ef..82d4717 100644 --- a/plugin/webdevicons.vim +++ b/plugin/webdevicons.vim @@ -38,6 +38,10 @@ if !exists('g:webdevicons_enable_unite') let g:webdevicons_enable_unite = 1 endif +if !exists('g:webdevicons_enable_denite') + let g:webdevicons_enable_denite = 1 +endif + if !exists('g:webdevicons_enable_vimfiler') let g:webdevicons_enable_vimfiler = 1 endif @@ -430,7 +434,7 @@ endfunction function! s:initializeUnite() if exists('g:loaded_unite') && g:webdevicons_enable_unite let s:filters = { - \ 'name' : 'devicons_converter', + \ 'name' : 'devicons_unite_converter', \} function! s:filters.filter(candidates, context) @@ -461,7 +465,17 @@ function! s:initializeUnite() call unite#define_filter(s:filters) unlet s:filters - call unite#custom#source('file,file_rec,buffer,file_rec/async,file_rec/neovim,file_rec/neovim2,file_rec/git', 'converters', 'devicons_converter') + call unite#custom#source('file,file_rec,buffer,file_rec/async,file_rec/neovim,file_rec/neovim2,file_rec/git', 'converters', 'devicons_unite_converter') + endif +endfunction + +" for denite plugin {{{3 +"======================================================================== + +" scope: local +function! s:initializeDenite() + if exists('g:loaded_denite') && g:webdevicons_enable_denite + call denite#custom#source('file_rec,file_old,buffer,directory_rec', 'converters', ['devicons_denite_converter']) endif endfunction @@ -510,6 +524,9 @@ function! s:initializeCtrlP() endif endfunction +" local initialization {{{2 +"======================================================================== + " scope: local function! s:initialize() call s:setDictionaries() @@ -517,14 +534,16 @@ function! s:initialize() call s:setCursorHold() call s:initializeFlagship() call s:initializeUnite() + call s:initializeDenite() call s:initializeVimfiler() call s:initializeCtrlP() endfunction -" local initialization {{{2 -"======================================================================== - -call s:initialize() +if v:vim_did_enter + call s:initialize() +else + au VimEnter * call s:initialize() +endif " public functions {{{2 "======================================================================== diff --git a/rplugin/python3/denite/filter/devicons_denite_converter.py b/rplugin/python3/denite/filter/devicons_denite_converter.py new file mode 100644 index 0000000..ac79193 --- /dev/null +++ b/rplugin/python3/denite/filter/devicons_denite_converter.py @@ -0,0 +1,16 @@ +# -*- 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']: + candidate['abbr'] = ' '+self.vim.funcs.WebDevIconsGetFileTypeSymbol(candidate['word'], isdir(candidate['word']))+' '+candidate['word'] + return context['candidates']