weirongxu / coc-explorer

📁 Explorer for coc.nvim
MIT License
1.15k stars 45 forks source link

How to work with long file names #365

Open tomaskallup opened 3 years ago

tomaskallup commented 3 years ago

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

weirongxu commented 3 years ago

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

svanharmelen commented 3 years ago

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.

weirongxu commented 3 years ago

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

Use getNodeInfo Api

svanharmelen commented 3 years ago

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