cleanup: remove unnecessary option restore_win_options
This was only necessary to begin with because I was using `vim.wo` to
set window options. I mistakenly thought that would set the option as
window-local, but it did not. This was fixed in
6f8bf067c0. Now all the window options
should function as expected without the extra logic.
This commit is contained in:
parent
308fe70d6c
commit
9e036c6a48
5 changed files with 6 additions and 35 deletions
|
|
@ -150,12 +150,10 @@ require("oil").setup({
|
||||||
conceallevel = 3,
|
conceallevel = 3,
|
||||||
concealcursor = "nvic",
|
concealcursor = "nvic",
|
||||||
},
|
},
|
||||||
-- Restore window options to previous values when leaving an oil buffer
|
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
|
||||||
restore_win_options = true,
|
delete_to_trash = false,
|
||||||
-- Skip the confirmation popup for simple operations
|
-- Skip the confirmation popup for simple operations
|
||||||
skip_confirm_for_simple_edits = false,
|
skip_confirm_for_simple_edits = false,
|
||||||
-- Deleted files will be removed with the trash_command (below).
|
|
||||||
delete_to_trash = false,
|
|
||||||
-- Change this to customize the command used when deleting to trash
|
-- Change this to customize the command used when deleting to trash
|
||||||
trash_command = "trash-put",
|
trash_command = "trash-put",
|
||||||
-- 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
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,10 @@ OPTIONS *oil-option
|
||||||
conceallevel = 3,
|
conceallevel = 3,
|
||||||
concealcursor = "nvic",
|
concealcursor = "nvic",
|
||||||
},
|
},
|
||||||
-- Restore window options to previous values when leaving an oil buffer
|
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
|
||||||
restore_win_options = true,
|
delete_to_trash = false,
|
||||||
-- Skip the confirmation popup for simple operations
|
-- Skip the confirmation popup for simple operations
|
||||||
skip_confirm_for_simple_edits = false,
|
skip_confirm_for_simple_edits = false,
|
||||||
-- Deleted files will be removed with the trash_command (below).
|
|
||||||
delete_to_trash = false,
|
|
||||||
-- Change this to customize the command used when deleting to trash
|
-- Change this to customize the command used when deleting to trash
|
||||||
trash_command = "trash-put",
|
trash_command = "trash-put",
|
||||||
-- 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
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,10 @@ local default_config = {
|
||||||
conceallevel = 3,
|
conceallevel = 3,
|
||||||
concealcursor = "nvic",
|
concealcursor = "nvic",
|
||||||
},
|
},
|
||||||
-- Restore window options to previous values when leaving an oil buffer
|
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
|
||||||
restore_win_options = true,
|
delete_to_trash = false,
|
||||||
-- Skip the confirmation popup for simple operations
|
-- Skip the confirmation popup for simple operations
|
||||||
skip_confirm_for_simple_edits = false,
|
skip_confirm_for_simple_edits = false,
|
||||||
-- Deleted files will be removed with the trash_command (below).
|
|
||||||
delete_to_trash = false,
|
|
||||||
-- Change this to customize the command used when deleting to trash
|
-- Change this to customize the command used when deleting to trash
|
||||||
trash_command = "trash-put",
|
trash_command = "trash-put",
|
||||||
-- 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
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,6 @@ M.save = function(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function restore_alt_buf()
|
local function restore_alt_buf()
|
||||||
local config = require("oil.config")
|
|
||||||
if vim.bo.filetype == "oil" then
|
if vim.bo.filetype == "oil" then
|
||||||
require("oil.view").set_win_options()
|
require("oil.view").set_win_options()
|
||||||
vim.api.nvim_win_set_var(0, "oil_did_enter", true)
|
vim.api.nvim_win_set_var(0, "oil_did_enter", true)
|
||||||
|
|
@ -742,10 +741,6 @@ local function restore_alt_buf()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.restore_win_options then
|
|
||||||
require("oil.view").restore_win_options()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,28 +171,10 @@ end
|
||||||
M.set_win_options = function()
|
M.set_win_options = function()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
for k, v in pairs(config.win_options) do
|
for k, v in pairs(config.win_options) do
|
||||||
if config.restore_win_options then
|
|
||||||
local varname = "_oil_" .. k
|
|
||||||
if not pcall(vim.api.nvim_win_get_var, winid, varname) then
|
|
||||||
local prev_value = vim.wo[k]
|
|
||||||
vim.api.nvim_win_set_var(winid, varname, prev_value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
M.restore_win_options = function()
|
|
||||||
local winid = vim.api.nvim_get_current_win()
|
|
||||||
for k in pairs(config.win_options) do
|
|
||||||
local varname = "_oil_" .. k
|
|
||||||
local has_opt, opt = pcall(vim.api.nvim_win_get_var, winid, varname)
|
|
||||||
if has_opt then
|
|
||||||
vim.api.nvim_set_option_value(k, opt, { scope = "local", win = winid })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---Get a list of visible oil buffers and a list of hidden oil 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue