diff options
author | justanothercatgirl <sotov@twistea.su> | 2025-01-17 13:11:40 +0300 |
---|---|---|
committer | justanothercatgirl <sotov@twistea.su> | 2025-01-17 13:11:40 +0300 |
commit | fea38c3c191163ea3f14f2c90236ebbde75fcbe5 (patch) | |
tree | 8a442ee129a787b5b44834e82509fe340182df36 /.config/nvim/lua/user/coderunner.lua | |
parent | b265c328f04362225a9d001580d0b8f5963ee1d9 (diff) |
merged changes from laptop into pc dotfiles
Diffstat (limited to '.config/nvim/lua/user/coderunner.lua')
-rw-r--r-- | .config/nvim/lua/user/coderunner.lua | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/.config/nvim/lua/user/coderunner.lua b/.config/nvim/lua/user/coderunner.lua index 843534f..77330ab 100644 --- a/.config/nvim/lua/user/coderunner.lua +++ b/.config/nvim/lua/user/coderunner.lua @@ -1,15 +1,5 @@ local term = require'toggleterm' -cxx = function() - local script = - 'echo $file > /dev/null;' .. - 'OLDPWD_=\\${PWD};' .. - 'while [[ ! -f CMakeLists.txt || ! -f compile_commands.json && \\\"\\$PWD\\\" != / ]]; do cd ..; done;' .. - 'if [[ -f CMakeLists.txt && -f compile_commands.json ]]; then mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make -j24 && ' .. - './\\$(sed -nr \\\"/add_executable/s/.*add_executable\\\\((\\\\S+).+/\\\\1/p\\\" ../CMakeLists.txt); fi;' .. - 'cd ${OLDPWD_}' - vim.cmd(string.format("TermExec cmd='%s'", script)) -end -- Define the code runner configuration require('code_runner').setup({ mode = "toggleterm", @@ -17,9 +7,16 @@ require('code_runner').setup({ startinsert = true, filetype = { rust = 'cargo check; if [ \\$? -ne 0 ]; then echo cargo check failed; else cargo run || cargo test -- --nocapture --test-threads=1; fi; echo $file > /dev/null', - cpp = cxx, - c = cxx, + cpp = function() + local script = + 'echo $file > /dev/null;' .. + 'while [[ ! -f CMakeLists.txt && \\\"\\$PWD\\\" != / ]]; do cd ..; done;' .. + 'if [[ -f CMakeLists.txt ]]; then mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make -j24 && ' .. + './\\$(sed -nr \\\"/add_executable/s/.*add_executable\\\\((\\\\S+).+/\\\\1/p\\\" ../CMakeLists.txt); fi;' .. + 'cd ..' + vim.cmd(string.format("TermExec cmd='%s'", script)) + end, python = 'python3 $file', - tex = "mkdir -p build && if pdflatex -interaction=batchmode -output-directory=build -output-format=pdf $file; then killall -SIGHUP mupdf; else echo -e \\\\\\\\x1b[1\\\\;31mBUILD FAILED\\\\\\\\x1b[0m; fi" + tex = 'mkdir -p build && pdflatex -output-directory=build -output-format=PDF $file' }, }) |