summaryrefslogtreecommitdiffstats
path: root/lua/conf/binds.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lua/conf/binds.lua16
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', {