coc-explorer
coc-explorer copied to clipboard
How to work with long file names
In our codebase, we have many layers of folders and some of the files have long names, this causes them to be cut off in coc-explorer and I'm not sure how to get around this. NerdTree had A
mapped to expand NerdTree split and then collapse it back.
I can scroll using w
and b
, but that's kind of annoying. Chaning root deeper into the structure doesn't help as the name still overflows
The current simple solution is to use Il to open floating window, and use Il to close it after the finished.
I used to have something like this when I used NERDTree (now tweaked for CoC Explorer):
function! s:ShowFilename()
redraw | echohl Debug |
\ echom match(getline('.'), '\[FILE\]') < 0 ?
\ 'CoC Explorer: ' . matchstr(getline('.'), '[0-9A-Za-z_/].*') : '' | echohl None
endfunction
autocmd CursorMoved \[coc-explorer\]* :call <SID>ShowFilename()
But it turns out it actually takes the line you see in the buffer. So if you shorted the filename with dots, it will also echo that same name including the dots.
Is it possible to somehow get the actual filename instead of using matchstr(getline('.'), '[0-9A-Za-z_/].*')
? That would be a nice solution which doesn't require you to type Il
on every line.
https://github.com/weirongxu/coc-explorer/wiki/Vim-API#explorergetnodeinfo
Use getNodeInfo Api
Works like a charm:
function! s:ShowFilename()
let s:node_info = CocAction('runCommand', 'explorer.getNodeInfo', 0)
redraw | echohl Debug | echom exists('s:node_info.fullpath') ?
\ 'CoC Explorer: ' . s:node_info.fullpath : '' | echohl None
endfunction
autocmd CursorMoved \[coc-explorer\]* :call <SID>ShowFilename()