Explorer extension for coc.nvim
Note: Still under development, maybe has some breaking changes.
>= vim 8.1.0579
or >= neovim 0.3.1
- Install by coc.nvim command:
:CocInstall coc-explorer
- Configuration custom vim mapping
:nmap <space>e :CocCommand explorer<CR>
- Open explorer
<space>e
- Press
?
to show mappings help
- Buffer source
- Highlight visible buffers in real time (neovim only)
- 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 when opening explorer
- Selection
- Cut / Copy / Paste
- Delete action use trash by default
- Open file in select / vsplit / tab
- Git status
- Reveal current file in real time (neovim only)
- Icons, use nerdfont
- Search files by Coc-list
- Preview file attributes by floating window
- LSP
- diagnostic
- file rename
- Exrename, like defx
- Archive file (use
lsar / unar
) - SSH
- Basic actions
- Git source
- Git actions
- Show help
:CocCommand explorer [options] [root-uri]
:CocCommand explorer
\ --toggle
\ --sources=buffer+,file+
\ /root/path
let g:coc_explorer_global_presets = {
\ '.vim': {
\ 'root-uri': '~/.vim',
\ },
\ 'floating': {
\ 'position': 'floating',
\ },
\ 'floatingLeftside': {
\ 'position': 'floating',
\ 'floating-position': 'left-center',
\ 'floating-width': 50,
\ },
\ 'floatingRightside': {
\ 'position': 'floating',
\ 'floating-position': 'left-center',
\ 'floating-width': 50,
\ },
\ 'simplify': {
\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]'
\ }
\ }
" Use preset argument to open it
nmap <space>ed :CocCommand explorer --preset .vim<CR>
nmap <space>ef :CocCommand explorer --preset floating<CR>
" List all presets
nmap <space>el :CocList explPresets
Explorer root, default:
getcwd()
whenbuftype
isnofile
workspace.rootPath
Open explorer use presets
Close the explorer if it exists, default: --toggle
Strategy for open action, types: select | vsplit | split | tab | previousBuffer | previousWindow | sourceWindow
, default: select
quit explorer when open action, default: --no-quit-on-open
Explorer sources, example: buffer+,file+
, default: buffer-,file+
expand
collapsed │
↓ ↓
buffer-,file+
└──┬─┘ └─┬┘
buffer source │
file source
Explorer position, supported position: left
, right
, tab
, floating
, default: left
Width of Explorer window for open in left or right side, default: 40
Content width, default: 0
Type of content width, types: win-width
, vim-width
, , default: vim-width
Explorer position for floating window, positions:
left-center
center
right-center
<number for left>,<number for top>
default: center
Width of Explorer window when position is floating, use negative value or zero to as width - value
, default: 0
Height of Explorer window when position is floating, use negative value or zero to as height - value
, default: 0
Width of content when position is floating, use negative value or zero to as width - value
, default: 0
Template for root node of buffer source
Columns:
- icon
- title
default: [icon] [title]
Template for child node of buffer source
Columns:
- selection
- name
- bufname
- modified
- bufnr
- readonly
- fullpath
default: [selection | 1] [bufnr] [name][modified][readonly] [fullpath]
Template for child node of buffer source
Columns: same with --buffer-child-template
default: [name][bufname][fullpath][modified][readonly]
Template for root node of file source
Columns:
- icon
- title
- root
- fullpath
default: [icon] [title] [root] [fullpath]
Labeling template for root node of file source
Columns: same with --file-root-template
default: [fullpath]
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]
Labeling template for child node of file source
Columns: same with --file-child-template
default: [fullpath][link][diagnosticWarning][diagnosticError][size][timeAccessed][timeModified][timeCreated][readonly][modified]
Explorer will expand to this filepath, default: current buffer
Example:
[git | 2] [selection | clip | 1] [diagnosticError & 1][filename growRight 1 omitCenter 5]
[git]
- Display
git
.
- Display
[git | 2]
- If
git
is not empty, displaygit
, otherwise display2 spaces
.
- If
[selection | clip | 1]
- Checking
selection
andclip
in turn, if one is not empty, display it, otherwise display1 spaces
.
- Checking
[diagnosticError & 1]
- If
diagnosticError
is empty, display nothing. otherwise displaydiagnosticError
and1 space
.
- If
[filename growRight 1 omitCenter 5]
- Flexible to display
filename
, grow right column volume is 1, omit center volume is 5
- Flexible to display
Grammar:
column
┌─────────┴───────────┐
│ │ volume of modifier
│ ┌────┬──────│──────────┴────┬────────────┐
┌───┴───┐ ┌─┴┐ ↓ ┌──┴───┐ ↓ ↓
[selection | clip | 1] [filename growRight 1 omitCenter 5]
↑ ↑ └───┬───┘ └────┬───┘
└──────┴───────────┬──────┴────────────┘
modifier
explorer.presets
: Explorer presets. type: object
explorer.keyMappingMode
: Keymapping mode. type: none | default
Default: "default"
explorer.keyMappings
: Custom keymappings. type: object
Default: {}
explorer.toggle
: Close the explorer if it exists. type: boolean
Default: true
explorer.position
: Explorer position. type: left | right | tab | floating
Default: "left"
explorer.width
: Width of explorer window for open in left or right side. type: number
Default: 40
explorer.contentWidth
: Content width, use negative value or zero to as `width - value`. type: integer
Default: 0
explorer.contentWidthType
: Type of content width. type: win-width | vim-width
Default: "vim-width"
explorer.floating.position
: Position of Explorer for floating window. type: undefined
Default: "center"
explorer.floating.width
: Width of explorer window when position is floating, use negative value or zero to as `width - value`. type: integer
Default: -10
explorer.floating.height
: Height of explorer window when position is floating, use negative value or zero to as `height - value`. type: integer
Default: -10
explorer.floating.contentWidth
: Width of content when position is floating, use negative value or zero to as `width - value`. type: integer
Default: 0
explorer.floating.border.enable
: . type: boolean
Default: true
explorer.floating.border.chars
: Border chars for floating window, Their order is left-top, top, right-top, right, right-bottom, bottom, left-bottom, left. type: array
Default: [
"┌",
"─",
"┐",
"│",
"┘",
"─",
"└",
"│"
]
explorer.floating.border.title
: . type: string
Default: "coc-explorer"
explorer.autoExpandSingleNode
: Automatically expand next node when it's a single node. type: boolean
Default: true
explorer.autoCollapseChildren
: Automatically collapse children. type: boolean
Default: true
explorer.activeMode
: Render explorer when after open or save buffer. type: boolean
Default: true
explorer.quitOnOpen
: quit explorer when open action. type: boolean
Default: false
explorer.previewAction.strategy
: Strategy for preview action. type: labeling
Default: "labeling"
explorer.previewAction.onHover
: Open preview when hovering over on node. type: boolean
Default: true
explorer.openAction.strategy
: Strategy for open action. type: select | vsplit | split | tab | previousBuffer | previousWindow | sourceWindow
Default: "select"
explorer.openAction.select.filterFloatWindows
: Filter floating windows in select strategy. type: boolean
Default: true
explorer.openAction.select.filter
: Filter windows for select strategy. type: object
Default: {
"buftypes": [
"terminal"
],
"filetypes": [
"vista_kind",
"qf"
],
"floatingWindows": true
}
explorer.openAction.for.directory
: The action when you open a directory of file source. type: string
Default: "cd"
explorer.sources
: Explorer sources. type: array
Default: [
{
"name": "buffer",
"expand": false
},
{
"name": "file",
"expand": true
}
]
explorer.icon.enableNerdfont
: Enable nerdfont. type: boolean
Default: false
explorer.icon.customIcons
: Custom icons and color highlights. type: object
Default: {
"icons": {},
"extensions": {},
"filenames": {},
"dirnames": {},
"patternMatches": {},
"dirPatternMatches": {}
}
explorer.icon.enableVimDevicons
: Enable use vim-devicons instead of built-in icon configuration. type: boolean
Default: false
explorer.icon.expanded
: Icon for expanded node. type: string
Default: "-"
explorer.icon.collapsed
: Icon for collapsed node. type: string
Default: "+"
explorer.icon.selected
: Selection selected chars for File source. type: string
Default: "✓"
explorer.icon.hidden
: Icon for hidden status. type: string
Default: "I"
explorer.buffer.showHiddenBuffers
: Default show hidden buffers. type: boolean
Default: false
explorer.buffer.tabOnly
: Default only show buffers in current tab. type: boolean
Default: false
explorer.buffer.root.template
: Template for root node of buffer source. type: string
Default: "[icon] [title]"
explorer.buffer.child.template
: Template for child node of buffer source. type: string
Default: "[selection | 1] [bufnr] [name][modified][readonly] [fullpath]"
explorer.buffer.child.labelingTemplate
: Labeling template for child node of buffer source. type: string
Default: "[name][bufname][fullpath][modified][readonly]"
explorer.datetime.format
: Explorer datetime format, check out https://date-fns.org/v2.9.0/docs/format. type: string
Default: "yy/MM/dd HH:mm:ss"
explorer.file.autoReveal
: Explorer will automatically expand to the current buffer. type: boolean
Default: true
explorer.file.diagnosticCountMax
: Maximum count of diagnostic column. type: number
Default: 99
explorer.file.hiddenRules
: Custom hidden rules for file. type: object
Default: {
"extensions": [
"o",
"a",
"obj",
"pyc"
],
"filenames": [],
"patternMatches": [
"^\\."
]
}
explorer.file.showHiddenFiles
: Default show hidden files. type: boolean
Default: false
explorer.file.root.template
: Template for root node of file source. type: string
Default: "[icon] [title] [root] [fullpath]"
explorer.file.root.labelingTemplate
: Labeling template for root node of file source. type: string
Default: "[fullpath]"
explorer.file.child.template
: Template for child node file source. type: string
Default: "[git | 2] [selection | clip | 1] [indent][icon | 1] [diagnosticError & 1][filename omitCenter 1][modified][readonly] [linkIcon & 1][link growRight 1 omitCenter 5][size]"
explorer.file.child.labelingTemplate
: Labeling template for child node of file source. type: string
Default: "[fullpath][link][diagnosticWarning][diagnosticError][size][timeAccessed][timeModified][timeCreated][readonly][modified]"
explorer.file.column.git.showIgnored
: Show ignored files in git column. type: boolean
Default: false
explorer.file.column.git.icon.mixed
: Icon for git mixed status. type: string
Default: "*"
explorer.file.column.git.icon.unmodified
: Icon for git unmodified status. type: string
Default: " "
explorer.file.column.git.icon.modified
: Icon for git modified status. type: string
Default: "M"
explorer.file.column.git.icon.added
: Icon for git added status. type: string
Default: "A"
explorer.file.column.git.icon.deleted
: Icon for git removed status. type: string
Default: "D"
explorer.file.column.git.icon.renamed
: Icon for git renamed status. type: string
Default: "R"
explorer.file.column.git.icon.copied
: Icon for git copied status. type: string
Default: "C"
explorer.file.column.git.icon.unmerged
: Icon for git unmerged status. type: string
Default: "U"
explorer.file.column.git.icon.untracked
: Icon for git untracked status. type: string
Default: "?"
explorer.file.column.git.icon.ignored
: Icon for git ignored status. type: string
Default: "!"
explorer.file.column.clip.copy
: Whether the file has been copied. type: string
explorer.file.column.clip.cut
: Whether the file has been cut. type: string
explorer.file.column.indent.chars
: Indent chars for file source. type: string
Default: " "
explorer.file.column.indent.indentLine
: Whether to display the alignment line. type: boolean
explorer.file.tabCD
: Change tab directory when performing the cd action. type: boolean
Default: true
explorer.git.command
: Git command. type: string
Default: "git"
explorer.debug
: Enable debug. type: boolean
Default: false
// coc-settings.json
{
"explorer.keyMappings": {
"i": false, // cancel default mapkey
"k": "nodePrev",
"j": "nodeNext",
"gk": "expandablePrev",
"gj": "expandableNext",
"*": "toggleSelection",
"<tab>": "actionMenu",
"h": "collapse",
"l": ["expandable?", "expand", "open"],
"J": ["toggleSelection", "nodeNext"],
"K": ["toggleSelection", "nodePrev"],
"gl": "expandRecursive",
"gh": "collapseRecursive",
"o": "expandOrCollapse",
"<cr>": ["expandable?", "cd", "open"],
"e": "open",
"s": "open:split",
"S": "open:split:plain",
"E": "open:vsplit",
"t": "open:tab",
"<bs>": "gotoParent",
"gp": "preview:labeling",
"y": "copyFilepath",
"Y": "copyFilename",
"c": "copyFile",
"x": "cutFile",
"p": "pasteFile",
"d": "delete",
"D": "deleteForever",
"a": "addFile",
"A": "addDirectory",
"r": "rename",
".": "toggleHidden",
"R": "refresh",
"?": "help",
"q": "quit",
"<esc>": "esc",
"X": "systemExecute",
"gd": "listDrive",
"f": "search",
"F": "searchRecursive",
"gf": "gotoSource:file",
"gb": "gotoSource:buffer",
"[[": "sourcePrev",
"]]": "sourceNext",
"[d": "diagnosticPrev",
"]d": "diagnosticNext",
"[c": "gitPrev",
"]c": "gitNext",
"<<": "gitStage",
">>": "gitUnstage"
}
}
- VSCode Explorer
- Shougo/vimfiler.vim
- Shougo/defx.nvim
- lambdalisue/fern.vim