Last active
December 24, 2015 07:18
-
-
Save itchyny/6762387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/autoload/vimfiler/view.vim b/autoload/vimfiler/view.vim | |
index 42139e2..d7c5eb0 100644 | |
--- a/autoload/vimfiler/view.vim | |
+++ b/autoload/vimfiler/view.vim | |
@@ -225,6 +225,20 @@ function! s:redraw_prompt() "{{{ | |
let &l:modifiable = modifiable_save | |
endfunction"}}} | |
+ | |
+function! vimfiler#view#_get_column(columns, file) | |
+ let column_result = '' | |
+ for column in a:columns | |
+ let column_string = column.get(a:file, b:vimfiler.context) | |
+ if len(column_string) > column.vimfiler__length | |
+ let column_string = vimfiler#util#truncate( | |
+ \ column_string, column.vimfiler__length) | |
+ endif | |
+ let column_result .= ' ' . column_string | |
+ endfor | |
+ return column_result | |
+endfunction | |
+ | |
function! vimfiler#view#_get_print_lines(files) "{{{ | |
" Clear previous syntax. | |
for syntax in b:vimfiler.syntaxes | |
@@ -281,6 +295,68 @@ function! vimfiler#view#_get_print_lines(files) "{{{ | |
" Print files. | |
let lines = [] | |
+ | |
+ if vimfiler#util#has_lua() | |
+ let ret = {} | |
+ | |
+lua << EOF | |
+do | |
+ local files = vim.eval('a:files') | |
+ local lines = vim.eval('lines') | |
+ local tree_indentation = vim.eval('g:vimfiler_tree_indentation') | |
+ local leaf_icon = vim.eval('g:vimfiler_tree_leaf_icon') | |
+ local marked_file_icon = vim.eval('g:vimfiler_marked_file_icon') | |
+ local readonly_file_icon = vim.eval('g:vimfiler_readonly_file_icon') | |
+ local opened_icon = vim.eval('g:vimfiler_tree_opened_icon') | |
+ local closed_icon = vim.eval('g:vimfiler_tree_closed_icon') | |
+ local file_icon = vim.eval('g:vimfiler_file_icon') | |
+ local max_len = vim.eval('max_len') | |
+ local ret = vim.eval('ret') | |
+ | |
+ for i = 0, #files - 1 do | |
+ local file = files[i] | |
+ local mark = '' | |
+ local is_writable = file.vimfiler__is_writable == nil and true or file.vimfiler__is_writable ~= 0 | |
+ local filename = file.vimfiler__abbr | |
+ if file.vimfiler__is_directory ~= 0 and filename:sub(-1) ~= '/' then | |
+ filename = filename .. '/' | |
+ end | |
+ if file.vimfiler__nest_level > 0 then | |
+ mark = mark .. string.rep(' ', file.vimfiler__nest_level * tree_indentation) .. leaf_icon | |
+ end | |
+ if file.vimfiler__is_marked ~= 0 then | |
+ mark = mark .. marked_file_icon | |
+ elseif file.vimfiler__is_directory ~= 0 then | |
+ mark = mark .. (not is_writable and not (file.vimfiler__is_opened ~= 0) and | |
+ readonly_file_icon or | |
+ (file.vimfiler__is_opened ~= 0 and opened_icon or closed_icon)) | |
+ else | |
+ mark = mark .. (not is_writable and readonly_file_icon or file_icon) | |
+ end | |
+ mark = mark .. ' ' | |
+ | |
+ local line = mark .. filename | |
+ ret.line = line | |
+ if #line > max_len then | |
+ line = vim.eval("vimfiler#util#truncate_smart(ret.line, max_len, max_len/2, '..')") | |
+ else | |
+ line = line .. string.rep(' ', max_len - vim.eval("vimfiler#util#wcswidth(ret.line)")) | |
+ end | |
+ | |
+ line = line .. vim.eval('vimfiler#view#_get_column(columns, a:files[' .. i .. '])') | |
+ | |
+ if line:sub(-1) == ' ' then | |
+ line = line:gsub("%s+$", '') | |
+ end | |
+ | |
+ lines:add(line) | |
+ | |
+ end | |
+end | |
+EOF | |
+ | |
+ else | |
+ | |
for file in a:files | |
let filename = file.vimfiler__abbr | |
if file.vimfiler__is_directory | |
@@ -331,6 +407,7 @@ function! vimfiler#view#_get_print_lines(files) "{{{ | |
call add(lines, line) | |
endfor | |
+ endif | |
return lines | |
endfunction"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment