coc-explorer icon indicating copy to clipboard operation
coc-explorer copied to clipboard

How to work with long file names

Open tomaskallup opened this issue 4 years ago • 4 comments

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 image

tomaskallup avatar Jan 12 '21 12:01 tomaskallup

The current simple solution is to use Il to open floating window, and use Il to close it after the finished.

weirongxu avatar Jan 13 '21 04:01 weirongxu

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.

svanharmelen avatar Jan 19 '21 09:01 svanharmelen

https://github.com/weirongxu/coc-explorer/wiki/Vim-API#explorergetnodeinfo

Use getNodeInfo Api

weirongxu avatar Jan 19 '21 09:01 weirongxu

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()

svanharmelen avatar Jan 19 '21 11:01 svanharmelen