refactor: remove vim.g.oil declarative config
Problem: the `vim.g.oil` configuration path was added prematurely.
It adds a second config entrypoint before the plugin has stabilized
enough to justify it.
Solution: remove `vim.g.oil` support from `plugin/oil.lua`,
`config.setup()`, docs, and tests. Users configure via
`require("oil").setup({})`.
This commit is contained in:
parent
8dd67f91e8
commit
14bb77d842
6 changed files with 119 additions and 146 deletions
4
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
4
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
|
|
@ -70,8 +70,8 @@ body:
|
||||||
spec = {
|
spec = {
|
||||||
{
|
{
|
||||||
'barrettruth/canola.nvim',
|
'barrettruth/canola.nvim',
|
||||||
init = function()
|
config = function()
|
||||||
vim.g.oil = {}
|
require('oil').setup({})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
15
doc/oil.txt
15
doc/oil.txt
|
|
@ -48,25 +48,12 @@ REQUIREMENTS *oil-requirement
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
CONFIG *oil-config*
|
CONFIG *oil-config*
|
||||||
|
|
||||||
Oil can be configured in two ways:
|
Configure oil via `setup()`: >lua
|
||||||
|
|
||||||
1. The traditional `setup()` call: >lua
|
|
||||||
require("oil").setup({
|
require("oil").setup({
|
||||||
-- your opts here
|
-- your opts here
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
|
|
||||||
2. Declarative configuration via `vim.g.oil`, which does not require calling
|
|
||||||
`setup()`: >lua
|
|
||||||
vim.g.oil = {
|
|
||||||
-- your opts here
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
When `vim.g.oil` is set, oil initializes automatically during plugin
|
|
||||||
loading. If `setup()` is called with explicit opts, those take precedence
|
|
||||||
over `vim.g.oil`.
|
|
||||||
|
|
||||||
The full list of options with their defaults:
|
The full list of options with their defaults:
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ issues against this fork.
|
||||||
## Issues
|
## Issues
|
||||||
|
|
||||||
| Issue | Description | Status |
|
| Issue | Description | Status |
|
||||||
| ------------------------------------------------------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
| ------------------------------------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||||
| [#85](https://github.com/stevearc/oil.nvim/issues/85) | Git status column | open |
|
| [#85](https://github.com/stevearc/oil.nvim/issues/85) | Git status column | open |
|
||||||
| [#95](https://github.com/stevearc/oil.nvim/issues/95) | Undo after renaming files | open |
|
| [#95](https://github.com/stevearc/oil.nvim/issues/95) | Undo after renaming files | open |
|
||||||
| [#117](https://github.com/stevearc/oil.nvim/issues/117) | Move file into new dir via slash in name | open |
|
| [#117](https://github.com/stevearc/oil.nvim/issues/117) | Move file into new dir via slash in name | open |
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@ local M = {}
|
||||||
---@field border? string|string[] Window border
|
---@field border? string|string[] Window border
|
||||||
|
|
||||||
M.setup = function(opts)
|
M.setup = function(opts)
|
||||||
opts = opts or vim.g.oil or {}
|
opts = opts or {}
|
||||||
|
|
||||||
local new_conf = vim.tbl_deep_extend('keep', opts, default_config)
|
local new_conf = vim.tbl_deep_extend('keep', opts, default_config)
|
||||||
if not new_conf.use_default_keymaps then
|
if not new_conf.use_default_keymaps then
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
if vim.g.oil ~= nil then
|
|
||||||
require('oil').setup()
|
|
||||||
end
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,15 @@
|
||||||
local config = require('oil.config')
|
local config = require('oil.config')
|
||||||
|
|
||||||
describe('config', function()
|
describe('config', function()
|
||||||
after_each(function()
|
it('uses defaults when setup() is called with no args', function()
|
||||||
vim.g.oil = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('falls back to vim.g.oil when setup() is called with no args', function()
|
|
||||||
vim.g.oil = { delete_to_trash = true, cleanup_delay_ms = 5000 }
|
|
||||||
config.setup()
|
|
||||||
assert.is_true(config.delete_to_trash)
|
|
||||||
assert.equals(5000, config.cleanup_delay_ms)
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('uses defaults when neither opts nor vim.g.oil is set', function()
|
|
||||||
vim.g.oil = nil
|
|
||||||
config.setup()
|
config.setup()
|
||||||
assert.is_false(config.delete_to_trash)
|
assert.is_false(config.delete_to_trash)
|
||||||
assert.equals(2000, config.cleanup_delay_ms)
|
assert.equals(2000, config.cleanup_delay_ms)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('prefers explicit opts over vim.g.oil', function()
|
it('applies explicit opts', function()
|
||||||
vim.g.oil = { delete_to_trash = true }
|
config.setup({ delete_to_trash = true, cleanup_delay_ms = 5000 })
|
||||||
config.setup({ delete_to_trash = false })
|
assert.is_true(config.delete_to_trash)
|
||||||
assert.is_false(config.delete_to_trash)
|
assert.equals(5000, config.cleanup_delay_ms)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue