How justinmk/vim-dirvish works
Project Type and Purpose
• Dirvish is a Vim plugin (an open-source tool) that provides a filesystem navigator inside Vim.
• It’s not a client-server or full-stack app—it lives entirely in the Vim process, leveraging Vimscript, Vim’s conceal/syntax engine, buffer/arglist APIs, and occasional shell calls.
Main Components
a. Vim Core
• Buffer management, conceal, syntax engine, command/arglist infrastructure, shell (:!) support.
b. Dirvish Plugin Modules
1. plugin/dirvish.vim – plugin entrypoint; defines commands, mappings, autoload hooks.
2. autoload/dirvish.vim – pure Vimscript business logic (read directory, format lines, manage state).
3. ftplugin/dirvish.vim – filetype setup (buffer options, keybindings local to Dirvish buffers).
5. doc/dirvish.txt & README.md – user documentation.
c. File System
– Underlying filesystem from which directories are listed.
d. Shell
– Invoked via :! or :Shdo to execute batch operations.
e. External Plugins (optional)
– vim-eunuch, vim-unimpaired, dirvish-git, etc., which hook into Dirvish via exposed functions or filetype.
Relationships and Data Flows
1. User Issues a Dirvish Command or Mapping →
plugin/dirvish.vim
↓ calls
autoload/dirvish#open()
↓ reads
File System
↓ returns file list
autoload formats list → fills Vim buffer
↓ buffer rendered with
syntax/dirvish.vim (conceal) + ftplugin/dirvish.vim (keymaps)
↓ user navigates/selects → plugin invokes
arglist/global/Shdo → optionally Shell
↓ shell performs filesystem mutation or outputs script.
Architectural Patterns & Design Principles
• Modularity: clear separation between “entrypoint” (plugin/) and “logic” (autoload/).
• Filetype-driven behavior: ftplugin + syntax rules trigger automatically on set ft=dirvish.
• Minimalism: no persistent state beyond buffer contents; pure functions in autoload.
• Extensibility: autoload functions and filetype hooks serve as integration points for other plugins.