diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2023-10-09 17:48:24 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2023-10-09 17:48:24 +0530 |
| commit | dce9dc6101446f7a7379498f76972c78d9699fda (patch) | |
| tree | b732c4a0376c3135132d5a8f35281223a1020964 /.config/nvim/lua/compile.lua | |
| parent | 2033366fffb414a9144084e1dbed53b324d155e6 (diff) | |
new neovim config
Diffstat (limited to '')
| -rw-r--r-- | .config/nvim/lua/compile.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/.config/nvim/lua/compile.lua b/.config/nvim/lua/compile.lua new file mode 100644 index 0000000..8343cfe --- /dev/null +++ b/.config/nvim/lua/compile.lua @@ -0,0 +1,48 @@ +local openTerminal = function(command) + local Terminal = require('toggleterm.terminal').Terminal + local term = Terminal:new({ + cmd = command, + direction = 'horizontal' + }) + term:toggle() +end + +local compilePath = vim.fn.getcwd() .. '/.compile' +local runPath = vim.fn.getcwd() .. '/.run' + +local checkGetFileContent = function(path, typ) + local file_exists = os.rename(path, path) + + if file_exists then + openTerminal( + 'echo "Directory: $(pwd)"; echo "' .. typ .. ' started at $(date +"%H:%M:%S")"; echo; ' + .. 'bash ' .. path .. + '; echo; echo "' .. typ .. ' finished at $(date +"%H:%M:%S")"; read' + ) + return + end + + local file = io.open(path, 'w') + + file:seek('set') + file:write([[#!/bin/sh +set -xe +]] + ) + file:close() + print('Created ' .. path) + return nil +end + +vim.keymap.set('n', 'zz', function() + checkGetFileContent( + compilePath, + 'Compilation' + ) +end) +vim.keymap.set('n', 'zx', function() + checkGetFileContent( + runPath, + 'Run' + ) +end) |
