Config restructure: flatten and modernize the option surface #33
Labels
No labels
autorelease: pending
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream/digest
upstream/pr
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
barrettruth/canola.nvim#33
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The config inherited from oil.nvim is deeply nested, has mixed concerns, function-valued fields that prevent declarative `vim.g.canola` configuration, and redundant/confusing boolean pairs. v1.0.0 is a clean break — every setting gets reconsidered.
Finalized Spec
Type Definitions
```lua
---@alias canola.SortPreset
---|'"default"' -- { { 'type', 'asc' }, { 'name', 'asc' } }
---|'"name"' -- { { 'name', 'asc' } }
---|'"modified"' -- { { 'mtime', 'desc' }, { 'name', 'asc' } }
---|'"size"' -- { { 'size', 'desc' }, { 'name', 'asc' } }
---|'"extension"' -- { { 'name', 'asc' } } grouped by ext
---@alias canola.ConfirmMode
---| true -- confirm all mutations
---| '"delete"' -- only confirm deletes
---| false -- confirm nothing
---@alias canola.SaveMode
---| '"prompt"' -- prompt before writing mutations on select
---| '"auto"' -- write silently
---| false -- don't write
---@alias canola.WindowDimension number|{ [1]: number, [2]: number }
---@class (exact) canola.SortSpec
---@field [1] string
---@field [2] "asc"|"desc"
---@class (exact) canola.SortConfig
---@field by canola.SortPreset|canola.SortSpec[]
---@field natural? boolean --- default: true
---@field ignore_case? boolean --- default: false
---@class (exact) canola.HiddenConfig
---@field patterns string[] --- Lua patterns matched against filename
---@field always string[] --- never shown, even with show_hidden
---@class (exact) canola.DeleteConfig
---@field wipe_buffers boolean
---@class (exact) canola.CreateConfig
---@field file_mode integer --- decimal (420 = 0644)
---@field dir_mode integer --- decimal (493 = 0755)
---@class (exact) canola.LspConfig
---@field enabled boolean
---@field timeout_ms integer
---@field autosave boolean|"unmodified"
---@class (exact) canola.FloatConfig
---@field default boolean
---@field padding integer
---@field max_width integer --- 0 = auto
---@field max_height integer --- 0 = auto
---@field border? string|string[] --- overrides global border
---@field preview_split "auto"|"left"|"right"|"above"|"below"
---@field win_options table<string, any>
---@class (exact) canola.PreviewConfig
---@field follow boolean --- update on cursor move
---@field live boolean --- false=scratch, true=full buffer load
---@field max_file_size_mb number
---@field disable string[] --- Lua patterns to skip preview
---@field win_options table<string, any>
---@class (exact) canola.ConfirmationConfig
---@field max_width canola.WindowDimension
---@field min_width canola.WindowDimension
---@field width? number
---@field max_height canola.WindowDimension
---@field min_height canola.WindowDimension
---@field height? number
---@field border? string|string[] --- overrides global border
---@field win_options table<string, any>
---@class (exact) canola.Config
---@field columns canola.ColumnSpec[]
---@field cursor boolean
---@field watch boolean
---@field border? string|string[]
---@field show_hidden boolean
---@field hidden canola.HiddenConfig
---@field sort canola.SortPreset|canola.SortConfig
---@field highlights { [1]: string, [2]: string }[]
---@field confirm canola.ConfirmMode
---@field save canola.SaveMode
---@field delete canola.DeleteConfig
---@field create canola.CreateConfig
---@field keymaps table<string, string|table|false>
---@field lsp canola.LspConfig
---@field float canola.FloatConfig
---@field preview canola.PreviewConfig
---@field confirmation canola.ConfirmationConfig
---@field buf_options table<string, any>
---@field win_options table<string, any>
```
Defaults
```lua
local default_config = {
columns = { 'icon' },
cursor = true,
watch = false,
border = nil,
show_hidden = false,
hidden = {
patterns = { '^%.' },
always = {},
},
sort = 'default',
highlights = {},
confirm = true,
save = 'prompt',
delete = {
wipe_buffers = false,
},
create = {
file_mode = 420,
dir_mode = 493,
},
keymaps = {
['g?'] = { 'actions.show_help', mode = 'n' },
[''] = 'actions.select',
[''] = { 'actions.select', opts = { vertical = true } },
[''] = { 'actions.select', opts = { horizontal = true } },
[''] = { 'actions.select', opts = { tab = true } },
[''] = 'actions.preview',
[''] = { 'actions.close', mode = 'n' },
[''] = 'actions.refresh',
['-'] = { 'actions.parent', mode = 'n' },
['_'] = { 'actions.open_cwd', mode = 'n' },
['`'] = { 'actions.cd', mode = 'n' },
['g~'] = { 'actions.cd', opts = { scope = 'tab' }, mode = 'n' },
['gs'] = { 'actions.change_sort', mode = 'n' },
['gx'] = 'actions.open_external',
['g.'] = { 'actions.toggle_hidden', mode = 'n' },
['g\'] = { 'actions.toggle_trash', mode = 'n' },
},
lsp = {
enabled = true,
timeout_ms = 1000,
autosave = false,
},
float = {
default = false,
padding = 2,
max_width = 0,
max_height = 0,
border = nil,
preview_split = 'auto',
win_options = { winblend = 0 },
},
preview = {
follow = true,
live = false,
max_file_size_mb = 10,
disable = {},
win_options = {},
},
confirmation = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = 0.9,
min_height = { 5, 0.1 },
height = nil,
border = nil,
win_options = { winblend = 0 },
},
buf_options = {
buflisted = false,
bufhidden = 'hide',
},
win_options = {
wrap = false,
signcolumn = 'no',
cursorcolumn = false,
foldcolumn = '0',
spell = false,
list = false,
conceallevel = 3,
concealcursor = 'nvic',
},
}
```
Sort Presets
Sort accepts a preset string or full config table:
```lua
sort = 'modified'
sort = { by = 'modified', natural = true, ignore_case = false }
sort = { by = { { 'type', 'asc' }, { 'name', 'asc' } }, natural = true }
```
Highlights
Pattern-based filename highlighting. Array of `{ lua_pattern, highlight_group }` pairs, first match wins. Built-in highlights (`CanolaHidden`, `CanolaExecutable`, `CanolaOrphanLink`) apply as base layer; user patterns override.
```lua
highlights = {
{ '%.lua$', 'CanolaLua' },
{ '%.md$', 'CanolaMarkdown' },
{ '^Makefile$', 'CanolaMakefile' },
}
```
Migration Map
Adapter Config
Each canola-collection adapter owns its config in a separate `vim.g` variable:
Design Principles
Relationship to Other Issues