diff options
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/.config/nvim/lua/tobyvin/filetype.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/filetype.lua b/nvim/.config/nvim/lua/tobyvin/filetype.lua index 6e52fdd..e98f5b8 100644 --- a/nvim/.config/nvim/lua/tobyvin/filetype.lua +++ b/nvim/.config/nvim/lua/tobyvin/filetype.lua @@ -9,5 +9,20 @@ vim.filetype.add({ }, pattern = { [".*%.conf"] = { "confini", { priority = -math.huge } }, + ["/var/tmp/.*"] = function(_, bufnr, _) + local pid = vim.fn.getpid() + local cl = vim.fn.readfile(("/proc/%s/comm"):format(pid)) + + while #cl >= 1 and cl[1] == "nvim" do + pid = vim.fn.split(vim.fn.readfile(("/proc/%s/stat"):format(pid))[1])[4] + cl = vim.fn.split(vim.fn.readfile(("/proc/%s/cmdline"):format(pid))[1], "\n") + + if #cl >= 1 and cl[1] == "sudoedit" or (#cl >= 2 and cl[1] == "sudo" and cl[2] == "-e") then + return vim.filetype.match({ buf = bufnr, filename = cl[#cl] }) + end + end + + return vim.filetype.match({ buf = bufnr }) + end, }, }) |