aboutsummaryrefslogtreecommitdiffstats
path: root/lua/simenandre
diff options
context:
space:
mode:
authorSimen A. W. Olsen <hello@simenandre.no>2024-12-27 21:02:58 +0100
committerSimen A. W. Olsen <hello@simenandre.no>2024-12-27 21:02:58 +0100
commit807903b91c013b56e77f9f70758bd137e42cbb65 (patch)
tree35cb07e80feb7bcaaf1b9994bcbef6abcced4358 /lua/simenandre
parent17a5f795123841fab25165c6916a287a8b68fc8f (diff)
downloadconfig.nvim-807903b91c013b56e77f9f70758bd137e42cbb65.tar.gz
config.nvim-807903b91c013b56e77f9f70758bd137e42cbb65.zip
update oil config and lock file
Diffstat (limited to 'lua/simenandre')
-rw-r--r--lua/simenandre/plugins/oil.lua97
1 files changed, 48 insertions, 49 deletions
diff --git a/lua/simenandre/plugins/oil.lua b/lua/simenandre/plugins/oil.lua
index dff5e1e..7b4ca42 100644
--- a/lua/simenandre/plugins/oil.lua
+++ b/lua/simenandre/plugins/oil.lua
@@ -1,58 +1,57 @@
--- helper function to parse output
-local function parse_output(proc)
- local result = proc:wait()
- local ret = {}
- if result.code == 0 then
- for line in vim.gsplit(result.stdout, "\n", { plain = true, trimempty = true }) do
- -- Remove trailing slash
- line = line:gsub("/$", "")
- ret[line] = true
- end
- end
- return ret
-end
-
--- build git status cache
-local function new_git_status()
- return setmetatable({}, {
- __index = function(self, key)
- local ignore_proc = vim.system(
- { "git", "ls-files", "--ignored", "--exclude-standard", "--others", "--directory" },
- {
- cwd = key,
- text = true,
- }
- )
- local tracked_proc = vim.system({ "git", "ls-tree", "HEAD", "--name-only" }, {
- cwd = key,
- text = true,
- })
- local ret = {
- ignored = parse_output(ignore_proc),
- tracked = parse_output(tracked_proc),
- }
-
- rawset(self, key, ret)
- return ret
- end,
- })
-end
-local git_status = new_git_status()
-
--- Clear git status cache on refresh
-local refresh = require("oil.actions").refresh
-local orig_refresh = refresh.callback
-refresh.callback = function(...)
- git_status = new_git_status()
- orig_refresh(...)
-end
-
return {
"stevearc/oil.nvim",
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
+ -- helper function to parse output
+ local function parse_output(proc)
+ local result = proc:wait()
+ local ret = {}
+ if result.code == 0 then
+ for line in vim.gsplit(result.stdout, "\n", { plain = true, trimempty = true }) do
+ -- Remove trailing slash
+ line = line:gsub("/$", "")
+ ret[line] = true
+ end
+ end
+ return ret
+ end
+
+ -- build git status cache
+ local function new_git_status()
+ return setmetatable({}, {
+ __index = function(self, key)
+ local ignore_proc = vim.system(
+ { "git", "ls-files", "--ignored", "--exclude-standard", "--others", "--directory" },
+ {
+ cwd = key,
+ text = true,
+ }
+ )
+ local tracked_proc = vim.system({ "git", "ls-tree", "HEAD", "--name-only" }, {
+ cwd = key,
+ text = true,
+ })
+ local ret = {
+ ignored = parse_output(ignore_proc),
+ tracked = parse_output(tracked_proc),
+ }
+
+ rawset(self, key, ret)
+ return ret
+ end,
+ })
+ end
+ local git_status = new_git_status()
+
+ -- Clear git status cache on refresh
+ local refresh = require("oil.actions").refresh
+ local orig_refresh = refresh.callback
+ refresh.callback = function(...)
+ git_status = new_git_status()
+ orig_refresh(...)
+ end
require("oil").setup({
columns = { "icon" },
keymaps = {