Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Denite Support #191

Merged
merged 7 commits into from
Apr 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions plugin/webdevicons.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -510,21 +524,26 @@ function! s:initializeCtrlP()
endif
endfunction

" local initialization {{{2
"========================================================================

" scope: local
function! s:initialize()
call s:setDictionaries()
call s:setSyntax()
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
"========================================================================
Expand Down
16 changes: 16 additions & 0 deletions rplugin/python3/denite/filter/devicons_denite_converter.py
Original file line number Diff line number Diff line change
@@ -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']