From 7f176487052a155d43c6b64ef44b6dd775e94f99 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 4 Feb 2023 12:03:19 -0800 Subject: [PATCH] fix: better behaved lazy loading in autocmds --- lua/oil/init.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 01ec2cf..2896869 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -531,9 +531,8 @@ end local function restore_alt_buf() local config = require("oil.config") - local view = require("oil.view") if vim.bo.filetype == "oil" then - view.set_win_options() + require("oil.view").set_win_options() vim.api.nvim_win_set_var(0, "oil_did_enter", true) elseif vim.w.oil_did_enter then vim.api.nvim_win_del_var(0, "oil_did_enter") @@ -556,7 +555,7 @@ local function restore_alt_buf() end if config.restore_win_options then - view.restore_win_options() + require("oil.view").restore_win_options() end end end @@ -706,11 +705,10 @@ M.setup = function(opts) pattern = "*", callback = function() local util = require("oil.util") - local view = require("oil.view") local bufname = vim.api.nvim_buf_get_name(0) local scheme = util.parse_url(bufname) if scheme and config.adapters[scheme] then - view.maybe_set_cursor() + require("oil.view").maybe_set_cursor() elseif vim.fn.isdirectory(bufname) == 0 then -- Only run this logic if we are *not* in an oil buffer (and it's not a directory, which -- will be replaced by an oil:// url)