refactor: revert canola namespace to oil and remove vim.g config (#120)
Some checks are pending
quality / changes (push) Waiting to run
quality / Lua Format Check (push) Blocked by required conditions
quality / Lua Lint Check (push) Blocked by required conditions
quality / Lua Type Check (push) Blocked by required conditions
quality / Markdown Format Check (push) Blocked by required conditions
test / Test (Neovim nightly) (push) Waiting to run
test / Test (Neovim stable) (push) Waiting to run
Some checks are pending
quality / changes (push) Waiting to run
quality / Lua Format Check (push) Blocked by required conditions
quality / Lua Lint Check (push) Blocked by required conditions
quality / Lua Type Check (push) Blocked by required conditions
quality / Markdown Format Check (push) Blocked by required conditions
test / Test (Neovim nightly) (push) Waiting to run
test / Test (Neovim stable) (push) Waiting to run
* refactor: revert module namespace from canola back to oil
Problem: the canola rename creates unnecessary friction for users
migrating from stevearc/oil.nvim — every `require('oil')` call and
config reference must change.
Solution: revert all module paths, URL schemes, autocmd groups,
highlight groups, and filetype names back to `oil`. The repo stays
`canola.nvim` for identity; the code is a drop-in replacement.
* 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
9298b48c5d
commit
e2cd1e66cf
69 changed files with 1724 additions and 1754 deletions
6
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
|
|
@ -50,7 +50,7 @@ body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: 'Health check'
|
label: 'Health check'
|
||||||
description: 'Output of `:checkhealth canola`'
|
description: 'Output of `:checkhealth oil`'
|
||||||
render: text
|
render: text
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|
@ -70,8 +70,8 @@ body:
|
||||||
spec = {
|
spec = {
|
||||||
{
|
{
|
||||||
'barrettruth/canola.nvim',
|
'barrettruth/canola.nvim',
|
||||||
init = function()
|
config = function()
|
||||||
vim.g.canola = {}
|
require('oil').setup({})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
218
doc/upstream.md
218
doc/upstream.md
|
|
@ -32,113 +32,113 @@ 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 |
|
||||||
| [#156](https://github.com/stevearc/oil.nvim/issues/156) | Paste path of files into oil buffer | open |
|
| [#156](https://github.com/stevearc/oil.nvim/issues/156) | Paste path of files into oil buffer | open |
|
||||||
| [#200](https://github.com/stevearc/oil.nvim/issues/200) | Highlights not working when opening a file | not actionable — cannot reproduce, nvim 0.9.4 |
|
| [#200](https://github.com/stevearc/oil.nvim/issues/200) | Highlights not working when opening a file | not actionable — cannot reproduce, nvim 0.9.4 |
|
||||||
| [#207](https://github.com/stevearc/oil.nvim/issues/207) | Suppress "no longer available" message | fixed — `cleanup_buffers_on_delete` option |
|
| [#207](https://github.com/stevearc/oil.nvim/issues/207) | Suppress "no longer available" message | fixed — `cleanup_buffers_on_delete` option |
|
||||||
| [#210](https://github.com/stevearc/oil.nvim/issues/210) | FTP support | open |
|
| [#210](https://github.com/stevearc/oil.nvim/issues/210) | FTP support | open |
|
||||||
| [#213](https://github.com/stevearc/oil.nvim/issues/213) | Disable preview for large files | fixed ([#85](https://github.com/barrettruth/canola.nvim/pull/85)) |
|
| [#213](https://github.com/stevearc/oil.nvim/issues/213) | Disable preview for large files | fixed ([#85](https://github.com/barrettruth/canola.nvim/pull/85)) |
|
||||||
| [#226](https://github.com/stevearc/oil.nvim/issues/226) | K8s/Docker adapter | not actionable — no demand |
|
| [#226](https://github.com/stevearc/oil.nvim/issues/226) | K8s/Docker adapter | not actionable — no demand |
|
||||||
| [#232](https://github.com/stevearc/oil.nvim/issues/232) | Cannot close last window | open |
|
| [#232](https://github.com/stevearc/oil.nvim/issues/232) | Cannot close last window | open |
|
||||||
| [#254](https://github.com/stevearc/oil.nvim/issues/254) | Buffer modified highlight group | open |
|
| [#254](https://github.com/stevearc/oil.nvim/issues/254) | Buffer modified highlight group | open |
|
||||||
| [#263](https://github.com/stevearc/oil.nvim/issues/263) | Diff mode | open |
|
| [#263](https://github.com/stevearc/oil.nvim/issues/263) | Diff mode | open |
|
||||||
| [#276](https://github.com/stevearc/oil.nvim/issues/276) | Archives manipulation | not actionable — nvim has builtin zip support |
|
| [#276](https://github.com/stevearc/oil.nvim/issues/276) | Archives manipulation | not actionable — nvim has builtin zip support |
|
||||||
| [#280](https://github.com/stevearc/oil.nvim/issues/280) | vim-projectionist support | open |
|
| [#280](https://github.com/stevearc/oil.nvim/issues/280) | vim-projectionist support | open |
|
||||||
| [#288](https://github.com/stevearc/oil.nvim/issues/288) | No reliable repro; likely lazy.nvim timing | not actionable |
|
| [#288](https://github.com/stevearc/oil.nvim/issues/288) | No reliable repro; likely lazy.nvim timing | not actionable |
|
||||||
| [#289](https://github.com/stevearc/oil.nvim/issues/289) | Show absolute path toggle | open |
|
| [#289](https://github.com/stevearc/oil.nvim/issues/289) | Show absolute path toggle | open |
|
||||||
| [#294](https://github.com/stevearc/oil.nvim/issues/294) | Can't handle emojis in filenames | not actionable — libuv bug ([nodejs/node#49042](https://github.com/nodejs/node/issues/49042)) |
|
| [#294](https://github.com/stevearc/oil.nvim/issues/294) | Can't handle emojis in filenames | not actionable — libuv bug ([nodejs/node#49042](https://github.com/nodejs/node/issues/49042)) |
|
||||||
| [#298](https://github.com/stevearc/oil.nvim/issues/298) | Open float on neovim directory startup | open |
|
| [#298](https://github.com/stevearc/oil.nvim/issues/298) | Open float on neovim directory startup | open |
|
||||||
| [#302](https://github.com/stevearc/oil.nvim/issues/302) | `buflisted=true` after jumplist nav | fixed ([#71](https://github.com/barrettruth/canola.nvim/pull/71)) |
|
| [#302](https://github.com/stevearc/oil.nvim/issues/302) | `buflisted=true` after jumplist nav | fixed ([#71](https://github.com/barrettruth/canola.nvim/pull/71)) |
|
||||||
| [#303](https://github.com/stevearc/oil.nvim/issues/303) | Preview in float window mode | open |
|
| [#303](https://github.com/stevearc/oil.nvim/issues/303) | Preview in float window mode | open |
|
||||||
| [#325](https://github.com/stevearc/oil.nvim/issues/325) | oil-ssh error from command line | open |
|
| [#325](https://github.com/stevearc/oil.nvim/issues/325) | oil-ssh error from command line | open |
|
||||||
| [#330](https://github.com/stevearc/oil.nvim/issues/330) | Telescope opens file in oil float | not actionable — cross-plugin, no repro |
|
| [#330](https://github.com/stevearc/oil.nvim/issues/330) | Telescope opens file in oil float | not actionable — cross-plugin, no repro |
|
||||||
| [#332](https://github.com/stevearc/oil.nvim/issues/332) | Buffer not fixed to floating window | not actionable — cannot reproduce |
|
| [#332](https://github.com/stevearc/oil.nvim/issues/332) | Buffer not fixed to floating window | not actionable — cannot reproduce |
|
||||||
| [#335](https://github.com/stevearc/oil.nvim/issues/335) | Disable editing outside root dir | open |
|
| [#335](https://github.com/stevearc/oil.nvim/issues/335) | Disable editing outside root dir | open |
|
||||||
| [#349](https://github.com/stevearc/oil.nvim/issues/349) | Parent directory as column/vsplit | open |
|
| [#349](https://github.com/stevearc/oil.nvim/issues/349) | Parent directory as column/vsplit | open |
|
||||||
| [#351](https://github.com/stevearc/oil.nvim/issues/351) | Paste deleted file from register | open |
|
| [#351](https://github.com/stevearc/oil.nvim/issues/351) | Paste deleted file from register | open |
|
||||||
| [#359](https://github.com/stevearc/oil.nvim/issues/359) | Parse error on filenames differing by space | not actionable — parser uses whitespace as column delimiter |
|
| [#359](https://github.com/stevearc/oil.nvim/issues/359) | Parse error on filenames differing by space | not actionable — parser uses whitespace as column delimiter |
|
||||||
| [#360](https://github.com/stevearc/oil.nvim/issues/360) | Pick window to open file into | open |
|
| [#360](https://github.com/stevearc/oil.nvim/issues/360) | Pick window to open file into | open |
|
||||||
| [#362](https://github.com/stevearc/oil.nvim/issues/362) | "Could not find oil adapter for scheme" | not actionable — no repro, old nvim (0.9.5) |
|
| [#362](https://github.com/stevearc/oil.nvim/issues/362) | "Could not find oil adapter for scheme" | not actionable — no repro, old nvim (0.9.5) |
|
||||||
| [#363](https://github.com/stevearc/oil.nvim/issues/363) | `prompt_save_on_select_new_entry` wrong prompt | fixed |
|
| [#363](https://github.com/stevearc/oil.nvim/issues/363) | `prompt_save_on_select_new_entry` wrong prompt | fixed |
|
||||||
| [#371](https://github.com/stevearc/oil.nvim/issues/371) | Constrain cursor in insert mode | fixed ([#93](https://github.com/barrettruth/canola.nvim/pull/93)) |
|
| [#371](https://github.com/stevearc/oil.nvim/issues/371) | Constrain cursor in insert mode | fixed ([#93](https://github.com/barrettruth/canola.nvim/pull/93)) |
|
||||||
| [#373](https://github.com/stevearc/oil.nvim/issues/373) | Dir from quickfix with bqf/trouble broken | open |
|
| [#373](https://github.com/stevearc/oil.nvim/issues/373) | Dir from quickfix with bqf/trouble broken | open |
|
||||||
| [#375](https://github.com/stevearc/oil.nvim/issues/375) | Highlights for file types and permissions | open |
|
| [#375](https://github.com/stevearc/oil.nvim/issues/375) | Highlights for file types and permissions | open |
|
||||||
| [#380](https://github.com/stevearc/oil.nvim/issues/380) | Silently overriding `show_hidden` | not actionable — counter to config intent |
|
| [#380](https://github.com/stevearc/oil.nvim/issues/380) | Silently overriding `show_hidden` | not actionable — counter to config intent |
|
||||||
| [#382](https://github.com/stevearc/oil.nvim/issues/382) | Relative path in window title | not actionable — solved by `get_win_title` callback ([#482](https://github.com/stevearc/oil.nvim/pull/482)) |
|
| [#382](https://github.com/stevearc/oil.nvim/issues/382) | Relative path in window title | not actionable — solved by `get_win_title` callback ([#482](https://github.com/stevearc/oil.nvim/pull/482)) |
|
||||||
| [#392](https://github.com/stevearc/oil.nvim/issues/392) | Option to skip delete prompt | fixed |
|
| [#392](https://github.com/stevearc/oil.nvim/issues/392) | Option to skip delete prompt | fixed |
|
||||||
| [#393](https://github.com/stevearc/oil.nvim/issues/393) | Auto-save on select | fixed |
|
| [#393](https://github.com/stevearc/oil.nvim/issues/393) | Auto-save on select | fixed |
|
||||||
| [#396](https://github.com/stevearc/oil.nvim/issues/396) | Customize preview content | open |
|
| [#396](https://github.com/stevearc/oil.nvim/issues/396) | Customize preview content | open |
|
||||||
| [#399](https://github.com/stevearc/oil.nvim/issues/399) | Open file without closing Oil | open |
|
| [#399](https://github.com/stevearc/oil.nvim/issues/399) | Open file without closing Oil | open |
|
||||||
| [#404](https://github.com/stevearc/oil.nvim/issues/404) | Restricted UNC paths | not actionable — Windows-only |
|
| [#404](https://github.com/stevearc/oil.nvim/issues/404) | Restricted UNC paths | not actionable — Windows-only |
|
||||||
| [#416](https://github.com/stevearc/oil.nvim/issues/416) | Cannot remap key to open split | open |
|
| [#416](https://github.com/stevearc/oil.nvim/issues/416) | Cannot remap key to open split | open |
|
||||||
| [#431](https://github.com/stevearc/oil.nvim/issues/431) | More SSH adapter documentation | duplicate of [#525](https://github.com/stevearc/oil.nvim/issues/525) |
|
| [#431](https://github.com/stevearc/oil.nvim/issues/431) | More SSH adapter documentation | duplicate of [#525](https://github.com/stevearc/oil.nvim/issues/525) |
|
||||||
| [#435](https://github.com/stevearc/oil.nvim/issues/435) | Error previewing with semantic tokens LSP | fixed — cherry-picked ([#467](https://github.com/stevearc/oil.nvim/pull/467)) |
|
| [#435](https://github.com/stevearc/oil.nvim/issues/435) | Error previewing with semantic tokens LSP | fixed — cherry-picked ([#467](https://github.com/stevearc/oil.nvim/pull/467)) |
|
||||||
| [#436](https://github.com/stevearc/oil.nvim/issues/436) | Owner and group columns | open |
|
| [#436](https://github.com/stevearc/oil.nvim/issues/436) | Owner and group columns | open |
|
||||||
| [#444](https://github.com/stevearc/oil.nvim/issues/444) | Opening behaviour customization | open |
|
| [#444](https://github.com/stevearc/oil.nvim/issues/444) | Opening behaviour customization | open |
|
||||||
| [#446](https://github.com/stevearc/oil.nvim/issues/446) | Executable highlighting | cherry-picked ([#698](https://github.com/stevearc/oil.nvim/pull/698)) |
|
| [#446](https://github.com/stevearc/oil.nvim/issues/446) | Executable highlighting | cherry-picked ([#698](https://github.com/stevearc/oil.nvim/pull/698)) |
|
||||||
| [#449](https://github.com/stevearc/oil.nvim/issues/449) | Renaming TypeScript files stopped working | open |
|
| [#449](https://github.com/stevearc/oil.nvim/issues/449) | Renaming TypeScript files stopped working | open |
|
||||||
| [#450](https://github.com/stevearc/oil.nvim/issues/450) | Highlight opened file in directory listing | open |
|
| [#450](https://github.com/stevearc/oil.nvim/issues/450) | Highlight opened file in directory listing | open |
|
||||||
| [#457](https://github.com/stevearc/oil.nvim/issues/457) | Custom column API | open |
|
| [#457](https://github.com/stevearc/oil.nvim/issues/457) | Custom column API | open |
|
||||||
| [#466](https://github.com/stevearc/oil.nvim/issues/466) | Select into window on right | open |
|
| [#466](https://github.com/stevearc/oil.nvim/issues/466) | Select into window on right | open |
|
||||||
| [#473](https://github.com/stevearc/oil.nvim/issues/473) | Show hidden when dir is all-hidden | fixed ([#85](https://github.com/barrettruth/canola.nvim/pull/85)) |
|
| [#473](https://github.com/stevearc/oil.nvim/issues/473) | Show hidden when dir is all-hidden | fixed ([#85](https://github.com/barrettruth/canola.nvim/pull/85)) |
|
||||||
| [#479](https://github.com/stevearc/oil.nvim/issues/479) | Harpoon integration recipe | open |
|
| [#479](https://github.com/stevearc/oil.nvim/issues/479) | Harpoon integration recipe | open |
|
||||||
| [#483](https://github.com/stevearc/oil.nvim/issues/483) | Spell downloads depend on netrw | not actionable — fixed in neovim#34940 |
|
| [#483](https://github.com/stevearc/oil.nvim/issues/483) | Spell downloads depend on netrw | not actionable — fixed in neovim#34940 |
|
||||||
| [#486](https://github.com/stevearc/oil.nvim/issues/486) | Directory sizes show misleading 4.1k | fixed ([#87](https://github.com/barrettruth/canola.nvim/pull/87)) |
|
| [#486](https://github.com/stevearc/oil.nvim/issues/486) | Directory sizes show misleading 4.1k | fixed ([#87](https://github.com/barrettruth/canola.nvim/pull/87)) |
|
||||||
| [#492](https://github.com/stevearc/oil.nvim/issues/492) | j/k remapping question | not actionable — answered |
|
| [#492](https://github.com/stevearc/oil.nvim/issues/492) | j/k remapping question | not actionable — answered |
|
||||||
| [#507](https://github.com/stevearc/oil.nvim/issues/507) | lacasitos.nvim conflict | not actionable — cross-plugin + Windows-only |
|
| [#507](https://github.com/stevearc/oil.nvim/issues/507) | lacasitos.nvim conflict | not actionable — cross-plugin + Windows-only |
|
||||||
| [#521](https://github.com/stevearc/oil.nvim/issues/521) | oil-ssh connection issues | open |
|
| [#521](https://github.com/stevearc/oil.nvim/issues/521) | oil-ssh connection issues | open |
|
||||||
| [#525](https://github.com/stevearc/oil.nvim/issues/525) | SSH adapter documentation | open |
|
| [#525](https://github.com/stevearc/oil.nvim/issues/525) | SSH adapter documentation | open |
|
||||||
| [#531](https://github.com/stevearc/oil.nvim/issues/531) | Incomplete drive letters | not actionable — Windows-only |
|
| [#531](https://github.com/stevearc/oil.nvim/issues/531) | Incomplete drive letters | not actionable — Windows-only |
|
||||||
| [#533](https://github.com/stevearc/oil.nvim/issues/533) | `constrain_cursor` bug | not actionable — needs repro |
|
| [#533](https://github.com/stevearc/oil.nvim/issues/533) | `constrain_cursor` bug | not actionable — needs repro |
|
||||||
| [#570](https://github.com/stevearc/oil.nvim/issues/570) | Improve c0/d0 for renaming | open |
|
| [#570](https://github.com/stevearc/oil.nvim/issues/570) | Improve c0/d0 for renaming | open |
|
||||||
| [#571](https://github.com/stevearc/oil.nvim/issues/571) | Callback before `highlight_filename` | open |
|
| [#571](https://github.com/stevearc/oil.nvim/issues/571) | Callback before `highlight_filename` | open |
|
||||||
| [#578](https://github.com/stevearc/oil.nvim/issues/578) | Hidden file dimming recipe | fixed |
|
| [#578](https://github.com/stevearc/oil.nvim/issues/578) | Hidden file dimming recipe | fixed |
|
||||||
| [#587](https://github.com/stevearc/oil.nvim/issues/587) | Alt+h keymap | not actionable — user config issue |
|
| [#587](https://github.com/stevearc/oil.nvim/issues/587) | Alt+h keymap | not actionable — user config issue |
|
||||||
| [#599](https://github.com/stevearc/oil.nvim/issues/599) | user:group display and manipulation | open |
|
| [#599](https://github.com/stevearc/oil.nvim/issues/599) | user:group display and manipulation | open |
|
||||||
| [#607](https://github.com/stevearc/oil.nvim/issues/607) | Per-host SCP args | open |
|
| [#607](https://github.com/stevearc/oil.nvim/issues/607) | Per-host SCP args | open |
|
||||||
| [#609](https://github.com/stevearc/oil.nvim/issues/609) | Cursor placement via Snacks picker | not actionable — Windows-only |
|
| [#609](https://github.com/stevearc/oil.nvim/issues/609) | Cursor placement via Snacks picker | not actionable — Windows-only |
|
||||||
| [#612](https://github.com/stevearc/oil.nvim/issues/612) | Delete buffers on file delete | fixed |
|
| [#612](https://github.com/stevearc/oil.nvim/issues/612) | Delete buffers on file delete | fixed |
|
||||||
| [#615](https://github.com/stevearc/oil.nvim/issues/615) | Cursor at name column on o/O | fixed ([#72](https://github.com/barrettruth/canola.nvim/pull/72)) |
|
| [#615](https://github.com/stevearc/oil.nvim/issues/615) | Cursor at name column on o/O | fixed ([#72](https://github.com/barrettruth/canola.nvim/pull/72)) |
|
||||||
| [#617](https://github.com/stevearc/oil.nvim/issues/617) | Filetype by actual filetype | open |
|
| [#617](https://github.com/stevearc/oil.nvim/issues/617) | Filetype by actual filetype | open |
|
||||||
| [#621](https://github.com/stevearc/oil.nvim/issues/621) | `toggle()` for regular windows | fixed ([#88](https://github.com/barrettruth/canola.nvim/pull/88)) |
|
| [#621](https://github.com/stevearc/oil.nvim/issues/621) | `toggle()` for regular windows | fixed ([#88](https://github.com/barrettruth/canola.nvim/pull/88)) |
|
||||||
| [#623](https://github.com/stevearc/oil.nvim/issues/623) | bufferline.nvim interaction | open |
|
| [#623](https://github.com/stevearc/oil.nvim/issues/623) | bufferline.nvim interaction | open |
|
||||||
| [#624](https://github.com/stevearc/oil.nvim/issues/624) | Mutation race | not actionable — no reliable repro |
|
| [#624](https://github.com/stevearc/oil.nvim/issues/624) | Mutation race | not actionable — no reliable repro |
|
||||||
| [#625](https://github.com/stevearc/oil.nvim/issues/625) | E19 mark invalid line | not actionable — intractable without neovim API changes |
|
| [#625](https://github.com/stevearc/oil.nvim/issues/625) | E19 mark invalid line | not actionable — intractable without neovim API changes |
|
||||||
| [#632](https://github.com/stevearc/oil.nvim/issues/632) | Preview + move = copy | fixed ([#12](https://github.com/barrettruth/canola.nvim/pull/12)) |
|
| [#632](https://github.com/stevearc/oil.nvim/issues/632) | Preview + move = copy | fixed ([#12](https://github.com/barrettruth/canola.nvim/pull/12)) |
|
||||||
| [#636](https://github.com/stevearc/oil.nvim/issues/636) | Telescope picker opens in active buffer | not actionable — cannot reproduce |
|
| [#636](https://github.com/stevearc/oil.nvim/issues/636) | Telescope picker opens in active buffer | not actionable — cannot reproduce |
|
||||||
| [#637](https://github.com/stevearc/oil.nvim/issues/637) | Inconsistent symlink resolution | not actionable — nightly-only, no stable repro |
|
| [#637](https://github.com/stevearc/oil.nvim/issues/637) | Inconsistent symlink resolution | not actionable — nightly-only, no stable repro |
|
||||||
| [#641](https://github.com/stevearc/oil.nvim/issues/641) | Flicker on `actions.parent` | open |
|
| [#641](https://github.com/stevearc/oil.nvim/issues/641) | Flicker on `actions.parent` | open |
|
||||||
| [#642](https://github.com/stevearc/oil.nvim/issues/642) | W10 warning under `nvim -R` | fixed |
|
| [#642](https://github.com/stevearc/oil.nvim/issues/642) | W10 warning under `nvim -R` | fixed |
|
||||||
| [#645](https://github.com/stevearc/oil.nvim/issues/645) | `close_float` action | fixed |
|
| [#645](https://github.com/stevearc/oil.nvim/issues/645) | `close_float` action | fixed |
|
||||||
| [#646](https://github.com/stevearc/oil.nvim/issues/646) | `get_current_dir` nil on SSH | fixed — `get_current_url()` API |
|
| [#646](https://github.com/stevearc/oil.nvim/issues/646) | `get_current_dir` nil on SSH | fixed — `get_current_url()` API |
|
||||||
| [#650](https://github.com/stevearc/oil.nvim/issues/650) | LSP `workspace.fileOperations` events | fixed |
|
| [#650](https://github.com/stevearc/oil.nvim/issues/650) | LSP `workspace.fileOperations` events | fixed |
|
||||||
| [#655](https://github.com/stevearc/oil.nvim/issues/655) | File statistics as virtual text | open |
|
| [#655](https://github.com/stevearc/oil.nvim/issues/655) | File statistics as virtual text | open |
|
||||||
| [#659](https://github.com/stevearc/oil.nvim/issues/659) | Mark and diff files in buffer | open |
|
| [#659](https://github.com/stevearc/oil.nvim/issues/659) | Mark and diff files in buffer | open |
|
||||||
| [#664](https://github.com/stevearc/oil.nvim/issues/664) | Session reload extra buffer | not actionable — no repro |
|
| [#664](https://github.com/stevearc/oil.nvim/issues/664) | Session reload extra buffer | not actionable — no repro |
|
||||||
| [#665](https://github.com/stevearc/oil.nvim/issues/665) | Hot load preview fast-scratch buffers | not actionable — no clear architecture |
|
| [#665](https://github.com/stevearc/oil.nvim/issues/665) | Hot load preview fast-scratch buffers | not actionable — no clear architecture |
|
||||||
| [#668](https://github.com/stevearc/oil.nvim/issues/668) | Custom yes/no confirmation | not actionable — no demand |
|
| [#668](https://github.com/stevearc/oil.nvim/issues/668) | Custom yes/no confirmation | not actionable — no demand |
|
||||||
| [#670](https://github.com/stevearc/oil.nvim/issues/670) | Multi-directory cmdline args ignored | fixed ([#11](https://github.com/barrettruth/canola.nvim/pull/11)) |
|
| [#670](https://github.com/stevearc/oil.nvim/issues/670) | Multi-directory cmdline args ignored | fixed ([#11](https://github.com/barrettruth/canola.nvim/pull/11)) |
|
||||||
| [#671](https://github.com/stevearc/oil.nvim/issues/671) | Yanking between nvim instances | not actionable — addressed upstream by clipboard actions |
|
| [#671](https://github.com/stevearc/oil.nvim/issues/671) | Yanking between nvim instances | not actionable — addressed upstream by clipboard actions |
|
||||||
| [#673](https://github.com/stevearc/oil.nvim/issues/673) | Symlink newlines crash | fixed |
|
| [#673](https://github.com/stevearc/oil.nvim/issues/673) | Symlink newlines crash | fixed |
|
||||||
| [#675](https://github.com/stevearc/oil.nvim/issues/675) | Move file into folder by renaming | open |
|
| [#675](https://github.com/stevearc/oil.nvim/issues/675) | Move file into folder by renaming | open |
|
||||||
| [#676](https://github.com/stevearc/oil.nvim/issues/676) | Windows path conversion | not actionable — Windows-only |
|
| [#676](https://github.com/stevearc/oil.nvim/issues/676) | Windows path conversion | not actionable — Windows-only |
|
||||||
| [#678](https://github.com/stevearc/oil.nvim/issues/678) | `buftype='acwrite'` causes `mksession` to skip oil windows | open |
|
| [#678](https://github.com/stevearc/oil.nvim/issues/678) | `buftype='acwrite'` causes `mksession` to skip oil windows | open |
|
||||||
| [#679](https://github.com/stevearc/oil.nvim/issues/679) | Executable file sign | cherry-picked ([#698](https://github.com/stevearc/oil.nvim/pull/698)) |
|
| [#679](https://github.com/stevearc/oil.nvim/issues/679) | Executable file sign | cherry-picked ([#698](https://github.com/stevearc/oil.nvim/pull/698)) |
|
||||||
| [#682](https://github.com/stevearc/oil.nvim/issues/682) | `get_current_dir()` nil | cherry-picked ([#727](https://github.com/stevearc/oil.nvim/pull/727)) |
|
| [#682](https://github.com/stevearc/oil.nvim/issues/682) | `get_current_dir()` nil | cherry-picked ([#727](https://github.com/stevearc/oil.nvim/pull/727)) |
|
||||||
| [#683](https://github.com/stevearc/oil.nvim/issues/683) | Path not shown in floating mode | fixed |
|
| [#683](https://github.com/stevearc/oil.nvim/issues/683) | Path not shown in floating mode | fixed |
|
||||||
| [#684](https://github.com/stevearc/oil.nvim/issues/684) | User and group columns | open |
|
| [#684](https://github.com/stevearc/oil.nvim/issues/684) | User and group columns | open |
|
||||||
| [#685](https://github.com/stevearc/oil.nvim/issues/685) | Plain directory paths in buffer names | not actionable — protocol prefix is fundamental to buffer identity |
|
| [#685](https://github.com/stevearc/oil.nvim/issues/685) | Plain directory paths in buffer names | not actionable — protocol prefix is fundamental to buffer identity |
|
||||||
| [#690](https://github.com/stevearc/oil.nvim/issues/690) | `OilFileIcon` highlight group | fixed |
|
| [#690](https://github.com/stevearc/oil.nvim/issues/690) | `OilFileIcon` highlight group | fixed |
|
||||||
| [#692](https://github.com/stevearc/oil.nvim/issues/692) | Keymap normalization | cherry-picked ([#725](https://github.com/stevearc/oil.nvim/pull/725)) |
|
| [#692](https://github.com/stevearc/oil.nvim/issues/692) | Keymap normalization | cherry-picked ([#725](https://github.com/stevearc/oil.nvim/pull/725)) |
|
||||||
| [#699](https://github.com/stevearc/oil.nvim/issues/699) | `select` blocks UI with slow FileType autocmd | fixed ([#106](https://github.com/barrettruth/canola.nvim/pull/106)) |
|
| [#699](https://github.com/stevearc/oil.nvim/issues/699) | `select` blocks UI with slow FileType autocmd | fixed ([#106](https://github.com/barrettruth/canola.nvim/pull/106)) |
|
||||||
| [#707](https://github.com/stevearc/oil.nvim/issues/707) | Move file/dir into new dir by renaming | open |
|
| [#707](https://github.com/stevearc/oil.nvim/issues/707) | Move file/dir into new dir by renaming | open |
|
||||||
| [#710](https://github.com/stevearc/oil.nvim/issues/710) | buftype empty on BufEnter | fixed ([#10](https://github.com/barrettruth/canola.nvim/pull/10)) |
|
| [#710](https://github.com/stevearc/oil.nvim/issues/710) | buftype empty on BufEnter | fixed ([#10](https://github.com/barrettruth/canola.nvim/pull/10)) |
|
||||||
| [#714](https://github.com/stevearc/oil.nvim/issues/714) | Support question | not actionable — answered |
|
| [#714](https://github.com/stevearc/oil.nvim/issues/714) | Support question | not actionable — answered |
|
||||||
| [#719](https://github.com/stevearc/oil.nvim/issues/719) | Neovim crash on node_modules | not actionable — libuv/neovim bug |
|
| [#719](https://github.com/stevearc/oil.nvim/issues/719) | Neovim crash on node_modules | not actionable — libuv/neovim bug |
|
||||||
| [#726](https://github.com/stevearc/oil.nvim/issues/726) | Meta discussion/roadmap | not actionable |
|
| [#726](https://github.com/stevearc/oil.nvim/issues/726) | Meta discussion/roadmap | not actionable |
|
||||||
| [#736](https://github.com/stevearc/oil.nvim/issues/736) | Make icons virtual text | open |
|
| [#736](https://github.com/stevearc/oil.nvim/issues/736) | Make icons virtual text | open |
|
||||||
| [#738](https://github.com/stevearc/oil.nvim/issues/738) | Allow changing mtime/atime via time column | open |
|
| [#738](https://github.com/stevearc/oil.nvim/issues/738) | Allow changing mtime/atime via time column | open |
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
local fs = require('canola.fs')
|
|
||||||
|
|
||||||
if fs.is_mac then
|
|
||||||
return require('canola.adapters.trash.mac')
|
|
||||||
elseif fs.is_windows then
|
|
||||||
return require('canola.adapters.trash.windows')
|
|
||||||
else
|
|
||||||
return require('canola.adapters.trash.freedesktop')
|
|
||||||
end
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.show_help = {
|
M.show_help = {
|
||||||
callback = function()
|
callback = function()
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
require('canola.keymap_util').show_help(config.keymaps)
|
require('oil.keymap_util').show_help(config.keymaps)
|
||||||
end,
|
end,
|
||||||
desc = 'Show default keymaps',
|
desc = 'Show default keymaps',
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ M.select = {
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local callback = opts.callback
|
local callback = opts.callback
|
||||||
opts.callback = nil
|
opts.callback = nil
|
||||||
canola.select(opts, callback)
|
oil.select(opts, callback)
|
||||||
end,
|
end,
|
||||||
parameters = {
|
parameters = {
|
||||||
vertical = {
|
vertical = {
|
||||||
|
|
@ -38,7 +38,7 @@ M.select = {
|
||||||
},
|
},
|
||||||
close = {
|
close = {
|
||||||
type = 'boolean',
|
type = 'boolean',
|
||||||
desc = 'Close the original canola buffer once selection is made',
|
desc = 'Close the original oil buffer once selection is made',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ M.select_vsplit = {
|
||||||
desc = 'Open the entry under the cursor in a vertical split',
|
desc = 'Open the entry under the cursor in a vertical split',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
canola.select({ vertical = true })
|
oil.select({ vertical = true })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ M.select_split = {
|
||||||
desc = 'Open the entry under the cursor in a horizontal split',
|
desc = 'Open the entry under the cursor in a horizontal split',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
canola.select({ horizontal = true })
|
oil.select({ horizontal = true })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ M.select_tab = {
|
||||||
desc = 'Open the entry under the cursor in a new tab',
|
desc = 'Open the entry under the cursor in a new tab',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
canola.select({ tab = true })
|
oil.select({ tab = true })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,25 +84,25 @@ M.preview = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
if not entry then
|
if not entry then
|
||||||
vim.notify('Could not find entry under cursor', vim.log.levels.ERROR)
|
vim.notify('Could not find entry under cursor', vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local winid = util.get_preview_win()
|
local winid = util.get_preview_win()
|
||||||
if winid then
|
if winid then
|
||||||
local cur_id = vim.w[winid].canola_entry_id
|
local cur_id = vim.w[winid].oil_entry_id
|
||||||
if entry.id == cur_id then
|
if entry.id == cur_id then
|
||||||
vim.api.nvim_win_close(winid, true)
|
vim.api.nvim_win_close(winid, true)
|
||||||
if util.is_floating_win() then
|
if util.is_floating_win() then
|
||||||
local layout = require('canola.layout')
|
local layout = require('oil.layout')
|
||||||
local win_opts = layout.get_fullscreen_win_opts()
|
local win_opts = layout.get_fullscreen_win_opts()
|
||||||
vim.api.nvim_win_set_config(0, win_opts)
|
vim.api.nvim_win_set_config(0, win_opts)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
canola.open_preview(opts)
|
oil.open_preview(opts)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,35 +162,35 @@ M.preview_scroll_right = {
|
||||||
|
|
||||||
M.parent = {
|
M.parent = {
|
||||||
desc = 'Navigate to the parent path',
|
desc = 'Navigate to the parent path',
|
||||||
callback = canola.open,
|
callback = oil.open,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.close = {
|
M.close = {
|
||||||
desc = 'Close canola and restore original buffer',
|
desc = 'Close oil and restore original buffer',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
canola.close(opts)
|
oil.close(opts)
|
||||||
end,
|
end,
|
||||||
parameters = {
|
parameters = {
|
||||||
exit_if_last_buf = {
|
exit_if_last_buf = {
|
||||||
type = 'boolean',
|
type = 'boolean',
|
||||||
desc = 'Exit vim if canola is closed as the last buffer',
|
desc = 'Exit vim if oil is closed as the last buffer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
M.close_float = {
|
M.close_float = {
|
||||||
desc = 'Close canola if the window is floating, otherwise do nothing',
|
desc = 'Close oil if the window is floating, otherwise do nothing',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
if vim.w.is_canola_win then
|
if vim.w.is_oil_win then
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
canola.close(opts)
|
oil.close(opts)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
parameters = {
|
parameters = {
|
||||||
exit_if_last_buf = {
|
exit_if_last_buf = {
|
||||||
type = 'boolean',
|
type = 'boolean',
|
||||||
desc = 'Exit vim if canola is closed as the last buffer',
|
desc = 'Exit vim if oil is closed as the last buffer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ M.close_float = {
|
||||||
---@param cmd string
|
---@param cmd string
|
||||||
---@param silent? boolean
|
---@param silent? boolean
|
||||||
local function cd(cmd, silent)
|
local function cd(cmd, silent)
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if dir then
|
if dir then
|
||||||
vim.cmd({ cmd = cmd, args = { dir } })
|
vim.cmd({ cmd = cmd, args = { dir } })
|
||||||
if not silent then
|
if not silent then
|
||||||
|
|
@ -210,7 +210,7 @@ local function cd(cmd, silent)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.cd = {
|
M.cd = {
|
||||||
desc = ':cd to the current canola directory',
|
desc = ':cd to the current oil directory',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local cmd = 'cd'
|
local cmd = 'cd'
|
||||||
|
|
@ -234,7 +234,7 @@ M.cd = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.tcd = {
|
M.tcd = {
|
||||||
desc = ':tcd to the current canola directory',
|
desc = ':tcd to the current oil directory',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
cd('tcd')
|
cd('tcd')
|
||||||
|
|
@ -242,31 +242,31 @@ M.tcd = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.open_cwd = {
|
M.open_cwd = {
|
||||||
desc = "Open canola in Neovim's current working directory",
|
desc = "Open oil in Neovim's current working directory",
|
||||||
callback = function()
|
callback = function()
|
||||||
canola.open(vim.fn.getcwd())
|
oil.open(vim.fn.getcwd())
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.toggle_hidden = {
|
M.toggle_hidden = {
|
||||||
desc = 'Toggle hidden files and directories',
|
desc = 'Toggle hidden files and directories',
|
||||||
callback = function()
|
callback = function()
|
||||||
require('canola.view').toggle_hidden()
|
require('oil.view').toggle_hidden()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.open_terminal = {
|
M.open_terminal = {
|
||||||
desc = 'Open a terminal in the current directory',
|
desc = 'Open a terminal in the current directory',
|
||||||
callback = function()
|
callback = function()
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local bufname = vim.api.nvim_buf_get_name(0)
|
local bufname = vim.api.nvim_buf_get_name(0)
|
||||||
local adapter = config.get_adapter_by_scheme(bufname)
|
local adapter = config.get_adapter_by_scheme(bufname)
|
||||||
if not adapter then
|
if not adapter then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if adapter.name == 'files' then
|
if adapter.name == 'files' then
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
assert(dir, 'Canola buffer with files adapter must have current directory')
|
assert(dir, 'Oil buffer with files adapter must have current directory')
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_set_current_buf(bufnr)
|
vim.api.nvim_set_current_buf(bufnr)
|
||||||
if vim.fn.has('nvim-0.11') == 1 then
|
if vim.fn.has('nvim-0.11') == 1 then
|
||||||
|
|
@ -278,8 +278,8 @@ M.open_terminal = {
|
||||||
elseif adapter.name == 'ssh' then
|
elseif adapter.name == 'ssh' then
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_set_current_buf(bufnr)
|
vim.api.nvim_set_current_buf(bufnr)
|
||||||
local url = require('canola.adapters.ssh').parse_url(bufname)
|
local url = require('oil.adapters.ssh').parse_url(bufname)
|
||||||
local cmd = require('canola.adapters.ssh.connection').create_ssh_command(url)
|
local cmd = require('oil.adapters.ssh.connection').create_ssh_command(url)
|
||||||
local term_id
|
local term_id
|
||||||
if vim.fn.has('nvim-0.11') == 1 then
|
if vim.fn.has('nvim-0.11') == 1 then
|
||||||
term_id = vim.fn.jobstart(cmd, { term = true })
|
term_id = vim.fn.jobstart(cmd, { term = true })
|
||||||
|
|
@ -324,8 +324,8 @@ end
|
||||||
M.open_external = {
|
M.open_external = {
|
||||||
desc = 'Open the entry under the cursor in an external program',
|
desc = 'Open the entry under the cursor in an external program',
|
||||||
callback = function()
|
callback = function()
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if not entry or not dir then
|
if not entry or not dir then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -381,9 +381,9 @@ M.open_cmdline = {
|
||||||
opts = vim.tbl_deep_extend('keep', opts or {}, {
|
opts = vim.tbl_deep_extend('keep', opts or {}, {
|
||||||
shorten_path = true,
|
shorten_path = true,
|
||||||
})
|
})
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
if not entry then
|
if not entry then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -421,8 +421,8 @@ M.yank_entry = {
|
||||||
desc = 'Yank the filepath of the entry under the cursor to a register',
|
desc = 'Yank the filepath of the entry under the cursor to a register',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if not entry or not dir then
|
if not entry or not dir then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -448,8 +448,8 @@ M.copy_entry_path = {
|
||||||
desc = 'Yank the filepath of the entry under the cursor to a register',
|
desc = 'Yank the filepath of the entry under the cursor to a register',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if not entry or not dir then
|
if not entry or not dir then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -461,7 +461,7 @@ M.copy_entry_filename = {
|
||||||
desc = 'Yank the filename of the entry under the cursor to a register',
|
desc = 'Yank the filename of the entry under the cursor to a register',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
if not entry then
|
if not entry then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -472,14 +472,14 @@ M.copy_entry_filename = {
|
||||||
M.copy_to_system_clipboard = {
|
M.copy_to_system_clipboard = {
|
||||||
desc = 'Copy the entry under the cursor to the system clipboard',
|
desc = 'Copy the entry under the cursor to the system clipboard',
|
||||||
callback = function()
|
callback = function()
|
||||||
require('canola.clipboard').copy_to_system_clipboard()
|
require('oil.clipboard').copy_to_system_clipboard()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.paste_from_system_clipboard = {
|
M.paste_from_system_clipboard = {
|
||||||
desc = 'Paste the system clipboard into the current canola directory',
|
desc = 'Paste the system clipboard into the current oil directory',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
require('canola.clipboard').paste_from_system_clipboard(opts and opts.delete_original)
|
require('oil.clipboard').paste_from_system_clipboard(opts and opts.delete_original)
|
||||||
end,
|
end,
|
||||||
parameters = {
|
parameters = {
|
||||||
delete_original = {
|
delete_original = {
|
||||||
|
|
@ -493,8 +493,8 @@ M.open_cmdline_dir = {
|
||||||
desc = 'Open vim cmdline with current directory as an argument',
|
desc = 'Open vim cmdline with current directory as an argument',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if dir then
|
if dir then
|
||||||
open_cmdline_with_path(fs.shorten_path(dir))
|
open_cmdline_with_path(fs.shorten_path(dir))
|
||||||
end
|
end
|
||||||
|
|
@ -507,24 +507,24 @@ M.change_sort = {
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if opts.sort then
|
if opts.sort then
|
||||||
canola.set_sort(opts.sort)
|
oil.set_sort(opts.sort)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sort_cols = { 'name', 'size', 'atime', 'mtime', 'ctime', 'birthtime' }
|
local sort_cols = { 'name', 'size', 'atime', 'mtime', 'ctime', 'birthtime' }
|
||||||
vim.ui.select(sort_cols, { prompt = 'Sort by', kind = 'canola_sort_col' }, function(col)
|
vim.ui.select(sort_cols, { prompt = 'Sort by', kind = 'oil_sort_col' }, function(col)
|
||||||
if not col then
|
if not col then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.ui.select(
|
vim.ui.select(
|
||||||
{ 'ascending', 'descending' },
|
{ 'ascending', 'descending' },
|
||||||
{ prompt = 'Sort order', kind = 'canola_sort_order' },
|
{ prompt = 'Sort order', kind = 'oil_sort_order' },
|
||||||
function(order)
|
function(order)
|
||||||
if not order then
|
if not order then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
order = order == 'ascending' and 'asc' or 'desc'
|
order = order == 'ascending' and 'asc' or 'desc'
|
||||||
canola.set_sort({
|
oil.set_sort({
|
||||||
{ 'type', 'asc' },
|
{ 'type', 'asc' },
|
||||||
{ col, order },
|
{ col, order },
|
||||||
})
|
})
|
||||||
|
|
@ -534,8 +534,8 @@ M.change_sort = {
|
||||||
end,
|
end,
|
||||||
parameters = {
|
parameters = {
|
||||||
sort = {
|
sort = {
|
||||||
type = 'canola.SortSpec[]',
|
type = 'oil.SortSpec[]',
|
||||||
desc = 'List of columns plus direction (see |canola.set_sort|) instead of interactive selection',
|
desc = 'List of columns plus direction (see |oil.set_sort|) instead of interactive selection',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -543,19 +543,19 @@ M.change_sort = {
|
||||||
M.toggle_trash = {
|
M.toggle_trash = {
|
||||||
desc = 'Jump to and from the trash for the current directory',
|
desc = 'Jump to and from the trash for the current directory',
|
||||||
callback = function()
|
callback = function()
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local bufname = vim.api.nvim_buf_get_name(0)
|
local bufname = vim.api.nvim_buf_get_name(0)
|
||||||
local scheme, path = util.parse_url(bufname)
|
local scheme, path = util.parse_url(bufname)
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local url
|
local url
|
||||||
if scheme == 'canola://' then
|
if scheme == 'oil://' then
|
||||||
url = 'canola-trash://' .. path
|
url = 'oil-trash://' .. path
|
||||||
elseif scheme == 'canola-trash://' then
|
elseif scheme == 'oil-trash://' then
|
||||||
url = 'canola://' .. path
|
url = 'oil://' .. path
|
||||||
-- The non-linux trash implementations don't support per-directory trash,
|
-- The non-linux trash implementations don't support per-directory trash,
|
||||||
-- so jump back to the stored source buffer.
|
-- so jump back to the stored source buffer.
|
||||||
if not fs.is_linux then
|
if not fs.is_linux then
|
||||||
local src_bufnr = vim.b.canola_trash_toggle_src
|
local src_bufnr = vim.b.oil_trash_toggle_src
|
||||||
if src_bufnr and vim.api.nvim_buf_is_valid(src_bufnr) then
|
if src_bufnr and vim.api.nvim_buf_is_valid(src_bufnr) then
|
||||||
url = vim.api.nvim_buf_get_name(src_bufnr)
|
url = vim.api.nvim_buf_get_name(src_bufnr)
|
||||||
end
|
end
|
||||||
|
|
@ -565,12 +565,12 @@ M.toggle_trash = {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.cmd.edit({ args = { url } })
|
vim.cmd.edit({ args = { url } })
|
||||||
vim.b.canola_trash_toggle_src = bufnr
|
vim.b.oil_trash_toggle_src = bufnr
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.send_to_qflist = {
|
M.send_to_qflist = {
|
||||||
desc = 'Sends files in the current canola directory to the quickfix list, replacing the previous entries.',
|
desc = 'Sends files in the current oil directory to the quickfix list, replacing the previous entries.',
|
||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
opts = vim.tbl_deep_extend('keep', opts or {}, {
|
opts = vim.tbl_deep_extend('keep', opts or {}, {
|
||||||
target = 'qflist',
|
target = 'qflist',
|
||||||
|
|
@ -600,7 +600,7 @@ M.send_to_qflist = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.add_to_qflist = {
|
M.add_to_qflist = {
|
||||||
desc = 'Adds files in the current canola directory to the quickfix list, keeping the previous entries.',
|
desc = 'Adds files in the current oil directory to the quickfix list, keeping the previous entries.',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
util.send_to_quickfix({
|
util.send_to_quickfix({
|
||||||
|
|
@ -611,7 +611,7 @@ M.add_to_qflist = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.send_to_loclist = {
|
M.send_to_loclist = {
|
||||||
desc = 'Sends files in the current canola directory to the location list, replacing the previous entries.',
|
desc = 'Sends files in the current oil directory to the location list, replacing the previous entries.',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
util.send_to_quickfix({
|
util.send_to_quickfix({
|
||||||
|
|
@ -622,7 +622,7 @@ M.send_to_loclist = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.add_to_loclist = {
|
M.add_to_loclist = {
|
||||||
desc = 'Adds files in the current canola directory to the location list, keeping the previous entries.',
|
desc = 'Adds files in the current oil directory to the location list, keeping the previous entries.',
|
||||||
deprecated = true,
|
deprecated = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
util.send_to_quickfix({
|
util.send_to_quickfix({
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local columns = require('canola.columns')
|
local columns = require('oil.columns')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local git = require('canola.git')
|
local git = require('oil.git')
|
||||||
local log = require('canola.log')
|
local log = require('oil.log')
|
||||||
local permissions = require('canola.adapters.files.permissions')
|
local permissions = require('oil.adapters.files.permissions')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
@ -35,11 +35,11 @@ local function read_link_data(path, cb)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class (exact) canola.FilesAdapter: canola.Adapter
|
---@class (exact) oil.FilesAdapter: oil.Adapter
|
||||||
---@field to_short_os_path fun(path: string, entry_type: nil|canola.EntryType): string
|
---@field to_short_os_path fun(path: string, entry_type: nil|oil.EntryType): string
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param entry_type nil|canola.EntryType
|
---@param entry_type nil|oil.EntryType
|
||||||
---@return string
|
---@return string
|
||||||
M.to_short_os_path = function(path, entry_type)
|
M.to_short_os_path = function(path, entry_type)
|
||||||
local shortpath = fs.shorten_path(fs.posix_to_os_path(path))
|
local shortpath = fs.shorten_path(fs.posix_to_os_path(path))
|
||||||
|
|
@ -229,7 +229,7 @@ local function columns_require_stat(column_defs)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return file_columns[name]
|
return file_columns[name]
|
||||||
end
|
end
|
||||||
|
|
@ -287,7 +287,7 @@ M.normalize_url = function(url, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@param cb fun(path: nil|string)
|
---@param cb fun(path: nil|string)
|
||||||
M.get_entry_path = function(url, entry, cb)
|
M.get_entry_path = function(url, entry, cb)
|
||||||
if entry.id then
|
if entry.id then
|
||||||
|
|
@ -306,7 +306,7 @@ M.get_entry_path = function(url, entry, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param parent_dir string
|
---@param parent_dir string
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@param require_stat boolean
|
---@param require_stat boolean
|
||||||
---@param cb fun(err?: string)
|
---@param cb fun(err?: string)
|
||||||
local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
||||||
|
|
@ -318,7 +318,7 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sometimes fs_readdir entries don't have a type, so we need to stat them.
|
-- Sometimes fs_readdir entries don't have a type, so we need to stat them.
|
||||||
-- See https://github.com/stevearc/canola.nvim/issues/543
|
-- See https://github.com/stevearc/oil.nvim/issues/543
|
||||||
if not require_stat and not entry[FIELD_TYPE] then
|
if not require_stat and not entry[FIELD_TYPE] then
|
||||||
require_stat = true
|
require_stat = true
|
||||||
end
|
end
|
||||||
|
|
@ -367,7 +367,7 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- On windows, sometimes the entry type from fs_readdir is "link" but the actual type is not.
|
-- On windows, sometimes the entry type from fs_readdir is "link" but the actual type is not.
|
||||||
-- See https://github.com/stevearc/canola.nvim/issues/535
|
-- See https://github.com/stevearc/oil.nvim/issues/535
|
||||||
if fs.is_windows then
|
if fs.is_windows then
|
||||||
local old_fetch_metadata = fetch_entry_metadata
|
local old_fetch_metadata = fetch_entry_metadata
|
||||||
fetch_entry_metadata = function(parent_dir, entry, require_stat, cb)
|
fetch_entry_metadata = function(parent_dir, entry, require_stat, cb)
|
||||||
|
|
@ -396,7 +396,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
local function list_windows_drives(url, column_defs, cb)
|
local function list_windows_drives(url, column_defs, cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
assert(path)
|
assert(path)
|
||||||
|
|
@ -443,7 +443,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, cb)
|
M.list = function(url, column_defs, cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
assert(path)
|
assert(path)
|
||||||
|
|
@ -521,7 +521,7 @@ M.is_modifiable = function(bufnr)
|
||||||
return uv.fs_access(dir, 'W') == true
|
return uv.fs_access(dir, 'W') == true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -563,7 +563,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -610,7 +610,7 @@ M.perform_action = function(action, cb)
|
||||||
if not err then
|
if not err then
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaFileCreated', modeline = false, data = { path = path } }
|
{ pattern = 'OilFileCreated', modeline = false, data = { path = path } }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
cb(err)
|
cb(err)
|
||||||
|
|
@ -634,7 +634,7 @@ M.perform_action = function(action, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.delete_to_trash then
|
if config.delete_to_trash then
|
||||||
require('canola.adapters.trash').delete_to_trash(path, cb)
|
require('oil.adapters.trash').delete_to_trash(path, cb)
|
||||||
else
|
else
|
||||||
fs.recursive_delete(action.entry_type, path, cb)
|
fs.recursive_delete(action.entry_type, path, cb)
|
||||||
end
|
end
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local loading = require('canola.loading')
|
local loading = require('oil.loading')
|
||||||
local pathutil = require('canola.pathutil')
|
local pathutil = require('oil.pathutil')
|
||||||
local s3fs = require('canola.adapters.s3.s3fs')
|
local s3fs = require('oil.adapters.s3.s3fs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
---@class (exact) canola.s3Url
|
---@class (exact) oil.s3Url
|
||||||
---@field scheme string
|
---@field scheme string
|
||||||
---@field bucket nil|string
|
---@field bucket nil|string
|
||||||
---@field path nil|string
|
---@field path nil|string
|
||||||
|
|
||||||
---@param canola_url string
|
---@param oil_url string
|
||||||
---@return canola.s3Url
|
---@return oil.s3Url
|
||||||
M.parse_url = function(canola_url)
|
M.parse_url = function(oil_url)
|
||||||
local scheme, url = util.parse_url(canola_url)
|
local scheme, url = util.parse_url(oil_url)
|
||||||
assert(scheme and url, string.format("Malformed input url '%s'", canola_url))
|
assert(scheme and url, string.format("Malformed input url '%s'", oil_url))
|
||||||
local ret = { scheme = scheme }
|
local ret = { scheme = scheme }
|
||||||
local bucket, path = url:match('^([^/]+)/?(.*)$')
|
local bucket, path = url:match('^([^/]+)/?(.*)$')
|
||||||
ret.bucket = bucket
|
ret.bucket = bucket
|
||||||
ret.path = path ~= '' and path or nil
|
ret.path = path ~= '' and path or nil
|
||||||
if not ret.bucket and ret.path then
|
if not ret.bucket and ret.path then
|
||||||
error(string.format('Parsing error for s3 url: %s', canola_url))
|
error(string.format('Parsing error for s3 url: %s', oil_url))
|
||||||
end
|
end
|
||||||
---@cast ret canola.s3Url
|
---@cast ret oil.s3Url
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.s3Url
|
---@param url oil.s3Url
|
||||||
---@return string
|
---@return string
|
||||||
local function url_to_str(url)
|
local function url_to_str(url)
|
||||||
local pieces = { url.scheme }
|
local pieces = { url.scheme }
|
||||||
|
|
@ -48,7 +48,7 @@ local function url_to_str(url)
|
||||||
return table.concat(pieces, '')
|
return table.concat(pieces, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.s3Url
|
---@param url oil.s3Url
|
||||||
---@param is_folder boolean
|
---@param is_folder boolean
|
||||||
---@return string
|
---@return string
|
||||||
local function url_to_s3(url, is_folder)
|
local function url_to_s3(url, is_folder)
|
||||||
|
|
@ -68,7 +68,7 @@ local function url_to_s3(url, is_folder)
|
||||||
return table.concat(pieces, '')
|
return table.concat(pieces, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.s3Url
|
---@param url oil.s3Url
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function is_bucket(url)
|
local function is_bucket(url)
|
||||||
assert(url.bucket and url.bucket ~= '')
|
assert(url.bucket and url.bucket ~= '')
|
||||||
|
|
@ -143,7 +143,7 @@ s3_columns.birthtime = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return s3_columns[name]
|
return s3_columns[name]
|
||||||
end
|
end
|
||||||
|
|
@ -171,7 +171,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param callback fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param callback fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, callback)
|
M.list = function(url, column_defs, callback)
|
||||||
if vim.fn.executable('aws') ~= 1 then
|
if vim.fn.executable('aws') ~= 1 then
|
||||||
callback('`aws` is not executable. Can you run `aws s3 ls`?')
|
callback('`aws` is not executable. Can you run `aws s3 ls`?')
|
||||||
|
|
@ -189,7 +189,7 @@ M.is_modifiable = function(bufnr)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
local is_folder = action.entry_type == 'directory'
|
local is_folder = action.entry_type == 'directory'
|
||||||
|
|
@ -221,7 +221,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
local is_folder = action.entry_type == 'directory'
|
local is_folder = action.entry_type == 'directory'
|
||||||
|
|
@ -330,7 +330,7 @@ M.read_file = function(bufnr)
|
||||||
local basename = pathutil.basename(bufname)
|
local basename = pathutil.basename(bufname)
|
||||||
local cache_dir = vim.fn.stdpath('cache')
|
local cache_dir = vim.fn.stdpath('cache')
|
||||||
assert(type(cache_dir) == 'string')
|
assert(type(cache_dir) == 'string')
|
||||||
local tmpdir = fs.join(cache_dir, 'canola')
|
local tmpdir = fs.join(cache_dir, 'oil')
|
||||||
fs.mkdirp(tmpdir)
|
fs.mkdirp(tmpdir)
|
||||||
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 's3_XXXXXX'))
|
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 's3_XXXXXX'))
|
||||||
if fd then
|
if fd then
|
||||||
|
|
@ -368,7 +368,7 @@ M.write_file = function(bufnr)
|
||||||
local url = M.parse_url(bufname)
|
local url = M.parse_url(bufname)
|
||||||
local cache_dir = vim.fn.stdpath('cache')
|
local cache_dir = vim.fn.stdpath('cache')
|
||||||
assert(type(cache_dir) == 'string')
|
assert(type(cache_dir) == 'string')
|
||||||
local tmpdir = fs.join(cache_dir, 'canola')
|
local tmpdir = fs.join(cache_dir, 'oil')
|
||||||
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 's3_XXXXXXXX'))
|
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 's3_XXXXXXXX'))
|
||||||
if fd then
|
if fd then
|
||||||
vim.loop.fs_close(fd)
|
vim.loop.fs_close(fd)
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local shell = require('canola.shell')
|
local shell = require('oil.shell')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
---@param line string
|
---@param line string
|
||||||
---@return string Name of entry
|
---@return string Name of entry
|
||||||
---@return canola.EntryType
|
---@return oil.EntryType
|
||||||
---@return table Metadata for entry
|
---@return table Metadata for entry
|
||||||
local function parse_ls_line_bucket(line)
|
local function parse_ls_line_bucket(line)
|
||||||
local date, name = line:match('^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(.*)$')
|
local date, name = line:match('^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(.*)$')
|
||||||
|
|
@ -24,7 +24,7 @@ end
|
||||||
|
|
||||||
---@param line string
|
---@param line string
|
||||||
---@return string Name of entry
|
---@return string Name of entry
|
||||||
---@return canola.EntryType
|
---@return oil.EntryType
|
||||||
---@return table Metadata for entry
|
---@return table Metadata for entry
|
||||||
local function parse_ls_line_file(line)
|
local function parse_ls_line_file(line)
|
||||||
local name = line:match('^%s+PRE%s+(.*)/$')
|
local name = line:match('^%s+PRE%s+(.*)/$')
|
||||||
|
|
@ -52,7 +52,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param callback fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param callback fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
function M.list_dir(url, path, callback)
|
function M.list_dir(url, path, callback)
|
||||||
local cmd = create_s3_command({ 'ls', path, '--color=off', '--no-cli-pager' })
|
local cmd = create_s3_command({ 'ls', path, '--color=off', '--no-cli-pager' })
|
||||||
shell.run(cmd, function(err, lines)
|
shell.run(cmd, function(err, lines)
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local loading = require('canola.loading')
|
local loading = require('oil.loading')
|
||||||
local pathutil = require('canola.pathutil')
|
local pathutil = require('oil.pathutil')
|
||||||
local permissions = require('canola.adapters.files.permissions')
|
local permissions = require('oil.adapters.files.permissions')
|
||||||
local shell = require('canola.shell')
|
local shell = require('oil.shell')
|
||||||
local sshfs = require('canola.adapters.ssh.sshfs')
|
local sshfs = require('oil.adapters.ssh.sshfs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_NAME = constants.FIELD_NAME
|
local FIELD_NAME = constants.FIELD_NAME
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
---@class (exact) canola.sshUrl
|
---@class (exact) oil.sshUrl
|
||||||
---@field scheme string
|
---@field scheme string
|
||||||
---@field host string
|
---@field host string
|
||||||
---@field user nil|string
|
---@field user nil|string
|
||||||
|
|
@ -28,11 +28,11 @@ local function scp(args, ...)
|
||||||
shell.run(cmd, ...)
|
shell.run(cmd, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param canola_url string
|
---@param oil_url string
|
||||||
---@return canola.sshUrl
|
---@return oil.sshUrl
|
||||||
M.parse_url = function(canola_url)
|
M.parse_url = function(oil_url)
|
||||||
local scheme, url = util.parse_url(canola_url)
|
local scheme, url = util.parse_url(oil_url)
|
||||||
assert(scheme and url, string.format("Malformed input url '%s'", canola_url))
|
assert(scheme and url, string.format("Malformed input url '%s'", oil_url))
|
||||||
local ret = { scheme = scheme }
|
local ret = { scheme = scheme }
|
||||||
local username, rem = url:match('^([^@%s]+)@(.*)$')
|
local username, rem = url:match('^([^@%s]+)@(.*)$')
|
||||||
ret.user = username
|
ret.user = username
|
||||||
|
|
@ -48,14 +48,14 @@ M.parse_url = function(canola_url)
|
||||||
ret.path = path
|
ret.path = path
|
||||||
end
|
end
|
||||||
if not ret.host or not ret.path then
|
if not ret.host or not ret.path then
|
||||||
error(string.format('Malformed SSH url: %s', canola_url))
|
error(string.format('Malformed SSH url: %s', oil_url))
|
||||||
end
|
end
|
||||||
|
|
||||||
---@cast ret canola.sshUrl
|
---@cast ret oil.sshUrl
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.sshUrl
|
---@param url oil.sshUrl
|
||||||
---@return string
|
---@return string
|
||||||
local function url_to_str(url)
|
local function url_to_str(url)
|
||||||
local pieces = { url.scheme }
|
local pieces = { url.scheme }
|
||||||
|
|
@ -72,7 +72,7 @@ local function url_to_str(url)
|
||||||
return table.concat(pieces, '')
|
return table.concat(pieces, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.sshUrl
|
---@param url oil.sshUrl
|
||||||
---@return string
|
---@return string
|
||||||
local function url_to_scp(url)
|
local function url_to_scp(url)
|
||||||
local pieces = { 'scp://' }
|
local pieces = { 'scp://' }
|
||||||
|
|
@ -90,8 +90,8 @@ local function url_to_scp(url)
|
||||||
return table.concat(pieces, '')
|
return table.concat(pieces, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url1 canola.sshUrl
|
---@param url1 oil.sshUrl
|
||||||
---@param url2 canola.sshUrl
|
---@param url2 oil.sshUrl
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function url_hosts_equal(url1, url2)
|
local function url_hosts_equal(url1, url2)
|
||||||
return url1.host == url2.host and url1.port == url2.port and url1.user == url2.user
|
return url1.host == url2.host and url1.port == url2.port and url1.user == url2.user
|
||||||
|
|
@ -100,7 +100,7 @@ end
|
||||||
local _connections = {}
|
local _connections = {}
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param allow_retry nil|boolean
|
---@param allow_retry nil|boolean
|
||||||
---@return canola.sshFs
|
---@return oil.sshFs
|
||||||
local function get_connection(url, allow_retry)
|
local function get_connection(url, allow_retry)
|
||||||
local res = M.parse_url(url)
|
local res = M.parse_url(url)
|
||||||
res.scheme = config.adapter_to_scheme.ssh
|
res.scheme = config.adapter_to_scheme.ssh
|
||||||
|
|
@ -183,7 +183,7 @@ ssh_columns.size = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return ssh_columns[name]
|
return ssh_columns[name]
|
||||||
end
|
end
|
||||||
|
|
@ -228,7 +228,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param callback fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param callback fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, callback)
|
M.list = function(url, column_defs, callback)
|
||||||
local res = M.parse_url(url)
|
local res = M.parse_url(url)
|
||||||
|
|
||||||
|
|
@ -261,7 +261,7 @@ M.is_modifiable = function(bufnr)
|
||||||
return bit.band(rwx, 2) ~= 0
|
return bit.band(rwx, 2) ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -290,7 +290,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -372,7 +372,7 @@ M.read_file = function(bufnr)
|
||||||
local basename = pathutil.basename(bufname)
|
local basename = pathutil.basename(bufname)
|
||||||
local cache_dir = vim.fn.stdpath('cache')
|
local cache_dir = vim.fn.stdpath('cache')
|
||||||
assert(type(cache_dir) == 'string')
|
assert(type(cache_dir) == 'string')
|
||||||
local tmpdir = fs.join(cache_dir, 'canola')
|
local tmpdir = fs.join(cache_dir, 'oil')
|
||||||
fs.mkdirp(tmpdir)
|
fs.mkdirp(tmpdir)
|
||||||
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 'ssh_XXXXXX'))
|
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 'ssh_XXXXXX'))
|
||||||
if fd then
|
if fd then
|
||||||
|
|
@ -412,7 +412,7 @@ M.write_file = function(bufnr)
|
||||||
local scp_url = url_to_scp(url)
|
local scp_url = url_to_scp(url)
|
||||||
local cache_dir = vim.fn.stdpath('cache')
|
local cache_dir = vim.fn.stdpath('cache')
|
||||||
assert(type(cache_dir) == 'string')
|
assert(type(cache_dir) == 'string')
|
||||||
local tmpdir = fs.join(cache_dir, 'canola')
|
local tmpdir = fs.join(cache_dir, 'oil')
|
||||||
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 'ssh_XXXXXXXX'))
|
local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, 'ssh_XXXXXXXX'))
|
||||||
if fd then
|
if fd then
|
||||||
vim.loop.fs_close(fd)
|
vim.loop.fs_close(fd)
|
||||||
|
|
@ -446,7 +446,7 @@ M.goto_file = function()
|
||||||
url.path = vim.fs.dirname(fullpath)
|
url.path = vim.fs.dirname(fullpath)
|
||||||
local parurl = url_to_str(url)
|
local parurl = url_to_str(url)
|
||||||
|
|
||||||
---@cast M canola.Adapter
|
---@cast M oil.Adapter
|
||||||
util.adapter_list_all(M, parurl, {}, function(err, entries)
|
util.adapter_list_all(M, parurl, {}, function(err, entries)
|
||||||
if err then
|
if err then
|
||||||
vim.notify(string.format("Error finding file '%s': %s", fname, err), vim.log.levels.ERROR)
|
vim.notify(string.format("Error finding file '%s': %s", fname, err), vim.log.levels.ERROR)
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local layout = require('canola.layout')
|
local layout = require('oil.layout')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
---@class (exact) canola.sshCommand
|
---@class (exact) oil.sshCommand
|
||||||
---@field cmd string|string[]
|
---@field cmd string|string[]
|
||||||
---@field cb fun(err?: string, output?: string[])
|
---@field cb fun(err?: string, output?: string[])
|
||||||
---@field running? boolean
|
---@field running? boolean
|
||||||
|
|
||||||
---@class (exact) canola.sshConnection
|
---@class (exact) oil.sshConnection
|
||||||
---@field new fun(url: canola.sshUrl): canola.sshConnection
|
---@field new fun(url: oil.sshUrl): oil.sshConnection
|
||||||
---@field create_ssh_command fun(url: canola.sshUrl): string[]
|
---@field create_ssh_command fun(url: oil.sshUrl): string[]
|
||||||
---@field meta {user?: string, groups?: string[]}
|
---@field meta {user?: string, groups?: string[]}
|
||||||
---@field connection_error nil|string
|
---@field connection_error nil|string
|
||||||
---@field connected boolean
|
---@field connected boolean
|
||||||
---@field private term_bufnr integer
|
---@field private term_bufnr integer
|
||||||
---@field private jid integer
|
---@field private jid integer
|
||||||
---@field private term_winid nil|integer
|
---@field private term_winid nil|integer
|
||||||
---@field private commands canola.sshCommand[]
|
---@field private commands oil.sshCommand[]
|
||||||
---@field private _stdout string[]
|
---@field private _stdout string[]
|
||||||
local SSHConnection = {}
|
local SSHConnection = {}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ local function get_last_lines(bufnr, num_lines)
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.sshUrl
|
---@param url oil.sshUrl
|
||||||
---@return string[]
|
---@return string[]
|
||||||
function SSHConnection.create_ssh_command(url)
|
function SSHConnection.create_ssh_command(url)
|
||||||
local host = url.host
|
local host = url.host
|
||||||
|
|
@ -79,8 +79,8 @@ function SSHConnection.create_ssh_command(url)
|
||||||
return command
|
return command
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.sshUrl
|
---@param url oil.sshUrl
|
||||||
---@return canola.sshConnection
|
---@return oil.sshConnection
|
||||||
function SSHConnection.new(url)
|
function SSHConnection.new(url)
|
||||||
local command = SSHConnection.create_ssh_command(url)
|
local command = SSHConnection.create_ssh_command(url)
|
||||||
vim.list_extend(command, {
|
vim.list_extend(command, {
|
||||||
|
|
@ -142,7 +142,7 @@ function SSHConnection.new(url)
|
||||||
self:_set_connection_error('SSH connection terminated gracefully')
|
self:_set_connection_error('SSH connection terminated gracefully')
|
||||||
else
|
else
|
||||||
self:_set_connection_error(
|
self:_set_connection_error(
|
||||||
'Unknown SSH error\nTo see more, run :lua require("canola.adapters.ssh").open_terminal()'
|
'Unknown SSH error\nTo see more, run :lua require("oil.adapters.ssh").open_terminal()'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end, 20)
|
end, 20)
|
||||||
|
|
@ -176,7 +176,7 @@ function SSHConnection.new(url)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
---@cast self canola.sshConnection
|
---@cast self oil.sshConnection
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
local SSHConnection = require('canola.adapters.ssh.connection')
|
local SSHConnection = require('oil.adapters.ssh.connection')
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local permissions = require('canola.adapters.files.permissions')
|
local permissions = require('oil.adapters.files.permissions')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
---@class (exact) canola.sshFs
|
---@class (exact) oil.sshFs
|
||||||
---@field new fun(url: canola.sshUrl): canola.sshFs
|
---@field new fun(url: oil.sshUrl): oil.sshFs
|
||||||
---@field conn canola.sshConnection
|
---@field conn oil.sshConnection
|
||||||
local SSHFS = {}
|
local SSHFS = {}
|
||||||
|
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
|
|
@ -23,7 +23,7 @@ local typechar_map = {
|
||||||
}
|
}
|
||||||
---@param line string
|
---@param line string
|
||||||
---@return string Name of entry
|
---@return string Name of entry
|
||||||
---@return canola.EntryType
|
---@return oil.EntryType
|
||||||
---@return table Metadata for entry
|
---@return table Metadata for entry
|
||||||
local function parse_ls_line(line)
|
local function parse_ls_line(line)
|
||||||
local typechar, perms, refcount, user, group, rem =
|
local typechar, perms, refcount, user, group, rem =
|
||||||
|
|
@ -74,10 +74,10 @@ local function shellescape(str)
|
||||||
return "'" .. str:gsub("'", "'\\''") .. "'"
|
return "'" .. str:gsub("'", "'\\''") .. "'"
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url canola.sshUrl
|
---@param url oil.sshUrl
|
||||||
---@return canola.sshFs
|
---@return oil.sshFs
|
||||||
function SSHFS.new(url)
|
function SSHFS.new(url)
|
||||||
---@type canola.sshFs
|
---@type oil.sshFs
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
conn = SSHConnection.new(url),
|
conn = SSHConnection.new(url),
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -144,7 +144,7 @@ local dir_meta = {}
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param callback fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param callback fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
function SSHFS:list_dir(url, path, callback)
|
function SSHFS:list_dir(url, path, callback)
|
||||||
local path_postfix = ''
|
local path_postfix = ''
|
||||||
if path ~= '' then
|
if path ~= '' then
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
|
|
@ -12,7 +12,7 @@ local dir_listing = {}
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, cb)
|
M.list = function(url, column_defs, cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
local entries = dir_listing[path] or {}
|
local entries = dir_listing[path] or {}
|
||||||
|
|
@ -29,8 +29,8 @@ M.test_clear = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@return canola.InternalEntry
|
---@return oil.InternalEntry
|
||||||
M.test_set = function(path, entry_type)
|
M.test_set = function(path, entry_type)
|
||||||
if path == '/' then
|
if path == '/' then
|
||||||
return {}
|
return {}
|
||||||
|
|
@ -49,12 +49,12 @@ M.test_set = function(path, entry_type)
|
||||||
entry_type = entry_type,
|
entry_type = entry_type,
|
||||||
}
|
}
|
||||||
table.insert(dir_listing[parent], entry)
|
table.insert(dir_listing[parent], entry)
|
||||||
local parent_url = 'canola-test://' .. parent
|
local parent_url = 'oil-test://' .. parent
|
||||||
return cache.create_and_store_entry(parent_url, entry.name, entry.entry_type)
|
return cache.create_and_store_entry(parent_url, entry.name, entry.entry_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
@ -65,7 +65,7 @@ M.is_modifiable = function(bufnr)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'create' or action.type == 'delete' then
|
if action.type == 'create' or action.type == 'delete' then
|
||||||
|
|
@ -77,7 +77,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
cb()
|
cb()
|
||||||
9
lua/oil/adapters/trash.lua
Normal file
9
lua/oil/adapters/trash.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local fs = require('oil.fs')
|
||||||
|
|
||||||
|
if fs.is_mac then
|
||||||
|
return require('oil.adapters.trash.mac')
|
||||||
|
elseif fs.is_windows then
|
||||||
|
return require('oil.adapters.trash.windows')
|
||||||
|
else
|
||||||
|
return require('oil.adapters.trash.freedesktop')
|
||||||
|
end
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
-- Based on the FreeDesktop.org trash specification
|
-- Based on the FreeDesktop.org trash specification
|
||||||
-- https://specifications.freedesktop.org/trash/1.0/
|
-- https://specifications.freedesktop.org/trash/1.0/
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
@ -127,12 +127,12 @@ M.normalize_url = function(url, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@param cb fun(path: string)
|
---@param cb fun(path: string)
|
||||||
M.get_entry_path = function(url, entry, cb)
|
M.get_entry_path = function(url, entry, cb)
|
||||||
local internal_entry = assert(cache.get_entry_by_id(entry.id))
|
local internal_entry = assert(cache.get_entry_by_id(entry.id))
|
||||||
local meta = assert(internal_entry[FIELD_META])
|
local meta = assert(internal_entry[FIELD_META])
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = meta.trash_info
|
local trash_info = meta.trash_info
|
||||||
if not trash_info then
|
if not trash_info then
|
||||||
-- This is a subpath in the trash
|
-- This is a subpath in the trash
|
||||||
|
|
@ -143,10 +143,10 @@ M.get_entry_path = function(url, entry, cb)
|
||||||
if meta.stat.type == 'directory' then
|
if meta.stat.type == 'directory' then
|
||||||
path = util.addslash(path)
|
path = util.addslash(path)
|
||||||
end
|
end
|
||||||
cb('canola://' .. path)
|
cb('oil://' .. path)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class canola.TrashInfo
|
---@class oil.TrashInfo
|
||||||
---@field trash_file string
|
---@field trash_file string
|
||||||
---@field info_file string
|
---@field info_file string
|
||||||
---@field original_path string
|
---@field original_path string
|
||||||
|
|
@ -154,7 +154,7 @@ end
|
||||||
---@field stat uv.aliases.fs_stat_table
|
---@field stat uv.aliases.fs_stat_table
|
||||||
|
|
||||||
---@param info_file string
|
---@param info_file string
|
||||||
---@param cb fun(err?: string, info?: canola.TrashInfo)
|
---@param cb fun(err?: string, info?: oil.TrashInfo)
|
||||||
local function read_trash_info(info_file, cb)
|
local function read_trash_info(info_file, cb)
|
||||||
if not vim.endswith(info_file, '.trashinfo') then
|
if not vim.endswith(info_file, '.trashinfo') then
|
||||||
return cb('File is not .trashinfo')
|
return cb('File is not .trashinfo')
|
||||||
|
|
@ -210,7 +210,7 @@ local function read_trash_info(info_file, cb)
|
||||||
cb('.trashinfo file points to non-existant file')
|
cb('.trashinfo file points to non-existant file')
|
||||||
else
|
else
|
||||||
trash_info.stat = trash_stat
|
trash_info.stat = trash_stat
|
||||||
---@cast trash_info canola.TrashInfo
|
---@cast trash_info oil.TrashInfo
|
||||||
cb(nil, trash_info)
|
cb(nil, trash_info)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -222,7 +222,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, cb)
|
M.list = function(url, column_defs, cb)
|
||||||
cb = vim.schedule_wrap(cb)
|
cb = vim.schedule_wrap(cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
|
|
@ -357,7 +357,7 @@ file_columns.mtime = {
|
||||||
if not meta then
|
if not meta then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = meta.trash_info
|
local trash_info = meta.trash_info
|
||||||
local time = trash_info and trash_info.deletion_date or meta.stat and meta.stat.mtime.sec
|
local time = trash_info and trash_info.deletion_date or meta.stat and meta.stat.mtime.sec
|
||||||
if not time then
|
if not time then
|
||||||
|
|
@ -380,7 +380,7 @@ file_columns.mtime = {
|
||||||
|
|
||||||
get_sort_value = function(entry)
|
get_sort_value = function(entry)
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type nil|canola.TrashInfo
|
---@type nil|oil.TrashInfo
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
if trash_info then
|
if trash_info then
|
||||||
return trash_info.deletion_date
|
return trash_info.deletion_date
|
||||||
|
|
@ -402,14 +402,14 @@ file_columns.mtime = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return file_columns[name]
|
return file_columns[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
M.supported_cross_adapter_actions = { files = 'move' }
|
M.supported_cross_adapter_actions = { files = 'move' }
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.filter_action = function(action)
|
M.filter_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -432,7 +432,7 @@ M.filter_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param err canola.ParseError
|
---@param err oil.ParseError
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.filter_error = function(err)
|
M.filter_error = function(err)
|
||||||
if err.message == 'Duplicate filename' then
|
if err.message == 'Duplicate filename' then
|
||||||
|
|
@ -441,13 +441,13 @@ M.filter_error = function(err)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'delete' then
|
if action.type == 'delete' then
|
||||||
local entry = assert(cache.get_entry_by_url(action.url))
|
local entry = assert(cache.get_entry_by_url(action.url))
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = assert(meta).trash_info
|
local trash_info = assert(meta).trash_info
|
||||||
local short_path = fs.shorten_path(trash_info.original_path)
|
local short_path = fs.shorten_path(trash_info.original_path)
|
||||||
return string.format(' PURGE %s', short_path)
|
return string.format(' PURGE %s', short_path)
|
||||||
|
|
@ -488,7 +488,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param trash_info canola.TrashInfo
|
---@param trash_info oil.TrashInfo
|
||||||
---@param cb fun(err?: string)
|
---@param cb fun(err?: string)
|
||||||
local function purge(trash_info, cb)
|
local function purge(trash_info, cb)
|
||||||
fs.recursive_delete('file', trash_info.info_file, function(err)
|
fs.recursive_delete('file', trash_info.info_file, function(err)
|
||||||
|
|
@ -525,7 +525,7 @@ local function write_info_file(path, info_path, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param cb fun(err?: string, trash_info?: canola.TrashInfo)
|
---@param cb fun(err?: string, trash_info?: oil.TrashInfo)
|
||||||
local function create_trash_info(path, cb)
|
local function create_trash_info(path, cb)
|
||||||
local trash_dir = get_write_trash_dir(path)
|
local trash_dir = get_write_trash_dir(path)
|
||||||
local basename = vim.fs.basename(path)
|
local basename = vim.fs.basename(path)
|
||||||
|
|
@ -542,7 +542,7 @@ local function create_trash_info(path, cb)
|
||||||
if info_err then
|
if info_err then
|
||||||
return cb(info_err)
|
return cb(info_err)
|
||||||
end
|
end
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = {
|
local trash_info = {
|
||||||
original_path = path,
|
original_path = path,
|
||||||
trash_file = dest_path,
|
trash_file = dest_path,
|
||||||
|
|
@ -555,13 +555,13 @@ local function create_trash_info(path, cb)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
if action.type == 'delete' then
|
if action.type == 'delete' then
|
||||||
local entry = assert(cache.get_entry_by_url(action.url))
|
local entry = assert(cache.get_entry_by_url(action.url))
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = assert(meta).trash_info
|
local trash_info = assert(meta).trash_info
|
||||||
purge(trash_info, cb)
|
purge(trash_info, cb)
|
||||||
elseif action.type == 'move' then
|
elseif action.type == 'move' then
|
||||||
|
|
@ -576,7 +576,7 @@ M.perform_action = function(action, cb)
|
||||||
assert(dest_path)
|
assert(dest_path)
|
||||||
local entry = assert(cache.get_entry_by_url(action.src_url))
|
local entry = assert(cache.get_entry_by_url(action.src_url))
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = assert(meta).trash_info
|
local trash_info = assert(meta).trash_info
|
||||||
fs.recursive_move(action.entry_type, trash_info.trash_file, dest_path, function(err)
|
fs.recursive_move(action.entry_type, trash_info.trash_file, dest_path, function(err)
|
||||||
if err then
|
if err then
|
||||||
|
|
@ -607,7 +607,7 @@ M.perform_action = function(action, cb)
|
||||||
assert(dest_path)
|
assert(dest_path)
|
||||||
local entry = assert(cache.get_entry_by_url(action.src_url))
|
local entry = assert(cache.get_entry_by_url(action.src_url))
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type canola.TrashInfo
|
---@type oil.TrashInfo
|
||||||
local trash_info = assert(meta).trash_info
|
local trash_info = assert(meta).trash_info
|
||||||
fs.recursive_copy(action.entry_type, trash_info.trash_file, dest_path, cb)
|
fs.recursive_copy(action.entry_type, trash_info.trash_file, dest_path, cb)
|
||||||
else
|
else
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
|
|
||||||
|
|
@ -29,20 +29,20 @@ M.normalize_url = function(url, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@param cb fun(path: string)
|
---@param cb fun(path: string)
|
||||||
M.get_entry_path = function(url, entry, cb)
|
M.get_entry_path = function(url, entry, cb)
|
||||||
local trash_dir = get_trash_dir()
|
local trash_dir = get_trash_dir()
|
||||||
local path = fs.join(trash_dir, entry.name)
|
local path = fs.join(trash_dir, entry.name)
|
||||||
if entry.type == 'directory' then
|
if entry.type == 'directory' then
|
||||||
path = 'canola://' .. path
|
path = 'oil://' .. path
|
||||||
end
|
end
|
||||||
cb(path)
|
cb(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, cb)
|
M.list = function(url, column_defs, cb)
|
||||||
cb = vim.schedule_wrap(cb)
|
cb = vim.schedule_wrap(cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
|
|
@ -106,14 +106,14 @@ M.is_modifiable = function(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
M.supported_cross_adapter_actions = { files = 'move' }
|
M.supported_cross_adapter_actions = { files = 'move' }
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -143,7 +143,7 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
local trash_dir = get_trash_dir()
|
local trash_dir = get_trash_dir()
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local powershell_trash = require('canola.adapters.trash.windows.powershell-trash')
|
local powershell_trash = require('oil.adapters.trash.windows.powershell-trash')
|
||||||
|
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
|
|
@ -36,7 +36,7 @@ local win_addslash = function(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class canola.WindowsTrashInfo
|
---@class oil.WindowsTrashInfo
|
||||||
---@field trash_file string
|
---@field trash_file string
|
||||||
---@field original_path string
|
---@field original_path string
|
||||||
---@field deletion_date integer
|
---@field deletion_date integer
|
||||||
|
|
@ -44,7 +44,7 @@ end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
---@param cb fun(err?: string, entries?: canola.InternalEntry[], fetch_more?: fun())
|
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||||
M.list = function(url, column_defs, cb)
|
M.list = function(url, column_defs, cb)
|
||||||
local _, path = util.parse_url(url)
|
local _, path = util.parse_url(url)
|
||||||
path = fs.posix_to_os_path(assert(path))
|
path = fs.posix_to_os_path(assert(path))
|
||||||
|
|
@ -70,11 +70,11 @@ M.list = function(url, column_defs, cb)
|
||||||
)
|
)
|
||||||
local displayed_entries = vim.tbl_map(
|
local displayed_entries = vim.tbl_map(
|
||||||
---@param entry {IsFolder: boolean, DeletionDate: integer, Name: string, Path: string, OriginalPath: string}
|
---@param entry {IsFolder: boolean, DeletionDate: integer, Name: string, Path: string, OriginalPath: string}
|
||||||
---@return {[1]:nil, [2]:string, [3]:string, [4]:{stat: uv_fs_t, trash_info: canola.WindowsTrashInfo, display_name: string}}
|
---@return {[1]:nil, [2]:string, [3]:string, [4]:{stat: uv_fs_t, trash_info: oil.WindowsTrashInfo, display_name: string}}
|
||||||
function(entry)
|
function(entry)
|
||||||
local parent = win_addslash(assert(vim.fn.fnamemodify(entry.OriginalPath, ':h')))
|
local parent = win_addslash(assert(vim.fn.fnamemodify(entry.OriginalPath, ':h')))
|
||||||
|
|
||||||
--- @type canola.InternalEntry
|
--- @type oil.InternalEntry
|
||||||
local cache_entry
|
local cache_entry
|
||||||
if path == parent or show_all_files then
|
if path == parent or show_all_files then
|
||||||
local deleted_file_tail = assert(vim.fn.fnamemodify(entry.Path, ':t'))
|
local deleted_file_tail = assert(vim.fn.fnamemodify(entry.Path, ':t'))
|
||||||
|
|
@ -96,7 +96,7 @@ M.list = function(url, column_defs, cb)
|
||||||
end
|
end
|
||||||
cache_entry[FIELD_META] = {
|
cache_entry[FIELD_META] = {
|
||||||
stat = nil,
|
stat = nil,
|
||||||
---@type canola.WindowsTrashInfo
|
---@type oil.WindowsTrashInfo
|
||||||
trash_info = {
|
trash_info = {
|
||||||
trash_file = entry.Path,
|
trash_file = entry.Path,
|
||||||
original_path = entry.OriginalPath,
|
original_path = entry.OriginalPath,
|
||||||
|
|
@ -142,7 +142,7 @@ file_columns.mtime = {
|
||||||
if not meta then
|
if not meta then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
---@type canola.WindowsTrashInfo
|
---@type oil.WindowsTrashInfo
|
||||||
local trash_info = meta.trash_info
|
local trash_info = meta.trash_info
|
||||||
local time = trash_info and trash_info.deletion_date
|
local time = trash_info and trash_info.deletion_date
|
||||||
if not time then
|
if not time then
|
||||||
|
|
@ -165,7 +165,7 @@ file_columns.mtime = {
|
||||||
|
|
||||||
get_sort_value = function(entry)
|
get_sort_value = function(entry)
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type nil|canola.WindowsTrashInfo
|
---@type nil|oil.WindowsTrashInfo
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
if trash_info and trash_info.deletion_date then
|
if trash_info and trash_info.deletion_date then
|
||||||
return trash_info.deletion_date
|
return trash_info.deletion_date
|
||||||
|
|
@ -187,12 +187,12 @@ file_columns.mtime = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(name)
|
M.get_column = function(name)
|
||||||
return file_columns[name]
|
return file_columns[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.filter_action = function(action)
|
M.filter_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
|
|
@ -232,11 +232,11 @@ M.normalize_url = function(url, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@param cb fun(path: string)
|
---@param cb fun(path: string)
|
||||||
M.get_entry_path = function(url, entry, cb)
|
M.get_entry_path = function(url, entry, cb)
|
||||||
local internal_entry = assert(cache.get_entry_by_id(entry.id))
|
local internal_entry = assert(cache.get_entry_by_id(entry.id))
|
||||||
local meta = internal_entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: canola.WindowsTrashInfo, display_name: string}]]
|
local meta = internal_entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: oil.WindowsTrashInfo, display_name: string}]]
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
if not trash_info then
|
if not trash_info then
|
||||||
-- This is a subpath in the trash
|
-- This is a subpath in the trash
|
||||||
|
|
@ -248,10 +248,10 @@ M.get_entry_path = function(url, entry, cb)
|
||||||
if entry.type == 'directory' then
|
if entry.type == 'directory' then
|
||||||
path = win_addslash(path)
|
path = win_addslash(path)
|
||||||
end
|
end
|
||||||
cb('canola://' .. path)
|
cb('oil://' .. path)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param err canola.ParseError
|
---@param err oil.ParseError
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.filter_error = function(err)
|
M.filter_error = function(err)
|
||||||
if err.message == 'Duplicate filename' then
|
if err.message == 'Duplicate filename' then
|
||||||
|
|
@ -260,13 +260,13 @@ M.filter_error = function(err)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return string
|
---@return string
|
||||||
M.render_action = function(action)
|
M.render_action = function(action)
|
||||||
if action.type == 'delete' then
|
if action.type == 'delete' then
|
||||||
local entry = assert(cache.get_entry_by_url(action.url))
|
local entry = assert(cache.get_entry_by_url(action.url))
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type canola.WindowsTrashInfo
|
---@type oil.WindowsTrashInfo
|
||||||
local trash_info = assert(meta).trash_info
|
local trash_info = assert(meta).trash_info
|
||||||
local short_path = fs.shorten_path(trash_info.original_path)
|
local short_path = fs.shorten_path(trash_info.original_path)
|
||||||
return string.format(' PURGE %s', short_path)
|
return string.format(' PURGE %s', short_path)
|
||||||
|
|
@ -307,8 +307,8 @@ M.render_action = function(action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param trash_info canola.WindowsTrashInfo
|
---@param trash_info oil.WindowsTrashInfo
|
||||||
---@param cb fun(err?: string, raw_entries: canola.WindowsRawEntry[]?)
|
---@param cb fun(err?: string, raw_entries: oil.WindowsRawEntry[]?)
|
||||||
local purge = function(trash_info, cb)
|
local purge = function(trash_info, cb)
|
||||||
fs.recursive_delete('file', trash_info.info_file, function(err)
|
fs.recursive_delete('file', trash_info.info_file, function(err)
|
||||||
if err then
|
if err then
|
||||||
|
|
@ -320,7 +320,7 @@ end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param type string
|
---@param type string
|
||||||
---@param cb fun(err?: string, trash_info?: canola.TrashInfo)
|
---@param cb fun(err?: string, trash_info?: oil.TrashInfo)
|
||||||
local function create_trash_info_and_copy(path, type, cb)
|
local function create_trash_info_and_copy(path, type, cb)
|
||||||
local temp_path = path .. 'temp'
|
local temp_path = path .. 'temp'
|
||||||
-- create a temporary copy on the same location
|
-- create a temporary copy on the same location
|
||||||
|
|
@ -344,12 +344,12 @@ local function create_trash_info_and_copy(path, type, cb)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.perform_action = function(action, cb)
|
M.perform_action = function(action, cb)
|
||||||
if action.type == 'delete' then
|
if action.type == 'delete' then
|
||||||
local entry = assert(cache.get_entry_by_url(action.url))
|
local entry = assert(cache.get_entry_by_url(action.url))
|
||||||
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: canola.WindowsTrashInfo, display_name: string}]]
|
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: oil.WindowsTrashInfo, display_name: string}]]
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
|
|
||||||
purge(trash_info, cb)
|
purge(trash_info, cb)
|
||||||
|
|
@ -365,7 +365,7 @@ M.perform_action = function(action, cb)
|
||||||
assert(dest_path)
|
assert(dest_path)
|
||||||
dest_path = fs.posix_to_os_path(dest_path)
|
dest_path = fs.posix_to_os_path(dest_path)
|
||||||
local entry = assert(cache.get_entry_by_url(action.src_url))
|
local entry = assert(cache.get_entry_by_url(action.src_url))
|
||||||
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: canola.WindowsTrashInfo, display_name: string}]]
|
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: oil.WindowsTrashInfo, display_name: string}]]
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
fs.recursive_move(action.entry_type, trash_info.trash_file, dest_path, function(err)
|
fs.recursive_move(action.entry_type, trash_info.trash_file, dest_path, function(err)
|
||||||
if err then
|
if err then
|
||||||
|
|
@ -389,7 +389,7 @@ M.perform_action = function(action, cb)
|
||||||
assert(dest_path)
|
assert(dest_path)
|
||||||
dest_path = fs.posix_to_os_path(dest_path)
|
dest_path = fs.posix_to_os_path(dest_path)
|
||||||
local entry = assert(cache.get_entry_by_url(action.src_url))
|
local entry = assert(cache.get_entry_by_url(action.src_url))
|
||||||
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: canola.WindowsTrashInfo, display_name: string}]]
|
local meta = entry[FIELD_META] --[[@as {stat: uv_fs_t, trash_info: oil.WindowsTrashInfo, display_name: string}]]
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
fs.recursive_copy(action.entry_type, trash_info.trash_file, dest_path, cb)
|
fs.recursive_copy(action.entry_type, trash_info.trash_file, dest_path, cb)
|
||||||
else
|
else
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
---@class (exact) canola.PowershellCommand
|
---@class (exact) oil.PowershellCommand
|
||||||
---@field cmd string
|
---@field cmd string
|
||||||
---@field cb fun(err?: string, output?: string)
|
---@field cb fun(err?: string, output?: string)
|
||||||
---@field running? boolean
|
---@field running? boolean
|
||||||
|
|
||||||
---@class canola.PowershellConnection
|
---@class oil.PowershellConnection
|
||||||
---@field private jid integer
|
---@field private jid integer
|
||||||
---@field private execution_error? string
|
---@field private execution_error? string
|
||||||
---@field private commands canola.PowershellCommand[]
|
---@field private commands oil.PowershellCommand[]
|
||||||
---@field private stdout string[]
|
---@field private stdout string[]
|
||||||
---@field private is_reading_data boolean
|
---@field private is_reading_data boolean
|
||||||
local PowershellConnection = {}
|
local PowershellConnection = {}
|
||||||
|
|
||||||
---@param init_command? string
|
---@param init_command? string
|
||||||
---@return canola.PowershellConnection
|
---@return oil.PowershellConnection
|
||||||
function PowershellConnection.new(init_command)
|
function PowershellConnection.new(init_command)
|
||||||
local self = setmetatable({
|
local self = setmetatable({
|
||||||
commands = {},
|
commands = {},
|
||||||
|
|
@ -22,7 +22,7 @@ function PowershellConnection.new(init_command)
|
||||||
|
|
||||||
self:_init(init_command)
|
self:_init(init_command)
|
||||||
|
|
||||||
---@type canola.PowershellConnection
|
---@type oil.PowershellConnection
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
-- A wrapper around trash operations using windows powershell
|
-- A wrapper around trash operations using windows powershell
|
||||||
local Powershell = require('canola.adapters.trash.windows.powershell-connection')
|
local Powershell = require('oil.adapters.trash.windows.powershell-connection')
|
||||||
|
|
||||||
---@class canola.WindowsRawEntry
|
---@class oil.WindowsRawEntry
|
||||||
---@field IsFolder boolean
|
---@field IsFolder boolean
|
||||||
---@field DeletionDate integer
|
---@field DeletionDate integer
|
||||||
---@field Name string
|
---@field Name string
|
||||||
|
|
@ -30,10 +30,10 @@ $data = @(foreach ($i in $folder.items())
|
||||||
ConvertTo-Json $data -Compress
|
ConvertTo-Json $data -Compress
|
||||||
]]
|
]]
|
||||||
|
|
||||||
---@type nil|canola.PowershellConnection
|
---@type nil|oil.PowershellConnection
|
||||||
local list_entries_powershell
|
local list_entries_powershell
|
||||||
|
|
||||||
---@param cb fun(err?: string, raw_entries?: canola.WindowsRawEntry[])
|
---@param cb fun(err?: string, raw_entries?: oil.WindowsRawEntry[])
|
||||||
M.list_raw_entries = function(cb)
|
M.list_raw_entries = function(cb)
|
||||||
if not list_entries_powershell then
|
if not list_entries_powershell then
|
||||||
list_entries_powershell = Powershell.new(list_entries_init)
|
list_entries_powershell = Powershell.new(list_entries_init)
|
||||||
|
|
@ -63,7 +63,7 @@ $path = Get-Item '%s'
|
||||||
$folder.ParseName($path.FullName).InvokeVerb('delete')
|
$folder.ParseName($path.FullName).InvokeVerb('delete')
|
||||||
]]
|
]]
|
||||||
|
|
||||||
---@type nil|canola.PowershellConnection
|
---@type nil|oil.PowershellConnection
|
||||||
local delete_to_trash_powershell
|
local delete_to_trash_powershell
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_ID = constants.FIELD_ID
|
local FIELD_ID = constants.FIELD_ID
|
||||||
|
|
@ -8,11 +8,11 @@ local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
local next_id = 1
|
local next_id = 1
|
||||||
|
|
||||||
-- Map<url, Map<entry name, canola.InternalEntry>>
|
-- Map<url, Map<entry name, oil.InternalEntry>>
|
||||||
---@type table<string, table<string, canola.InternalEntry>>
|
---@type table<string, table<string, oil.InternalEntry>>
|
||||||
local url_directory = {}
|
local url_directory = {}
|
||||||
|
|
||||||
---@type table<integer, canola.InternalEntry>
|
---@type table<integer, oil.InternalEntry>
|
||||||
local entries_by_id = {}
|
local entries_by_id = {}
|
||||||
|
|
||||||
---@type table<integer, string>
|
---@type table<integer, string>
|
||||||
|
|
@ -42,8 +42,8 @@ end
|
||||||
|
|
||||||
---@param parent_url string
|
---@param parent_url string
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param type canola.EntryType
|
---@param type oil.EntryType
|
||||||
---@return canola.InternalEntry
|
---@return oil.InternalEntry
|
||||||
M.create_entry = function(parent_url, name, type)
|
M.create_entry = function(parent_url, name, type)
|
||||||
parent_url = util.addslash(parent_url)
|
parent_url = util.addslash(parent_url)
|
||||||
local parent = tmp_url_directory[parent_url] or url_directory[parent_url]
|
local parent = tmp_url_directory[parent_url] or url_directory[parent_url]
|
||||||
|
|
@ -58,7 +58,7 @@ M.create_entry = function(parent_url, name, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param parent_url string
|
---@param parent_url string
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
M.store_entry = function(parent_url, entry)
|
M.store_entry = function(parent_url, entry)
|
||||||
parent_url = util.addslash(parent_url)
|
parent_url = util.addslash(parent_url)
|
||||||
local parent = url_directory[parent_url]
|
local parent = url_directory[parent_url]
|
||||||
|
|
@ -85,8 +85,8 @@ end
|
||||||
|
|
||||||
---@param parent_url string
|
---@param parent_url string
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param type canola.EntryType
|
---@param type oil.EntryType
|
||||||
---@return canola.InternalEntry
|
---@return oil.InternalEntry
|
||||||
M.create_and_store_entry = function(parent_url, name, type)
|
M.create_and_store_entry = function(parent_url, name, type)
|
||||||
local entry = M.create_entry(parent_url, name, type)
|
local entry = M.create_entry(parent_url, name, type)
|
||||||
M.store_entry(parent_url, entry)
|
M.store_entry(parent_url, entry)
|
||||||
|
|
@ -115,13 +115,13 @@ M.end_update_url = function(parent_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param id integer
|
---@param id integer
|
||||||
---@return nil|canola.InternalEntry
|
---@return nil|oil.InternalEntry
|
||||||
M.get_entry_by_id = function(id)
|
M.get_entry_by_id = function(id)
|
||||||
return entries_by_id[id]
|
return entries_by_id[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@return nil|canola.InternalEntry
|
---@return nil|oil.InternalEntry
|
||||||
M.get_entry_by_url = function(url)
|
M.get_entry_by_url = function(url)
|
||||||
local scheme, path = util.parse_url(url)
|
local scheme, path = util.parse_url(url)
|
||||||
assert(path)
|
assert(path)
|
||||||
|
|
@ -141,13 +141,13 @@ M.get_parent_url = function(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@return table<string, canola.InternalEntry>
|
---@return table<string, oil.InternalEntry>
|
||||||
M.list_url = function(url)
|
M.list_url = function(url)
|
||||||
url = util.addslash(url)
|
url = util.addslash(url)
|
||||||
return url_directory[url] or {}
|
return url_directory[url] or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
M.perform_action = function(action)
|
M.perform_action = function(action)
|
||||||
if action.type == 'create' then
|
if action.type == 'create' then
|
||||||
local scheme, path = util.parse_url(action.url)
|
local scheme, path = util.parse_url(action.url)
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local canola = require('canola')
|
local columns = require('oil.columns')
|
||||||
local columns = require('canola.columns')
|
local config = require('oil.config')
|
||||||
local config = require('canola.config')
|
local fs = require('oil.fs')
|
||||||
local fs = require('canola.fs')
|
local oil = require('oil')
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local view = require('canola.view')
|
local view = require('oil.view')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -35,9 +35,9 @@ local function is_linux_desktop_gnome()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param winid integer
|
---@param winid integer
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@param column_defs canola.ColumnSpec[]
|
---@param column_defs oil.ColumnSpec[]
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
local function write_pasted(winid, entry, column_defs, adapter, bufnr)
|
local function write_pasted(winid, entry, column_defs, adapter, bufnr)
|
||||||
local col_width = {}
|
local col_width = {}
|
||||||
|
|
@ -52,7 +52,7 @@ local function write_pasted(winid, entry, column_defs, adapter, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param parent_url string
|
---@param parent_url string
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
local function remove_entry_from_parent_buffer(parent_url, entry)
|
local function remove_entry_from_parent_buffer(parent_url, entry)
|
||||||
local bufnr = vim.fn.bufadd(parent_url)
|
local bufnr = vim.fn.bufadd(parent_url)
|
||||||
assert(vim.api.nvim_buf_is_loaded(bufnr), 'Expected parent buffer to be loaded during paste')
|
assert(vim.api.nvim_buf_is_loaded(bufnr), 'Expected parent buffer to be loaded during paste')
|
||||||
|
|
@ -77,7 +77,7 @@ end
|
||||||
---@param delete_original? boolean
|
---@param delete_original? boolean
|
||||||
local function paste_paths(paths, delete_original)
|
local function paste_paths(paths, delete_original)
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local scheme = 'canola://'
|
local scheme = 'oil://'
|
||||||
local adapter = assert(config.get_adapter_by_scheme(scheme))
|
local adapter = assert(config.get_adapter_by_scheme(scheme))
|
||||||
local column_defs = columns.get_supported_columns(scheme)
|
local column_defs = columns.get_supported_columns(scheme)
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
|
|
@ -140,7 +140,7 @@ local function paste_paths(paths, delete_original)
|
||||||
for parent_url, _ in pairs(parent_urls) do
|
for parent_url, _ in pairs(parent_urls) do
|
||||||
local new_bufnr = vim.api.nvim_create_buf(false, false)
|
local new_bufnr = vim.api.nvim_create_buf(false, false)
|
||||||
vim.api.nvim_buf_set_name(new_bufnr, parent_url)
|
vim.api.nvim_buf_set_name(new_bufnr, parent_url)
|
||||||
canola.load_canola_buffer(new_bufnr)
|
oil.load_oil_buffer(new_bufnr)
|
||||||
util.run_after_load(new_bufnr, complete_loading)
|
util.run_after_load(new_bufnr, complete_loading)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -162,7 +162,7 @@ local function range_from_selection()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.copy_to_system_clipboard = function()
|
M.copy_to_system_clipboard = function()
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if not dir then
|
if not dir then
|
||||||
vim.notify('System clipboard only works for local files', vim.log.levels.ERROR)
|
vim.notify('System clipboard only works for local files', vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
|
|
@ -180,13 +180,13 @@ M.copy_to_system_clipboard = function()
|
||||||
end
|
end
|
||||||
local start_row, end_row = range_from_selection()
|
local start_row, end_row = range_from_selection()
|
||||||
for i = start_row, end_row do
|
for i = start_row, end_row do
|
||||||
table.insert(entries, canola.get_entry_on_line(0, i))
|
table.insert(entries, oil.get_entry_on_line(0, i))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- leave visual mode
|
-- leave visual mode
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'n', true)
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'n', true)
|
||||||
else
|
else
|
||||||
table.insert(entries, canola.get_cursor_entry())
|
table.insert(entries, oil.get_cursor_entry())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This removes holes in the list-like table
|
-- This removes holes in the list-like table
|
||||||
|
|
@ -298,7 +298,7 @@ end
|
||||||
|
|
||||||
---@param delete_original? boolean Delete the source file after pasting
|
---@param delete_original? boolean Delete the source file after pasting
|
||||||
M.paste_from_system_clipboard = function(delete_original)
|
M.paste_from_system_clipboard = function(delete_original)
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if not dir then
|
if not dir then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_NAME = constants.FIELD_NAME
|
local FIELD_NAME = constants.FIELD_NAME
|
||||||
|
|
@ -9,33 +9,33 @@ local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
local all_columns = {}
|
local all_columns = {}
|
||||||
|
|
||||||
---@alias canola.ColumnSpec string|{[1]: string, [string]: any}
|
---@alias oil.ColumnSpec string|{[1]: string, [string]: any}
|
||||||
|
|
||||||
---@class (exact) canola.ColumnDefinition
|
---@class (exact) oil.ColumnDefinition
|
||||||
---@field render fun(entry: canola.InternalEntry, conf: nil|table, bufnr: integer): nil|canola.TextChunk
|
---@field render fun(entry: oil.InternalEntry, conf: nil|table, bufnr: integer): nil|oil.TextChunk
|
||||||
---@field parse fun(line: string, conf: nil|table): nil|string, nil|string
|
---@field parse fun(line: string, conf: nil|table): nil|string, nil|string
|
||||||
---@field compare? fun(entry: canola.InternalEntry, parsed_value: any): boolean
|
---@field compare? fun(entry: oil.InternalEntry, parsed_value: any): boolean
|
||||||
---@field render_action? fun(action: canola.ChangeAction): string
|
---@field render_action? fun(action: oil.ChangeAction): string
|
||||||
---@field perform_action? fun(action: canola.ChangeAction, callback: fun(err: nil|string))
|
---@field perform_action? fun(action: oil.ChangeAction, callback: fun(err: nil|string))
|
||||||
---@field get_sort_value? fun(entry: canola.InternalEntry): number|string
|
---@field get_sort_value? fun(entry: oil.InternalEntry): number|string
|
||||||
---@field create_sort_value_factory? fun(num_entries: integer): fun(entry: canola.InternalEntry): number|string
|
---@field create_sort_value_factory? fun(num_entries: integer): fun(entry: oil.InternalEntry): number|string
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param column canola.ColumnDefinition
|
---@param column oil.ColumnDefinition
|
||||||
M.register = function(name, column)
|
M.register = function(name, column)
|
||||||
all_columns[name] = column
|
all_columns[name] = column
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param defn canola.ColumnSpec
|
---@param defn oil.ColumnSpec
|
||||||
---@return nil|canola.ColumnDefinition
|
---@return nil|oil.ColumnDefinition
|
||||||
M.get_column = function(adapter, defn)
|
M.get_column = function(adapter, defn)
|
||||||
local name = util.split_config(defn)
|
local name = util.split_config(defn)
|
||||||
return all_columns[name] or adapter.get_column(name)
|
return all_columns[name] or adapter.get_column(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter_or_scheme string|canola.Adapter
|
---@param adapter_or_scheme string|oil.Adapter
|
||||||
---@return canola.ColumnSpec[]
|
---@return oil.ColumnSpec[]
|
||||||
M.get_supported_columns = function(adapter_or_scheme)
|
M.get_supported_columns = function(adapter_or_scheme)
|
||||||
local adapter
|
local adapter
|
||||||
if type(adapter_or_scheme) == 'string' then
|
if type(adapter_or_scheme) == 'string' then
|
||||||
|
|
@ -53,15 +53,15 @@ M.get_supported_columns = function(adapter_or_scheme)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local EMPTY = { '-', 'CanolaEmpty' }
|
local EMPTY = { '-', 'OilEmpty' }
|
||||||
|
|
||||||
M.EMPTY = EMPTY
|
M.EMPTY = EMPTY
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param col_def canola.ColumnSpec
|
---@param col_def oil.ColumnSpec
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return canola.TextChunk
|
---@return oil.TextChunk
|
||||||
M.render_col = function(adapter, col_def, entry, bufnr)
|
M.render_col = function(adapter, col_def, entry, bufnr)
|
||||||
local name, conf = util.split_config(col_def)
|
local name, conf = util.split_config(col_def)
|
||||||
local column = M.get_column(adapter, name)
|
local column = M.get_column(adapter, name)
|
||||||
|
|
@ -90,9 +90,9 @@ M.render_col = function(adapter, col_def, entry, bufnr)
|
||||||
return chunk
|
return chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param line string
|
---@param line string
|
||||||
---@param col_def canola.ColumnSpec
|
---@param col_def oil.ColumnSpec
|
||||||
---@return nil|string
|
---@return nil|string
|
||||||
---@return nil|string
|
---@return nil|string
|
||||||
M.parse_col = function(adapter, line, col_def)
|
M.parse_col = function(adapter, line, col_def)
|
||||||
|
|
@ -108,9 +108,9 @@ M.parse_col = function(adapter, line, col_def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param col_name string
|
---@param col_name string
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@param parsed_value any
|
---@param parsed_value any
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.compare = function(adapter, col_name, entry, parsed_value)
|
M.compare = function(adapter, col_name, entry, parsed_value)
|
||||||
|
|
@ -122,8 +122,8 @@ M.compare = function(adapter, col_name, entry, parsed_value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param action canola.ChangeAction
|
---@param action oil.ChangeAction
|
||||||
---@return string
|
---@return string
|
||||||
M.render_change_action = function(adapter, action)
|
M.render_change_action = function(adapter, action)
|
||||||
local column = M.get_column(adapter, action.column)
|
local column = M.get_column(adapter, action.column)
|
||||||
|
|
@ -137,8 +137,8 @@ M.render_change_action = function(adapter, action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param action canola.ChangeAction
|
---@param action oil.ChangeAction
|
||||||
---@param callback fun(err: nil|string)
|
---@param callback fun(err: nil|string)
|
||||||
M.perform_change_action = function(adapter, action, callback)
|
M.perform_change_action = function(adapter, action, callback)
|
||||||
local column = M.get_column(adapter, action.column)
|
local column = M.get_column(adapter, action.column)
|
||||||
|
|
@ -205,7 +205,7 @@ local default_type_icons = {
|
||||||
directory = 'dir',
|
directory = 'dir',
|
||||||
socket = 'sock',
|
socket = 'sock',
|
||||||
}
|
}
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function is_entry_directory(entry)
|
local function is_entry_directory(entry)
|
||||||
local type = entry[FIELD_TYPE]
|
local type = entry[FIELD_TYPE]
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
local default_config = {
|
local default_config = {
|
||||||
-- Canola will take over directory buffers (e.g. `vim .` or `:e src/`)
|
-- Oil will take over directory buffers (e.g. `vim .` or `:e src/`)
|
||||||
-- Set to false if you want some other plugin (e.g. netrw) to open when you edit directories.
|
-- Set to false if you want some other plugin (e.g. netrw) to open when you edit directories.
|
||||||
default_file_explorer = true,
|
default_file_explorer = true,
|
||||||
-- Id is automatically added at the beginning, and name at the end
|
-- Id is automatically added at the beginning, and name at the end
|
||||||
-- See :help canola-columns
|
-- See :help oil-columns
|
||||||
columns = {
|
columns = {
|
||||||
'icon',
|
'icon',
|
||||||
-- "permissions",
|
-- "permissions",
|
||||||
-- "size",
|
-- "size",
|
||||||
-- "mtime",
|
-- "mtime",
|
||||||
},
|
},
|
||||||
-- Buffer-local options to use for canola buffers
|
-- Buffer-local options to use for oil buffers
|
||||||
buf_options = {
|
buf_options = {
|
||||||
buflisted = false,
|
buflisted = false,
|
||||||
bufhidden = 'hide',
|
bufhidden = 'hide',
|
||||||
},
|
},
|
||||||
-- Window-local options to use for canola buffers
|
-- Window-local options to use for oil buffers
|
||||||
win_options = {
|
win_options = {
|
||||||
wrap = false,
|
wrap = false,
|
||||||
signcolumn = 'no',
|
signcolumn = 'no',
|
||||||
|
|
@ -26,20 +26,20 @@ local default_config = {
|
||||||
conceallevel = 3,
|
conceallevel = 3,
|
||||||
concealcursor = 'nvic',
|
concealcursor = 'nvic',
|
||||||
},
|
},
|
||||||
-- Send deleted files to the trash instead of permanently deleting them (:help canola-trash)
|
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
|
||||||
delete_to_trash = false,
|
delete_to_trash = false,
|
||||||
-- Wipe open buffers for files deleted via canola (:help canola.cleanup_buffers_on_delete)
|
-- Wipe open buffers for files deleted via oil (:help oil.cleanup_buffers_on_delete)
|
||||||
cleanup_buffers_on_delete = false,
|
cleanup_buffers_on_delete = false,
|
||||||
-- Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits)
|
-- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits)
|
||||||
skip_confirm_for_simple_edits = false,
|
skip_confirm_for_simple_edits = false,
|
||||||
skip_confirm_for_delete = false,
|
skip_confirm_for_delete = false,
|
||||||
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
|
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
|
||||||
-- (:help prompt_save_on_select_new_entry)
|
-- (:help prompt_save_on_select_new_entry)
|
||||||
prompt_save_on_select_new_entry = true,
|
prompt_save_on_select_new_entry = true,
|
||||||
auto_save_on_select_new_entry = false,
|
auto_save_on_select_new_entry = false,
|
||||||
-- Canola will automatically delete hidden buffers after this delay
|
-- Oil will automatically delete hidden buffers after this delay
|
||||||
-- You can set the delay to false to disable cleanup entirely
|
-- You can set the delay to false to disable cleanup entirely
|
||||||
-- Note that the cleanup process only starts when none of the canola buffers are currently displayed
|
-- Note that the cleanup process only starts when none of the oil buffers are currently displayed
|
||||||
cleanup_delay_ms = 2000,
|
cleanup_delay_ms = 2000,
|
||||||
lsp_file_methods = {
|
lsp_file_methods = {
|
||||||
-- Enable or disable LSP file operations
|
-- Enable or disable LSP file operations
|
||||||
|
|
@ -50,17 +50,17 @@ local default_config = {
|
||||||
-- Set to "unmodified" to only save unmodified buffers
|
-- Set to "unmodified" to only save unmodified buffers
|
||||||
autosave_changes = false,
|
autosave_changes = false,
|
||||||
},
|
},
|
||||||
-- Constrain the cursor to the editable parts of the canola buffer
|
-- Constrain the cursor to the editable parts of the oil buffer
|
||||||
-- Set to `false` to disable, or "name" to keep it on the file names
|
-- Set to `false` to disable, or "name" to keep it on the file names
|
||||||
constrain_cursor = 'editable',
|
constrain_cursor = 'editable',
|
||||||
-- Set to true to watch the filesystem for changes and reload canola
|
-- Set to true to watch the filesystem for changes and reload oil
|
||||||
watch_for_changes = false,
|
watch_for_changes = false,
|
||||||
-- Keymaps in canola buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
|
-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
|
||||||
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" })
|
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" })
|
||||||
-- Additionally, if it is a string that matches "actions.<name>",
|
-- Additionally, if it is a string that matches "actions.<name>",
|
||||||
-- it will use the mapping at require("canola.actions").<name>
|
-- it will use the mapping at require("oil.actions").<name>
|
||||||
-- Set to `false` to remove a keymap
|
-- Set to `false` to remove a keymap
|
||||||
-- See :help canola-actions for a list of all available actions
|
-- See :help oil-actions for a list of all available actions
|
||||||
keymaps = {
|
keymaps = {
|
||||||
['g?'] = { 'actions.show_help', mode = 'n' },
|
['g?'] = { 'actions.show_help', mode = 'n' },
|
||||||
['<CR>'] = 'actions.select',
|
['<CR>'] = 'actions.select',
|
||||||
|
|
@ -101,7 +101,7 @@ local default_config = {
|
||||||
case_insensitive = false,
|
case_insensitive = false,
|
||||||
sort = {
|
sort = {
|
||||||
-- sort order can be "asc" or "desc"
|
-- sort order can be "asc" or "desc"
|
||||||
-- see :help canola-columns to see which columns are sortable
|
-- see :help oil-columns to see which columns are sortable
|
||||||
{ 'type', 'asc' },
|
{ 'type', 'asc' },
|
||||||
{ 'name', 'asc' },
|
{ 'name', 'asc' },
|
||||||
},
|
},
|
||||||
|
|
@ -129,7 +129,7 @@ local default_config = {
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
-- Configuration for the floating window in canola.open_float
|
-- Configuration for the floating window in oil.open_float
|
||||||
float = {
|
float = {
|
||||||
-- Padding around the floating window
|
-- Padding around the floating window
|
||||||
padding = 2,
|
padding = 2,
|
||||||
|
|
@ -140,7 +140,7 @@ local default_config = {
|
||||||
win_options = {
|
win_options = {
|
||||||
winblend = 0,
|
winblend = 0,
|
||||||
},
|
},
|
||||||
-- optionally override the canola buffers window title with custom function: fun(winid: integer): string
|
-- optionally override the oil buffers window title with custom function: fun(winid: integer): string
|
||||||
get_win_title = nil,
|
get_win_title = nil,
|
||||||
-- preview_split: Split direction: "auto", "left", "right", "above", "below".
|
-- preview_split: Split direction: "auto", "left", "right", "above", "below".
|
||||||
preview_split = 'auto',
|
preview_split = 'auto',
|
||||||
|
|
@ -215,26 +215,26 @@ local default_config = {
|
||||||
-- write their own adapters, and so there's no real reason to edit these config options. For that
|
-- write their own adapters, and so there's no real reason to edit these config options. For that
|
||||||
-- reason, I'm taking them out of the section above so they won't show up in the autogen docs.
|
-- reason, I'm taking them out of the section above so they won't show up in the autogen docs.
|
||||||
|
|
||||||
-- not "canola-s3://" on older neovim versions, since it doesn't open buffers correctly with a number
|
-- not "oil-s3://" on older neovim versions, since it doesn't open buffers correctly with a number
|
||||||
-- in the name
|
-- in the name
|
||||||
local canola_s3_string = vim.fn.has('nvim-0.12') == 1 and 'canola-s3://' or 'canola-sss://'
|
local oil_s3_string = vim.fn.has('nvim-0.12') == 1 and 'oil-s3://' or 'oil-sss://'
|
||||||
default_config.adapters = {
|
default_config.adapters = {
|
||||||
['canola://'] = 'files',
|
['oil://'] = 'files',
|
||||||
['canola-ssh://'] = 'ssh',
|
['oil-ssh://'] = 'ssh',
|
||||||
[canola_s3_string] = 's3',
|
[oil_s3_string] = 's3',
|
||||||
['canola-trash://'] = 'trash',
|
['oil-trash://'] = 'trash',
|
||||||
}
|
}
|
||||||
default_config.adapter_aliases = {}
|
default_config.adapter_aliases = {}
|
||||||
-- We want the function in the default config for documentation generation, but if we nil it out
|
-- We want the function in the default config for documentation generation, but if we nil it out
|
||||||
-- here we can get some performance wins
|
-- here we can get some performance wins
|
||||||
default_config.view_options.highlight_filename = nil
|
default_config.view_options.highlight_filename = nil
|
||||||
|
|
||||||
---@class canola.Config
|
---@class oil.Config
|
||||||
---@field adapters table<string, string> Hidden from SetupOpts
|
---@field adapters table<string, string> Hidden from SetupOpts
|
||||||
---@field adapter_aliases table<string, string> Hidden from SetupOpts
|
---@field adapter_aliases table<string, string> Hidden from SetupOpts
|
||||||
---@field silence_scp_warning? boolean Undocumented option
|
---@field silence_scp_warning? boolean Undocumented option
|
||||||
---@field default_file_explorer boolean
|
---@field default_file_explorer boolean
|
||||||
---@field columns canola.ColumnSpec[]
|
---@field columns oil.ColumnSpec[]
|
||||||
---@field buf_options table<string, any>
|
---@field buf_options table<string, any>
|
||||||
---@field win_options table<string, any>
|
---@field win_options table<string, any>
|
||||||
---@field delete_to_trash boolean
|
---@field delete_to_trash boolean
|
||||||
|
|
@ -244,158 +244,158 @@ default_config.view_options.highlight_filename = nil
|
||||||
---@field prompt_save_on_select_new_entry boolean
|
---@field prompt_save_on_select_new_entry boolean
|
||||||
---@field auto_save_on_select_new_entry boolean
|
---@field auto_save_on_select_new_entry boolean
|
||||||
---@field cleanup_delay_ms integer
|
---@field cleanup_delay_ms integer
|
||||||
---@field lsp_file_methods canola.LspFileMethods
|
---@field lsp_file_methods oil.LspFileMethods
|
||||||
---@field constrain_cursor false|"name"|"editable"
|
---@field constrain_cursor false|"name"|"editable"
|
||||||
---@field watch_for_changes boolean
|
---@field watch_for_changes boolean
|
||||||
---@field keymaps table<string, any>
|
---@field keymaps table<string, any>
|
||||||
---@field use_default_keymaps boolean
|
---@field use_default_keymaps boolean
|
||||||
---@field view_options canola.ViewOptions
|
---@field view_options oil.ViewOptions
|
||||||
---@field new_file_mode integer
|
---@field new_file_mode integer
|
||||||
---@field new_dir_mode integer
|
---@field new_dir_mode integer
|
||||||
---@field extra_scp_args string[]
|
---@field extra_scp_args string[]
|
||||||
---@field extra_s3_args string[]
|
---@field extra_s3_args string[]
|
||||||
---@field git canola.GitOptions
|
---@field git oil.GitOptions
|
||||||
---@field float canola.FloatWindowConfig
|
---@field float oil.FloatWindowConfig
|
||||||
---@field preview_win canola.PreviewWindowConfig
|
---@field preview_win oil.PreviewWindowConfig
|
||||||
---@field confirmation canola.ConfirmationWindowConfig
|
---@field confirmation oil.ConfirmationWindowConfig
|
||||||
---@field progress canola.ProgressWindowConfig
|
---@field progress oil.ProgressWindowConfig
|
||||||
---@field ssh canola.SimpleWindowConfig
|
---@field ssh oil.SimpleWindowConfig
|
||||||
---@field keymaps_help canola.SimpleWindowConfig
|
---@field keymaps_help oil.SimpleWindowConfig
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- For backwards compatibility
|
-- For backwards compatibility
|
||||||
---@alias canola.setupOpts canola.SetupOpts
|
---@alias oil.setupOpts oil.SetupOpts
|
||||||
|
|
||||||
---@class (exact) canola.SetupOpts
|
---@class (exact) oil.SetupOpts
|
||||||
---@field default_file_explorer? boolean Canola will take over directory buffers (e.g. `vim .` or `:e src/`). Set to false if you still want to use netrw.
|
---@field default_file_explorer? boolean Oil will take over directory buffers (e.g. `vim .` or `:e src/`). Set to false if you still want to use netrw.
|
||||||
---@field columns? canola.ColumnSpec[] The columns to display. See :help canola-columns.
|
---@field columns? oil.ColumnSpec[] The columns to display. See :help oil-columns.
|
||||||
---@field buf_options? table<string, any> Buffer-local options to use for canola buffers
|
---@field buf_options? table<string, any> Buffer-local options to use for oil buffers
|
||||||
---@field win_options? table<string, any> Window-local options to use for canola buffers
|
---@field win_options? table<string, any> Window-local options to use for oil buffers
|
||||||
---@field delete_to_trash? boolean Send deleted files to the trash instead of permanently deleting them (:help canola-trash).
|
---@field delete_to_trash? boolean Send deleted files to the trash instead of permanently deleting them (:help oil-trash).
|
||||||
---@field cleanup_buffers_on_delete? boolean Wipe open buffers for files deleted via canola (:help canola.cleanup_buffers_on_delete).
|
---@field cleanup_buffers_on_delete? boolean Wipe open buffers for files deleted via oil (:help oil.cleanup_buffers_on_delete).
|
||||||
---@field skip_confirm_for_simple_edits? boolean Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits).
|
---@field skip_confirm_for_simple_edits? boolean Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits).
|
||||||
---@field skip_confirm_for_delete? boolean Skip the confirmation popup when all pending actions are deletes (:help canola.skip_confirm_for_delete).
|
---@field skip_confirm_for_delete? boolean Skip the confirmation popup when all pending actions are deletes (:help oil.skip_confirm_for_delete).
|
||||||
---@field prompt_save_on_select_new_entry? boolean Selecting a new/moved/renamed file or directory will prompt you to save changes first (:help prompt_save_on_select_new_entry).
|
---@field prompt_save_on_select_new_entry? boolean Selecting a new/moved/renamed file or directory will prompt you to save changes first (:help prompt_save_on_select_new_entry).
|
||||||
---@field auto_save_on_select_new_entry? boolean Automatically save changes when selecting a new/moved/renamed entry, instead of prompting (:help canola.auto_save_on_select_new_entry).
|
---@field auto_save_on_select_new_entry? boolean Automatically save changes when selecting a new/moved/renamed entry, instead of prompting (:help oil.auto_save_on_select_new_entry).
|
||||||
---@field cleanup_delay_ms? integer Canola will automatically delete hidden buffers after this delay. You can set the delay to false to disable cleanup entirely. Note that the cleanup process only starts when none of the canola buffers are currently displayed.
|
---@field cleanup_delay_ms? integer Oil will automatically delete hidden buffers after this delay. You can set the delay to false to disable cleanup entirely. Note that the cleanup process only starts when none of the oil buffers are currently displayed.
|
||||||
---@field lsp_file_methods? canola.SetupLspFileMethods Configure LSP file operation integration.
|
---@field lsp_file_methods? oil.SetupLspFileMethods Configure LSP file operation integration.
|
||||||
---@field constrain_cursor? false|"name"|"editable" Constrain the cursor to the editable parts of the canola buffer. Set to `false` to disable, or "name" to keep it on the file names.
|
---@field constrain_cursor? false|"name"|"editable" Constrain the cursor to the editable parts of the oil buffer. Set to `false` to disable, or "name" to keep it on the file names.
|
||||||
---@field watch_for_changes? boolean Set to true to watch the filesystem for changes and reload canola.
|
---@field watch_for_changes? boolean Set to true to watch the filesystem for changes and reload oil.
|
||||||
---@field keymaps? table<string, any>
|
---@field keymaps? table<string, any>
|
||||||
---@field use_default_keymaps? boolean Set to false to disable all of the above keymaps
|
---@field use_default_keymaps? boolean Set to false to disable all of the above keymaps
|
||||||
---@field view_options? canola.SetupViewOptions Configure which files are shown and how they are shown.
|
---@field view_options? oil.SetupViewOptions Configure which files are shown and how they are shown.
|
||||||
---@field new_file_mode? integer Permission mode for new files in decimal (default 420 = 0644)
|
---@field new_file_mode? integer Permission mode for new files in decimal (default 420 = 0644)
|
||||||
---@field new_dir_mode? integer Permission mode for new directories in decimal (default 493 = 0755)
|
---@field new_dir_mode? integer Permission mode for new directories in decimal (default 493 = 0755)
|
||||||
---@field extra_scp_args? string[] Extra arguments to pass to SCP when moving/copying files over SSH
|
---@field extra_scp_args? string[] Extra arguments to pass to SCP when moving/copying files over SSH
|
||||||
---@field extra_s3_args? string[] Extra arguments to pass to aws s3 when moving/copying files using aws s3
|
---@field extra_s3_args? string[] Extra arguments to pass to aws s3 when moving/copying files using aws s3
|
||||||
---@field git? canola.SetupGitOptions EXPERIMENTAL support for performing file operations with git
|
---@field git? oil.SetupGitOptions EXPERIMENTAL support for performing file operations with git
|
||||||
---@field float? canola.SetupFloatWindowConfig Configuration for the floating window in canola.open_float
|
---@field float? oil.SetupFloatWindowConfig Configuration for the floating window in oil.open_float
|
||||||
---@field preview_win? canola.SetupPreviewWindowConfig Configuration for the file preview window
|
---@field preview_win? oil.SetupPreviewWindowConfig Configuration for the file preview window
|
||||||
---@field confirmation? canola.SetupConfirmationWindowConfig Configuration for the floating action confirmation window
|
---@field confirmation? oil.SetupConfirmationWindowConfig Configuration for the floating action confirmation window
|
||||||
---@field progress? canola.SetupProgressWindowConfig Configuration for the floating progress window
|
---@field progress? oil.SetupProgressWindowConfig Configuration for the floating progress window
|
||||||
---@field ssh? canola.SetupSimpleWindowConfig Configuration for the floating SSH window
|
---@field ssh? oil.SetupSimpleWindowConfig Configuration for the floating SSH window
|
||||||
---@field keymaps_help? canola.SetupSimpleWindowConfig Configuration for the floating keymaps help window
|
---@field keymaps_help? oil.SetupSimpleWindowConfig Configuration for the floating keymaps help window
|
||||||
|
|
||||||
---@class (exact) canola.LspFileMethods
|
---@class (exact) oil.LspFileMethods
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field timeout_ms integer
|
---@field timeout_ms integer
|
||||||
---@field autosave_changes boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers.
|
---@field autosave_changes boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers.
|
||||||
|
|
||||||
---@class (exact) canola.SetupLspFileMethods
|
---@class (exact) oil.SetupLspFileMethods
|
||||||
---@field enabled? boolean Enable or disable LSP file operations
|
---@field enabled? boolean Enable or disable LSP file operations
|
||||||
---@field timeout_ms? integer Time to wait for LSP file operations to complete before skipping.
|
---@field timeout_ms? integer Time to wait for LSP file operations to complete before skipping.
|
||||||
---@field autosave_changes? boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers.
|
---@field autosave_changes? boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers.
|
||||||
|
|
||||||
---@class (exact) canola.ViewOptions
|
---@class (exact) oil.ViewOptions
|
||||||
---@field show_hidden boolean
|
---@field show_hidden boolean
|
||||||
---@field show_hidden_when_empty boolean
|
---@field show_hidden_when_empty boolean
|
||||||
---@field is_hidden_file fun(name: string, bufnr: integer, entry: canola.Entry): boolean
|
---@field is_hidden_file fun(name: string, bufnr: integer, entry: oil.Entry): boolean
|
||||||
---@field is_always_hidden fun(name: string, bufnr: integer, entry: canola.Entry): boolean
|
---@field is_always_hidden fun(name: string, bufnr: integer, entry: oil.Entry): boolean
|
||||||
---@field natural_order boolean|"fast"
|
---@field natural_order boolean|"fast"
|
||||||
---@field case_insensitive boolean
|
---@field case_insensitive boolean
|
||||||
---@field sort canola.SortSpec[]
|
---@field sort oil.SortSpec[]
|
||||||
---@field highlight_filename? fun(entry: canola.Entry, is_hidden: boolean, is_link_target: boolean, is_link_orphan: boolean, bufnr: integer): string|nil
|
---@field highlight_filename? fun(entry: oil.Entry, is_hidden: boolean, is_link_target: boolean, is_link_orphan: boolean, bufnr: integer): string|nil
|
||||||
|
|
||||||
---@class (exact) canola.SetupViewOptions
|
---@class (exact) oil.SetupViewOptions
|
||||||
---@field show_hidden? boolean Show files and directories that start with "."
|
---@field show_hidden? boolean Show files and directories that start with "."
|
||||||
---@field show_hidden_when_empty? boolean When true and the directory has no visible entries, show hidden entries instead of an empty listing (:help canola.show_hidden_when_empty).
|
---@field show_hidden_when_empty? boolean When true and the directory has no visible entries, show hidden entries instead of an empty listing (:help oil.show_hidden_when_empty).
|
||||||
---@field is_hidden_file? fun(name: string, bufnr: integer): boolean This function defines what is considered a "hidden" file
|
---@field is_hidden_file? fun(name: string, bufnr: integer): boolean This function defines what is considered a "hidden" file
|
||||||
---@field is_always_hidden? fun(name: string, bufnr: integer): boolean This function defines what will never be shown, even when `show_hidden` is set
|
---@field is_always_hidden? fun(name: string, bufnr: integer): boolean This function defines what will never be shown, even when `show_hidden` is set
|
||||||
---@field natural_order? boolean|"fast" Sort file names with numbers in a more intuitive order for humans. Can be slow for large directories.
|
---@field natural_order? boolean|"fast" Sort file names with numbers in a more intuitive order for humans. Can be slow for large directories.
|
||||||
---@field case_insensitive? boolean Sort file and directory names case insensitive
|
---@field case_insensitive? boolean Sort file and directory names case insensitive
|
||||||
---@field sort? canola.SortSpec[] Sort order for the file list
|
---@field sort? oil.SortSpec[] Sort order for the file list
|
||||||
---@field highlight_filename? fun(entry: canola.Entry, is_hidden: boolean, is_link_target: boolean, is_link_orphan: boolean): string|nil Customize the highlight group for the file name
|
---@field highlight_filename? fun(entry: oil.Entry, is_hidden: boolean, is_link_target: boolean, is_link_orphan: boolean): string|nil Customize the highlight group for the file name
|
||||||
|
|
||||||
---@class (exact) canola.SortSpec
|
---@class (exact) oil.SortSpec
|
||||||
---@field [1] string
|
---@field [1] string
|
||||||
---@field [2] "asc"|"desc"
|
---@field [2] "asc"|"desc"
|
||||||
|
|
||||||
---@class (exact) canola.GitOptions
|
---@class (exact) oil.GitOptions
|
||||||
---@field add fun(path: string): boolean
|
---@field add fun(path: string): boolean
|
||||||
---@field mv fun(src_path: string, dest_path: string): boolean
|
---@field mv fun(src_path: string, dest_path: string): boolean
|
||||||
---@field rm fun(path: string): boolean
|
---@field rm fun(path: string): boolean
|
||||||
|
|
||||||
---@class (exact) canola.SetupGitOptions
|
---@class (exact) oil.SetupGitOptions
|
||||||
---@field add? fun(path: string): boolean Return true to automatically git add a new file
|
---@field add? fun(path: string): boolean Return true to automatically git add a new file
|
||||||
---@field mv? fun(src_path: string, dest_path: string): boolean Return true to automatically git mv a moved file
|
---@field mv? fun(src_path: string, dest_path: string): boolean Return true to automatically git mv a moved file
|
||||||
---@field rm? fun(path: string): boolean Return true to automatically git rm a deleted file
|
---@field rm? fun(path: string): boolean Return true to automatically git rm a deleted file
|
||||||
|
|
||||||
---@class (exact) canola.WindowDimensionDualConstraint
|
---@class (exact) oil.WindowDimensionDualConstraint
|
||||||
---@field [1] number
|
---@field [1] number
|
||||||
---@field [2] number
|
---@field [2] number
|
||||||
|
|
||||||
---@alias canola.WindowDimension number|canola.WindowDimensionDualConstraint
|
---@alias oil.WindowDimension number|oil.WindowDimensionDualConstraint
|
||||||
|
|
||||||
---@class (exact) canola.WindowConfig
|
---@class (exact) oil.WindowConfig
|
||||||
---@field max_width canola.WindowDimension
|
---@field max_width oil.WindowDimension
|
||||||
---@field min_width canola.WindowDimension
|
---@field min_width oil.WindowDimension
|
||||||
---@field width? number
|
---@field width? number
|
||||||
---@field max_height canola.WindowDimension
|
---@field max_height oil.WindowDimension
|
||||||
---@field min_height canola.WindowDimension
|
---@field min_height oil.WindowDimension
|
||||||
---@field height? number
|
---@field height? number
|
||||||
---@field border string|string[]
|
---@field border string|string[]
|
||||||
---@field win_options table<string, any>
|
---@field win_options table<string, any>
|
||||||
|
|
||||||
---@class (exact) canola.SetupWindowConfig
|
---@class (exact) oil.SetupWindowConfig
|
||||||
---@field max_width? canola.WindowDimension Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total"
|
---@field max_width? oil.WindowDimension Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total"
|
||||||
---@field min_width? canola.WindowDimension Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. min_width = {40, 0.4} means "the greater of 40 columns or 40% of total"
|
---@field min_width? oil.WindowDimension Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. min_width = {40, 0.4} means "the greater of 40 columns or 40% of total"
|
||||||
---@field width? number Define an integer/float for the exact width of the preview window
|
---@field width? number Define an integer/float for the exact width of the preview window
|
||||||
---@field max_height? canola.WindowDimension Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total"
|
---@field max_height? oil.WindowDimension Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total"
|
||||||
---@field min_height? canola.WindowDimension Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. min_height = {5, 0.1} means "the greater of 5 columns or 10% of total"
|
---@field min_height? oil.WindowDimension Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%). Can be a single value or a list of mixed integer/float types. min_height = {5, 0.1} means "the greater of 5 columns or 10% of total"
|
||||||
---@field height? number Define an integer/float for the exact height of the preview window
|
---@field height? number Define an integer/float for the exact height of the preview window
|
||||||
---@field border? string|string[] Window border
|
---@field border? string|string[] Window border
|
||||||
---@field win_options? table<string, any>
|
---@field win_options? table<string, any>
|
||||||
|
|
||||||
---@alias canola.PreviewMethod
|
---@alias oil.PreviewMethod
|
||||||
---| '"load"' # Load the previewed file into a buffer
|
---| '"load"' # Load the previewed file into a buffer
|
||||||
---| '"scratch"' # Put the text into a scratch buffer to avoid LSP attaching
|
---| '"scratch"' # Put the text into a scratch buffer to avoid LSP attaching
|
||||||
---| '"fast_scratch"' # Put only the visible text into a scratch buffer
|
---| '"fast_scratch"' # Put only the visible text into a scratch buffer
|
||||||
|
|
||||||
---@class (exact) canola.PreviewWindowConfig
|
---@class (exact) oil.PreviewWindowConfig
|
||||||
---@field update_on_cursor_moved boolean
|
---@field update_on_cursor_moved boolean
|
||||||
---@field preview_method canola.PreviewMethod
|
---@field preview_method oil.PreviewMethod
|
||||||
---@field disable_preview fun(filename: string): boolean
|
---@field disable_preview fun(filename: string): boolean
|
||||||
---@field max_file_size number Maximum file size (in MB) to preview. Files larger than this will show a placeholder.
|
---@field max_file_size number Maximum file size (in MB) to preview. Files larger than this will show a placeholder.
|
||||||
---@field win_options table<string, any>
|
---@field win_options table<string, any>
|
||||||
|
|
||||||
---@class (exact) canola.ConfirmationWindowConfig : canola.WindowConfig
|
---@class (exact) oil.ConfirmationWindowConfig : oil.WindowConfig
|
||||||
|
|
||||||
---@class (exact) canola.SetupPreviewWindowConfig
|
---@class (exact) oil.SetupPreviewWindowConfig
|
||||||
---@field update_on_cursor_moved? boolean Whether the preview window is automatically updated when the cursor is moved
|
---@field update_on_cursor_moved? boolean Whether the preview window is automatically updated when the cursor is moved
|
||||||
---@field disable_preview? fun(filename: string): boolean A function that returns true to disable preview on a file e.g. to avoid lag
|
---@field disable_preview? fun(filename: string): boolean A function that returns true to disable preview on a file e.g. to avoid lag
|
||||||
---@field max_file_size? number Maximum file size in MB to show in preview. Files exceeding this will not be loaded (:help canola.preview_win). Set to nil to disable the limit.
|
---@field max_file_size? number Maximum file size in MB to show in preview. Files exceeding this will not be loaded (:help oil.preview_win). Set to nil to disable the limit.
|
||||||
---@field preview_method? canola.PreviewMethod How to open the preview window
|
---@field preview_method? oil.PreviewMethod How to open the preview window
|
||||||
---@field win_options? table<string, any> Window-local options to use for preview window buffers
|
---@field win_options? table<string, any> Window-local options to use for preview window buffers
|
||||||
|
|
||||||
---@class (exact) canola.SetupConfirmationWindowConfig : canola.SetupWindowConfig
|
---@class (exact) oil.SetupConfirmationWindowConfig : oil.SetupWindowConfig
|
||||||
|
|
||||||
---@class (exact) canola.ProgressWindowConfig : canola.WindowConfig
|
---@class (exact) oil.ProgressWindowConfig : oil.WindowConfig
|
||||||
---@field minimized_border string|string[]
|
---@field minimized_border string|string[]
|
||||||
|
|
||||||
---@class (exact) canola.SetupProgressWindowConfig : canola.SetupWindowConfig
|
---@class (exact) oil.SetupProgressWindowConfig : oil.SetupWindowConfig
|
||||||
---@field minimized_border? string|string[] The border for the minimized progress window
|
---@field minimized_border? string|string[] The border for the minimized progress window
|
||||||
|
|
||||||
---@class (exact) canola.FloatWindowConfig
|
---@class (exact) oil.FloatWindowConfig
|
||||||
---@field padding integer
|
---@field padding integer
|
||||||
---@field max_width integer
|
---@field max_width integer
|
||||||
---@field max_height integer
|
---@field max_height integer
|
||||||
|
|
@ -405,7 +405,7 @@ local M = {}
|
||||||
---@field preview_split "auto"|"left"|"right"|"above"|"below"
|
---@field preview_split "auto"|"left"|"right"|"above"|"below"
|
||||||
---@field override fun(conf: table): table
|
---@field override fun(conf: table): table
|
||||||
|
|
||||||
---@class (exact) canola.SetupFloatWindowConfig
|
---@class (exact) oil.SetupFloatWindowConfig
|
||||||
---@field padding? integer
|
---@field padding? integer
|
||||||
---@field max_width? integer
|
---@field max_width? integer
|
||||||
---@field max_height? integer
|
---@field max_height? integer
|
||||||
|
|
@ -415,14 +415,14 @@ local M = {}
|
||||||
---@field preview_split? "auto"|"left"|"right"|"above"|"below" Direction that the preview command will split the window
|
---@field preview_split? "auto"|"left"|"right"|"above"|"below" Direction that the preview command will split the window
|
||||||
---@field override? fun(conf: table): table
|
---@field override? fun(conf: table): table
|
||||||
|
|
||||||
---@class (exact) canola.SimpleWindowConfig
|
---@class (exact) oil.SimpleWindowConfig
|
||||||
---@field border string|string[]
|
---@field border string|string[]
|
||||||
|
|
||||||
---@class (exact) canola.SetupSimpleWindowConfig
|
---@class (exact) oil.SetupSimpleWindowConfig
|
||||||
---@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.canola 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
|
||||||
|
|
@ -468,7 +468,7 @@ M.setup = function(opts)
|
||||||
new_conf.lsp_file_methods.autosave_changes = new_conf.lsp_rename_autosave
|
new_conf.lsp_file_methods.autosave_changes = new_conf.lsp_rename_autosave
|
||||||
new_conf.lsp_rename_autosave = nil
|
new_conf.lsp_rename_autosave = nil
|
||||||
vim.notify_once(
|
vim.notify_once(
|
||||||
'canola config value lsp_rename_autosave has moved to lsp_file_methods.autosave_changes.\nCompatibility will be removed on 2024-09-01.',
|
'oil config value lsp_rename_autosave has moved to lsp_file_methods.autosave_changes.\nCompatibility will be removed on 2024-09-01.',
|
||||||
vim.log.levels.WARN
|
vim.log.levels.WARN
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -490,7 +490,7 @@ M.setup = function(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param scheme nil|string
|
---@param scheme nil|string
|
||||||
---@return nil|canola.Adapter
|
---@return nil|oil.Adapter
|
||||||
M.get_adapter_by_scheme = function(scheme)
|
M.get_adapter_by_scheme = function(scheme)
|
||||||
if not scheme then
|
if not scheme then
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -510,7 +510,7 @@ M.get_adapter_by_scheme = function(scheme)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local ok
|
local ok
|
||||||
ok, adapter = pcall(require, string.format('canola.adapters.%s', name))
|
ok, adapter = pcall(require, string.format('oil.adapters.%s', name))
|
||||||
if ok then
|
if ok then
|
||||||
adapter.name = name
|
adapter.name = name
|
||||||
M._adapter_by_scheme[scheme] = adapter
|
M._adapter_by_scheme[scheme] = adapter
|
||||||
|
|
@ -2,9 +2,9 @@ local M = {}
|
||||||
|
|
||||||
---Store entries as a list-like table for maximum space efficiency and retrieval speed.
|
---Store entries as a list-like table for maximum space efficiency and retrieval speed.
|
||||||
---We use the constants below to index into the table.
|
---We use the constants below to index into the table.
|
||||||
---@alias canola.InternalEntry {[1]: integer, [2]: string, [3]: canola.EntryType, [4]: nil|table}
|
---@alias oil.InternalEntry {[1]: integer, [2]: string, [3]: oil.EntryType, [4]: nil|table}
|
||||||
|
|
||||||
-- Indexes into canola.InternalEntry
|
-- Indexes into oil.InternalEntry
|
||||||
M.FIELD_ID = 1
|
M.FIELD_ID = 1
|
||||||
M.FIELD_NAME = 2
|
M.FIELD_NAME = 2
|
||||||
M.FIELD_TYPE = 3
|
M.FIELD_TYPE = 3
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local log = require('canola.log')
|
local log = require('oil.log')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
|
|
@ -170,7 +170,7 @@ M.mkdirp = function(dir, mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param dir string
|
---@param dir string
|
||||||
---@param cb fun(err: nil|string, entries: nil|{type: canola.EntryType, name: string})
|
---@param cb fun(err: nil|string, entries: nil|{type: oil.EntryType, name: string})
|
||||||
M.listdir = function(dir, cb)
|
M.listdir = function(dir, cb)
|
||||||
---@diagnostic disable-next-line: param-type-mismatch, discard-returns
|
---@diagnostic disable-next-line: param-type-mismatch, discard-returns
|
||||||
uv.fs_opendir(dir, function(open_err, fd)
|
uv.fs_opendir(dir, function(open_err, fd)
|
||||||
|
|
@ -205,7 +205,7 @@ M.listdir = function(dir, cb)
|
||||||
end, 10000)
|
end, 10000)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.recursive_delete = function(entry_type, path, cb)
|
M.recursive_delete = function(entry_type, path, cb)
|
||||||
|
|
@ -285,7 +285,7 @@ local move_undofile = vim.schedule_wrap(function(src_path, dest_path, copy)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@param src_path string
|
---@param src_path string
|
||||||
---@param dest_path string
|
---@param dest_path string
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
|
|
@ -357,7 +357,7 @@ M.recursive_copy = function(entry_type, src_path, dest_path, cb)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@param src_path string
|
---@param src_path string
|
||||||
---@param dest_path string
|
---@param dest_path string
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
-- integration with git operations
|
-- integration with git operations
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ M.rm = function(path, cb)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@param src_path string
|
---@param src_path string
|
||||||
---@param dest_path string
|
---@param dest_path string
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
||||||
local actions = require('canola.actions')
|
local actions = require('oil.actions')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local layout = require('canola.layout')
|
local layout = require('oil.layout')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@param rhs string|table|fun()
|
---@param rhs string|table|fun()
|
||||||
|
|
@ -13,7 +13,7 @@ local function resolve(rhs)
|
||||||
local action_name = vim.split(rhs, '.', { plain = true })[2]
|
local action_name = vim.split(rhs, '.', { plain = true })[2]
|
||||||
local action = actions[action_name]
|
local action = actions[action_name]
|
||||||
if not action then
|
if not action then
|
||||||
vim.notify('[canola.nvim] Unknown action name: ' .. action_name, vim.log.levels.ERROR)
|
vim.notify('[oil.nvim] Unknown action name: ' .. action_name, vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
return resolve(action)
|
return resolve(action)
|
||||||
elseif type(rhs) == 'table' then
|
elseif type(rhs) == 'table' then
|
||||||
|
|
@ -121,7 +121,7 @@ M.show_help = function(keymaps)
|
||||||
|
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines)
|
||||||
local ns = vim.api.nvim_create_namespace('Canola')
|
local ns = vim.api.nvim_create_namespace('Oil')
|
||||||
for _, hl in ipairs(highlights) do
|
for _, hl in ipairs(highlights) do
|
||||||
local hl_group, lnum, start_col, end_col = unpack(hl)
|
local hl_group, lnum, start_col, end_col = unpack(hl)
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, start_col, {
|
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, start_col, {
|
||||||
|
|
@ -98,7 +98,7 @@ M.calculate_height = function(desired_height, opts)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class (exact) canola.WinLayout
|
---@class (exact) oil.WinLayout
|
||||||
---@field width integer
|
---@field width integer
|
||||||
---@field height integer
|
---@field height integer
|
||||||
---@field row integer
|
---@field row integer
|
||||||
|
|
@ -106,7 +106,7 @@ end
|
||||||
|
|
||||||
---@return vim.api.keyset.win_config
|
---@return vim.api.keyset.win_config
|
||||||
M.get_fullscreen_win_opts = function()
|
M.get_fullscreen_win_opts = function()
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
|
|
||||||
local total_width = M.get_editor_width()
|
local total_width = M.get_editor_width()
|
||||||
local total_height = M.get_editor_height()
|
local total_height = M.get_editor_height()
|
||||||
|
|
@ -141,15 +141,15 @@ end
|
||||||
---@param winid integer
|
---@param winid integer
|
||||||
---@param direction "above"|"below"|"left"|"right"|"auto"
|
---@param direction "above"|"below"|"left"|"right"|"auto"
|
||||||
---@param gap integer
|
---@param gap integer
|
||||||
---@return canola.WinLayout root_dim New dimensions of the original window
|
---@return oil.WinLayout root_dim New dimensions of the original window
|
||||||
---@return canola.WinLayout new_dim New dimensions of the new window
|
---@return oil.WinLayout new_dim New dimensions of the new window
|
||||||
M.split_window = function(winid, direction, gap)
|
M.split_window = function(winid, direction, gap)
|
||||||
if direction == 'auto' then
|
if direction == 'auto' then
|
||||||
direction = vim.o.splitright and 'right' or 'left'
|
direction = vim.o.splitright and 'right' or 'left'
|
||||||
end
|
end
|
||||||
|
|
||||||
local float_config = vim.api.nvim_win_get_config(winid)
|
local float_config = vim.api.nvim_win_get_config(winid)
|
||||||
---@type canola.WinLayout
|
---@type oil.WinLayout
|
||||||
local dim_root = {
|
local dim_root = {
|
||||||
width = float_config.width,
|
width = float_config.width,
|
||||||
height = float_config.height,
|
height = float_config.height,
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local timers = {}
|
local timers = {}
|
||||||
|
|
@ -11,14 +11,14 @@ Log.level = vim.log.levels.WARN
|
||||||
|
|
||||||
---@return string
|
---@return string
|
||||||
Log.get_logfile = function()
|
Log.get_logfile = function()
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
|
|
||||||
local ok, stdpath = pcall(vim.fn.stdpath, 'log')
|
local ok, stdpath = pcall(vim.fn.stdpath, 'log')
|
||||||
if not ok then
|
if not ok then
|
||||||
stdpath = vim.fn.stdpath('cache')
|
stdpath = vim.fn.stdpath('cache')
|
||||||
end
|
end
|
||||||
assert(type(stdpath) == 'string')
|
assert(type(stdpath) == 'string')
|
||||||
return fs.join(stdpath, 'canola.log')
|
return fs.join(stdpath, 'oil.log')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param level integer
|
---@param level integer
|
||||||
|
|
@ -73,11 +73,11 @@ local function initialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
local parent = vim.fs.dirname(filepath)
|
local parent = vim.fs.dirname(filepath)
|
||||||
require('canola.fs').mkdirp(parent)
|
require('oil.fs').mkdirp(parent)
|
||||||
|
|
||||||
local logfile, openerr = io.open(filepath, 'a+')
|
local logfile, openerr = io.open(filepath, 'a+')
|
||||||
if not logfile then
|
if not logfile then
|
||||||
local err_msg = string.format('Failed to open canola.nvim log file: %s', openerr)
|
local err_msg = string.format('Failed to open oil.nvim log file: %s', openerr)
|
||||||
vim.notify(err_msg, vim.log.levels.ERROR)
|
vim.notify(err_msg, vim.log.levels.ERROR)
|
||||||
else
|
else
|
||||||
write = function(line)
|
write = function(line)
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local workspace = require('canola.lsp.workspace')
|
local workspace = require('oil.lsp.workspace')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@param actions canola.Action[]
|
---@param actions oil.Action[]
|
||||||
---@return fun() did_perform Call this function when the file operations have been completed
|
---@return fun() did_perform Call this function when the file operations have been completed
|
||||||
M.will_perform_file_operations = function(actions)
|
M.will_perform_file_operations = function(actions)
|
||||||
local moves = {}
|
local moves = {}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local ms = require('vim.lsp.protocol').Methods
|
local ms = require('vim.lsp.protocol').Methods
|
||||||
if vim.fn.has('nvim-0.10') == 0 then
|
if vim.fn.has('nvim-0.10') == 0 then
|
||||||
ms = {
|
ms = {
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
local columns = require('canola.columns')
|
local columns = require('oil.columns')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local layout = require('canola.layout')
|
local layout = require('oil.layout')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@param actions canola.Action[]
|
---@param actions oil.Action[]
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function is_simple_edit(actions)
|
local function is_simple_edit(actions)
|
||||||
local num_create = 0
|
local num_create = 0
|
||||||
|
|
@ -53,7 +53,7 @@ local function render_lines(winid, bufnr, lines)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param actions canola.Action[]
|
---@param actions oil.Action[]
|
||||||
---@param should_confirm nil|boolean
|
---@param should_confirm nil|boolean
|
||||||
---@param cb fun(proceed: boolean)
|
---@param cb fun(proceed: boolean)
|
||||||
M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
|
M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
|
||||||
|
|
@ -90,7 +90,7 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
|
||||||
local adapter = util.get_adapter_for_action(action)
|
local adapter = util.get_adapter_for_action(action)
|
||||||
local line
|
local line
|
||||||
if action.type == 'change' then
|
if action.type == 'change' then
|
||||||
---@cast action canola.ChangeAction
|
---@cast action oil.ChangeAction
|
||||||
line = columns.render_change_action(adapter, action)
|
line = columns.render_change_action(adapter, action)
|
||||||
else
|
else
|
||||||
line = adapter.render_action(action)
|
line = adapter.render_action(action)
|
||||||
|
|
@ -118,14 +118,11 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
|
||||||
border = config.confirmation.border,
|
border = config.confirmation.border,
|
||||||
})
|
})
|
||||||
if not ok then
|
if not ok then
|
||||||
vim.notify(
|
vim.notify(string.format('Error showing oil preview window: %s', winid), vim.log.levels.ERROR)
|
||||||
string.format('Error showing canola preview window: %s', winid),
|
|
||||||
vim.log.levels.ERROR
|
|
||||||
)
|
|
||||||
cb(false)
|
cb(false)
|
||||||
end
|
end
|
||||||
vim.bo[bufnr].filetype = 'canola_preview'
|
vim.bo[bufnr].filetype = 'oil_preview'
|
||||||
vim.bo[bufnr].syntax = 'canola_preview'
|
vim.bo[bufnr].syntax = 'oil_preview'
|
||||||
for k, v in pairs(config.confirmation.win_options) do
|
for k, v in pairs(config.confirmation.win_options) do
|
||||||
vim.api.nvim_set_option_value(k, v, { scope = 'local', win = winid })
|
vim.api.nvim_set_option_value(k, v, { scope = 'local', win = winid })
|
||||||
end
|
end
|
||||||
|
|
@ -1,60 +1,60 @@
|
||||||
local Progress = require('canola.mutator.progress')
|
local Progress = require('oil.mutator.progress')
|
||||||
local Trie = require('canola.mutator.trie')
|
local Trie = require('oil.mutator.trie')
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local canola = require('canola')
|
local columns = require('oil.columns')
|
||||||
local columns = require('canola.columns')
|
local config = require('oil.config')
|
||||||
local config = require('canola.config')
|
local confirmation = require('oil.mutator.confirmation')
|
||||||
local confirmation = require('canola.mutator.confirmation')
|
local constants = require('oil.constants')
|
||||||
local constants = require('canola.constants')
|
local fs = require('oil.fs')
|
||||||
local fs = require('canola.fs')
|
local lsp_helpers = require('oil.lsp.helpers')
|
||||||
local lsp_helpers = require('canola.lsp.helpers')
|
local oil = require('oil')
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local view = require('canola.view')
|
local view = require('oil.view')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_NAME = constants.FIELD_NAME
|
local FIELD_NAME = constants.FIELD_NAME
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
|
|
||||||
---@alias canola.Action canola.CreateAction|canola.DeleteAction|canola.MoveAction|canola.CopyAction|canola.ChangeAction
|
---@alias oil.Action oil.CreateAction|oil.DeleteAction|oil.MoveAction|oil.CopyAction|oil.ChangeAction
|
||||||
|
|
||||||
---@class (exact) canola.CreateAction
|
---@class (exact) oil.CreateAction
|
||||||
---@field type "create"
|
---@field type "create"
|
||||||
---@field url string
|
---@field url string
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field link nil|string
|
---@field link nil|string
|
||||||
|
|
||||||
---@class (exact) canola.DeleteAction
|
---@class (exact) oil.DeleteAction
|
||||||
---@field type "delete"
|
---@field type "delete"
|
||||||
---@field url string
|
---@field url string
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
|
|
||||||
---@class (exact) canola.MoveAction
|
---@class (exact) oil.MoveAction
|
||||||
---@field type "move"
|
---@field type "move"
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field src_url string
|
---@field src_url string
|
||||||
---@field dest_url string
|
---@field dest_url string
|
||||||
|
|
||||||
---@class (exact) canola.CopyAction
|
---@class (exact) oil.CopyAction
|
||||||
---@field type "copy"
|
---@field type "copy"
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field src_url string
|
---@field src_url string
|
||||||
---@field dest_url string
|
---@field dest_url string
|
||||||
|
|
||||||
---@class (exact) canola.ChangeAction
|
---@class (exact) oil.ChangeAction
|
||||||
---@field type "change"
|
---@field type "change"
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field url string
|
---@field url string
|
||||||
---@field column string
|
---@field column string
|
||||||
---@field value any
|
---@field value any
|
||||||
|
|
||||||
---@param all_diffs table<integer, canola.Diff[]>
|
---@param all_diffs table<integer, oil.Diff[]>
|
||||||
---@return canola.Action[]
|
---@return oil.Action[]
|
||||||
M.create_actions_from_diffs = function(all_diffs)
|
M.create_actions_from_diffs = function(all_diffs)
|
||||||
---@type canola.Action[]
|
---@type oil.Action[]
|
||||||
local actions = {}
|
local actions = {}
|
||||||
|
|
||||||
---@type table<integer, canola.Diff[]>
|
---@type table<integer, oil.Diff[]>
|
||||||
local diff_by_id = setmetatable({}, {
|
local diff_by_id = setmetatable({}, {
|
||||||
__index = function(t, key)
|
__index = function(t, key)
|
||||||
local list = {}
|
local list = {}
|
||||||
|
|
@ -69,7 +69,7 @@ M.create_actions_from_diffs = function(all_diffs)
|
||||||
-- > foo/bar/b.txt
|
-- > foo/bar/b.txt
|
||||||
local seen_creates = {}
|
local seen_creates = {}
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
local function add_action(action)
|
local function add_action(action)
|
||||||
local adapter = assert(config.get_adapter_by_scheme(action.dest_url or action.url))
|
local adapter = assert(config.get_adapter_by_scheme(action.dest_url or action.url))
|
||||||
if not adapter.filter_action or adapter.filter_action(action) then
|
if not adapter.filter_action or adapter.filter_action(action) then
|
||||||
|
|
@ -195,8 +195,8 @@ M.create_actions_from_diffs = function(all_diffs)
|
||||||
return M.enforce_action_order(actions)
|
return M.enforce_action_order(actions)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param actions canola.Action[]
|
---@param actions oil.Action[]
|
||||||
---@return canola.Action[]
|
---@return oil.Action[]
|
||||||
M.enforce_action_order = function(actions)
|
M.enforce_action_order = function(actions)
|
||||||
local src_trie = Trie.new()
|
local src_trie = Trie.new()
|
||||||
local dest_trie = Trie.new()
|
local dest_trie = Trie.new()
|
||||||
|
|
@ -220,7 +220,7 @@ M.enforce_action_order = function(actions)
|
||||||
|
|
||||||
---Gets the dependencies of a particular action. Effectively dynamically calculates the dependency
|
---Gets the dependencies of a particular action. Effectively dynamically calculates the dependency
|
||||||
---"edges" of the graph.
|
---"edges" of the graph.
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
local function get_deps(action)
|
local function get_deps(action)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
if action.type == 'delete' then
|
if action.type == 'delete' then
|
||||||
|
|
@ -278,8 +278,8 @@ M.enforce_action_order = function(actions)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return nil|canola.Action The leaf action
|
---@return nil|oil.Action The leaf action
|
||||||
---@return nil|canola.Action When no leaves found, this is the last action in the loop
|
---@return nil|oil.Action When no leaves found, this is the last action in the loop
|
||||||
local function find_leaf(action, seen)
|
local function find_leaf(action, seen)
|
||||||
if not seen then
|
if not seen then
|
||||||
seen = {}
|
seen = {}
|
||||||
|
|
@ -321,7 +321,7 @@ M.enforce_action_order = function(actions)
|
||||||
-- We've detected a move cycle (e.g. MOVE /a -> /b + MOVE /b -> /a)
|
-- We've detected a move cycle (e.g. MOVE /a -> /b + MOVE /b -> /a)
|
||||||
-- Split one of the moves and retry
|
-- Split one of the moves and retry
|
||||||
local intermediate_url =
|
local intermediate_url =
|
||||||
string.format('%s__canola_tmp_%05d', loop_action.src_url, math.random(999999))
|
string.format('%s__oil_tmp_%05d', loop_action.src_url, math.random(999999))
|
||||||
local move_1 = {
|
local move_1 = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = loop_action.entry_type,
|
entry_type = loop_action.entry_type,
|
||||||
|
|
@ -383,12 +383,12 @@ end
|
||||||
|
|
||||||
local progress
|
local progress
|
||||||
|
|
||||||
---@param actions canola.Action[]
|
---@param actions oil.Action[]
|
||||||
---@param cb fun(err: nil|string)
|
---@param cb fun(err: nil|string)
|
||||||
M.process_actions = function(actions, cb)
|
M.process_actions = function(actions, cb)
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaActionsPre', modeline = false, data = { actions = actions } }
|
{ pattern = 'OilActionsPre', modeline = false, data = { actions = actions } }
|
||||||
)
|
)
|
||||||
|
|
||||||
local did_complete = nil
|
local did_complete = nil
|
||||||
|
|
@ -437,7 +437,7 @@ M.process_actions = function(actions, cb)
|
||||||
end
|
end
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaActionsPost', modeline = false, data = { err = err, actions = actions } }
|
{ pattern = 'OilActionsPost', modeline = false, data = { err = err, actions = actions } }
|
||||||
)
|
)
|
||||||
cb(err)
|
cb(err)
|
||||||
end
|
end
|
||||||
|
|
@ -488,7 +488,7 @@ M.process_actions = function(actions, cb)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if action.type == 'change' then
|
if action.type == 'change' then
|
||||||
---@cast action canola.ChangeAction
|
---@cast action oil.ChangeAction
|
||||||
columns.perform_change_action(adapter, action, callback)
|
columns.perform_change_action(adapter, action, callback)
|
||||||
else
|
else
|
||||||
adapter.perform_action(action, callback)
|
adapter.perform_action(action, callback)
|
||||||
|
|
@ -524,7 +524,7 @@ M.try_write_changes = function(confirm, cb)
|
||||||
local was_modified = vim.bo.modified
|
local was_modified = vim.bo.modified
|
||||||
local buffers = view.get_all_buffers()
|
local buffers = view.get_all_buffers()
|
||||||
local all_diffs = {}
|
local all_diffs = {}
|
||||||
---@type table<integer, canola.ParseError[]>
|
---@type table<integer, oil.ParseError[]>
|
||||||
local all_errors = {}
|
local all_errors = {}
|
||||||
|
|
||||||
mutation_in_progress = true
|
mutation_in_progress = true
|
||||||
|
|
@ -552,7 +552,7 @@ M.try_write_changes = function(confirm, cb)
|
||||||
mutation_in_progress = false
|
mutation_in_progress = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local ns = vim.api.nvim_create_namespace('Canola')
|
local ns = vim.api.nvim_create_namespace('Oil')
|
||||||
vim.diagnostic.reset(ns)
|
vim.diagnostic.reset(ns)
|
||||||
if not vim.tbl_isempty(all_errors) then
|
if not vim.tbl_isempty(all_errors) then
|
||||||
for bufnr, errors in pairs(all_errors) do
|
for bufnr, errors in pairs(all_errors) do
|
||||||
|
|
@ -579,7 +579,7 @@ M.try_write_changes = function(confirm, cb)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
unlock()
|
unlock()
|
||||||
cb('Error parsing canola buffers')
|
cb('Error parsing oil buffers')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -596,12 +596,12 @@ M.try_write_changes = function(confirm, cb)
|
||||||
vim.schedule_wrap(function(err)
|
vim.schedule_wrap(function(err)
|
||||||
view.unlock_buffers()
|
view.unlock_buffers()
|
||||||
if err then
|
if err then
|
||||||
err = string.format('[canola] Error applying actions: %s', err)
|
err = string.format('[oil] Error applying actions: %s', err)
|
||||||
view.rerender_all_canola_buffers(nil, function()
|
view.rerender_all_oil_buffers(nil, function()
|
||||||
cb(err)
|
cb(err)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local current_entry = canola.get_cursor_entry()
|
local current_entry = oil.get_cursor_entry()
|
||||||
if current_entry then
|
if current_entry then
|
||||||
-- get the entry under the cursor and make sure the cursor stays on it
|
-- get the entry under the cursor and make sure the cursor stays on it
|
||||||
view.set_last_cursor(
|
view.set_last_cursor(
|
||||||
|
|
@ -609,10 +609,10 @@ M.try_write_changes = function(confirm, cb)
|
||||||
vim.split(current_entry.parsed_name or current_entry.name, '/')[1]
|
vim.split(current_entry.parsed_name or current_entry.name, '/')[1]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
view.rerender_all_canola_buffers(nil, function(render_err)
|
view.rerender_all_oil_buffers(nil, function(render_err)
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaMutationComplete', modeline = false }
|
{ pattern = 'OilMutationComplete', modeline = false }
|
||||||
)
|
)
|
||||||
cb(render_err)
|
cb(render_err)
|
||||||
end)
|
end)
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local columns = require('canola.columns')
|
local columns = require('oil.columns')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local view = require('canola.view')
|
local view = require('oil.view')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_ID = constants.FIELD_ID
|
local FIELD_ID = constants.FIELD_ID
|
||||||
|
|
@ -12,23 +12,23 @@ local FIELD_NAME = constants.FIELD_NAME
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
---@alias canola.Diff canola.DiffNew|canola.DiffDelete|canola.DiffChange
|
---@alias oil.Diff oil.DiffNew|oil.DiffDelete|oil.DiffChange
|
||||||
|
|
||||||
---@class (exact) canola.DiffNew
|
---@class (exact) oil.DiffNew
|
||||||
---@field type "new"
|
---@field type "new"
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field id nil|integer
|
---@field id nil|integer
|
||||||
---@field link nil|string
|
---@field link nil|string
|
||||||
|
|
||||||
---@class (exact) canola.DiffDelete
|
---@class (exact) oil.DiffDelete
|
||||||
---@field type "delete"
|
---@field type "delete"
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field id integer
|
---@field id integer
|
||||||
|
|
||||||
---@class (exact) canola.DiffChange
|
---@class (exact) oil.DiffChange
|
||||||
---@field type "change"
|
---@field type "change"
|
||||||
---@field entry_type canola.EntryType
|
---@field entry_type oil.EntryType
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field column string
|
---@field column string
|
||||||
---@field value any
|
---@field value any
|
||||||
|
|
@ -57,16 +57,16 @@ local function compare_link_target(meta, parsed_entry)
|
||||||
return meta_name == parsed_name
|
return meta_name == parsed_name
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class (exact) canola.ParseResult
|
---@class (exact) oil.ParseResult
|
||||||
---@field data table Parsed entry data
|
---@field data table Parsed entry data
|
||||||
---@field ranges table<string, integer[]> Locations of the various columns
|
---@field ranges table<string, integer[]> Locations of the various columns
|
||||||
---@field entry nil|canola.InternalEntry If the entry already exists
|
---@field entry nil|oil.InternalEntry If the entry already exists
|
||||||
|
|
||||||
---Parse a single line in a buffer
|
---Parse a single line in a buffer
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param line string
|
---@param line string
|
||||||
---@param column_defs canola.ColumnSpec[]
|
---@param column_defs oil.ColumnSpec[]
|
||||||
---@return nil|canola.ParseResult
|
---@return nil|oil.ParseResult
|
||||||
---@return nil|string Error
|
---@return nil|string Error
|
||||||
M.parse_line = function(adapter, line, column_defs)
|
M.parse_line = function(adapter, line, column_defs)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
|
|
@ -142,18 +142,18 @@ M.parse_line = function(adapter, line, column_defs)
|
||||||
return { data = ret, entry = entry, ranges = ranges }
|
return { data = ret, entry = entry, ranges = ranges }
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class (exact) canola.ParseError
|
---@class (exact) oil.ParseError
|
||||||
---@field lnum integer
|
---@field lnum integer
|
||||||
---@field col integer
|
---@field col integer
|
||||||
---@field message string
|
---@field message string
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return canola.Diff[] diffs
|
---@return oil.Diff[] diffs
|
||||||
---@return canola.ParseError[] errors Parsing errors
|
---@return oil.ParseError[] errors Parsing errors
|
||||||
M.parse = function(bufnr)
|
M.parse = function(bufnr)
|
||||||
---@type canola.Diff[]
|
---@type oil.Diff[]
|
||||||
local diffs = {}
|
local diffs = {}
|
||||||
---@type canola.ParseError[]
|
---@type oil.ParseError[]
|
||||||
local errors = {}
|
local errors = {}
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
local adapter = util.get_adapter(bufnr, true)
|
local adapter = util.get_adapter(bufnr, true)
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local columns = require('canola.columns')
|
local columns = require('oil.columns')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local layout = require('canola.layout')
|
local layout = require('oil.layout')
|
||||||
local loading = require('canola.loading')
|
local loading = require('oil.loading')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local Progress = {}
|
local Progress = {}
|
||||||
|
|
||||||
local FPS = 20
|
local FPS = 20
|
||||||
|
|
@ -68,7 +68,7 @@ function Progress:show(opts)
|
||||||
style = 'minimal',
|
style = 'minimal',
|
||||||
border = config.progress.border,
|
border = config.progress.border,
|
||||||
})
|
})
|
||||||
vim.bo[self.bufnr].filetype = 'canola_progress'
|
vim.bo[self.bufnr].filetype = 'oil_progress'
|
||||||
for k, v in pairs(config.progress.win_options) do
|
for k, v in pairs(config.progress.win_options) do
|
||||||
vim.api.nvim_set_option_value(k, v, { scope = 'local', win = self.winid })
|
vim.api.nvim_set_option_value(k, v, { scope = 'local', win = self.winid })
|
||||||
end
|
end
|
||||||
|
|
@ -121,7 +121,7 @@ function Progress:_render()
|
||||||
if self.min_bufnr and vim.api.nvim_buf_is_valid(self.min_bufnr) then
|
if self.min_bufnr and vim.api.nvim_buf_is_valid(self.min_bufnr) then
|
||||||
util.render_text(
|
util.render_text(
|
||||||
self.min_bufnr,
|
self.min_bufnr,
|
||||||
{ string.format('%sCanola: %s', self.spinner, self.count) },
|
{ string.format('%sOil: %s', self.spinner, self.count) },
|
||||||
{ winid = self.min_winid, h_align = 'left' }
|
{ winid = self.min_winid, h_align = 'left' }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -189,17 +189,17 @@ function Progress:minimize()
|
||||||
self.min_bufnr = bufnr
|
self.min_bufnr = bufnr
|
||||||
self.min_winid = winid
|
self.min_winid = winid
|
||||||
self:_render()
|
self:_render()
|
||||||
vim.notify_once('Restore progress window with :Canola --progress')
|
vim.notify_once('Restore progress window with :Oil --progress')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@param idx integer
|
---@param idx integer
|
||||||
---@param total integer
|
---@param total integer
|
||||||
function Progress:set_action(action, idx, total)
|
function Progress:set_action(action, idx, total)
|
||||||
local adapter = util.get_adapter_for_action(action)
|
local adapter = util.get_adapter_for_action(action)
|
||||||
local change_line
|
local change_line
|
||||||
if action.type == 'change' then
|
if action.type == 'change' then
|
||||||
---@cast action canola.ChangeAction
|
---@cast action oil.ChangeAction
|
||||||
change_line = columns.render_change_action(adapter, action)
|
change_line = columns.render_change_action(adapter, action)
|
||||||
else
|
else
|
||||||
change_line = adapter.render_action(action)
|
change_line = adapter.render_action(action)
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
---@class (exact) canola.Trie
|
---@class (exact) oil.Trie
|
||||||
---@field new fun(): canola.Trie
|
---@field new fun(): oil.Trie
|
||||||
---@field private root table
|
---@field private root table
|
||||||
local Trie = {}
|
local Trie = {}
|
||||||
|
|
||||||
---@return canola.Trie
|
---@return oil.Trie
|
||||||
Trie.new = function()
|
Trie.new = function()
|
||||||
---@type canola.Trie
|
---@type oil.Trie
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
root = { values = {}, children = {} },
|
root = { values = {}, children = {} },
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -80,7 +80,7 @@ end
|
||||||
|
|
||||||
---Add the first action that affects a parent path of the url
|
---Add the first action that affects a parent path of the url
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param ret canola.InternalEntry[]
|
---@param ret oil.InternalEntry[]
|
||||||
function Trie:accum_first_parents_of(url, ret)
|
function Trie:accum_first_parents_of(url, ret)
|
||||||
local pieces = self:_url_to_path_pieces(url)
|
local pieces = self:_url_to_path_pieces(url)
|
||||||
local containers = { self.root }
|
local containers = { self.root }
|
||||||
|
|
@ -117,8 +117,8 @@ end
|
||||||
|
|
||||||
---Add all actions affecting children of the url
|
---Add all actions affecting children of the url
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param ret canola.InternalEntry[]
|
---@param ret oil.InternalEntry[]
|
||||||
---@param filter nil|fun(entry: canola.Action): boolean
|
---@param filter nil|fun(entry: oil.Action): boolean
|
||||||
function Trie:accum_children_of(url, ret, filter)
|
function Trie:accum_children_of(url, ret, filter)
|
||||||
local pieces = self:_url_to_path_pieces(url)
|
local pieces = self:_url_to_path_pieces(url)
|
||||||
local current = self.root
|
local current = self.root
|
||||||
|
|
@ -137,8 +137,8 @@ end
|
||||||
|
|
||||||
---Add all actions at a specific path
|
---Add all actions at a specific path
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param ret canola.InternalEntry[]
|
---@param ret oil.InternalEntry[]
|
||||||
---@param filter? fun(entry: canola.Action): boolean
|
---@param filter? fun(entry: oil.Action): boolean
|
||||||
function Trie:accum_actions_at(url, ret, filter)
|
function Trie:accum_actions_at(url, ret, filter)
|
||||||
local pieces = self:_url_to_path_pieces(url)
|
local pieces = self:_url_to_path_pieces(url)
|
||||||
local current = self.root
|
local current = self.root
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
---@class canola.Ringbuf
|
---@class oil.Ringbuf
|
||||||
---@field private size integer
|
---@field private size integer
|
||||||
---@field private tail integer
|
---@field private tail integer
|
||||||
---@field private buf string[]
|
---@field private buf string[]
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ local FIELD_NAME = constants.FIELD_NAME
|
||||||
local FIELD_TYPE = constants.FIELD_TYPE
|
local FIELD_TYPE = constants.FIELD_TYPE
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
||||||
---@alias canola.IconProvider fun(type: string, name: string, conf: table?, ft: string?): (icon: string, hl: string)
|
---@alias oil.IconProvider fun(type: string, name: string, conf: table?, ft: string?): (icon: string, hl: string)
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@return nil|string
|
---@return nil|string
|
||||||
|
|
@ -77,13 +77,13 @@ end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param silent? boolean
|
---@param silent? boolean
|
||||||
---@return nil|canola.Adapter
|
---@return nil|oil.Adapter
|
||||||
M.get_adapter = function(bufnr, silent)
|
M.get_adapter = function(bufnr, silent)
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
local adapter = config.get_adapter_by_scheme(bufname)
|
local adapter = config.get_adapter_by_scheme(bufname)
|
||||||
if not adapter and not silent then
|
if not adapter and not silent then
|
||||||
vim.notify_once(
|
vim.notify_once(
|
||||||
string.format("[canola] could not find adapter for buffer '%s://'", bufname),
|
string.format("[oil] could not find adapter for buffer '%s://'", bufname),
|
||||||
vim.log.levels.ERROR
|
vim.log.levels.ERROR
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -92,7 +92,7 @@ end
|
||||||
|
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param width integer|nil
|
---@param width integer|nil
|
||||||
---@param align canola.ColumnAlign
|
---@param align oil.ColumnAlign
|
||||||
---@return string padded_text
|
---@return string padded_text
|
||||||
---@return integer left_padding
|
---@return integer left_padding
|
||||||
M.pad_align = function(text, width, align)
|
M.pad_align = function(text, width, align)
|
||||||
|
|
@ -135,8 +135,8 @@ M.tbl_slice = function(tbl, start_idx, end_idx)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@return canola.Entry
|
---@return oil.Entry
|
||||||
M.export_entry = function(entry)
|
M.export_entry = function(entry)
|
||||||
return {
|
return {
|
||||||
name = entry[FIELD_NAME],
|
name = entry[FIELD_NAME],
|
||||||
|
|
@ -244,7 +244,7 @@ end
|
||||||
---@param url string
|
---@param url string
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function get_possible_buffer_names_from_url(url)
|
local function get_possible_buffer_names_from_url(url)
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local scheme, path = M.parse_url(url)
|
local scheme, path = M.parse_url(url)
|
||||||
if config.adapters[scheme] == 'files' then
|
if config.adapters[scheme] == 'files' then
|
||||||
assert(path)
|
assert(path)
|
||||||
|
|
@ -253,7 +253,7 @@ local function get_possible_buffer_names_from_url(url)
|
||||||
return { url }
|
return { url }
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry_type canola.EntryType
|
---@param entry_type oil.EntryType
|
||||||
---@param src_url string
|
---@param src_url string
|
||||||
---@param dest_url string
|
---@param dest_url string
|
||||||
M.update_moved_buffers = function(entry_type, src_url, dest_url)
|
M.update_moved_buffers = function(entry_type, src_url, dest_url)
|
||||||
|
|
@ -271,7 +271,7 @@ M.update_moved_buffers = function(entry_type, src_url, dest_url)
|
||||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
if vim.startswith(bufname, src_url) then
|
if vim.startswith(bufname, src_url) then
|
||||||
-- Handle canola directory buffers
|
-- Handle oil directory buffers
|
||||||
vim.api.nvim_buf_set_name(bufnr, dest_url .. bufname:sub(src_url:len() + 1))
|
vim.api.nvim_buf_set_name(bufnr, dest_url .. bufname:sub(src_url:len() + 1))
|
||||||
elseif bufname ~= '' and vim.bo[bufnr].buftype == '' then
|
elseif bufname ~= '' and vim.bo[bufnr].buftype == '' then
|
||||||
-- Handle regular buffers
|
-- Handle regular buffers
|
||||||
|
|
@ -309,11 +309,11 @@ M.split_config = function(name_or_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias canola.ColumnAlign "left"|"center"|"right"
|
---@alias oil.ColumnAlign "left"|"center"|"right"
|
||||||
|
|
||||||
---@param lines canola.TextChunk[][]
|
---@param lines oil.TextChunk[][]
|
||||||
---@param col_width integer[]
|
---@param col_width integer[]
|
||||||
---@param col_align? canola.ColumnAlign[]
|
---@param col_align? oil.ColumnAlign[]
|
||||||
---@return string[]
|
---@return string[]
|
||||||
---@return any[][] List of highlights {group, lnum, col_start, col_end}
|
---@return any[][] List of highlights {group, lnum, col_start, col_end}
|
||||||
M.render_table = function(lines, col_width, col_align)
|
M.render_table = function(lines, col_width, col_align)
|
||||||
|
|
@ -364,7 +364,7 @@ end
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param highlights any[][] List of highlights {group, lnum, col_start, col_end}
|
---@param highlights any[][] List of highlights {group, lnum, col_start, col_end}
|
||||||
M.set_highlights = function(bufnr, highlights)
|
M.set_highlights = function(bufnr, highlights)
|
||||||
local ns = vim.api.nvim_create_namespace('Canola')
|
local ns = vim.api.nvim_create_namespace('Oil')
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||||
for _, hl in ipairs(highlights) do
|
for _, hl in ipairs(highlights) do
|
||||||
local group, line, col_start, col_end = unpack(hl)
|
local group, line, col_start, col_end = unpack(hl)
|
||||||
|
|
@ -381,7 +381,7 @@ end
|
||||||
---@return string
|
---@return string
|
||||||
M.addslash = function(path, os_slash)
|
M.addslash = function(path, os_slash)
|
||||||
local slash = '/'
|
local slash = '/'
|
||||||
if os_slash and require('canola.fs').is_windows then
|
if os_slash and require('oil.fs').is_windows then
|
||||||
slash = '\\'
|
slash = '\\'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -413,7 +413,7 @@ M.get_title = function(winid)
|
||||||
|
|
||||||
if config.adapters[scheme] == 'files' then
|
if config.adapters[scheme] == 'files' then
|
||||||
assert(path)
|
assert(path)
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
title = vim.fn.fnamemodify(fs.posix_to_os_path(path), ':~')
|
title = vim.fn.fnamemodify(fs.posix_to_os_path(path), ':~')
|
||||||
end
|
end
|
||||||
return title
|
return title
|
||||||
|
|
@ -445,7 +445,7 @@ M.add_title_to_win = function(winid, opts)
|
||||||
col = vim.api.nvim_win_get_width(winid) - 1 - width
|
col = vim.api.nvim_win_get_width(winid) - 1 - width
|
||||||
elseif opts.align ~= 'left' then
|
elseif opts.align ~= 'left' then
|
||||||
vim.notify(
|
vim.notify(
|
||||||
string.format("Unknown canola window title alignment: '%s'", opts.align),
|
string.format("Unknown oil window title alignment: '%s'", opts.align),
|
||||||
vim.log.levels.ERROR
|
vim.log.levels.ERROR
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -470,7 +470,7 @@ M.add_title_to_win = function(winid, opts)
|
||||||
vim.bo[bufnr].bufhidden = 'wipe'
|
vim.bo[bufnr].bufhidden = 'wipe'
|
||||||
|
|
||||||
local update_autocmd = vim.api.nvim_create_autocmd('BufWinEnter', {
|
local update_autocmd = vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||||
desc = 'Update canola floating window title when buffer changes',
|
desc = 'Update oil floating window title when buffer changes',
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
callback = function(params)
|
callback = function(params)
|
||||||
local winbuf = params.buf
|
local winbuf = params.buf
|
||||||
|
|
@ -500,7 +500,7 @@ M.add_title_to_win = function(winid, opts)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd('WinClosed', {
|
vim.api.nvim_create_autocmd('WinClosed', {
|
||||||
desc = 'Close canola floating window title when floating window closes',
|
desc = 'Close oil floating window title when floating window closes',
|
||||||
pattern = tostring(winid),
|
pattern = tostring(winid),
|
||||||
callback = function()
|
callback = function()
|
||||||
if title_winid and vim.api.nvim_win_is_valid(title_winid) then
|
if title_winid and vim.api.nvim_win_is_valid(title_winid) then
|
||||||
|
|
@ -522,9 +522,9 @@ M.add_title_to_win = function(winid, opts)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param action canola.Action
|
---@param action oil.Action
|
||||||
---@return canola.Adapter
|
---@return oil.Adapter
|
||||||
---@return nil|canola.CrossAdapterAction
|
---@return nil|oil.CrossAdapterAction
|
||||||
M.get_adapter_for_action = function(action)
|
M.get_adapter_for_action = function(action)
|
||||||
local adapter = assert(config.get_adapter_by_scheme(action.url or action.src_url))
|
local adapter = assert(config.get_adapter_by_scheme(action.url or action.src_url))
|
||||||
if action.dest_url then
|
if action.dest_url then
|
||||||
|
|
@ -675,12 +675,12 @@ end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_canola_bufnr = function(bufnr)
|
M.is_oil_bufnr = function(bufnr)
|
||||||
local filetype = vim.bo[bufnr].filetype
|
local filetype = vim.bo[bufnr].filetype
|
||||||
if filetype == 'canola' then
|
if filetype == 'oil' then
|
||||||
return true
|
return true
|
||||||
elseif filetype ~= '' then
|
elseif filetype ~= '' then
|
||||||
-- If the filetype is set and is NOT "canola", then it's not an canola buffer
|
-- If the filetype is set and is NOT "oil", then it's not an oil buffer
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local scheme = M.parse_url(vim.api.nvim_buf_get_name(bufnr))
|
local scheme = M.parse_url(vim.api.nvim_buf_get_name(bufnr))
|
||||||
|
|
@ -713,7 +713,7 @@ M.get_preview_win = function(opts)
|
||||||
if
|
if
|
||||||
vim.api.nvim_win_is_valid(winid)
|
vim.api.nvim_win_is_valid(winid)
|
||||||
and vim.wo[winid].previewwindow
|
and vim.wo[winid].previewwindow
|
||||||
and (opts.include_not_owned or vim.w[winid]['canola_preview'])
|
and (opts.include_not_owned or vim.w[winid]['oil_preview'])
|
||||||
then
|
then
|
||||||
return winid
|
return winid
|
||||||
end
|
end
|
||||||
|
|
@ -722,9 +722,9 @@ end
|
||||||
|
|
||||||
---@return fun() restore Function that restores the cursor
|
---@return fun() restore Function that restores the cursor
|
||||||
M.hide_cursor = function()
|
M.hide_cursor = function()
|
||||||
vim.api.nvim_set_hl(0, 'CanolaPreviewCursor', { nocombine = true, blend = 100 })
|
vim.api.nvim_set_hl(0, 'OilPreviewCursor', { nocombine = true, blend = 100 })
|
||||||
local original_guicursor = vim.go.guicursor
|
local original_guicursor = vim.go.guicursor
|
||||||
vim.go.guicursor = 'a:CanolaPreviewCursor/CanolaPreviewCursor'
|
vim.go.guicursor = 'a:OilPreviewCursor/OilPreviewCursor'
|
||||||
|
|
||||||
return function()
|
return function()
|
||||||
-- HACK: see https://github.com/neovim/neovim/issues/21018
|
-- HACK: see https://github.com/neovim/neovim/issues/21018
|
||||||
|
|
@ -758,12 +758,12 @@ M.buf_get_win = function(bufnr, preferred_win)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param opts {columns?: string[], no_cache?: boolean}
|
---@param opts {columns?: string[], no_cache?: boolean}
|
||||||
---@param callback fun(err: nil|string, entries: nil|canola.InternalEntry[])
|
---@param callback fun(err: nil|string, entries: nil|oil.InternalEntry[])
|
||||||
M.adapter_list_all = function(adapter, url, opts, callback)
|
M.adapter_list_all = function(adapter, url, opts, callback)
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
if not opts.no_cache then
|
if not opts.no_cache then
|
||||||
local entries = cache.list_url(url)
|
local entries = cache.list_url(url)
|
||||||
if not vim.tbl_isempty(entries) then
|
if not vim.tbl_isempty(entries) then
|
||||||
|
|
@ -787,15 +787,15 @@ M.adapter_list_all = function(adapter, url, opts, callback)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Send files from the current canola directory to quickfix
|
---Send files from the current oil directory to quickfix
|
||||||
---based on the provided options.
|
---based on the provided options.
|
||||||
---@param opts {target?: "qflist"|"loclist", action?: "r"|"a", only_matching_search?: boolean}
|
---@param opts {target?: "qflist"|"loclist", action?: "r"|"a", only_matching_search?: boolean}
|
||||||
M.send_to_quickfix = function(opts)
|
M.send_to_quickfix = function(opts)
|
||||||
if type(opts) ~= 'table' then
|
if type(opts) ~= 'table' then
|
||||||
opts = {}
|
opts = {}
|
||||||
end
|
end
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local dir = canola.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if type(dir) ~= 'string' then
|
if type(dir) ~= 'string' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -806,7 +806,7 @@ M.send_to_quickfix = function(opts)
|
||||||
local match_all = not opts.only_matching_search
|
local match_all = not opts.only_matching_search
|
||||||
local qf_entries = {}
|
local qf_entries = {}
|
||||||
for i = range.start_lnum, range.end_lnum do
|
for i = range.start_lnum, range.end_lnum do
|
||||||
local entry = canola.get_entry_on_line(0, i)
|
local entry = oil.get_entry_on_line(0, i)
|
||||||
if entry and entry.type == 'file' and (match_all or M.is_matching(entry)) then
|
if entry and entry.type == 'file' and (match_all or M.is_matching(entry)) then
|
||||||
local qf_entry = {
|
local qf_entry = {
|
||||||
filename = dir .. entry.name,
|
filename = dir .. entry.name,
|
||||||
|
|
@ -818,11 +818,11 @@ M.send_to_quickfix = function(opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #qf_entries == 0 then
|
if #qf_entries == 0 then
|
||||||
vim.notify('[canola] No entries found to send to quickfix', vim.log.levels.WARN)
|
vim.notify('[oil] No entries found to send to quickfix', vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.api.nvim_exec_autocmds('QuickFixCmdPre', {})
|
vim.api.nvim_exec_autocmds('QuickFixCmdPre', {})
|
||||||
local qf_title = 'canola files'
|
local qf_title = 'oil files'
|
||||||
local action = opts.action == 'a' and 'a' or 'r'
|
local action = opts.action == 'a' and 'a' or 'r'
|
||||||
if opts.target == 'loclist' then
|
if opts.target == 'loclist' then
|
||||||
vim.fn.setloclist(0, {}, action, { title = qf_title, items = qf_entries })
|
vim.fn.setloclist(0, {}, action, { title = qf_title, items = qf_entries })
|
||||||
|
|
@ -856,7 +856,7 @@ M.get_visual_range = function()
|
||||||
return { start_lnum = start_lnum, end_lnum = end_lnum }
|
return { start_lnum = start_lnum, end_lnum = end_lnum }
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_matching = function(entry)
|
M.is_matching = function(entry)
|
||||||
-- if search highlightig is not enabled, all files are considered to match
|
-- if search highlightig is not enabled, all files are considered to match
|
||||||
|
|
@ -875,11 +875,11 @@ M.run_after_load = function(bufnr, callback)
|
||||||
if bufnr == 0 then
|
if bufnr == 0 then
|
||||||
bufnr = vim.api.nvim_get_current_buf()
|
bufnr = vim.api.nvim_get_current_buf()
|
||||||
end
|
end
|
||||||
if vim.b[bufnr].canola_ready then
|
if vim.b[bufnr].oil_ready then
|
||||||
callback()
|
callback()
|
||||||
else
|
else
|
||||||
vim.api.nvim_create_autocmd('User', {
|
vim.api.nvim_create_autocmd('User', {
|
||||||
pattern = 'CanolaEnter',
|
pattern = 'OilEnter',
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
if args.data.buf == bufnr then
|
if args.data.buf == bufnr then
|
||||||
vim.api.nvim_buf_call(bufnr, callback)
|
vim.api.nvim_buf_call(bufnr, callback)
|
||||||
|
|
@ -890,7 +890,7 @@ M.run_after_load = function(bufnr, callback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_directory = function(entry)
|
M.is_directory = function(entry)
|
||||||
local is_directory = entry.type == 'directory'
|
local is_directory = entry.type == 'directory'
|
||||||
|
|
@ -904,11 +904,11 @@ M.is_directory = function(entry)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get the :edit path for an entry
|
---Get the :edit path for an entry
|
||||||
---@param bufnr integer The canola buffer that contains the entry
|
---@param bufnr integer The oil buffer that contains the entry
|
||||||
---@param entry canola.Entry
|
---@param entry oil.Entry
|
||||||
---@param callback fun(normalized_url: string)
|
---@param callback fun(normalized_url: string)
|
||||||
M.get_edit_path = function(bufnr, entry, callback)
|
M.get_edit_path = function(bufnr, entry, callback)
|
||||||
local pathutil = require('canola.pathutil')
|
local pathutil = require('oil.pathutil')
|
||||||
|
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
local scheme, dir = M.parse_url(bufname)
|
local scheme, dir = M.parse_url(bufname)
|
||||||
|
|
@ -930,7 +930,7 @@ M.get_edit_path = function(bufnr, entry, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check for an icon provider and return a common icon provider API
|
--- Check for an icon provider and return a common icon provider API
|
||||||
---@return (canola.IconProvider)?
|
---@return (oil.IconProvider)?
|
||||||
M.get_icon_provider = function()
|
M.get_icon_provider = function()
|
||||||
-- prefer mini.icons
|
-- prefer mini.icons
|
||||||
local _, mini_icons = pcall(require, 'mini.icons')
|
local _, mini_icons = pcall(require, 'mini.icons')
|
||||||
|
|
@ -954,20 +954,20 @@ M.get_icon_provider = function()
|
||||||
return function(type, name, conf, ft)
|
return function(type, name, conf, ft)
|
||||||
if type == 'directory' then
|
if type == 'directory' then
|
||||||
local icon, hl = nonicons.get('file-directory-fill')
|
local icon, hl = nonicons.get('file-directory-fill')
|
||||||
return icon or (conf and conf.directory or ''), hl or 'CanolaDirIcon'
|
return icon or (conf and conf.directory or ''), hl or 'OilDirIcon'
|
||||||
end
|
end
|
||||||
if ft then
|
if ft then
|
||||||
local ft_icon, ft_hl = nonicons.get_icon_by_filetype(ft)
|
local ft_icon, ft_hl = nonicons.get_icon_by_filetype(ft)
|
||||||
if ft_icon then
|
if ft_icon then
|
||||||
return ft_icon, ft_hl or 'CanolaFileIcon'
|
return ft_icon, ft_hl or 'OilFileIcon'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local icon, hl = nonicons.get_icon(name)
|
local icon, hl = nonicons.get_icon(name)
|
||||||
if icon then
|
if icon then
|
||||||
return icon, hl or 'CanolaFileIcon'
|
return icon, hl or 'OilFileIcon'
|
||||||
end
|
end
|
||||||
local fallback, fallback_hl = nonicons.get('file')
|
local fallback, fallback_hl = nonicons.get('file')
|
||||||
return fallback or (conf and conf.default_file or ''), fallback_hl or 'CanolaFileIcon'
|
return fallback or (conf and conf.default_file or ''), fallback_hl or 'OilFileIcon'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -979,7 +979,7 @@ M.get_icon_provider = function()
|
||||||
|
|
||||||
return function(type, name, conf, ft)
|
return function(type, name, conf, ft)
|
||||||
if type == 'directory' then
|
if type == 'directory' then
|
||||||
return conf and conf.directory or '', 'CanolaDirIcon'
|
return conf and conf.directory or '', 'OilDirIcon'
|
||||||
else
|
else
|
||||||
if ft then
|
if ft then
|
||||||
local ft_icon, ft_hl = devicons.get_icon_by_filetype(ft)
|
local ft_icon, ft_hl = devicons.get_icon_by_filetype(ft)
|
||||||
|
|
@ -988,7 +988,7 @@ M.get_icon_provider = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local icon, hl = devicons.get_icon(name)
|
local icon, hl = devicons.get_icon(name)
|
||||||
hl = hl or 'CanolaFileIcon'
|
hl = hl or 'OilFileIcon'
|
||||||
icon = icon or (conf and conf.default_file or '')
|
icon = icon or (conf and conf.default_file or '')
|
||||||
return icon, hl
|
return icon, hl
|
||||||
end
|
end
|
||||||
|
|
@ -997,7 +997,7 @@ end
|
||||||
|
|
||||||
---Read a buffer into a scratch buffer and apply syntactic highlighting when possible
|
---Read a buffer into a scratch buffer and apply syntactic highlighting when possible
|
||||||
---@param path string The path to the file to read
|
---@param path string The path to the file to read
|
||||||
---@param preview_method canola.PreviewMethod
|
---@param preview_method oil.PreviewMethod
|
||||||
---@return nil|integer
|
---@return nil|integer
|
||||||
M.read_file_to_scratch_buffer = function(path, preview_method)
|
M.read_file_to_scratch_buffer = function(path, preview_method)
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
|
|
@ -1032,7 +1032,7 @@ M.read_file_to_scratch_buffer = function(path, preview_method)
|
||||||
|
|
||||||
-- Replace the scratch buffer with a real buffer if we enter it
|
-- Replace the scratch buffer with a real buffer if we enter it
|
||||||
vim.api.nvim_create_autocmd('BufEnter', {
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
desc = 'canola.nvim replace scratch buffer with real buffer',
|
desc = 'oil.nvim replace scratch buffer with real buffer',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
|
|
@ -1045,7 +1045,7 @@ M.read_file_to_scratch_buffer = function(path, preview_method)
|
||||||
-- preview
|
-- preview
|
||||||
if vim.wo.previewwindow then
|
if vim.wo.previewwindow then
|
||||||
vim.bo.bufhidden = 'wipe'
|
vim.bo.bufhidden = 'wipe'
|
||||||
vim.b.canola_preview_buffer = true
|
vim.b.oil_preview_buffer = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local columns = require('canola.columns')
|
local columns = require('oil.columns')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local keymap_util = require('canola.keymap_util')
|
local keymap_util = require('oil.keymap_util')
|
||||||
local loading = require('canola.loading')
|
local loading = require('oil.loading')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local FIELD_ID = constants.FIELD_ID
|
local FIELD_ID = constants.FIELD_ID
|
||||||
|
|
@ -18,7 +18,7 @@ local FIELD_META = constants.FIELD_META
|
||||||
local last_cursor_entry = {}
|
local last_cursor_entry = {}
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@return boolean display
|
---@return boolean display
|
||||||
---@return boolean is_hidden Whether the file is classified as a hidden file
|
---@return boolean is_hidden Whether the file is classified as a hidden file
|
||||||
M.should_display = function(bufnr, entry)
|
M.should_display = function(bufnr, entry)
|
||||||
|
|
@ -41,7 +41,7 @@ end
|
||||||
|
|
||||||
---Set the cursor to the last_cursor_entry if one exists
|
---Set the cursor to the last_cursor_entry if one exists
|
||||||
M.maybe_set_cursor = function()
|
M.maybe_set_cursor = function()
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local bufname = vim.api.nvim_buf_get_name(0)
|
local bufname = vim.api.nvim_buf_get_name(0)
|
||||||
local entry_name = last_cursor_entry[bufname]
|
local entry_name = last_cursor_entry[bufname]
|
||||||
if not entry_name then
|
if not entry_name then
|
||||||
|
|
@ -49,7 +49,7 @@ M.maybe_set_cursor = function()
|
||||||
end
|
end
|
||||||
local line_count = vim.api.nvim_buf_line_count(0)
|
local line_count = vim.api.nvim_buf_line_count(0)
|
||||||
for lnum = 1, line_count do
|
for lnum = 1, line_count do
|
||||||
local entry = canola.get_entry_on_line(0, lnum)
|
local entry = oil.get_entry_on_line(0, lnum)
|
||||||
if entry and entry.name == entry_name then
|
if entry and entry.name == entry_name then
|
||||||
local line = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, true)[1]
|
local line = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, true)[1]
|
||||||
local id_str = line:match('^/(%d+)')
|
local id_str = line:match('^/(%d+)')
|
||||||
|
|
@ -101,18 +101,18 @@ M.toggle_hidden = function()
|
||||||
vim.notify('Cannot toggle hidden files when you have unsaved changes', vim.log.levels.WARN)
|
vim.notify('Cannot toggle hidden files when you have unsaved changes', vim.log.levels.WARN)
|
||||||
else
|
else
|
||||||
config.view_options.show_hidden = not config.view_options.show_hidden
|
config.view_options.show_hidden = not config.view_options.show_hidden
|
||||||
M.rerender_all_canola_buffers({ refetch = false })
|
M.rerender_all_oil_buffers({ refetch = false })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param is_hidden_file fun(filename: string, bufnr: integer, entry: canola.Entry): boolean
|
---@param is_hidden_file fun(filename: string, bufnr: integer, entry: oil.Entry): boolean
|
||||||
M.set_is_hidden_file = function(is_hidden_file)
|
M.set_is_hidden_file = function(is_hidden_file)
|
||||||
local any_modified = are_any_modified()
|
local any_modified = are_any_modified()
|
||||||
if any_modified then
|
if any_modified then
|
||||||
vim.notify('Cannot change is_hidden_file when you have unsaved changes', vim.log.levels.WARN)
|
vim.notify('Cannot change is_hidden_file when you have unsaved changes', vim.log.levels.WARN)
|
||||||
else
|
else
|
||||||
config.view_options.is_hidden_file = is_hidden_file
|
config.view_options.is_hidden_file = is_hidden_file
|
||||||
M.rerender_all_canola_buffers({ refetch = false })
|
M.rerender_all_oil_buffers({ refetch = false })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ M.set_columns = function(cols)
|
||||||
else
|
else
|
||||||
config.columns = cols
|
config.columns = cols
|
||||||
-- TODO only refetch if we don't have all the necessary data for the columns
|
-- TODO only refetch if we don't have all the necessary data for the columns
|
||||||
M.rerender_all_canola_buffers({ refetch = true })
|
M.rerender_all_oil_buffers({ refetch = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -134,15 +134,15 @@ M.set_sort = function(new_sort)
|
||||||
else
|
else
|
||||||
config.view_options.sort = new_sort
|
config.view_options.sort = new_sort
|
||||||
-- TODO only refetch if we don't have all the necessary data for the columns
|
-- TODO only refetch if we don't have all the necessary data for the columns
|
||||||
M.rerender_all_canola_buffers({ refetch = true })
|
M.rerender_all_oil_buffers({ refetch = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class canola.ViewData
|
---@class oil.ViewData
|
||||||
---@field fs_event? any uv_fs_event_t
|
---@field fs_event? any uv_fs_event_t
|
||||||
|
|
||||||
-- List of bufnrs
|
-- List of bufnrs
|
||||||
---@type table<integer, canola.ViewData>
|
---@type table<integer, oil.ViewData>
|
||||||
local session = {}
|
local session = {}
|
||||||
|
|
||||||
---@return integer[]
|
---@return integer[]
|
||||||
|
|
@ -151,7 +151,7 @@ M.get_all_buffers = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local buffers_locked = false
|
local buffers_locked = false
|
||||||
---Make all canola buffers nomodifiable
|
---Make all oil buffers nomodifiable
|
||||||
M.lock_buffers = function()
|
M.lock_buffers = function()
|
||||||
buffers_locked = true
|
buffers_locked = true
|
||||||
for bufnr in pairs(session) do
|
for bufnr in pairs(session) do
|
||||||
|
|
@ -161,7 +161,7 @@ M.lock_buffers = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Restore normal modifiable settings for canola buffers
|
---Restore normal modifiable settings for oil buffers
|
||||||
M.unlock_buffers = function()
|
M.unlock_buffers = function()
|
||||||
buffers_locked = false
|
buffers_locked = false
|
||||||
for bufnr in pairs(session) do
|
for bufnr in pairs(session) do
|
||||||
|
|
@ -177,8 +177,8 @@ end
|
||||||
---@param opts? table
|
---@param opts? table
|
||||||
---@param callback? fun(err: nil|string)
|
---@param callback? fun(err: nil|string)
|
||||||
---@note
|
---@note
|
||||||
--- This DISCARDS ALL MODIFICATIONS a user has made to canola buffers
|
--- This DISCARDS ALL MODIFICATIONS a user has made to oil buffers
|
||||||
M.rerender_all_canola_buffers = function(opts, callback)
|
M.rerender_all_oil_buffers = function(opts, callback)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local buffers = M.get_all_buffers()
|
local buffers = M.get_all_buffers()
|
||||||
local hidden_buffers = {}
|
local hidden_buffers = {}
|
||||||
|
|
@ -193,7 +193,7 @@ M.rerender_all_canola_buffers = function(opts, callback)
|
||||||
local cb = util.cb_collect(#buffers, callback or function() end)
|
local cb = util.cb_collect(#buffers, callback or function() end)
|
||||||
for _, bufnr in ipairs(buffers) do
|
for _, bufnr in ipairs(buffers) do
|
||||||
if hidden_buffers[bufnr] then
|
if hidden_buffers[bufnr] then
|
||||||
vim.b[bufnr].canola_dirty = opts
|
vim.b[bufnr].oil_dirty = opts
|
||||||
-- We also need to mark this as nomodified so it doesn't interfere with quitting vim
|
-- We also need to mark this as nomodified so it doesn't interfere with quitting vim
|
||||||
vim.bo[bufnr].modified = false
|
vim.bo[bufnr].modified = false
|
||||||
vim.schedule(cb)
|
vim.schedule(cb)
|
||||||
|
|
@ -219,7 +219,7 @@ M.set_win_options = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get a list of visible canola buffers and a list of hidden canola buffers
|
---Get a list of visible oil buffers and a list of hidden oil buffers
|
||||||
---@note
|
---@note
|
||||||
--- If any buffers are modified, return values are nil
|
--- If any buffers are modified, return values are nil
|
||||||
---@return nil|integer[] visible
|
---@return nil|integer[] visible
|
||||||
|
|
@ -244,7 +244,7 @@ local function get_visible_hidden_buffers()
|
||||||
return visible_buffers, vim.tbl_keys(hidden_buffers)
|
return visible_buffers, vim.tbl_keys(hidden_buffers)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Delete unmodified, hidden canola buffers and if none remain, clear the cache
|
---Delete unmodified, hidden oil buffers and if none remain, clear the cache
|
||||||
M.delete_hidden_buffers = function()
|
M.delete_hidden_buffers = function()
|
||||||
local visible_buffers, hidden_buffers = get_visible_hidden_buffers()
|
local visible_buffers, hidden_buffers = get_visible_hidden_buffers()
|
||||||
if
|
if
|
||||||
|
|
@ -261,7 +261,7 @@ M.delete_hidden_buffers = function()
|
||||||
cache.clear_everything()
|
cache.clear_everything()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param ranges table<string, integer[]>
|
---@param ranges table<string, integer[]>
|
||||||
---@return integer
|
---@return integer
|
||||||
local function get_first_mutable_column_col(adapter, ranges)
|
local function get_first_mutable_column_col(adapter, ranges)
|
||||||
|
|
@ -278,12 +278,12 @@ local function get_first_mutable_column_col(adapter, ranges)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param bufnr integer
|
--- @param bufnr integer
|
||||||
--- @param adapter canola.Adapter
|
--- @param adapter oil.Adapter
|
||||||
--- @param mode false|"name"|"editable"
|
--- @param mode false|"name"|"editable"
|
||||||
--- @param cur integer[]
|
--- @param cur integer[]
|
||||||
--- @return integer[] | nil
|
--- @return integer[] | nil
|
||||||
local function calc_constrained_cursor_pos(bufnr, adapter, mode, cur)
|
local function calc_constrained_cursor_pos(bufnr, adapter, mode, cur)
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local line = vim.api.nvim_buf_get_lines(bufnr, cur[1] - 1, cur[1], true)[1]
|
local line = vim.api.nvim_buf_get_lines(bufnr, cur[1] - 1, cur[1], true)[1]
|
||||||
local column_defs = columns.get_supported_columns(adapter)
|
local column_defs = columns.get_supported_columns(adapter)
|
||||||
local result = parser.parse_line(adapter, line, column_defs)
|
local result = parser.parse_line(adapter, line, column_defs)
|
||||||
|
|
@ -377,7 +377,7 @@ local function show_insert_guide(bufnr)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local column_defs = columns.get_supported_columns(adapter)
|
local column_defs = columns.get_supported_columns(adapter)
|
||||||
local result = parser.parse_line(adapter, ref_line, column_defs)
|
local result = parser.parse_line(adapter, ref_line, column_defs)
|
||||||
if not result or not result.ranges then
|
if not result or not result.ranges then
|
||||||
|
|
@ -401,18 +401,18 @@ local function show_insert_guide(bufnr)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.w.canola_saved_ve = vim.wo.virtualedit
|
vim.w.oil_saved_ve = vim.wo.virtualedit
|
||||||
vim.wo.virtualedit = 'all'
|
vim.wo.virtualedit = 'all'
|
||||||
vim.api.nvim_win_set_cursor(0, { cur[1], virtual_col })
|
vim.api.nvim_win_set_cursor(0, { cur[1], virtual_col })
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('TextChangedI', {
|
vim.api.nvim_create_autocmd('TextChangedI', {
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.w.canola_saved_ve ~= nil then
|
if vim.w.oil_saved_ve ~= nil then
|
||||||
vim.wo.virtualedit = vim.w.canola_saved_ve
|
vim.wo.virtualedit = vim.w.oil_saved_ve
|
||||||
vim.w.canola_saved_ve = nil
|
vim.w.oil_saved_ve = nil
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -424,14 +424,14 @@ local function redraw_trash_virtual_text(bufnr)
|
||||||
if not vim.api.nvim_buf_is_valid(bufnr) or not vim.api.nvim_buf_is_loaded(bufnr) then
|
if not vim.api.nvim_buf_is_valid(bufnr) or not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local adapter = util.get_adapter(bufnr, true)
|
local adapter = util.get_adapter(bufnr, true)
|
||||||
if not adapter or adapter.name ~= 'trash' then
|
if not adapter or adapter.name ~= 'trash' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local _, buf_path = util.parse_url(vim.api.nvim_buf_get_name(bufnr))
|
local _, buf_path = util.parse_url(vim.api.nvim_buf_get_name(bufnr))
|
||||||
local os_path = fs.posix_to_os_path(assert(buf_path))
|
local os_path = fs.posix_to_os_path(assert(buf_path))
|
||||||
local ns = vim.api.nvim_create_namespace('CanolaVtext')
|
local ns = vim.api.nvim_create_namespace('OilVtext')
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||||
local column_defs = columns.get_supported_columns(adapter)
|
local column_defs = columns.get_supported_columns(adapter)
|
||||||
for lnum, line in ipairs(vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)) do
|
for lnum, line in ipairs(vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)) do
|
||||||
|
|
@ -439,14 +439,14 @@ local function redraw_trash_virtual_text(bufnr)
|
||||||
local entry = result and result.entry
|
local entry = result and result.entry
|
||||||
if entry then
|
if entry then
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
---@type nil|canola.TrashInfo
|
---@type nil|oil.TrashInfo
|
||||||
local trash_info = meta and meta.trash_info
|
local trash_info = meta and meta.trash_info
|
||||||
if trash_info then
|
if trash_info then
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, 0, {
|
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, 0, {
|
||||||
virt_text = {
|
virt_text = {
|
||||||
{
|
{
|
||||||
'➜ ' .. fs.shorten_path(trash_info.original_path, os_path),
|
'➜ ' .. fs.shorten_path(trash_info.original_path, os_path),
|
||||||
'CanolaTrashSourcePath',
|
'OilTrashSourcePath',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -465,13 +465,13 @@ M.initialize = function(bufnr)
|
||||||
end
|
end
|
||||||
vim.api.nvim_clear_autocmds({
|
vim.api.nvim_clear_autocmds({
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
})
|
})
|
||||||
vim.bo[bufnr].buftype = 'acwrite'
|
vim.bo[bufnr].buftype = 'acwrite'
|
||||||
vim.bo[bufnr].readonly = false
|
vim.bo[bufnr].readonly = false
|
||||||
vim.bo[bufnr].swapfile = false
|
vim.bo[bufnr].swapfile = false
|
||||||
vim.bo[bufnr].syntax = 'canola'
|
vim.bo[bufnr].syntax = 'oil'
|
||||||
vim.bo[bufnr].filetype = 'canola'
|
vim.bo[bufnr].filetype = 'oil'
|
||||||
vim.b[bufnr].EditorConfig_disable = 1
|
vim.b[bufnr].EditorConfig_disable = 1
|
||||||
session[bufnr] = session[bufnr] or {}
|
session[bufnr] = session[bufnr] or {}
|
||||||
for k, v in pairs(config.buf_options) do
|
for k, v in pairs(config.buf_options) do
|
||||||
|
|
@ -480,15 +480,15 @@ M.initialize = function(bufnr)
|
||||||
vim.api.nvim_buf_call(bufnr, M.set_win_options)
|
vim.api.nvim_buf_call(bufnr, M.set_win_options)
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('BufHidden', {
|
vim.api.nvim_create_autocmd('BufHidden', {
|
||||||
desc = 'Delete canola buffers when no longer in use',
|
desc = 'Delete oil buffers when no longer in use',
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
nested = true,
|
nested = true,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- First wait a short time (100ms) for the buffer change to settle
|
-- First wait a short time (100ms) for the buffer change to settle
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
local visible_buffers = get_visible_hidden_buffers()
|
local visible_buffers = get_visible_hidden_buffers()
|
||||||
-- Only delete canola buffers if none of them are visible
|
-- Only delete oil buffers if none of them are visible
|
||||||
if visible_buffers and vim.tbl_isempty(visible_buffers) then
|
if visible_buffers and vim.tbl_isempty(visible_buffers) then
|
||||||
-- Check if cleanup is enabled
|
-- Check if cleanup is enabled
|
||||||
if type(config.cleanup_delay_ms) == 'number' then
|
if type(config.cleanup_delay_ms) == 'number' then
|
||||||
|
|
@ -505,7 +505,7 @@ M.initialize = function(bufnr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd('BufUnload', {
|
vim.api.nvim_create_autocmd('BufUnload', {
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
nested = true,
|
nested = true,
|
||||||
once = true,
|
once = true,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
|
|
@ -518,20 +518,20 @@ M.initialize = function(bufnr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd('BufEnter', {
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local opts = vim.b[args.buf].canola_dirty
|
local opts = vim.b[args.buf].oil_dirty
|
||||||
if opts then
|
if opts then
|
||||||
vim.b[args.buf].canola_dirty = nil
|
vim.b[args.buf].oil_dirty = nil
|
||||||
M.render_buffer_async(args.buf, opts)
|
M.render_buffer_async(args.buf, opts)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
local timer
|
local timer
|
||||||
vim.api.nvim_create_autocmd('InsertEnter', {
|
vim.api.nvim_create_autocmd('InsertEnter', {
|
||||||
desc = 'Constrain canola cursor position',
|
desc = 'Constrain oil cursor position',
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- For some reason the cursor bounces back to its original position,
|
-- For some reason the cursor bounces back to its original position,
|
||||||
|
|
@ -543,21 +543,21 @@ M.initialize = function(bufnr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd('InsertLeave', {
|
vim.api.nvim_create_autocmd('InsertLeave', {
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.w.canola_saved_ve ~= nil then
|
if vim.w.oil_saved_ve ~= nil then
|
||||||
vim.wo.virtualedit = vim.w.canola_saved_ve
|
vim.wo.virtualedit = vim.w.oil_saved_ve
|
||||||
vim.w.canola_saved_ve = nil
|
vim.w.oil_saved_ve = nil
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI', 'ModeChanged' }, {
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI', 'ModeChanged' }, {
|
||||||
desc = 'Update canola preview window',
|
desc = 'Update oil preview window',
|
||||||
group = 'Canola',
|
group = 'Oil',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
if vim.wo.previewwindow then
|
if vim.wo.previewwindow then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -582,14 +582,14 @@ M.initialize = function(bufnr)
|
||||||
if vim.api.nvim_get_current_buf() ~= bufnr then
|
if vim.api.nvim_get_current_buf() ~= bufnr then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
-- Don't update in visual mode. Visual mode implies editing not browsing,
|
-- Don't update in visual mode. Visual mode implies editing not browsing,
|
||||||
-- and updating the preview can cause flicker and stutter.
|
-- and updating the preview can cause flicker and stutter.
|
||||||
if entry and not util.is_visual_mode() then
|
if entry and not util.is_visual_mode() then
|
||||||
local winid = util.get_preview_win()
|
local winid = util.get_preview_win()
|
||||||
if winid then
|
if winid then
|
||||||
if entry.id ~= vim.w[winid].canola_entry_id then
|
if entry.id ~= vim.w[winid].oil_entry_id then
|
||||||
canola.open_preview()
|
oil.open_preview()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -623,8 +623,8 @@ M.initialize = function(bufnr)
|
||||||
fs_event:stop()
|
fs_event:stop()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local mutator = require('canola.mutator')
|
local mutator = require('oil.mutator')
|
||||||
if err or vim.bo[bufnr].modified or vim.b[bufnr].canola_dirty or mutator.is_mutating() then
|
if err or vim.bo[bufnr].modified or vim.b[bufnr].oil_dirty or mutator.is_mutating() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -637,7 +637,7 @@ M.initialize = function(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If it is not currently visible, mark it as dirty
|
-- If it is not currently visible, mark it as dirty
|
||||||
vim.b[bufnr].canola_dirty = {}
|
vim.b[bufnr].oil_dirty = {}
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
session[bufnr].fs_event = fs_event
|
session[bufnr].fs_event = fs_event
|
||||||
|
|
@ -648,7 +648,7 @@ M.initialize = function(bufnr)
|
||||||
local debounce_timer = assert(uv.new_timer())
|
local debounce_timer = assert(uv.new_timer())
|
||||||
local pending = false
|
local pending = false
|
||||||
vim.api.nvim_create_autocmd('TextChanged', {
|
vim.api.nvim_create_autocmd('TextChanged', {
|
||||||
desc = 'Update canola virtual text of original path',
|
desc = 'Update oil virtual text of original path',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- Respond immediately to prevent flickering, the set the timer for a "cooldown period"
|
-- Respond immediately to prevent flickering, the set the timer for a "cooldown period"
|
||||||
|
|
@ -674,23 +674,23 @@ M.initialize = function(bufnr)
|
||||||
M.render_buffer_async(bufnr, {}, function(err)
|
M.render_buffer_async(bufnr, {}, function(err)
|
||||||
if err then
|
if err then
|
||||||
vim.notify(
|
vim.notify(
|
||||||
string.format('Error rendering canola buffer %s: %s', vim.api.nvim_buf_get_name(bufnr), err),
|
string.format('Error rendering oil buffer %s: %s', vim.api.nvim_buf_get_name(bufnr), err),
|
||||||
vim.log.levels.ERROR
|
vim.log.levels.ERROR
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
vim.b[bufnr].canola_ready = true
|
vim.b[bufnr].oil_ready = true
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaEnter', modeline = false, data = { buf = bufnr } }
|
{ pattern = 'OilEnter', modeline = false, data = { buf = bufnr } }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
keymap_util.set_keymaps(config.keymaps, bufnr)
|
keymap_util.set_keymaps(config.keymaps, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param num_entries integer
|
---@param num_entries integer
|
||||||
---@return fun(a: canola.InternalEntry, b: canola.InternalEntry): boolean
|
---@return fun(a: oil.InternalEntry, b: oil.InternalEntry): boolean
|
||||||
local function get_sort_function(adapter, num_entries)
|
local function get_sort_function(adapter, num_entries)
|
||||||
local idx_funs = {}
|
local idx_funs = {}
|
||||||
local sort_config = config.view_options.sort
|
local sort_config = config.view_options.sort
|
||||||
|
|
@ -767,7 +767,7 @@ local function render_buffer(bufnr, opts)
|
||||||
local entry_list = vim.tbl_values(entries)
|
local entry_list = vim.tbl_values(entries)
|
||||||
|
|
||||||
-- Only sort the entries once we have them all
|
-- Only sort the entries once we have them all
|
||||||
if not vim.b[bufnr].canola_rendering then
|
if not vim.b[bufnr].oil_rendering then
|
||||||
table.sort(entry_list, get_sort_function(adapter, #entry_list))
|
table.sort(entry_list, get_sort_function(adapter, #entry_list))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -882,13 +882,13 @@ local function get_link_text(name, meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
---@param entry canola.InternalEntry
|
---@param entry oil.InternalEntry
|
||||||
---@param column_defs table[]
|
---@param column_defs table[]
|
||||||
---@param col_width integer[]
|
---@param col_width integer[]
|
||||||
---@param adapter canola.Adapter
|
---@param adapter oil.Adapter
|
||||||
---@param is_hidden boolean
|
---@param is_hidden boolean
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return canola.TextChunk[]
|
---@return oil.TextChunk[]
|
||||||
M.format_entry_cols = function(entry, column_defs, col_width, adapter, is_hidden, bufnr)
|
M.format_entry_cols = function(entry, column_defs, col_width, adapter, is_hidden, bufnr)
|
||||||
local name = entry[FIELD_NAME]
|
local name = entry[FIELD_NAME]
|
||||||
local meta = entry[FIELD_META]
|
local meta = entry[FIELD_META]
|
||||||
|
|
@ -963,9 +963,9 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter, is_hidden
|
||||||
end
|
end
|
||||||
|
|
||||||
if entry_type == 'directory' then
|
if entry_type == 'directory' then
|
||||||
table.insert(cols, { name .. '/', 'CanolaDir' .. hl_suffix })
|
table.insert(cols, { name .. '/', 'OilDir' .. hl_suffix })
|
||||||
elseif entry_type == 'socket' then
|
elseif entry_type == 'socket' then
|
||||||
table.insert(cols, { name, 'CanolaSocket' .. hl_suffix })
|
table.insert(cols, { name, 'OilSocket' .. hl_suffix })
|
||||||
elseif entry_type == 'link' then
|
elseif entry_type == 'link' then
|
||||||
if not link_name then
|
if not link_name then
|
||||||
link_name, link_target = get_link_text(name, meta)
|
link_name, link_target = get_link_text(name, meta)
|
||||||
|
|
@ -973,23 +973,23 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter, is_hidden
|
||||||
local is_orphan = not (meta and meta.link_stat)
|
local is_orphan = not (meta and meta.link_stat)
|
||||||
if not link_name_hl then
|
if not link_name_hl then
|
||||||
if highlight_as_executable then
|
if highlight_as_executable then
|
||||||
link_name_hl = 'CanolaExecutable' .. hl_suffix
|
link_name_hl = 'OilExecutable' .. hl_suffix
|
||||||
else
|
else
|
||||||
link_name_hl = (is_orphan and 'CanolaOrphanLink' or 'CanolaLink') .. hl_suffix
|
link_name_hl = (is_orphan and 'OilOrphanLink' or 'OilLink') .. hl_suffix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(cols, { link_name, link_name_hl })
|
table.insert(cols, { link_name, link_name_hl })
|
||||||
|
|
||||||
if link_target then
|
if link_target then
|
||||||
if not link_target_hl then
|
if not link_target_hl then
|
||||||
link_target_hl = (is_orphan and 'CanolaOrphanLinkTarget' or 'CanolaLinkTarget') .. hl_suffix
|
link_target_hl = (is_orphan and 'OilOrphanLinkTarget' or 'OilLinkTarget') .. hl_suffix
|
||||||
end
|
end
|
||||||
table.insert(cols, { link_target, link_target_hl })
|
table.insert(cols, { link_target, link_target_hl })
|
||||||
end
|
end
|
||||||
elseif highlight_as_executable then
|
elseif highlight_as_executable then
|
||||||
table.insert(cols, { name, 'CanolaExecutable' .. hl_suffix })
|
table.insert(cols, { name, 'OilExecutable' .. hl_suffix })
|
||||||
else
|
else
|
||||||
table.insert(cols, { name, 'CanolaFile' .. hl_suffix })
|
table.insert(cols, { name, 'OilFile' .. hl_suffix })
|
||||||
end
|
end
|
||||||
|
|
||||||
return cols
|
return cols
|
||||||
|
|
@ -1022,7 +1022,7 @@ M.render_buffer_async = function(bufnr, opts, caller_callback)
|
||||||
if not err then
|
if not err then
|
||||||
vim.api.nvim_exec_autocmds(
|
vim.api.nvim_exec_autocmds(
|
||||||
'User',
|
'User',
|
||||||
{ pattern = 'CanolaReadPost', modeline = false, data = { buf = bufnr } }
|
{ pattern = 'OilReadPost', modeline = false, data = { buf = bufnr } }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if caller_callback then
|
if caller_callback then
|
||||||
|
|
@ -1039,7 +1039,7 @@ M.render_buffer_async = function(bufnr, opts, caller_callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If we're already rendering, queue up another rerender after it's complete
|
-- If we're already rendering, queue up another rerender after it's complete
|
||||||
if vim.b[bufnr].canola_rendering then
|
if vim.b[bufnr].oil_rendering then
|
||||||
if not pending_renders[bufnr] then
|
if not pending_renders[bufnr] then
|
||||||
pending_renders[bufnr] = { callback }
|
pending_renders[bufnr] = { callback }
|
||||||
elseif callback then
|
elseif callback then
|
||||||
|
|
@ -1049,13 +1049,13 @@ M.render_buffer_async = function(bufnr, opts, caller_callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
vim.b[bufnr].canola_rendering = true
|
vim.b[bufnr].oil_rendering = true
|
||||||
local _, dir = util.parse_url(bufname)
|
local _, dir = util.parse_url(bufname)
|
||||||
-- Undo should not return to a blank buffer
|
-- Undo should not return to a blank buffer
|
||||||
-- Method taken from :h clear-undo
|
-- Method taken from :h clear-undo
|
||||||
vim.bo[bufnr].undolevels = -1
|
vim.bo[bufnr].undolevels = -1
|
||||||
local handle_error = vim.schedule_wrap(function(message)
|
local handle_error = vim.schedule_wrap(function(message)
|
||||||
vim.b[bufnr].canola_rendering = false
|
vim.b[bufnr].oil_rendering = false
|
||||||
vim.bo[bufnr].undolevels = vim.api.nvim_get_option_value('undolevels', { scope = 'global' })
|
vim.bo[bufnr].undolevels = vim.api.nvim_get_option_value('undolevels', { scope = 'global' })
|
||||||
util.render_text(bufnr, { 'Error: ' .. message })
|
util.render_text(bufnr, { 'Error: ' .. message })
|
||||||
if pending_renders[bufnr] then
|
if pending_renders[bufnr] then
|
||||||
|
|
@ -1071,12 +1071,12 @@ M.render_buffer_async = function(bufnr, opts, caller_callback)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if not dir then
|
if not dir then
|
||||||
handle_error(string.format("Could not parse canola url '%s'", bufname))
|
handle_error(string.format("Could not parse oil url '%s'", bufname))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local adapter = util.get_adapter(bufnr, true)
|
local adapter = util.get_adapter(bufnr, true)
|
||||||
if not adapter then
|
if not adapter then
|
||||||
handle_error(string.format("[canola] no adapter for buffer '%s'", bufname))
|
handle_error(string.format("[oil] no adapter for buffer '%s'", bufname))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local start_ms = uv.hrtime() / 1e6
|
local start_ms = uv.hrtime() / 1e6
|
||||||
|
|
@ -1090,7 +1090,7 @@ M.render_buffer_async = function(bufnr, opts, caller_callback)
|
||||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.b[bufnr].canola_rendering = false
|
vim.b[bufnr].oil_rendering = false
|
||||||
loading.set_loading(bufnr, false)
|
loading.set_loading(bufnr, false)
|
||||||
render_buffer(bufnr, { jump = true })
|
render_buffer(bufnr, { jump = true })
|
||||||
M.set_last_cursor(bufname, nil)
|
M.set_last_cursor(bufname, nil)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.is_win_supported = function(winid, bufnr)
|
M.is_win_supported = function(winid, bufnr)
|
||||||
return vim.bo[bufnr].filetype == 'canola'
|
return vim.bo[bufnr].filetype == 'oil'
|
||||||
end
|
end
|
||||||
|
|
||||||
M.save_win = function(winid)
|
M.save_win = function(winid)
|
||||||
|
|
@ -11,7 +11,7 @@ M.save_win = function(winid)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.load_win = function(winid, config)
|
M.load_win = function(winid, config)
|
||||||
require('canola').open(config.bufname)
|
require('oil').open(config.bufname)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
@ -4,8 +4,8 @@ vim.opt.runtimepath:prepend('.')
|
||||||
local bm = require('benchmark')
|
local bm = require('benchmark')
|
||||||
bm.sandbox()
|
bm.sandbox()
|
||||||
|
|
||||||
---@module 'canola'
|
---@module 'oil'
|
||||||
---@type canola.SetupOpts
|
---@type oil.SetupOpts
|
||||||
local setup_opts = {
|
local setup_opts = {
|
||||||
-- columns = { "icon", "permissions", "size", "mtime" },
|
-- columns = { "icon", "permissions", "size", "mtime" },
|
||||||
}
|
}
|
||||||
|
|
@ -21,36 +21,36 @@ require('benchmark.files').create_files(TEST_DIR, 'file %d.txt', DIR_SIZE)
|
||||||
|
|
||||||
-- selene: allow(global_usage)
|
-- selene: allow(global_usage)
|
||||||
function _G.jit_profile()
|
function _G.jit_profile()
|
||||||
require('canola').setup(setup_opts)
|
require('oil').setup(setup_opts)
|
||||||
local finish = bm.jit_profile({ filename = TEST_DIR .. '/profile.txt' })
|
local finish = bm.jit_profile({ filename = TEST_DIR .. '/profile.txt' })
|
||||||
bm.wait_for_user_event('CanolaEnter', function()
|
bm.wait_for_user_event('OilEnter', function()
|
||||||
finish()
|
finish()
|
||||||
end)
|
end)
|
||||||
require('canola').open(TEST_DIR)
|
require('oil').open(TEST_DIR)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- selene: allow(global_usage)
|
-- selene: allow(global_usage)
|
||||||
function _G.flame_profile()
|
function _G.flame_profile()
|
||||||
local start, stop = bm.flame_profile({
|
local start, stop = bm.flame_profile({
|
||||||
pattern = 'canola*',
|
pattern = 'oil*',
|
||||||
filename = 'profile.json',
|
filename = 'profile.json',
|
||||||
})
|
})
|
||||||
require('canola').setup(setup_opts)
|
require('oil').setup(setup_opts)
|
||||||
start()
|
start()
|
||||||
bm.wait_for_user_event('CanolaEnter', function()
|
bm.wait_for_user_event('OilEnter', function()
|
||||||
stop(function()
|
stop(function()
|
||||||
vim.cmd.qall({ mods = { silent = true } })
|
vim.cmd.qall({ mods = { silent = true } })
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
require('canola').open(TEST_DIR)
|
require('oil').open(TEST_DIR)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- selene: allow(global_usage)
|
-- selene: allow(global_usage)
|
||||||
function _G.benchmark()
|
function _G.benchmark()
|
||||||
require('canola').setup(setup_opts)
|
require('oil').setup(setup_opts)
|
||||||
bm.run({ title = 'canola.nvim', iterations = ITERATIONS, warm_up = WARM_UP }, function(callback)
|
bm.run({ title = 'oil.nvim', iterations = ITERATIONS, warm_up = WARM_UP }, function(callback)
|
||||||
bm.wait_for_user_event('CanolaEnter', callback)
|
bm.wait_for_user_event('OilEnter', callback)
|
||||||
require('canola').open(TEST_DIR)
|
require('oil').open(TEST_DIR)
|
||||||
end, function(times)
|
end, function(times)
|
||||||
local avg = bm.avg(times, { trim_outliers = OUTLIERS })
|
local avg = bm.avg(times, { trim_outliers = OUTLIERS })
|
||||||
local std_dev = bm.std_dev(times, { trim_outliers = OUTLIERS })
|
local std_dev = bm.std_dev(times, { trim_outliers = OUTLIERS })
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
if vim.g.canola ~= nil then
|
|
||||||
require('canola').setup()
|
|
||||||
end
|
|
||||||
1
plugin/oil.lua
Normal file
1
plugin/oil.lua
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local canola = require('canola')
|
local fs = require('oil.fs')
|
||||||
local fs = require('canola.fs')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
describe('Alternate buffer', function()
|
describe('Alternate buffer', function()
|
||||||
|
|
@ -9,27 +9,27 @@ describe('Alternate buffer', function()
|
||||||
|
|
||||||
it('sets previous buffer as alternate', function()
|
it('sets previous buffer as alternate', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets previous buffer as alternate when editing url file', function()
|
it('sets previous buffer as alternate when editing url file', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
local readme = fs.join(vim.fn.getcwd(), 'README.md')
|
local readme = fs.join(vim.fn.getcwd(), 'README.md')
|
||||||
vim.cmd.edit({ args = { 'canola://' .. fs.os_to_posix_path(readme) } })
|
vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(readme) } })
|
||||||
test_util.wait_for_autocmd('BufEnter')
|
test_util.wait_for_autocmd('BufEnter')
|
||||||
assert.equals(readme, vim.api.nvim_buf_get_name(0))
|
assert.equals(readme, vim.api.nvim_buf_get_name(0))
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets previous buffer as alternate when editing canola://', function()
|
it('sets previous buffer as alternate when editing oil://', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
vim.cmd.edit({ args = { 'canola://' .. fs.os_to_posix_path(vim.fn.getcwd()) } })
|
vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(vim.fn.getcwd()) } })
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
@ -37,8 +37,8 @@ describe('Alternate buffer', function()
|
||||||
it('preserves alternate buffer if editing the same file', function()
|
it('preserves alternate buffer if editing the same file', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
@ -46,71 +46,71 @@ describe('Alternate buffer', function()
|
||||||
it('preserves alternate buffer if discarding changes', function()
|
it('preserves alternate buffer if discarding changes', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.equals('bar', vim.fn.expand('%'))
|
assert.equals('bar', vim.fn.expand('%'))
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets previous buffer as alternate after multi-dir hops', function()
|
it('sets previous buffer as alternate after multi-dir hops', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets previous buffer as alternate when inside canola buffer', function()
|
it('sets previous buffer as alternate when inside oil buffer', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
canola.open()
|
oil.open()
|
||||||
assert.equals('bar', vim.fn.expand('#'))
|
assert.equals('bar', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('preserves alternate when traversing canola dirs', function()
|
it('preserves alternate when traversing oil dirs', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
vim.wait(1000, function()
|
vim.wait(1000, function()
|
||||||
return canola.get_cursor_entry()
|
return oil.get_cursor_entry()
|
||||||
end, 10)
|
end, 10)
|
||||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||||
canola.select()
|
oil.select()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('preserves alternate when opening preview', function()
|
it('preserves alternate when opening preview', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
vim.wait(1000, function()
|
vim.wait(1000, function()
|
||||||
return canola.get_cursor_entry()
|
return oil.get_cursor_entry()
|
||||||
end, 10)
|
end, 10)
|
||||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||||
canola.open_preview()
|
oil.open_preview()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('floating window', function()
|
describe('floating window', function()
|
||||||
it('sets previous buffer as alternate', function()
|
it('sets previous buffer as alternate', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open_float()
|
oil.open_float()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.api.nvim_win_close(0, true)
|
vim.api.nvim_win_close(0, true)
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
|
|
@ -119,8 +119,8 @@ describe('Alternate buffer', function()
|
||||||
it('preserves alternate buffer if editing the same file', function()
|
it('preserves alternate buffer if editing the same file', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
canola.open_float()
|
oil.open_float()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
vim.api.nvim_win_close(0, true)
|
vim.api.nvim_win_close(0, true)
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
|
|
@ -129,19 +129,19 @@ describe('Alternate buffer', function()
|
||||||
it('preserves alternate buffer if discarding changes', function()
|
it('preserves alternate buffer if discarding changes', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
vim.cmd.edit({ args = { 'bar' } })
|
vim.cmd.edit({ args = { 'bar' } })
|
||||||
canola.open_float()
|
oil.open_float()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('preserves alternate when traversing to a new file', function()
|
it('preserves alternate when traversing to a new file', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
canola.open_float()
|
oil.open_float()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
test_util.feedkeys({ '/LICENSE<CR>' }, 10)
|
test_util.feedkeys({ '/LICENSE<CR>' }, 10)
|
||||||
canola.select()
|
oil.select()
|
||||||
test_util.wait_for_autocmd('BufEnter')
|
test_util.wait_for_autocmd('BufEnter')
|
||||||
assert.equals('LICENSE', vim.fn.expand('%:.'))
|
assert.equals('LICENSE', vim.fn.expand('%:.'))
|
||||||
assert.equals('foo', vim.fn.expand('#'))
|
assert.equals('foo', vim.fn.expand('#'))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
describe('close', function()
|
describe('close', function()
|
||||||
|
|
@ -10,35 +10,35 @@ describe('close', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not close buffer from visual mode', function()
|
it('does not close buffer from visual mode', function()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
test_util.feedkeys({ 'V' }, 10)
|
test_util.feedkeys({ 'V' }, 10)
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
test_util.feedkeys({ '<Esc>' }, 10)
|
test_util.feedkeys({ '<Esc>' }, 10)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not close buffer from operator-pending mode', function()
|
it('does not close buffer from operator-pending mode', function()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
vim.api.nvim_feedkeys('d', 'n', false)
|
vim.api.nvim_feedkeys('d', 'n', false)
|
||||||
vim.wait(20)
|
vim.wait(20)
|
||||||
local mode = vim.api.nvim_get_mode().mode
|
local mode = vim.api.nvim_get_mode().mode
|
||||||
if mode:match('^no') then
|
if mode:match('^no') then
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
end
|
end
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, true, true), 'n', false)
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, true, true), 'n', false)
|
||||||
vim.wait(20)
|
vim.wait(20)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('closes buffer from normal mode', function()
|
it('closes buffer from normal mode', function()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.not_equals('canola', vim.bo.filetype)
|
assert.not_equals('oil', vim.bo.filetype)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,15 @@
|
||||||
local config = require('canola.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.canola = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('falls back to vim.g.canola when setup() is called with no args', function()
|
|
||||||
vim.g.canola = { 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.canola is set', function()
|
|
||||||
vim.g.canola = 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.canola', function()
|
it('applies explicit opts', function()
|
||||||
vim.g.canola = { 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)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local TmpDir = require('spec.tmpdir')
|
local TmpDir = require('spec.tmpdir')
|
||||||
local files = require('canola.adapters.files')
|
local files = require('oil.adapters.files')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
describe('files adapter', function()
|
describe('files adapter', function()
|
||||||
|
|
@ -26,7 +26,7 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Creates files', function()
|
it('Creates files', function()
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt',
|
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
type = 'create',
|
type = 'create',
|
||||||
})
|
})
|
||||||
|
|
@ -38,7 +38,7 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Creates directories', function()
|
it('Creates directories', function()
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a',
|
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
type = 'create',
|
type = 'create',
|
||||||
})
|
})
|
||||||
|
|
@ -50,7 +50,7 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Deletes files', function()
|
it('Deletes files', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
local url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
url = url,
|
url = url,
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
|
|
@ -62,7 +62,7 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Deletes directories', function()
|
it('Deletes directories', function()
|
||||||
tmpdir:create({ 'a/' })
|
tmpdir:create({ 'a/' })
|
||||||
local url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
url = url,
|
url = url,
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
|
|
@ -74,8 +74,8 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Moves files', function()
|
it('Moves files', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
src_url = src_url,
|
src_url = src_url,
|
||||||
dest_url = dest_url,
|
dest_url = dest_url,
|
||||||
|
|
@ -90,8 +90,8 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Moves directories', function()
|
it('Moves directories', function()
|
||||||
tmpdir:create({ 'a/a.txt' })
|
tmpdir:create({ 'a/a.txt' })
|
||||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
src_url = src_url,
|
src_url = src_url,
|
||||||
dest_url = dest_url,
|
dest_url = dest_url,
|
||||||
|
|
@ -107,8 +107,8 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Copies files', function()
|
it('Copies files', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
src_url = src_url,
|
src_url = src_url,
|
||||||
dest_url = dest_url,
|
dest_url = dest_url,
|
||||||
|
|
@ -124,8 +124,8 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('Recursively copies directories', function()
|
it('Recursively copies directories', function()
|
||||||
tmpdir:create({ 'a/a.txt' })
|
tmpdir:create({ 'a/a.txt' })
|
||||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||||
local err = test_util.await(files.perform_action, 2, {
|
local err = test_util.await(files.perform_action, 2, {
|
||||||
src_url = src_url,
|
src_url = src_url,
|
||||||
dest_url = dest_url,
|
dest_url = dest_url,
|
||||||
|
|
@ -141,22 +141,22 @@ describe('files adapter', function()
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Editing a new canola://path/ creates an canola buffer', function()
|
it('Editing a new oil://path/ creates an oil buffer', function()
|
||||||
local tmpdir_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||||
vim.cmd.edit({ args = { tmpdir_url } })
|
vim.cmd.edit({ args = { tmpdir_url } })
|
||||||
test_util.wait_canola_ready()
|
test_util.wait_oil_ready()
|
||||||
local new_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'newdir'
|
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'newdir'
|
||||||
vim.cmd.edit({ args = { new_url } })
|
vim.cmd.edit({ args = { new_url } })
|
||||||
test_util.wait_canola_ready()
|
test_util.wait_oil_ready()
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
assert.equals(new_url .. '/', vim.api.nvim_buf_get_name(0))
|
assert.equals(new_url .. '/', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Editing a new canola://file.rb creates a normal buffer', function()
|
it('Editing a new oil://file.rb creates a normal buffer', function()
|
||||||
local tmpdir_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||||
vim.cmd.edit({ args = { tmpdir_url } })
|
vim.cmd.edit({ args = { tmpdir_url } })
|
||||||
test_util.wait_for_autocmd('BufReadPost')
|
test_util.wait_for_autocmd('BufReadPost')
|
||||||
local new_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb'
|
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb'
|
||||||
vim.cmd.edit({ args = { new_url } })
|
vim.cmd.edit({ args = { new_url } })
|
||||||
test_util.wait_for_autocmd('BufReadPost')
|
test_util.wait_for_autocmd('BufReadPost')
|
||||||
assert.equals('ruby', vim.bo.filetype)
|
assert.equals('ruby', vim.bo.filetype)
|
||||||
|
|
@ -165,9 +165,9 @@ describe('files adapter', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('cleanup_buffers_on_delete', function()
|
describe('cleanup_buffers_on_delete', function()
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local config = require('canola.config')
|
local config = require('oil.config')
|
||||||
local mutator = require('canola.mutator')
|
local mutator = require('oil.mutator')
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
config.cleanup_buffers_on_delete = true
|
config.cleanup_buffers_on_delete = true
|
||||||
|
|
@ -179,12 +179,12 @@ describe('files adapter', function()
|
||||||
|
|
||||||
it('wipes the buffer for a deleted file', function()
|
it('wipes the buffer for a deleted file', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
local dirurl = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||||
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||||
cache.create_and_store_entry(dirurl, 'a.txt', 'file')
|
cache.create_and_store_entry(dirurl, 'a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { filepath } })
|
vim.cmd.edit({ args = { filepath } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local url = 'canola://' .. filepath
|
local url = 'oil://' .. filepath
|
||||||
test_util.await(mutator.process_actions, 2, {
|
test_util.await(mutator.process_actions, 2, {
|
||||||
{ type = 'delete', url = url, entry_type = 'file' },
|
{ type = 'delete', url = url, entry_type = 'file' },
|
||||||
})
|
})
|
||||||
|
|
@ -194,12 +194,12 @@ describe('files adapter', function()
|
||||||
it('does not wipe the buffer when disabled', function()
|
it('does not wipe the buffer when disabled', function()
|
||||||
config.cleanup_buffers_on_delete = false
|
config.cleanup_buffers_on_delete = false
|
||||||
tmpdir:create({ 'b.txt' })
|
tmpdir:create({ 'b.txt' })
|
||||||
local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
local dirurl = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||||
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||||
cache.create_and_store_entry(dirurl, 'b.txt', 'file')
|
cache.create_and_store_entry(dirurl, 'b.txt', 'file')
|
||||||
vim.cmd.edit({ args = { filepath } })
|
vim.cmd.edit({ args = { filepath } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local url = 'canola://' .. filepath
|
local url = 'oil://' .. filepath
|
||||||
test_util.await(mutator.process_actions, 2, {
|
test_util.await(mutator.process_actions, 2, {
|
||||||
{ type = 'delete', url = url, entry_type = 'file' },
|
{ type = 'delete', url = url, entry_type = 'file' },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
-- Manual test for minimizing/restoring progress window
|
-- Manual test for minimizing/restoring progress window
|
||||||
local Progress = require('canola.mutator.progress')
|
local Progress = require('oil.mutator.progress')
|
||||||
|
|
||||||
local progress = Progress.new()
|
local progress = Progress.new()
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ for i = 1, 10, 1 do
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
progress:set_action({
|
progress:set_action({
|
||||||
type = 'create',
|
type = 'create',
|
||||||
url = string.format('canola:///tmp/test_%d.txt', i),
|
url = string.format('oil:///tmp/test_%d.txt', i),
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}, i, 10)
|
}, i, 10)
|
||||||
end, (i - 1) * 1000)
|
end, (i - 1) * 1000)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
describe('update_moved_buffers', function()
|
describe('update_moved_buffers', function()
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
|
@ -8,51 +8,51 @@ describe('update_moved_buffers', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames moved buffers', function()
|
it('Renames moved buffers', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar.txt' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/bar.txt' } })
|
||||||
util.update_moved_buffers('file', 'canola-test:///foo/bar.txt', 'canola-test:///foo/baz.txt')
|
util.update_moved_buffers('file', 'oil-test:///foo/bar.txt', 'oil-test:///foo/baz.txt')
|
||||||
assert.equals('canola-test:///foo/baz.txt', vim.api.nvim_buf_get_name(0))
|
assert.equals('oil-test:///foo/baz.txt', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames moved buffers when they are normal files', function()
|
it('Renames moved buffers when they are normal files', function()
|
||||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'canola', 'test')
|
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'oil', 'test')
|
||||||
local testfile = fs.join(tmpdir, 'foo.txt')
|
local testfile = fs.join(tmpdir, 'foo.txt')
|
||||||
vim.cmd.edit({ args = { testfile } })
|
vim.cmd.edit({ args = { testfile } })
|
||||||
util.update_moved_buffers(
|
util.update_moved_buffers(
|
||||||
'file',
|
'file',
|
||||||
'canola://' .. fs.os_to_posix_path(testfile),
|
'oil://' .. fs.os_to_posix_path(testfile),
|
||||||
'canola://' .. fs.os_to_posix_path(fs.join(tmpdir, 'bar.txt'))
|
'oil://' .. fs.os_to_posix_path(fs.join(tmpdir, 'bar.txt'))
|
||||||
)
|
)
|
||||||
assert.equals(fs.join(tmpdir, 'bar.txt'), vim.api.nvim_buf_get_name(0))
|
assert.equals(fs.join(tmpdir, 'bar.txt'), vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames directories', function()
|
it('Renames directories', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///bar/')
|
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///bar/')
|
||||||
assert.equals('canola-test:///bar/', vim.api.nvim_buf_get_name(0))
|
assert.equals('oil-test:///bar/', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames subdirectories', function()
|
it('Renames subdirectories', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/bar/' } })
|
||||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///baz/')
|
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///baz/')
|
||||||
assert.equals('canola-test:///baz/bar/', vim.api.nvim_buf_get_name(0))
|
assert.equals('oil-test:///baz/bar/', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames subfiles', function()
|
it('Renames subfiles', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar.txt' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/bar.txt' } })
|
||||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///baz/')
|
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///baz/')
|
||||||
assert.equals('canola-test:///baz/bar.txt', vim.api.nvim_buf_get_name(0))
|
assert.equals('oil-test:///baz/bar.txt', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Renames subfiles when they are normal files', function()
|
it('Renames subfiles when they are normal files', function()
|
||||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'canola', 'test')
|
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'oil', 'test')
|
||||||
local foo = fs.join(tmpdir, 'foo')
|
local foo = fs.join(tmpdir, 'foo')
|
||||||
local bar = fs.join(tmpdir, 'bar')
|
local bar = fs.join(tmpdir, 'bar')
|
||||||
local testfile = fs.join(foo, 'foo.txt')
|
local testfile = fs.join(foo, 'foo.txt')
|
||||||
vim.cmd.edit({ args = { testfile } })
|
vim.cmd.edit({ args = { testfile } })
|
||||||
util.update_moved_buffers(
|
util.update_moved_buffers(
|
||||||
'directory',
|
'directory',
|
||||||
'canola://' .. fs.os_to_posix_path(foo),
|
'oil://' .. fs.os_to_posix_path(foo),
|
||||||
'canola://' .. fs.os_to_posix_path(bar)
|
'oil://' .. fs.os_to_posix_path(bar)
|
||||||
)
|
)
|
||||||
assert.equals(fs.join(bar, 'foo.txt'), vim.api.nvim_buf_get_name(0))
|
assert.equals(fs.join(bar, 'foo.txt'), vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local mutator = require('canola.mutator')
|
local mutator = require('oil.mutator')
|
||||||
local test_adapter = require('canola.adapters.test')
|
local test_adapter = require('oil.adapters.test')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
local FIELD_ID = constants.FIELD_ID
|
local FIELD_ID = constants.FIELD_ID
|
||||||
|
|
@ -15,7 +15,7 @@ describe('mutator', function()
|
||||||
|
|
||||||
describe('build actions', function()
|
describe('build actions', function()
|
||||||
it('empty diffs produce no actions', function()
|
it('empty diffs produce no actions', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local actions = mutator.create_actions_from_diffs({
|
local actions = mutator.create_actions_from_diffs({
|
||||||
[bufnr] = {},
|
[bufnr] = {},
|
||||||
|
|
@ -24,7 +24,7 @@ describe('mutator', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('constructs CREATE actions', function()
|
it('constructs CREATE actions', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'new', name = 'a.txt', entry_type = 'file' },
|
{ type = 'new', name = 'a.txt', entry_type = 'file' },
|
||||||
|
|
@ -36,14 +36,14 @@ describe('mutator', function()
|
||||||
{
|
{
|
||||||
type = 'create',
|
type = 'create',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
url = 'canola-test:///foo/a.txt',
|
url = 'oil-test:///foo/a.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('constructs DELETE actions', function()
|
it('constructs DELETE actions', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||||
|
|
@ -55,14 +55,14 @@ describe('mutator', function()
|
||||||
{
|
{
|
||||||
type = 'delete',
|
type = 'delete',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
url = 'canola-test:///foo/a.txt',
|
url = 'oil-test:///foo/a.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('constructs COPY actions', function()
|
it('constructs COPY actions', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'new', name = 'b.txt', entry_type = 'file', id = file[FIELD_ID] },
|
{ type = 'new', name = 'b.txt', entry_type = 'file', id = file[FIELD_ID] },
|
||||||
|
|
@ -74,15 +74,15 @@ describe('mutator', function()
|
||||||
{
|
{
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = 'canola-test:///foo/a.txt',
|
src_url = 'oil-test:///foo/a.txt',
|
||||||
dest_url = 'canola-test:///foo/b.txt',
|
dest_url = 'oil-test:///foo/b.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('constructs MOVE actions', function()
|
it('constructs MOVE actions', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||||
|
|
@ -95,15 +95,15 @@ describe('mutator', function()
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = 'canola-test:///foo/a.txt',
|
src_url = 'oil-test:///foo/a.txt',
|
||||||
dest_url = 'canola-test:///foo/b.txt',
|
dest_url = 'oil-test:///foo/b.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('correctly orders MOVE + CREATE', function()
|
it('correctly orders MOVE + CREATE', function()
|
||||||
local file = test_adapter.test_set('/a.txt', 'file')
|
local file = test_adapter.test_set('/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||||
|
|
@ -117,13 +117,13 @@ describe('mutator', function()
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = 'canola-test:///a.txt',
|
src_url = 'oil-test:///a.txt',
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = 'create',
|
type = 'create',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
url = 'canola-test:///a.txt',
|
url = 'oil-test:///a.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
@ -131,7 +131,7 @@ describe('mutator', function()
|
||||||
it('resolves MOVE loops', function()
|
it('resolves MOVE loops', function()
|
||||||
local afile = test_adapter.test_set('/a.txt', 'file')
|
local afile = test_adapter.test_set('/a.txt', 'file')
|
||||||
local bfile = test_adapter.test_set('/b.txt', 'file')
|
local bfile = test_adapter.test_set('/b.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diffs = {
|
local diffs = {
|
||||||
{ type = 'delete', name = 'a.txt', id = afile[FIELD_ID] },
|
{ type = 'delete', name = 'a.txt', id = afile[FIELD_ID] },
|
||||||
|
|
@ -143,25 +143,25 @@ describe('mutator', function()
|
||||||
local actions = mutator.create_actions_from_diffs({
|
local actions = mutator.create_actions_from_diffs({
|
||||||
[bufnr] = diffs,
|
[bufnr] = diffs,
|
||||||
})
|
})
|
||||||
local tmp_url = 'canola-test:///a.txt__canola_tmp_510852'
|
local tmp_url = 'oil-test:///a.txt__oil_tmp_510852'
|
||||||
assert.are.same({
|
assert.are.same({
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = 'canola-test:///a.txt',
|
src_url = 'oil-test:///a.txt',
|
||||||
dest_url = tmp_url,
|
dest_url = tmp_url,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = 'canola-test:///b.txt',
|
src_url = 'oil-test:///b.txt',
|
||||||
dest_url = 'canola-test:///a.txt',
|
dest_url = 'oil-test:///a.txt',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
src_url = tmp_url,
|
src_url = tmp_url,
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
},
|
},
|
||||||
}, actions)
|
}, actions)
|
||||||
end)
|
end)
|
||||||
|
|
@ -171,11 +171,11 @@ describe('mutator', function()
|
||||||
it('Creates files inside dir before move', function()
|
it('Creates files inside dir before move', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///b',
|
dest_url = 'oil-test:///b',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
local create = { type = 'create', url = 'canola-test:///a/hi.txt', entry_type = 'file' }
|
local create = { type = 'create', url = 'oil-test:///a/hi.txt', entry_type = 'file' }
|
||||||
local actions = { move, create }
|
local actions = { move, create }
|
||||||
local ordered_actions = mutator.enforce_action_order(actions)
|
local ordered_actions = mutator.enforce_action_order(actions)
|
||||||
assert.are.same({ create, move }, ordered_actions)
|
assert.are.same({ create, move }, ordered_actions)
|
||||||
|
|
@ -184,11 +184,11 @@ describe('mutator', function()
|
||||||
it('Moves file out of parent before deleting parent', function()
|
it('Moves file out of parent before deleting parent', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a/b.txt',
|
src_url = 'oil-test:///a/b.txt',
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}
|
}
|
||||||
local delete = { type = 'delete', url = 'canola-test:///a', entry_type = 'directory' }
|
local delete = { type = 'delete', url = 'oil-test:///a', entry_type = 'directory' }
|
||||||
local actions = { delete, move }
|
local actions = { delete, move }
|
||||||
local ordered_actions = mutator.enforce_action_order(actions)
|
local ordered_actions = mutator.enforce_action_order(actions)
|
||||||
assert.are.same({ move, delete }, ordered_actions)
|
assert.are.same({ move, delete }, ordered_actions)
|
||||||
|
|
@ -197,14 +197,14 @@ describe('mutator', function()
|
||||||
it('Handles parent child move ordering', function()
|
it('Handles parent child move ordering', function()
|
||||||
local move1 = {
|
local move1 = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a/b',
|
src_url = 'oil-test:///a/b',
|
||||||
dest_url = 'canola-test:///b',
|
dest_url = 'oil-test:///b',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
local move2 = {
|
local move2 = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///b/a',
|
dest_url = 'oil-test:///b/a',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
local actions = { move2, move1 }
|
local actions = { move2, move1 }
|
||||||
|
|
@ -215,13 +215,13 @@ describe('mutator', function()
|
||||||
it('Handles a delete inside a moved folder', function()
|
it('Handles a delete inside a moved folder', function()
|
||||||
local del = {
|
local del = {
|
||||||
type = 'delete',
|
type = 'delete',
|
||||||
url = 'canola-test:///a/b.txt',
|
url = 'oil-test:///a/b.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}
|
}
|
||||||
local move = {
|
local move = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///b',
|
dest_url = 'oil-test:///b',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
local actions = { move, del }
|
local actions = { move, del }
|
||||||
|
|
@ -232,8 +232,8 @@ describe('mutator', function()
|
||||||
it('Detects move directory loops', function()
|
it('Detects move directory loops', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///a/b',
|
dest_url = 'oil-test:///a/b',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
assert.has_error(function()
|
assert.has_error(function()
|
||||||
|
|
@ -244,8 +244,8 @@ describe('mutator', function()
|
||||||
it('Detects copy directory loops', function()
|
it('Detects copy directory loops', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///a/b',
|
dest_url = 'oil-test:///a/b',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
assert.has_error(function()
|
assert.has_error(function()
|
||||||
|
|
@ -256,8 +256,8 @@ describe('mutator', function()
|
||||||
it('Detects nested copy directory loops', function()
|
it('Detects nested copy directory loops', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
src_url = 'canola-test:///a',
|
src_url = 'oil-test:///a',
|
||||||
dest_url = 'canola-test:///a/b/a',
|
dest_url = 'oil-test:///a/b/a',
|
||||||
entry_type = 'directory',
|
entry_type = 'directory',
|
||||||
}
|
}
|
||||||
assert.has_error(function()
|
assert.has_error(function()
|
||||||
|
|
@ -267,10 +267,10 @@ describe('mutator', function()
|
||||||
|
|
||||||
describe('change', function()
|
describe('change', function()
|
||||||
it('applies CHANGE after CREATE', function()
|
it('applies CHANGE after CREATE', function()
|
||||||
local create = { type = 'create', url = 'canola-test:///a/hi.txt', entry_type = 'file' }
|
local create = { type = 'create', url = 'oil-test:///a/hi.txt', entry_type = 'file' }
|
||||||
local change = {
|
local change = {
|
||||||
type = 'change',
|
type = 'change',
|
||||||
url = 'canola-test:///a/hi.txt',
|
url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
column = 'TEST',
|
column = 'TEST',
|
||||||
value = 'TEST',
|
value = 'TEST',
|
||||||
|
|
@ -283,13 +283,13 @@ describe('mutator', function()
|
||||||
it('applies CHANGE after COPY src', function()
|
it('applies CHANGE after COPY src', function()
|
||||||
local copy = {
|
local copy = {
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
src_url = 'canola-test:///a/hi.txt',
|
src_url = 'oil-test:///a/hi.txt',
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}
|
}
|
||||||
local change = {
|
local change = {
|
||||||
type = 'change',
|
type = 'change',
|
||||||
url = 'canola-test:///a/hi.txt',
|
url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
column = 'TEST',
|
column = 'TEST',
|
||||||
value = 'TEST',
|
value = 'TEST',
|
||||||
|
|
@ -302,13 +302,13 @@ describe('mutator', function()
|
||||||
it('applies CHANGE after COPY dest', function()
|
it('applies CHANGE after COPY dest', function()
|
||||||
local copy = {
|
local copy = {
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
src_url = 'canola-test:///b.txt',
|
src_url = 'oil-test:///b.txt',
|
||||||
dest_url = 'canola-test:///a/hi.txt',
|
dest_url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}
|
}
|
||||||
local change = {
|
local change = {
|
||||||
type = 'change',
|
type = 'change',
|
||||||
url = 'canola-test:///a/hi.txt',
|
url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
column = 'TEST',
|
column = 'TEST',
|
||||||
value = 'TEST',
|
value = 'TEST',
|
||||||
|
|
@ -321,13 +321,13 @@ describe('mutator', function()
|
||||||
it('applies CHANGE after MOVE dest', function()
|
it('applies CHANGE after MOVE dest', function()
|
||||||
local move = {
|
local move = {
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///b.txt',
|
src_url = 'oil-test:///b.txt',
|
||||||
dest_url = 'canola-test:///a/hi.txt',
|
dest_url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
}
|
}
|
||||||
local change = {
|
local change = {
|
||||||
type = 'change',
|
type = 'change',
|
||||||
url = 'canola-test:///a/hi.txt',
|
url = 'oil-test:///a/hi.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
column = 'TEST',
|
column = 'TEST',
|
||||||
value = 'TEST',
|
value = 'TEST',
|
||||||
|
|
@ -342,10 +342,10 @@ describe('mutator', function()
|
||||||
describe('perform actions', function()
|
describe('perform actions', function()
|
||||||
it('creates new entries', function()
|
it('creates new entries', function()
|
||||||
local actions = {
|
local actions = {
|
||||||
{ type = 'create', url = 'canola-test:///a.txt', entry_type = 'file' },
|
{ type = 'create', url = 'oil-test:///a.txt', entry_type = 'file' },
|
||||||
}
|
}
|
||||||
test_util.await(mutator.process_actions, 2, actions)
|
test_util.await(mutator.process_actions, 2, actions)
|
||||||
local files = cache.list_url('canola-test:///')
|
local files = cache.list_url('oil-test:///')
|
||||||
assert.are.same({
|
assert.are.same({
|
||||||
['a.txt'] = {
|
['a.txt'] = {
|
||||||
[FIELD_ID] = 1,
|
[FIELD_ID] = 1,
|
||||||
|
|
@ -358,10 +358,10 @@ describe('mutator', function()
|
||||||
it('deletes entries', function()
|
it('deletes entries', function()
|
||||||
local file = test_adapter.test_set('/a.txt', 'file')
|
local file = test_adapter.test_set('/a.txt', 'file')
|
||||||
local actions = {
|
local actions = {
|
||||||
{ type = 'delete', url = 'canola-test:///a.txt', entry_type = 'file' },
|
{ type = 'delete', url = 'oil-test:///a.txt', entry_type = 'file' },
|
||||||
}
|
}
|
||||||
test_util.await(mutator.process_actions, 2, actions)
|
test_util.await(mutator.process_actions, 2, actions)
|
||||||
local files = cache.list_url('canola-test:///')
|
local files = cache.list_url('oil-test:///')
|
||||||
assert.are.same({}, files)
|
assert.are.same({}, files)
|
||||||
assert.is_nil(cache.get_entry_by_id(file[FIELD_ID]))
|
assert.is_nil(cache.get_entry_by_id(file[FIELD_ID]))
|
||||||
assert.has_error(function()
|
assert.has_error(function()
|
||||||
|
|
@ -374,13 +374,13 @@ describe('mutator', function()
|
||||||
local actions = {
|
local actions = {
|
||||||
{
|
{
|
||||||
type = 'move',
|
type = 'move',
|
||||||
src_url = 'canola-test:///a.txt',
|
src_url = 'oil-test:///a.txt',
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
test_util.await(mutator.process_actions, 2, actions)
|
test_util.await(mutator.process_actions, 2, actions)
|
||||||
local files = cache.list_url('canola-test:///')
|
local files = cache.list_url('oil-test:///')
|
||||||
local new_entry = {
|
local new_entry = {
|
||||||
[FIELD_ID] = file[FIELD_ID],
|
[FIELD_ID] = file[FIELD_ID],
|
||||||
[FIELD_TYPE] = 'file',
|
[FIELD_TYPE] = 'file',
|
||||||
|
|
@ -390,7 +390,7 @@ describe('mutator', function()
|
||||||
['b.txt'] = new_entry,
|
['b.txt'] = new_entry,
|
||||||
}, files)
|
}, files)
|
||||||
assert.are.same(new_entry, cache.get_entry_by_id(file[FIELD_ID]))
|
assert.are.same(new_entry, cache.get_entry_by_id(file[FIELD_ID]))
|
||||||
assert.equals('canola-test:///', cache.get_parent_url(file[FIELD_ID]))
|
assert.equals('oil-test:///', cache.get_parent_url(file[FIELD_ID]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('copies entries', function()
|
it('copies entries', function()
|
||||||
|
|
@ -398,13 +398,13 @@ describe('mutator', function()
|
||||||
local actions = {
|
local actions = {
|
||||||
{
|
{
|
||||||
type = 'copy',
|
type = 'copy',
|
||||||
src_url = 'canola-test:///a.txt',
|
src_url = 'oil-test:///a.txt',
|
||||||
dest_url = 'canola-test:///b.txt',
|
dest_url = 'oil-test:///b.txt',
|
||||||
entry_type = 'file',
|
entry_type = 'file',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
test_util.await(mutator.process_actions, 2, actions)
|
test_util.await(mutator.process_actions, 2, actions)
|
||||||
local files = cache.list_url('canola-test:///')
|
local files = cache.list_url('oil-test:///')
|
||||||
local new_entry = {
|
local new_entry = {
|
||||||
[FIELD_ID] = file[FIELD_ID] + 1,
|
[FIELD_ID] = file[FIELD_ID] + 1,
|
||||||
[FIELD_TYPE] = 'file',
|
[FIELD_TYPE] = 'file',
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local constants = require('canola.constants')
|
local constants = require('oil.constants')
|
||||||
local parser = require('canola.mutator.parser')
|
local parser = require('oil.mutator.parser')
|
||||||
local test_adapter = require('canola.adapters.test')
|
local test_adapter = require('oil.adapters.test')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local view = require('canola.view')
|
local view = require('oil.view')
|
||||||
|
|
||||||
local FIELD_ID = constants.FIELD_ID
|
local FIELD_ID = constants.FIELD_ID
|
||||||
local FIELD_META = constants.FIELD_META
|
local FIELD_META = constants.FIELD_META
|
||||||
|
|
@ -19,7 +19,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('detects new files', function()
|
it('detects new files', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'a.txt',
|
'a.txt',
|
||||||
|
|
@ -29,7 +29,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('detects new directories', function()
|
it('detects new directories', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'foo/',
|
'foo/',
|
||||||
|
|
@ -39,7 +39,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('detects new links', function()
|
it('detects new links', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'a.txt -> b.txt',
|
'a.txt -> b.txt',
|
||||||
|
|
@ -53,7 +53,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('detects deleted files', function()
|
it('detects deleted files', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {})
|
set_lines(bufnr, {})
|
||||||
local diffs = parser.parse(bufnr)
|
local diffs = parser.parse(bufnr)
|
||||||
|
|
@ -64,7 +64,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('detects deleted directories', function()
|
it('detects deleted directories', function()
|
||||||
local dir = test_adapter.test_set('/foo/bar', 'directory')
|
local dir = test_adapter.test_set('/foo/bar', 'directory')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {})
|
set_lines(bufnr, {})
|
||||||
local diffs = parser.parse(bufnr)
|
local diffs = parser.parse(bufnr)
|
||||||
|
|
@ -76,7 +76,7 @@ describe('parser', function()
|
||||||
it('detects deleted links', function()
|
it('detects deleted links', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'link')
|
local file = test_adapter.test_set('/foo/a.txt', 'link')
|
||||||
file[FIELD_META] = { link = 'b.txt' }
|
file[FIELD_META] = { link = 'b.txt' }
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {})
|
set_lines(bufnr, {})
|
||||||
local diffs = parser.parse(bufnr)
|
local diffs = parser.parse(bufnr)
|
||||||
|
|
@ -87,7 +87,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('ignores empty lines', function()
|
it('ignores empty lines', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local cols = view.format_entry_cols(file, {}, {}, test_adapter, false)
|
local cols = view.format_entry_cols(file, {}, {}, test_adapter, false)
|
||||||
local lines = util.render_table({ cols }, {})
|
local lines = util.render_table({ cols }, {})
|
||||||
|
|
@ -99,7 +99,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('errors on missing filename', function()
|
it('errors on missing filename', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'/008',
|
'/008',
|
||||||
|
|
@ -116,7 +116,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('errors on empty dirname', function()
|
it('errors on empty dirname', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'/008 /',
|
'/008 /',
|
||||||
|
|
@ -133,7 +133,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('errors on duplicate names', function()
|
it('errors on duplicate names', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'foo',
|
'foo',
|
||||||
|
|
@ -152,7 +152,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('errors on duplicate names for existing files', function()
|
it('errors on duplicate names for existing files', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'a.txt',
|
'a.txt',
|
||||||
|
|
@ -170,7 +170,7 @@ describe('parser', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('ignores new dirs with empty name', function()
|
it('ignores new dirs with empty name', function()
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
'/',
|
'/',
|
||||||
|
|
@ -181,7 +181,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('parses a rename as a delete + new', function()
|
it('parses a rename as a delete + new', function()
|
||||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
string.format('/%d b.txt', file[FIELD_ID]),
|
string.format('/%d b.txt', file[FIELD_ID]),
|
||||||
|
|
@ -195,7 +195,7 @@ describe('parser', function()
|
||||||
|
|
||||||
it('detects a new trailing slash as a delete + create', function()
|
it('detects a new trailing slash as a delete + create', function()
|
||||||
local file = test_adapter.test_set('/foo', 'file')
|
local file = test_adapter.test_set('/foo', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
string.format('/%d foo/', file[FIELD_ID]),
|
string.format('/%d foo/', file[FIELD_ID]),
|
||||||
|
|
@ -210,7 +210,7 @@ describe('parser', function()
|
||||||
it('detects renamed files that conflict', function()
|
it('detects renamed files that conflict', function()
|
||||||
local afile = test_adapter.test_set('/foo/a.txt', 'file')
|
local afile = test_adapter.test_set('/foo/a.txt', 'file')
|
||||||
local bfile = test_adapter.test_set('/foo/b.txt', 'file')
|
local bfile = test_adapter.test_set('/foo/b.txt', 'file')
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
string.format('/%d a.txt', bfile[FIELD_ID]),
|
string.format('/%d a.txt', bfile[FIELD_ID]),
|
||||||
|
|
@ -238,7 +238,7 @@ describe('parser', function()
|
||||||
it('views link targets with trailing slashes as the same', function()
|
it('views link targets with trailing slashes as the same', function()
|
||||||
local file = test_adapter.test_set('/foo/mydir', 'link')
|
local file = test_adapter.test_set('/foo/mydir', 'link')
|
||||||
file[FIELD_META] = { link = 'dir/' }
|
file[FIELD_META] = { link = 'dir/' }
|
||||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
set_lines(bufnr, {
|
set_lines(bufnr, {
|
||||||
string.format('/%d mydir/ -> dir/', file[FIELD_ID]),
|
string.format('/%d mydir/ -> dir/', file[FIELD_ID]),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local pathutil = require('canola.pathutil')
|
local pathutil = require('oil.pathutil')
|
||||||
describe('pathutil', function()
|
describe('pathutil', function()
|
||||||
it('calculates parent path', function()
|
it('calculates parent path', function()
|
||||||
local cases = {
|
local cases = {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local TmpDir = require('spec.tmpdir')
|
local TmpDir = require('spec.tmpdir')
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
|
|
||||||
describe('canola preview', function()
|
describe('oil preview', function()
|
||||||
local tmpdir
|
local tmpdir
|
||||||
before_each(function()
|
before_each(function()
|
||||||
tmpdir = TmpDir.new()
|
tmpdir = TmpDir.new()
|
||||||
|
|
@ -17,8 +17,8 @@ describe('canola preview', function()
|
||||||
|
|
||||||
it('opens preview window', function()
|
it('opens preview window', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
test_util.canola_open(tmpdir.path)
|
test_util.oil_open(tmpdir.path)
|
||||||
test_util.await(canola.open_preview, 2)
|
test_util.await(oil.open_preview, 2)
|
||||||
local preview_win = util.get_preview_win()
|
local preview_win = util.get_preview_win()
|
||||||
assert.not_nil(preview_win)
|
assert.not_nil(preview_win)
|
||||||
assert(preview_win)
|
assert(preview_win)
|
||||||
|
|
@ -29,7 +29,7 @@ describe('canola preview', function()
|
||||||
|
|
||||||
it('opens preview window when open(preview={})', function()
|
it('opens preview window when open(preview={})', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
test_util.canola_open(tmpdir.path, { preview = {} })
|
test_util.oil_open(tmpdir.path, { preview = {} })
|
||||||
local preview_win = util.get_preview_win()
|
local preview_win = util.get_preview_win()
|
||||||
assert.not_nil(preview_win)
|
assert.not_nil(preview_win)
|
||||||
assert(preview_win)
|
assert(preview_win)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local TmpDir = require('spec.tmpdir')
|
local TmpDir = require('spec.tmpdir')
|
||||||
local actions = require('canola.actions')
|
local actions = require('oil.actions')
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
local view = require('canola.view')
|
local view = require('oil.view')
|
||||||
|
|
||||||
describe('regression tests', function()
|
describe('regression tests', function()
|
||||||
local tmpdir
|
local tmpdir
|
||||||
|
|
@ -21,29 +21,29 @@ describe('regression tests', function()
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
vim.cmd.vsplit()
|
vim.cmd.vsplit()
|
||||||
vim.cmd.edit({ args = { '%:p:h' } })
|
vim.cmd.edit({ args = { '%:p:h' } })
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
vim.cmd.wincmd({ args = { 'p' } })
|
vim.cmd.wincmd({ args = { 'p' } })
|
||||||
assert.equals('markdown', vim.bo.filetype)
|
assert.equals('markdown', vim.bo.filetype)
|
||||||
vim.cmd.edit({ args = { '%:p:h' } })
|
vim.cmd.edit({ args = { '%:p:h' } })
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.equals('canola', vim.bo.filetype)
|
assert.equals('oil', vim.bo.filetype)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('places the cursor on correct entry when opening on file', function()
|
it('places the cursor on correct entry when opening on file', function()
|
||||||
vim.cmd.edit({ args = { '.' } })
|
vim.cmd.edit({ args = { '.' } })
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
local entry = canola.get_cursor_entry()
|
local entry = oil.get_cursor_entry()
|
||||||
assert.not_nil(entry)
|
assert.not_nil(entry)
|
||||||
assert.not_equals('README.md', entry and entry.name)
|
assert.not_equals('README.md', entry and entry.name)
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
view.delete_hidden_buffers()
|
view.delete_hidden_buffers()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
entry = canola.get_cursor_entry()
|
entry = oil.get_cursor_entry()
|
||||||
assert.equals('README.md', entry and entry.name)
|
assert.equals('README.md', entry and entry.name)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("doesn't close floating windows canola didn't open itself", function()
|
it("doesn't close floating windows oil didn't open itself", function()
|
||||||
local winid = vim.api.nvim_open_win(vim.fn.bufadd('README.md'), true, {
|
local winid = vim.api.nvim_open_win(vim.fn.bufadd('README.md'), true, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 1,
|
row = 1,
|
||||||
|
|
@ -51,21 +51,21 @@ describe('regression tests', function()
|
||||||
width = 100,
|
width = 100,
|
||||||
height = 100,
|
height = 100,
|
||||||
})
|
})
|
||||||
canola.open()
|
oil.open()
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
canola.close()
|
oil.close()
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
assert.equals(winid, vim.api.nvim_get_current_win())
|
assert.equals(winid, vim.api.nvim_get_current_win())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("doesn't close splits on canola.close", function()
|
it("doesn't close splits on oil.close", function()
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
vim.cmd.vsplit()
|
vim.cmd.vsplit()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
canola.open()
|
oil.open()
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
canola.close()
|
oil.close()
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.equals(winid, vim.api.nvim_get_current_win())
|
assert.equals(winid, vim.api.nvim_get_current_win())
|
||||||
|
|
@ -73,24 +73,24 @@ describe('regression tests', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Returns to empty buffer on close', function()
|
it('Returns to empty buffer on close', function()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.not_equals('canola', vim.bo.filetype)
|
assert.not_equals('oil', vim.bo.filetype)
|
||||||
assert.equals('', vim.api.nvim_buf_get_name(0))
|
assert.equals('', vim.api.nvim_buf_get_name(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('All buffers set nomodified after save', function()
|
it('All buffers set nomodified after save', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
vim.cmd.edit({ args = { 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') } })
|
vim.cmd.edit({ args = { 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') } })
|
||||||
local first_dir = vim.api.nvim_get_current_buf()
|
local first_dir = vim.api.nvim_get_current_buf()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
test_util.feedkeys({ 'dd', 'itest/<esc>', '<CR>' }, 10)
|
test_util.feedkeys({ 'dd', 'itest/<esc>', '<CR>' }, 10)
|
||||||
vim.wait(1000, function()
|
vim.wait(1000, function()
|
||||||
return vim.bo.modifiable
|
return vim.bo.modifiable
|
||||||
end, 10)
|
end, 10)
|
||||||
test_util.feedkeys({ 'p' }, 10)
|
test_util.feedkeys({ 'p' }, 10)
|
||||||
canola.save({ confirm = false })
|
oil.save({ confirm = false })
|
||||||
vim.wait(1000, function()
|
vim.wait(1000, function()
|
||||||
return vim.bo.modifiable
|
return vim.bo.modifiable
|
||||||
end, 10)
|
end, 10)
|
||||||
|
|
@ -102,11 +102,11 @@ describe('regression tests', function()
|
||||||
|
|
||||||
it("refreshing buffer doesn't lose track of it", function()
|
it("refreshing buffer doesn't lose track of it", function()
|
||||||
vim.cmd.edit({ args = { '.' } })
|
vim.cmd.edit({ args = { '.' } })
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
vim.cmd.edit({ bang = true })
|
vim.cmd.edit({ bang = true })
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.are.same({ bufnr }, require('canola.view').get_all_buffers())
|
assert.are.same({ bufnr }, require('oil.view').get_all_buffers())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can copy a file multiple times', function()
|
it('can copy a file multiple times', function()
|
||||||
|
|
@ -126,8 +126,8 @@ describe('regression tests', function()
|
||||||
|
|
||||||
it('can open files from floating window', function()
|
it('can open files from floating window', function()
|
||||||
tmpdir:create({ 'a.txt' })
|
tmpdir:create({ 'a.txt' })
|
||||||
canola.open_float(tmpdir.path)
|
oil.open_float(tmpdir.path)
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
actions.select.callback()
|
actions.select.callback()
|
||||||
vim.wait(1000, function()
|
vim.wait(1000, function()
|
||||||
return vim.fn.expand('%:t') == 'a.txt'
|
return vim.fn.expand('%:t') == 'a.txt'
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
describe('canola select', function()
|
describe('oil select', function()
|
||||||
after_each(function()
|
after_each(function()
|
||||||
test_util.reset_editor()
|
test_util.reset_editor()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('opens file under cursor', function()
|
it('opens file under cursor', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
vim.cmd.normal({ args = { 'G' } })
|
vim.cmd.normal({ args = { 'G' } })
|
||||||
test_util.await(canola.select, 2)
|
test_util.await(oil.select, 2)
|
||||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals('canola', vim.bo.filetype)
|
assert.not_equals('oil', vim.bo.filetype)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('opens file in new tab', function()
|
it('opens file in new tab', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
test_util.await(canola.select, 2, { tab = true })
|
test_util.await(oil.select, 2, { tab = true })
|
||||||
assert.equals(2, #vim.api.nvim_list_tabpages())
|
assert.equals(2, #vim.api.nvim_list_tabpages())
|
||||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('opens file in new split', function()
|
it('opens file in new split', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
test_util.await(canola.select, 2, { vertical = true })
|
test_util.await(oil.select, 2, { vertical = true })
|
||||||
assert.equals(1, #vim.api.nvim_list_tabpages())
|
assert.equals(1, #vim.api.nvim_list_tabpages())
|
||||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('opens multiple files in new tabs', function()
|
it('opens multiple files in new tabs', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
vim.api.nvim_feedkeys('Vj', 'x', true)
|
vim.api.nvim_feedkeys('Vj', 'x', true)
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
test_util.await(canola.select, 2, { tab = true })
|
test_util.await(oil.select, 2, { tab = true })
|
||||||
assert.equals(3, #vim.api.nvim_list_tabpages())
|
assert.equals(3, #vim.api.nvim_list_tabpages())
|
||||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('opens multiple files in new splits', function()
|
it('opens multiple files in new splits', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
vim.api.nvim_feedkeys('Vj', 'x', true)
|
vim.api.nvim_feedkeys('Vj', 'x', true)
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
test_util.await(canola.select, 2, { vertical = true })
|
test_util.await(oil.select, 2, { vertical = true })
|
||||||
assert.equals(1, #vim.api.nvim_list_tabpages())
|
assert.equals(1, #vim.api.nvim_list_tabpages())
|
||||||
assert.equals(3, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(3, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
||||||
|
|
@ -56,20 +56,20 @@ describe('canola select', function()
|
||||||
it('same window', function()
|
it('same window', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
vim.cmd.normal({ args = { 'G' } })
|
vim.cmd.normal({ args = { 'G' } })
|
||||||
test_util.await(canola.select, 2, { close = true })
|
test_util.await(oil.select, 2, { close = true })
|
||||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.not_equals(bufnr, vim.api.nvim_get_current_buf())
|
assert.not_equals(bufnr, vim.api.nvim_get_current_buf())
|
||||||
assert.not_equals('canola', vim.bo.filetype)
|
assert.not_equals('oil', vim.bo.filetype)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('split', function()
|
it('split', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
test_util.await(canola.select, 2, { vertical = true, close = true })
|
test_util.await(oil.select, 2, { vertical = true, close = true })
|
||||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.equals(bufnr, vim.api.nvim_win_get_buf(winid))
|
assert.equals(bufnr, vim.api.nvim_win_get_buf(winid))
|
||||||
end)
|
end)
|
||||||
|
|
@ -78,8 +78,8 @@ describe('canola select', function()
|
||||||
vim.cmd.edit({ args = { 'foo' } })
|
vim.cmd.edit({ args = { 'foo' } })
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
test_util.await(canola.select, 2, { tab = true, close = true })
|
test_util.await(oil.select, 2, { tab = true, close = true })
|
||||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||||
assert.equals(2, #vim.api.nvim_list_tabpages())
|
assert.equals(2, #vim.api.nvim_list_tabpages())
|
||||||
vim.api.nvim_set_current_tabpage(tabpage)
|
vim.api.nvim_set_current_tabpage(tabpage)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
local cache = require('canola.cache')
|
local cache = require('oil.cache')
|
||||||
local test_adapter = require('canola.adapters.test')
|
local test_adapter = require('oil.adapters.test')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.reset_editor = function()
|
M.reset_editor = function()
|
||||||
require('canola').setup({
|
require('oil').setup({
|
||||||
columms = {},
|
columms = {},
|
||||||
adapters = {
|
adapters = {
|
||||||
['canola-test://'] = 'test',
|
['oil-test://'] = 'test',
|
||||||
},
|
},
|
||||||
prompt_save_on_select_new_entry = false,
|
prompt_save_on_select_new_entry = false,
|
||||||
})
|
})
|
||||||
|
|
@ -53,8 +53,8 @@ M.await_throwiferr = function(fn, nargs, ...)
|
||||||
return throwiferr(M.await(fn, nargs, ...))
|
return throwiferr(M.await(fn, nargs, ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
M.canola_open = function(...)
|
M.oil_open = function(...)
|
||||||
M.await(require('canola').open, 3, ...)
|
M.await(require('oil').open, 3, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.wait_for_autocmd = function(autocmd)
|
M.wait_for_autocmd = function(autocmd)
|
||||||
|
|
@ -81,7 +81,7 @@ M.wait_for_autocmd = function(autocmd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.wait_canola_ready = function()
|
M.wait_oil_ready = function()
|
||||||
local ready = false
|
local ready = false
|
||||||
util.run_after_load(
|
util.run_after_load(
|
||||||
0,
|
0,
|
||||||
|
|
@ -93,7 +93,7 @@ M.wait_canola_ready = function()
|
||||||
return ready
|
return ready
|
||||||
end, 10)
|
end, 10)
|
||||||
if not ready then
|
if not ready then
|
||||||
error('wait_canola_ready timed out')
|
error('wait_oil_ready timed out')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -113,34 +113,34 @@ M.feedkeys = function(actions, timestep)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.actions = {
|
M.actions = {
|
||||||
---Open canola and wait for it to finish rendering
|
---Open oil and wait for it to finish rendering
|
||||||
---@param args string[]
|
---@param args string[]
|
||||||
open = function(args)
|
open = function(args)
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.cmd.Canola({ args = args })
|
vim.cmd.Oil({ args = args })
|
||||||
if vim.b.canola_ready then
|
if vim.b.oil_ready then
|
||||||
vim.api.nvim_exec_autocmds('User', {
|
vim.api.nvim_exec_autocmds('User', {
|
||||||
pattern = 'CanolaEnter',
|
pattern = 'OilEnter',
|
||||||
modeline = false,
|
modeline = false,
|
||||||
data = { buf = vim.api.nvim_get_current_buf() },
|
data = { buf = vim.api.nvim_get_current_buf() },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
M.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
M.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
end,
|
end,
|
||||||
|
|
||||||
---Save all changes and wait for operation to complete
|
---Save all changes and wait for operation to complete
|
||||||
save = function()
|
save = function()
|
||||||
vim.schedule_wrap(require('canola').save)({ confirm = false })
|
vim.schedule_wrap(require('oil').save)({ confirm = false })
|
||||||
M.wait_for_autocmd({ 'User', pattern = 'CanolaMutationComplete' })
|
M.wait_for_autocmd({ 'User', pattern = 'OilMutationComplete' })
|
||||||
end,
|
end,
|
||||||
|
|
||||||
---@param bufnr? integer
|
---@param bufnr? integer
|
||||||
reload = function(bufnr)
|
reload = function(bufnr)
|
||||||
M.await(require('canola.view').render_buffer_async, 3, bufnr or 0)
|
M.await(require('oil.view').render_buffer_async, 3, bufnr or 0)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
---Move cursor to a file or directory in an canola buffer
|
---Move cursor to a file or directory in an oil buffer
|
||||||
---@param filename string
|
---@param filename string
|
||||||
focus = function(filename)
|
focus = function(filename)
|
||||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||||
|
|
@ -155,13 +155,13 @@ M.actions = {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
---Get the raw list of filenames from an unmodified canola buffer
|
---Get the raw list of filenames from an unmodified oil buffer
|
||||||
---@param bufnr? integer
|
---@param bufnr? integer
|
||||||
---@return string[]
|
---@return string[]
|
||||||
M.parse_entries = function(bufnr)
|
M.parse_entries = function(bufnr)
|
||||||
bufnr = bufnr or 0
|
bufnr = bufnr or 0
|
||||||
if vim.bo[bufnr].modified then
|
if vim.bo[bufnr].modified then
|
||||||
error("parse_entries doesn't work on a modified canola buffer")
|
error("parse_entries doesn't work on a modified oil buffer")
|
||||||
end
|
end
|
||||||
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
|
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
|
||||||
return vim.tbl_map(function(line)
|
return vim.tbl_map(function(line)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local fs = require('canola.fs')
|
local fs = require('oil.fs')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
|
|
@ -25,7 +25,7 @@ end
|
||||||
local TmpDir = {}
|
local TmpDir = {}
|
||||||
|
|
||||||
TmpDir.new = function()
|
TmpDir.new = function()
|
||||||
local path, err = vim.loop.fs_mkdtemp('canola_test_XXXXXXXXX')
|
local path, err = vim.loop.fs_mkdtemp('oil_test_XXXXXXXXX')
|
||||||
if not path then
|
if not path then
|
||||||
error(err)
|
error(err)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ describe('freedesktop', function()
|
||||||
local tmphome
|
local tmphome
|
||||||
local home = vim.env.XDG_DATA_HOME
|
local home = vim.env.XDG_DATA_HOME
|
||||||
before_each(function()
|
before_each(function()
|
||||||
require('canola.config').delete_to_trash = true
|
require('oil.config').delete_to_trash = true
|
||||||
tmpdir = TmpDir.new()
|
tmpdir = TmpDir.new()
|
||||||
tmphome = TmpDir.new()
|
tmphome = TmpDir.new()
|
||||||
package.loaded['canola.adapters.trash'] = require('canola.adapters.trash.freedesktop')
|
package.loaded['oil.adapters.trash'] = require('oil.adapters.trash.freedesktop')
|
||||||
vim.env.XDG_DATA_HOME = tmphome.path
|
vim.env.XDG_DATA_HOME = tmphome.path
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
|
@ -21,7 +21,7 @@ describe('freedesktop', function()
|
||||||
tmphome:dispose()
|
tmphome:dispose()
|
||||||
end
|
end
|
||||||
test_util.reset_editor()
|
test_util.reset_editor()
|
||||||
package.loaded['canola.adapters.trash'] = nil
|
package.loaded['oil.adapters.trash'] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('files can be moved to the trash', function()
|
it('files can be moved to the trash', function()
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
describe('url', function()
|
describe('url', function()
|
||||||
it('get_url_for_path', function()
|
it('get_url_for_path', function()
|
||||||
local cases = {
|
local cases = {
|
||||||
{ '', 'canola://' .. util.addslash(vim.fn.getcwd()) },
|
{ '', 'oil://' .. util.addslash(vim.fn.getcwd()) },
|
||||||
{
|
{
|
||||||
'term://~/canola.nvim//52953:/bin/sh',
|
'term://~/oil.nvim//52953:/bin/sh',
|
||||||
'canola://' .. vim.loop.os_homedir() .. '/canola.nvim/',
|
'oil://' .. vim.loop.os_homedir() .. '/oil.nvim/',
|
||||||
},
|
},
|
||||||
{ '/foo/bar.txt', 'canola:///foo/', 'bar.txt' },
|
{ '/foo/bar.txt', 'oil:///foo/', 'bar.txt' },
|
||||||
{ 'canola:///foo/bar.txt', 'canola:///foo/', 'bar.txt' },
|
{ 'oil:///foo/bar.txt', 'oil:///foo/', 'bar.txt' },
|
||||||
{ 'canola:///', 'canola:///' },
|
{ 'oil:///', 'oil:///' },
|
||||||
{
|
{
|
||||||
'canola-ssh://user@hostname:8888//bar.txt',
|
'oil-ssh://user@hostname:8888//bar.txt',
|
||||||
'canola-ssh://user@hostname:8888//',
|
'oil-ssh://user@hostname:8888//',
|
||||||
'bar.txt',
|
'bar.txt',
|
||||||
},
|
},
|
||||||
{ 'canola-ssh://user@hostname:8888//', 'canola-ssh://user@hostname:8888//' },
|
{ 'oil-ssh://user@hostname:8888//', 'oil-ssh://user@hostname:8888//' },
|
||||||
}
|
}
|
||||||
for _, case in ipairs(cases) do
|
for _, case in ipairs(cases) do
|
||||||
local input, expected, expected_basename = unpack(case)
|
local input, expected, expected_basename = unpack(case)
|
||||||
local output, basename = canola.get_buffer_parent_url(input, true)
|
local output, basename = oil.get_buffer_parent_url(input, true)
|
||||||
assert.equals(expected, output, string.format('Parent url for path "%s" failed', input))
|
assert.equals(expected, output, string.format('Parent url for path "%s" failed', input))
|
||||||
assert.equals(
|
assert.equals(
|
||||||
expected_basename,
|
expected_basename,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local util = require('canola.util')
|
local util = require('oil.util')
|
||||||
describe('util', function()
|
describe('util', function()
|
||||||
it('url_escape', function()
|
it('url_escape', function()
|
||||||
local cases = {
|
local cases = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local canola = require('canola')
|
local oil = require('oil')
|
||||||
local test_util = require('spec.test_util')
|
local test_util = require('spec.test_util')
|
||||||
|
|
||||||
describe('window options', function()
|
describe('window options', function()
|
||||||
|
|
@ -8,28 +8,28 @@ describe('window options', function()
|
||||||
|
|
||||||
it('Restores window options on close', function()
|
it('Restores window options on close', function()
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
canola.close()
|
oil.close()
|
||||||
assert.equals('auto', vim.o.signcolumn)
|
assert.equals('auto', vim.o.signcolumn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Restores window options on edit', function()
|
it('Restores window options on edit', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
assert.equals('auto', vim.o.signcolumn)
|
assert.equals('auto', vim.o.signcolumn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Restores window options on split <filename>', function()
|
it('Restores window options on split <filename>', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
vim.cmd.split({ args = { 'README.md' } })
|
vim.cmd.split({ args = { 'README.md' } })
|
||||||
assert.equals('auto', vim.o.signcolumn)
|
assert.equals('auto', vim.o.signcolumn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Restores window options on split', function()
|
it('Restores window options on split', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
vim.cmd.split()
|
vim.cmd.split()
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
|
|
@ -37,29 +37,29 @@ describe('window options', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Restores window options on tabnew <filename>', function()
|
it('Restores window options on tabnew <filename>', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
vim.cmd.tabnew({ args = { 'README.md' } })
|
vim.cmd.tabnew({ args = { 'README.md' } })
|
||||||
assert.equals('auto', vim.o.signcolumn)
|
assert.equals('auto', vim.o.signcolumn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Restores window options on tabnew', function()
|
it('Restores window options on tabnew', function()
|
||||||
test_util.canola_open()
|
test_util.oil_open()
|
||||||
assert.equals('no', vim.o.signcolumn)
|
assert.equals('no', vim.o.signcolumn)
|
||||||
vim.cmd.tabnew()
|
vim.cmd.tabnew()
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
assert.equals('auto', vim.o.signcolumn)
|
assert.equals('auto', vim.o.signcolumn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Sets the window options when re-entering canola buffer', function()
|
it('Sets the window options when re-entering oil buffer', function()
|
||||||
canola.open()
|
oil.open()
|
||||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||||
assert.truthy(vim.w.canola_did_enter)
|
assert.truthy(vim.w.oil_did_enter)
|
||||||
vim.cmd.edit({ args = { 'README.md' } })
|
vim.cmd.edit({ args = { 'README.md' } })
|
||||||
assert.falsy(vim.w.canola_did_enter)
|
assert.falsy(vim.w.oil_did_enter)
|
||||||
canola.open()
|
oil.open()
|
||||||
assert.truthy(vim.w.canola_did_enter)
|
assert.truthy(vim.w.oil_did_enter)
|
||||||
vim.cmd.vsplit()
|
vim.cmd.vsplit()
|
||||||
assert.truthy(vim.w.canola_did_enter)
|
assert.truthy(vim.w.oil_did_enter)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
if exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
syn match canolaId /^\/\d* / conceal
|
|
||||||
|
|
||||||
let b:current_syntax = "canola"
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
if exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
syn match canolaCreate /^CREATE\( BUCKET\)\? /
|
|
||||||
syn match canolaMove /^ MOVE /
|
|
||||||
syn match canolaDelete /^DELETE\( BUCKET\)\? /
|
|
||||||
syn match canolaCopy /^ COPY /
|
|
||||||
syn match canolaChange /^CHANGE /
|
|
||||||
" Trash operations
|
|
||||||
syn match canolaRestore /^RESTORE /
|
|
||||||
syn match canolaPurge /^ PURGE /
|
|
||||||
syn match canolaTrash /^ TRASH /
|
|
||||||
|
|
||||||
let b:current_syntax = "canola_preview"
|
|
||||||
7
syntax/oil.vim
Normal file
7
syntax/oil.vim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn match oilId /^\/\d* / conceal
|
||||||
|
|
||||||
|
let b:current_syntax = "oil"
|
||||||
15
syntax/oil_preview.vim
Normal file
15
syntax/oil_preview.vim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn match oilCreate /^CREATE\( BUCKET\)\? /
|
||||||
|
syn match oilMove /^ MOVE /
|
||||||
|
syn match oilDelete /^DELETE\( BUCKET\)\? /
|
||||||
|
syn match oilCopy /^ COPY /
|
||||||
|
syn match oilChange /^CHANGE /
|
||||||
|
" Trash operations
|
||||||
|
syn match oilRestore /^RESTORE /
|
||||||
|
syn match oilPurge /^ PURGE /
|
||||||
|
syn match oilTrash /^ TRASH /
|
||||||
|
|
||||||
|
let b:current_syntax = "oil_preview"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue