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:
Steven Arcangeli 2023-09-12 10:52:58 -07:00
parent 308fe70d6c
commit 9e036c6a48
5 changed files with 6 additions and 35 deletions

View file

@ -150,12 +150,10 @@ require("oil").setup({
conceallevel = 3,
concealcursor = "nvic",
},
-- Restore window options to previous values when leaving an oil buffer
restore_win_options = true,
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations
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
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first

View file

@ -41,12 +41,10 @@ OPTIONS *oil-option
conceallevel = 3,
concealcursor = "nvic",
},
-- Restore window options to previous values when leaving an oil buffer
restore_win_options = true,
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations
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
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first

View file

@ -26,12 +26,10 @@ local default_config = {
conceallevel = 3,
concealcursor = "nvic",
},
-- Restore window options to previous values when leaving an oil buffer
restore_win_options = true,
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations
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
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first

View file

@ -719,7 +719,6 @@ M.save = function(opts)
end
local function restore_alt_buf()
local config = require("oil.config")
if vim.bo.filetype == "oil" then
require("oil.view").set_win_options()
vim.api.nvim_win_set_var(0, "oil_did_enter", true)
@ -742,10 +741,6 @@ local function restore_alt_buf()
end
end
end
if config.restore_win_options then
require("oil.view").restore_win_options()
end
end
end

View file

@ -171,28 +171,10 @@ end
M.set_win_options = function()
local winid = vim.api.nvim_get_current_win()
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 })
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
---@note
--- If any buffers are modified, return values are nil