diff options
author | Squibid <me@zacharyscheiman.com> | 2024-03-29 23:28:36 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-03-29 23:28:36 -0400 |
commit | 2b1d1249dfd3bf4c32ebf203f2b4509c63efe096 (patch) | |
tree | bfef3c2995af94af418a927ae5b99326aae1cc41 /lua/conf | |
parent | c23619baf1522f6c4aa6cbbb85d5abc5b804043e (diff) | |
download | nvim-2b1d1249dfd3bf4c32ebf203f2b4509c63efe096.tar.gz nvim-2b1d1249dfd3bf4c32ebf203f2b4509c63efe096.tar.bz2 nvim-2b1d1249dfd3bf4c32ebf203f2b4509c63efe096.zip |
make <leader>x toggle executable status
Diffstat (limited to '')
-rw-r--r-- | lua/conf/binds.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua index d76cb8a..4549553 100644 --- a/lua/conf/binds.lua +++ b/lua/conf/binds.lua @@ -31,7 +31,21 @@ map('n', 'N', 'Nzzzv') map('n', '<C-d>', '<C-d>zz') -- half page jumping map('n', '<C-u>', '<C-u>zz') -map('n', '<leader>x', '<cmd>!chmod +x "%"<CR>') -- execute order 111 +map('n', '<leader>x', function() -- execute order 111 + local fn = vim.fn.expand("%:p") + if vim.fn.getftype(fn) == "file" then + local perm = vim.fn.getfperm(fn) + if string.match(perm, "x", 3) then + vim.notify("Removed executable flags", vim.log.levels.INFO, { title = misc.appid }) + vim.fn.setfperm(fn, string.sub(fn, 1, 2).."-"..string.sub(fn, 4, 5).."-"..string.sub(fn, 7, 8).."-") + else + vim.notify("Add executable flags", vim.log.levels.INFO, { title = misc.appid }) + vim.fn.setfperm(fn, string.sub(fn, 1, 2).."x"..string.sub(fn, 4, 5).."x"..string.sub(fn, 7, 8).."x") + end + else + vim.notify("File doesn't exist", vim.log.levels.INFO, { title = misc.appid }) + end +end) -- add some keybinds to the file view (netrw) a.nvim_create_autocmd('FileType', { |