feat: support vim.g.oil configuration + remove release-please (#17)
* feat: support vim.g.oil declarative configuration
Problem: oil.nvim requires an imperative require("oil").setup(opts)
call to initialize. The Neovim ecosystem is moving toward vim.g.plugin
as a declarative config source that works without explicit setup calls.
Solution: fall back to vim.g.oil in config.setup() when no opts are
passed, and add plugin/oil.lua to auto-initialize when vim.g.oil is
set. Explicit setup(opts) calls still take precedence. Update docs
and add tests for the new resolution order.
Closes: barrettruth/oil.nvim#1
* build: remove release-please pipeline
Problem: the release-please action creates automated releases that
are not needed for this fork's workflow.
Solution: remove the release job from tests.yml and the
release-please branch exclusion from the review request workflow.
* fix(doc): improve readme phrasing
* doc: minor phrasing "improvements"
* ci: add luarocks release on tag push
Problem: there is no automated way to publish oil.nvim to luarocks
when a new version is tagged.
Solution: add a luarocks workflow that triggers on v* tag pushes,
runs the test suite via workflow_call, then publishes via
luarocks-tag-release. Add workflow_call trigger to tests.yml so it
can be reused.
This commit is contained in:
parent
3b930636e3
commit
856716e6dc
8 changed files with 116 additions and 55 deletions
|
|
@ -4,8 +4,6 @@ permissions:
|
|||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, ready_for_review, synchronize]
|
||||
branches-ignore:
|
||||
- "release-please--**"
|
||||
|
||||
jobs:
|
||||
# Request review automatically when PRs are opened
|
||||
|
|
|
|||
21
.github/workflows/luarocks.yaml
vendored
Normal file
21
.github/workflows/luarocks.yaml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
name: luarocks
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
uses: ./.github/workflows/tests.yml
|
||||
|
||||
publish:
|
||||
needs: quality
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: nvim-neorocks/luarocks-tag-release@v7
|
||||
env:
|
||||
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
|
||||
25
.github/workflows/tests.yml
vendored
25
.github/workflows/tests.yml
vendored
|
|
@ -1,6 +1,7 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
|
@ -69,27 +70,3 @@ jobs:
|
|||
- name: Run tests
|
||||
run: |
|
||||
bash ./run_tests.sh
|
||||
|
||||
release:
|
||||
name: release
|
||||
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
needs:
|
||||
- luacheck
|
||||
- stylua
|
||||
- typecheck
|
||||
- run_tests
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: googleapis/release-please-action@v4
|
||||
id: release
|
||||
with:
|
||||
release-type: simple
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rickstaa/action-create-tag@v1
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
with:
|
||||
tag: stable
|
||||
message: "Current stable release: ${{ steps.release.outputs.tag_name }}"
|
||||
tag_exists_error: false
|
||||
force_push_tag: true
|
||||
|
|
|
|||
70
README.md
70
README.md
|
|
@ -66,44 +66,58 @@ Neovim 0.8+ and optionally [mini.icons](https://github.com/nvim-mini/mini.nvim/b
|
|||
|
||||
## Installation
|
||||
|
||||
Install with your favorite package manager or with luarocks.
|
||||
Install with your favorite package manager or with luarocks:
|
||||
|
||||
## Quick start
|
||||
|
||||
Add the following to your init.lua
|
||||
|
||||
```lua
|
||||
require("oil").setup()
|
||||
```console
|
||||
luarocks install oil.nvim
|
||||
```
|
||||
|
||||
Then open a directory with `nvim .`. Use `<CR>` to open a file/directory, and `-` to go up a directory. Otherwise, just treat it like a normal buffer and make changes as you like. Remember to `:w` when you're done to actually perform the actions.
|
||||
|
||||
If you want to mimic the `vim-vinegar` method of navigating to the parent directory of a file, add this keymap:
|
||||
|
||||
```lua
|
||||
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
|
||||
```
|
||||
|
||||
You can open a directory with `:edit <path>` or `:Oil <path>`. To open oil in a floating window, do `:Oil --float <path>`.
|
||||
|
||||
## Documentation
|
||||
|
||||
See `:help oil` for configuration, API reference, recipes, and more.
|
||||
```vim
|
||||
:help oil.nvim
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
**Q: Why "oil"**?
|
||||
**How do I migrate from `stevearc/oil.nvim` to `barrettruth/oil.nvim`?**
|
||||
|
||||
**A:** From the [vim-vinegar](https://github.com/tpope/vim-vinegar) README, a quote by Drew Neil:
|
||||
Replace your `setup()` call with a `vim.g.oil` assignment. For example, with
|
||||
[lazy.nvim](https://github.com/folke/lazy.nvim):
|
||||
|
||||
```lua
|
||||
-- before
|
||||
{
|
||||
'stevearc/oil.nvim',
|
||||
config = function(_, opts)
|
||||
require('oil').setup(opts)
|
||||
end,
|
||||
opts = {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
-- after
|
||||
{
|
||||
'stevearc/oil.nvim',
|
||||
init = function()
|
||||
vim.g.oil = {
|
||||
columns = { "icon", "size" },
|
||||
delete_to_trash = true,
|
||||
}
|
||||
end
|
||||
```
|
||||
|
||||
**Why "oil"**?
|
||||
|
||||
From the [vim-vinegar](https://github.com/tpope/vim-vinegar) README, a quote by Drew Neil:
|
||||
|
||||
> Split windows and the project drawer go together like oil and vinegar
|
||||
|
||||
Vinegar was taken. Let's be oil.
|
||||
Plus, I think it's pretty slick ;)
|
||||
|
||||
**Q: Why would I want to use oil vs any other plugin?**
|
||||
|
||||
**A:**
|
||||
**Why would I want to use oil vs any other plugin?**
|
||||
|
||||
- You like to use a netrw-like view to browse directories (as opposed to a file tree)
|
||||
- AND you want to be able to edit your filesystem like a buffer
|
||||
|
|
@ -111,14 +125,14 @@ Plus, I think it's pretty slick ;)
|
|||
|
||||
If you don't need those features specifically, check out the alternatives listed below
|
||||
|
||||
**Q: Can oil display files as a tree view**?
|
||||
**Can oil display files as a tree view**?
|
||||
|
||||
**A:** No. A tree view would require a completely different methodology, necessitating a complete rewrite.
|
||||
No. A tree view would require a completely different methodology, necessitating a complete rewrite.
|
||||
|
||||
**Q: What are some alternatives?**
|
||||
|
||||
**A:**
|
||||
**What are some alternatives?**
|
||||
|
||||
- [the original](https://github.com/stevearc/oil.nvim): the lesser-maintained but
|
||||
official `oil.nvim`
|
||||
- [mini.files](https://github.com/nvim-mini/mini.nvim/blob/main/readmes/mini-files.md): Also supports cross-directory filesystem-as-buffer edits with a column view.
|
||||
- [vim-vinegar](https://github.com/tpope/vim-vinegar): The granddaddy of single-directory file browsing.
|
||||
- [dirbuf.nvim](https://github.com/elihunter173/dirbuf.nvim): Edit filesystem like a buffer, but no cross-directory edits.
|
||||
|
|
|
|||
21
doc/oil.txt
21
doc/oil.txt
|
|
@ -48,6 +48,27 @@ REQUIREMENTS *oil-requirement
|
|||
--------------------------------------------------------------------------------
|
||||
CONFIG *oil-config*
|
||||
|
||||
Oil can be configured in two ways:
|
||||
|
||||
1. The traditional `setup()` call: >lua
|
||||
require("oil").setup({
|
||||
-- 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:
|
||||
|
||||
>lua
|
||||
require("oil").setup({
|
||||
-- Oil will take over directory buffers (e.g. `vim .` or `:e src/`)
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ local M = {}
|
|||
---@field border? string|string[] Window border
|
||||
|
||||
M.setup = function(opts)
|
||||
opts = opts or {}
|
||||
opts = opts or vim.g.oil or {}
|
||||
|
||||
local new_conf = vim.tbl_deep_extend("keep", opts, default_config)
|
||||
if not new_conf.use_default_keymaps then
|
||||
|
|
|
|||
3
plugin/oil.lua
Normal file
3
plugin/oil.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if vim.g.oil ~= nil then
|
||||
require("oil").setup()
|
||||
end
|
||||
27
tests/config_spec.lua
Normal file
27
tests/config_spec.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local config = require("oil.config")
|
||||
|
||||
describe("config", function()
|
||||
after_each(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()
|
||||
assert.is_false(config.delete_to_trash)
|
||||
assert.equals(2000, config.cleanup_delay_ms)
|
||||
end)
|
||||
|
||||
it("prefers explicit opts over vim.g.oil", function()
|
||||
vim.g.oil = { delete_to_trash = true }
|
||||
config.setup({ delete_to_trash = false })
|
||||
assert.is_false(config.delete_to_trash)
|
||||
end)
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue