weirongxu / coc-explorer

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

How to open explorer on the root of the project ? #459

Closed cabaalexander closed 3 years ago

cabaalexander commented 3 years ago

Now the current behavior is that when you open the explorer it will focus the current file wherever it is on your project tree.

I want for the explorer just open up showing me the tree of my project and with the explorer open if I open directories and do stuffs and I close it, it should remember how I left it the last time it was opened.

Is there an option to do such thing ? Thanks

weirongxu commented 3 years ago

You can configure the root directory using root-strategies https://github.com/weirongxu/coc-explorer#--root-strategies-root-strategies

cabaalexander commented 3 years ago

Oh, okay. So my next question is, where do I need to set up that configuration in the coc-settings.json file or in the file I have my coc-explorer presets ?

This is how my presets look (my config for coc-explorer):

" coc-explorer
autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif
let g:coc_explorer_global_presets = {
      \   'floating': {
      \      'position': 'floating',
      \      'root-strategies': 'keep',
      \   },
      \   'floatingLeftside': {
      \      'position': 'floating',
      \      'floating-position': 'left-center',
      \      'floating-width': 50,
      \   },
      \   'floatingRightside': {
      \      'position': 'floating',
      \      'floating-position': 'right-center',
      \      'floating-width': 50,
      \   }
      \ }
weirongxu commented 3 years ago

Oh, sorry I misunderstood you at first, you should be trying to diable the reveal behavior?

{
  "explorer.file.reveal.whenOpen": false
}
cabaalexander commented 3 years ago

Oh, thank you very much @weirongxu it worked like a charm. 😬 closing this.

cabaalexander commented 3 years ago

Sorry for bringing this up again but... 😅

Can this settings be activated by a flag like --reveal-when-open on mappings, an example would be this:

nnoremap <silent><leader>k :CocCommand explorer --preset floating<CR> " this wont reveal the file

nnoremap <silent><leader>K :CocCommand explorer --reveal-when-open --preset floating<CR> " this will reveal the file

I realize that sometimes I do want to reveal the file to do some action on it but not always 😅