diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-12-25 02:22:45 -0500 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-12-25 02:22:45 -0500 |
| commit | 7bef410c68cfbe09208467c07fe8676bea8db3b5 (patch) | |
| tree | 9f767bd514f6fc7ef8ca73c1195e3bd26eedf3ae /nvim/lua/plugins/oil.lua | |
| parent | 77baacf35a95598abc648fa6fe7305828232b606 (diff) | |
Tidy plugins
Diffstat (limited to 'nvim/lua/plugins/oil.lua')
| -rw-r--r-- | nvim/lua/plugins/oil.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/nvim/lua/plugins/oil.lua b/nvim/lua/plugins/oil.lua index 890e05d..0c0a2c3 100644 --- a/nvim/lua/plugins/oil.lua +++ b/nvim/lua/plugins/oil.lua @@ -1,3 +1,4 @@ +local oil_winnr = nil return { 'stevearc/oil.nvim', lazy = false, @@ -8,13 +9,18 @@ return { keys = { { "<leader>ef", function() - local filetype = vim.o.ft - if filetype == "oil" then - vim.cmd('q') + if not oil_winnr or not vim.api.nvim_win_is_valid(oil_winnr) then + vim.cmd("topleft vsplit +Oil") + oil_winnr = vim.api.nvim_get_current_win() + return + end + + if vim.api.nvim_get_current_win() == oil_winnr then + vim.api.nvim_win_close(oil_winnr, false) + oil_winnr = nil else - vim.cmd('topleft vsplit +Oil') + vim.api.nvim_set_current_win(oil_winnr) end - -- TODO: check for other open oil instances end, desc = "Open Oil file explorer in a far left split, similar to :Lexplore" } }, |
