better format
This commit is contained in:
parent
98d94876f2
commit
7b7fb56c4e
@ -16,7 +16,7 @@
|
|||||||
- [x] add / rename / delete file in directory
|
- [x] add / rename / delete file in directory
|
||||||
- [ ] update tree when altering the FS
|
- [ ] update tree when altering the FS
|
||||||
|
|
||||||
- [x] syntax highlighting
|
- [x] syntax highlighting ([exa](https://github.com/ogham/exa) like) and file icons with vim-devicons
|
||||||
- [ ] simple git integration (color of file changing when staged/changed)
|
- [ ] simple git integration (color of file changing when staged/changed)
|
||||||
|
|
||||||
- [ ] quickly find file in the directory structure
|
- [ ] quickly find file in the directory structure
|
||||||
@ -26,3 +26,4 @@
|
|||||||
- [ ] buffer / window should always stay on the left and never change size (open a file with only the tree open to reproduce this bug)
|
- [ ] buffer / window should always stay on the left and never change size (open a file with only the tree open to reproduce this bug)
|
||||||
- [ ] buffer / window should not disappear when only the tree is opened
|
- [ ] buffer / window should not disappear when only the tree is opened
|
||||||
|
|
||||||
|
- [ ] symbolic links
|
||||||
|
|||||||
@ -20,8 +20,36 @@ local function default_icons(_, isdir, open)
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function create_matcher(arr)
|
||||||
|
return function(name)
|
||||||
|
for _, n in pairs(arr) do
|
||||||
|
if string.match(name, n) then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_special = create_matcher({
|
||||||
|
'README',
|
||||||
|
'readme',
|
||||||
|
'Makefile',
|
||||||
|
'Cargo%.toml',
|
||||||
|
})
|
||||||
|
|
||||||
|
local is_pic = create_matcher({
|
||||||
|
'%.jpe?g$',
|
||||||
|
'%.png',
|
||||||
|
'%.gif'
|
||||||
|
})
|
||||||
|
|
||||||
|
local function is_executable(name)
|
||||||
|
return api.nvim_call_function('executable', { name }) == 1
|
||||||
|
end
|
||||||
|
|
||||||
local function dev_icons(pathname, isdir, open)
|
local function dev_icons(pathname, isdir, open)
|
||||||
if isdir == true then return default_icons(pathname, isdir, open) end
|
if isdir == true or is_special(pathname) == true or is_executable(pathname) == true or is_pic(pathname) == true then
|
||||||
|
return default_icons(pathname, isdir, open)
|
||||||
|
end
|
||||||
|
|
||||||
local icon = api.nvim_call_function('WebDevIconsGetFileTypeSymbol', { pathname, isdir })
|
local icon = api.nvim_call_function('WebDevIconsGetFileTypeSymbol', { pathname, isdir })
|
||||||
if icon == "" then return "" end
|
if icon == "" then return "" end
|
||||||
@ -78,8 +106,6 @@ local HIGHLIGHT_GROUPS = {
|
|||||||
['^.*%.jsx$'] = 'ReactFile';
|
['^.*%.jsx$'] = 'ReactFile';
|
||||||
['^.*%.tsx$'] = 'ReactFile';
|
['^.*%.tsx$'] = 'ReactFile';
|
||||||
['^.*%.html?$'] = 'HtmlFile';
|
['^.*%.html?$'] = 'HtmlFile';
|
||||||
['^.*%.png$'] = 'ImageFile';
|
|
||||||
['^.*%.jpe?g$'] = 'ImageFile';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local function highlight_line(buffer)
|
local function highlight_line(buffer)
|
||||||
@ -95,6 +121,12 @@ local function highlight_line(buffer)
|
|||||||
else
|
else
|
||||||
highlight('LuaTreeFolderName', line, 0, -1)
|
highlight('LuaTreeFolderName', line, 0, -1)
|
||||||
end
|
end
|
||||||
|
elseif is_special(node.name) == true then
|
||||||
|
highlight('LuaTreeSpecialFile', line, 0, -1)
|
||||||
|
elseif is_executable(node.path .. node.name) then
|
||||||
|
highlight('LuaTreeExecFile', line, 0, -1)
|
||||||
|
elseif is_pic(node.path .. node.name) then
|
||||||
|
highlight('LuaTreeImageFile', line, 0, -1)
|
||||||
else
|
else
|
||||||
for k, v in pairs(HIGHLIGHT_GROUPS) do
|
for k, v in pairs(HIGHLIGHT_GROUPS) do
|
||||||
if string.match(node.name, k) ~= nil then
|
if string.match(node.name, k) ~= nil then
|
||||||
|
|||||||
@ -9,12 +9,15 @@ let g:loaded_netrwPlugin = 1 " Disable netrw
|
|||||||
hi def link LuaTreePopup Normal
|
hi def link LuaTreePopup Normal
|
||||||
hi def LuaTreeEndOfBuffer guifg=bg
|
hi def LuaTreeEndOfBuffer guifg=bg
|
||||||
|
|
||||||
execute 'hi def LuaTreeFolderName guifg='.g:terminal_color_4.' gui=bold'
|
execute 'hi def LuaTreeFolderName gui=bold guifg='.g:terminal_color_4
|
||||||
execute 'hi def LuaTreeFolderIcon guifg='.g:terminal_color_11
|
execute 'hi def LuaTreeFolderIcon guifg='.g:terminal_color_11
|
||||||
|
|
||||||
|
execute 'hi def LuaTreeExecFile gui=bold guifg='.g:terminal_color_2
|
||||||
|
execute 'hi def LuaTreeSpecialFile gui=bold,underline guifg='.g:terminal_color_3
|
||||||
|
execute 'hi def LuaTreeImageFile gui=bold guifg='.g:terminal_color_5
|
||||||
|
|
||||||
execute 'hi def LuaTreeLicenseFile guifg='.g:terminal_color_3
|
execute 'hi def LuaTreeLicenseFile guifg='.g:terminal_color_3
|
||||||
execute 'hi def LuaTreeMarkdownFile guifg='.g:terminal_color_5
|
execute 'hi def LuaTreeMarkdownFile guifg='.g:terminal_color_5
|
||||||
execute 'hi def LuaTreeImageFile guifg='.g:terminal_color_5
|
|
||||||
execute 'hi def LuaTreeYamlFile guifg='.g:terminal_color_3
|
execute 'hi def LuaTreeYamlFile guifg='.g:terminal_color_3
|
||||||
execute 'hi def LuaTreeTomlFile guifg='.g:terminal_color_3
|
execute 'hi def LuaTreeTomlFile guifg='.g:terminal_color_3
|
||||||
execute 'hi def LuaTreeGitignoreFile guifg='.g:terminal_color_3
|
execute 'hi def LuaTreeGitignoreFile guifg='.g:terminal_color_3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user