From 9e036c6a4868b971127f3cb6bac6197bb4103723 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 12 Sep 2023 10:52:58 -0700 Subject: [PATCH] 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 6f8bf067c09e96d6bff548b5e6addb6d9c25a678. Now all the window options should function as expected without the extra logic. --- README.md | 6 ++---- doc/oil.txt | 6 ++---- lua/oil/config.lua | 6 ++---- lua/oil/init.lua | 5 ----- lua/oil/view.lua | 18 ------------------ 5 files changed, 6 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index eee9889..14404de 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/doc/oil.txt b/doc/oil.txt index 3334f6f..6c3890f 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -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 diff --git a/lua/oil/config.lua b/lua/oil/config.lua index d50f78f..b5e9a68 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -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 diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 68a3474..7e6c2ee 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -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 diff --git a/lua/oil/view.lua b/lua/oil/view.lua index 1d530dd..751fc60 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -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