0.26.6 • Published 9 months ago

coc-explorer v0.26.6

Weekly downloads
1,716
License
MIT
Repository
github
Last release
9 months ago

coc-explorer

Explorer extension for coc.nvim

Note: This project is still under development and may be broken.

Build Status

Screenshot

image

Requirements

>= vim 8.1.1418 or >= neovim 0.3.1

Usage

  1. Install by coc.nvim command:
    :CocInstall coc-explorer
  2. Configuration custom vim mapping
    :nmap <space>e <Cmd>CocCommand explorer<CR>
  3. Open explorer
    <space>e
  4. Press ? to show mappings help

More at Quickstart

Feature

  • Buffer source
    • Highlight visible buffers in real time
  • File tree source
    • Basic actions
      • Open file in select / vsplit / tab explorer.openAction.strategy options:
        • select: Open action use selection UI
        • vsplit: Open action use vsplit
        • split: Open action use split
        • tab: Open action use tab
        • previousBuffer: Open action use last used buffer
        • previousWindow: Open action use last used window
        • sourceWindow: Open action use the window where explorer opened
      • Selection
      • Cut / Copy / Paste
      • Delete action use trash by default
      • Other actions, press ? in explorer to check out the all actions
    • Git status
    • Automatically reveal the current file
    • Icons, use nerdfont
    • Search files by Coc-list
    • Preview file attributes by floating window
    • LSP
      • diagnostic
      • file rename (won't support, use watchman)
    • Exrename, like defx
    • Archive file (use lsar / unar)
    • SSH
  • Bookmark source (DEPRECATED) (require coc-bookmark)
  • Git source
    • Git actions
  • Show help

Command

:CocCommand explorer [options] [root-uri]

User events

  • CocExplorerOpenPre: triggered before open explorer
  • CocExplorerOpenPost: triggered after open explorer
  • CocExplorerQuitPre: triggered before quit explorer
  • CocExplorerQuitPost: triggered after quit explorer

Example

:CocCommand explorer
    \ --toggle
    \ --sources=buffer+,file+
    \ /root/path

Reveal to current buffer for closest coc-explorer

nmap <Leader>er <Cmd>call CocAction('runCommand', 'explorer.doAction', 'closest', ['reveal:0'], [['relative', 0, 'file']])<CR>

Presets

let g:coc_explorer_global_presets = {
\   '.vim': {
\     'root-uri': '~/.vim',
\   },
\   'cocConfig': {
\      'root-uri': '~/.config/coc',
\   },
\   'tab': {
\     'position': 'tab',
\     'quit-on-open': v:true,
\   },
\   'tab:$': {
\     'position': 'tab:$',
\     'quit-on-open': v:true,
\   },
\   'floating': {
\     'position': 'floating',
\     'open-action-strategy': 'sourceWindow',
\   },
\   'floatingTop': {
\     'position': 'floating',
\     'floating-position': 'center-top',
\     'open-action-strategy': 'sourceWindow',
\   },
\   'floatingLeftside': {
\     'position': 'floating',
\     'floating-position': 'left-center',
\     'floating-width': 50,
\     'open-action-strategy': 'sourceWindow',
\   },
\   'floatingRightside': {
\     'position': 'floating',
\     'floating-position': 'right-center',
\     'floating-width': 50,
\     'open-action-strategy': 'sourceWindow',
\   },
\   'simplify': {
\     'file-child-template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]'
\   },
\   'buffer': {
\     'sources': [{'name': 'buffer', 'expand': v:true}]
\   },
\ }

" Use preset argument to open it
nmap <space>ed <Cmd>CocCommand explorer --preset .vim<CR>
nmap <space>ef <Cmd>CocCommand explorer --preset floating<CR>
nmap <space>ec <Cmd>CocCommand explorer --preset cocConfig<CR>
nmap <space>eb <Cmd>CocCommand explorer --preset buffer<CR>

" List all presets
nmap <space>el <Cmd>CocList explPresets<CR>

Options

[root-uri]

Explorer root, default is use root-strategies

--root-strategies <root-strategies>

Strategies for root uri, types list of (keep | workspace | cwd | sourceBuffer | reveal | custom:name)

  • keep: never change the root path
  • workspace: workspace.root
  • cwd: getcwd()
  • sourceBuffer: directory of buffer
  • reveal: directory of reveal path

default is: workspace,cwd,sourceBuffer,reveal or "explorer.root.strategies" of coc-settings

Custom root patterns settings

{
  "explorer.root.customRules": {
    "vcs": {
      "patterns": [".git", ".hg", ".projections.json"]
    },
    "vcs-r": {
      "patterns": [".git", ".hg", ".projections.json"],
      "bottomUp": true
    }
  }
}

Using custom root patterns

{
  "explorer.root.strategies": ["workspace", "custom:vcs", "custom:vcs-r"]
}

or :CocCommand explorer --root-strategies workspace,custom:vcs,custom:vcs-r

--preset <name>

Open explorer use presets

--toggle | --no-toggle

Close the explorer if it exists, default: --toggle

--focus | --no-focus

Focus to explorer when opened, default: --focus

--open-action-strategy <strategy>

Strategy for open action, types: select | vsplit | split | tab | previousBuffer | previousWindow | sourceWindow, default: select

--quit-on-open | --no-quit-on-open

quit explorer when open action, default: --no-quit-on-open

--sources <sources>

Explorer sources, example: buffer+,file+, default: buffer-,file+

              expand
      collapsed │
          ↓     ↓
    buffer-,file+
    └──┬─┘  └─┬┘
buffer source │
          file source

--position <position>

Explorer position, supported position: left, right, tab, tab:0, tab:$, floating, default: left

--width <number>

Width of Explorer window for open in left or right side, default: 40

--content-width <number>

Content width, default: 0

--content-width-type <type>

Type of content width, types: win-width, vim-width, , default: vim-width

--floating-position <position>

Explorer position for floating window, positions:

  • left-center
  • center
  • right-center
  • center-top
  • <number for left>,<number for top>

default: center

--floating-width <number>

Width of Explorer window when position is floating, use negative value or zero to as width - value, default: 0

--floating-height <number>

Height of Explorer window when position is floating, use negative value or zero to as height - value, default: 0

--floating-content-width <number>

Width of content when position is floating, use negative value or zero to as width - value, default: 0

--buffer-root-template <template>

Template for root node of buffer source

Columns:

  • icon
  • hidden
  • title

default: [icon] [title] [hidden & 1]

--buffer-child-template <template>

Template for child node of buffer source

Columns:

  • selection
  • name
  • bufname
  • modified
  • bufnr
  • readonly
  • fullpath

default: [selection | 1] [bufnr] [name][modified][readonly] [fullpath]

--buffer-child-labeling-template <template>

Labeling template for child node of buffer source, use for preview when previewAction is labeling

Columns: same with --buffer-child-template

default: [name][bufname][fullpath][modified][readonly]

--file-root-template <template>

Template for root node of file source

Columns:

  • icon
  • hidden
  • title
  • root
  • fullpath

default: [icon] [title] [hidden & 1][root] [fullpath]

--file-root-labeling-template <template>

Labeling template for root node of file source, use for preview when previewAction is labeling

Columns: same with --file-root-template

default: [fullpath]

--file-child-template <template>

Template for child node file source

Columns:

  • git
  • selection
  • icon
  • filename
  • linkIcon
  • link
  • fullpath
  • indent
  • clip
  • size
  • readonly
  • modified
  • timeModified
  • timeCreated
  • timeAccessed
  • diagnosticError
  • diagnosticWarning

default: [git | 2] [selection | clip | 1] [indent][icon | 1] [diagnosticError & 1][filename omitCenter 1][modified][readonly] [linkIcon & 1][link growRight 1 omitCenter 5][size]

--file-child-labeling-template <template>

Labeling template for child node of file source, use for preview when previewAction is labeling

Columns: same with --file-child-template

default: [fullpath][link][diagnosticWarning][diagnosticError][size][timeAccessed][timeModified][timeCreated][readonly][modified]

--bookmark-root-template <template>

Template for root node of bookmark source

Columns:

  • icon
  • hidden
  • title

default: [icon] [title] [hidden & 1]

--bookmark-child-template <template>

Template for child node of bookmark source

Columns:

  • selection
  • position
  • filename
  • fullpath
  • line
  • annotation

default: [selection | 1] [filename] [position]

--bookmark-child-labeling-template <template>

Labeling template for child node of bookmark source, use for preview when previewAction is labeling

Columns: same with --bookmark-child-template

default: [filename][fullpath][position][line][annotation]

--reveal <filepath>

Explorer will expand to this filepath, default: current buffer

--reveal-when-open | --no-reveal-when-open

Explorer will automatically reveal to the current buffer when open explorer, default: "explorer.file.reveal.whenOpen"

Template grammar

Example:

[git | 2] [selection | clip | 1] [diagnosticError & 1][filename growRight 1 omitCenter 5]
  • [git]
    • Display git.
  • [git | 2]
    • If git is not empty, display git, otherwise display 2 spaces.
  • [selection | clip | 1]
    • Checking selection and clip in turn, if one is not empty, display it, otherwise display 1 spaces.
  • [diagnosticError & 1]
    • If diagnosticError is empty, display nothing. otherwise display diagnosticError and 1 space.
  • [filename growRight 1 omitCenter 5]
    • Flexible to display filename, grow right column volume is 1, omit center volume is 5

Grammar:

                      block
         ┌──────────────┴───────────────┐
┌────────┴───────────┐ ┌────────────────┴────────────────┐
[selection | clip | 1] [filename growRight 1 omitCenter 5]
                      ↑
                 plain string

            column
     ┌─────────┴───────────┐
     │                     │   volume of modifier
     │         ┌────┬──────│──────────┴────┬────────────┐
 ┌───┴───┐   ┌─┴┐   ↓   ┌──┴───┐           ↓            ↓
[selection | clip | 1] [filename growRight 1 omitCenter 5]
           ↑      ↑              └───┬───┘   └────┬───┘
           └──────┴───────────┬──────┴────────────┘
                           modifier

Custom mappings example

You can use ? to view all actions of current source

// coc-settings.json
{
  "explorer.keyMappings.global": {
    "i": false, // cancel default mapkey
    "<c-o>": "noop",

    "*": "toggleSelection",
    "<tab>": "actionMenu",

    "gk": ["wait", "expandablePrev"],
    "gj": ["wait", "expandableNext"],
    "h": ["wait", "collapse"],
    "l": ["wait", "expandable?", "expand", "open"],
    "J": ["wait", "toggleSelection", "normal:j"],
    "K": ["wait", "toggleSelection", "normal:k"],
    "gl": ["wait", "expand:recursive"],
    "gh": ["wait", "collapse:recursive"],
    "<2-LeftMouse>": [
      "expandable?",
      ["expanded?", "collapse", "expand"],
      "open"
    ],
    "o": ["wait", "expanded?", "collapse", "expand"],
    "<cr>": ["wait", "expandable?", "cd", "open"],
    "e": "open",
    "s": "open:split",
    "E": "open:vsplit",
    "t": "open:tab",
    "<bs>": ["wait", "gotoParent"],
    "gs": ["wait", "reveal:select"],
    "il": "preview:labeling",
    "ic": "preview:content",
    "Il": "previewOnHover:toggle:labeling",
    "Ic": "previewOnHover:toggle:content",
    "II": "previewOnHover:disable",

    "yp": "copyFilepath",
    "yn": "copyFilename",
    "yy": "copyFile",
    "dd": "cutFile",
    "p": "pasteFile",
    "df": "delete",
    "dF": "deleteForever",

    "a": "addFile",
    "A": "addDirectory",
    "r": "rename",

    "zh": "toggleHidden",
    "g<dot>": "toggleHidden",
    "R": "refresh",

    "?": "help",
    "q": "quit",
    "<esc>": "esc",
    "X": "systemExecute",
    "gd": "listDrive",

    "f": "search",
    "F": "searchRecursive",

    "gf": "gotoSource:file",
    "gb": "gotoSource:buffer",

    "[[": ["wait", "sourcePrev"],
    "]]": ["wait", "sourceNext"],

    "[i": ["wait", "indentPrev"],
    "]i": ["wait", "indentNext"],

    "[m": ["wait", "markPrev:modified"],
    "]m": ["wait", "markNext:modified"],

    "[d": ["wait", "markPrev:diagnosticError:diagnosticWarning"],
    "]d": ["wait", "markNext:diagnosticError:diagnosticWarning"],
    "[D": ["wait", "markPrev:diagnosticError"],
    "]D": ["wait", "markNext:diagnosticError"],

    "[c": ["wait", "markPrev:git"],
    "]c": ["wait", "markNext:git"],
    "<<": "gitStage",
    ">>": "gitUnstage"
  }
}

WIKI

FAQ

Example by Vim API and event hooks

function! s:explorer_cur_dir()
  let node_info = CocAction('runCommand', 'explorer.getNodeInfo', 0)
  return fnamemodify(node_info['fullpath'], ':h')
endfunction

function! s:exec_cur_dir(cmd)
  let dir = s:explorer_cur_dir()
  execute 'cd ' . dir
  execute a:cmd
endfunction

function! s:init_explorer()
  set winblend=10

  " Integration with other plugins

  " CocList
  nmap <buffer> <Leader>fg <Cmd>call <SID>exec_cur_dir('CocList -I grep')<CR>
  nmap <buffer> <Leader>fG <Cmd>call <SID>exec_cur_dir('CocList -I grep -regex')<CR>
  nmap <buffer> <C-p> <Cmd>call <SID>exec_cur_dir('CocList files')<CR>

  " vim-floaterm
  nmap <buffer> <Leader>ft <Cmd>call <SID>exec_cur_dir('FloatermNew --wintype=floating')<CR>
endfunction

function! s:enter_explorer()
  if &filetype == 'coc-explorer'
    " statusline
    setl statusline=coc-explorer
  endif
endfunction

augroup CocExplorerCustom
  autocmd!
  autocmd BufEnter * call <SID>enter_explorer()
  autocmd FileType coc-explorer call <SID>init_explorer()
augroup END

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

Settings

Commands

Configuration

Definitions

Inspired by

0.26.6

9 months ago

0.26.5

11 months ago

0.26.4

1 year ago

0.26.3

1 year ago

0.26.2

1 year ago

0.26.1

1 year ago

0.26.0

1 year ago

0.25.4

1 year ago

0.25.3

1 year ago

0.25.2

1 year ago

0.25.1

2 years ago

0.25.0

2 years ago

0.24.4

2 years ago

0.22.11

2 years ago

0.22.10

2 years ago

0.23.1

2 years ago

0.23.0

2 years ago

0.24.3

2 years ago

0.24.2

2 years ago

0.24.1

2 years ago

0.24.0

2 years ago

0.22.9

2 years ago

0.22.8

2 years ago

0.21.5

2 years ago

0.21.4

2 years ago

0.21.3

2 years ago

0.21.2

2 years ago

0.21.1

2 years ago

0.21.0

2 years ago

0.22.7

2 years ago

0.22.6

2 years ago

0.22.5

2 years ago

0.22.4

2 years ago

0.22.3

2 years ago

0.22.2

2 years ago

0.22.1

2 years ago

0.22.0

2 years ago

0.20.2

2 years ago

0.20.1

2 years ago

0.20.0

2 years ago

0.19.1

2 years ago

0.19.0

3 years ago

0.18.19

3 years ago

0.18.18

3 years ago

0.18.17

3 years ago

0.18.16

3 years ago

0.18.15

3 years ago

0.18.13

3 years ago

0.18.14

3 years ago

0.18.12

3 years ago

0.18.11

3 years ago

0.18.9

3 years ago

0.18.10

3 years ago

0.18.7

3 years ago

0.18.8

3 years ago

0.18.6

3 years ago

0.18.5

3 years ago

0.18.4

3 years ago

0.18.1

3 years ago

0.18.2

3 years ago

0.18.3

3 years ago

0.18.0

3 years ago

0.17.3

3 years ago

0.17.4

3 years ago

0.17.5

3 years ago

0.17.2

3 years ago

0.17.1

3 years ago

0.17.0

3 years ago

0.16.0

3 years ago

0.15.8

3 years ago

0.15.7

3 years ago

0.15.6

3 years ago

0.15.4

3 years ago

0.15.5

3 years ago

0.15.3

3 years ago

0.15.2

3 years ago

0.15.1

3 years ago

0.15.0

3 years ago

0.14.1

3 years ago

0.14.0

3 years ago

0.13.11

3 years ago

0.13.9

3 years ago

0.13.10

3 years ago

0.13.8

3 years ago

0.13.7

3 years ago

0.13.6

3 years ago

0.13.5

3 years ago

0.13.4

3 years ago

0.13.3

3 years ago

0.13.2

3 years ago

0.13.1

3 years ago

0.13.0

3 years ago

0.12.1

3 years ago

0.12.0

3 years ago

0.11.4

3 years ago

0.11.3

3 years ago

0.11.2

3 years ago

0.11.1

3 years ago

0.11.0

3 years ago

0.10.3

3 years ago

0.10.4

3 years ago

0.10.2

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.31

4 years ago

0.7.30

4 years ago

0.7.29

4 years ago

0.7.28

4 years ago

0.7.27

4 years ago

0.7.26

4 years ago

0.7.25

4 years ago

0.7.24

4 years ago

0.7.23

4 years ago

0.7.22

4 years ago

0.7.21

4 years ago

0.7.20

4 years ago

0.7.19

4 years ago

0.7.18

4 years ago

0.7.17

4 years ago

0.7.16

4 years ago

0.7.15

4 years ago

0.7.14

4 years ago

0.7.13

4 years ago

0.7.12

4 years ago

0.7.11

4 years ago

0.7.10

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.17

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.9

4 years ago

0.3.10

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.30

5 years ago

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago