CRAG666 / code_runner.nvim

Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
MIT License
534 stars 38 forks source link

How can I toggle RunCode and RunClose with the same keymap? #79

Closed abd0-omar closed 10 months ago

abd0-omar commented 1 year ago

I use r to run the code, is it possible to RunClose with r too?

CRAG666 commented 1 year ago

You can use vim.w to store a variable to determine whether or not it is running.

CRAG666 commented 1 year ago

@AbdoOrigin Currently with better_term mode you can assign a key to toggle the terminal

abd0-omar commented 1 year ago

Thanks, I'll look into it

justicenyaga commented 5 months ago

I know this is closed, but, I achieved the desired functionality by just using lua.

Here's a snippet on how to go about it for anyone who might want to implement this.

vim.keymap.set("n", "<leader>ex", function()
  local bufname = vim.fn.bufname("%")
  if bufname:find("crunner_") then
    vim.cmd("RunClose")
  else
    vim.cmd("RunCode")
  end
end, { desc = "Toggle Code Runner" })
abd0-omar commented 5 months ago

I know this is closed, but, I achieved the desired functionality by just using lua.

Here's a snippet on how to go about it for anyone who might want to implement this.

vim.keymap.set("n", "<leader>ex", function()
  local bufname = vim.fn.bufname("%")
  if bufname:find("crunner_") then
    vim.cmd("RunClose")
  else
    vim.cmd("RunCode")
  end
end, { desc = "Toggle Code Runner" })

Yeah that's exactly what I wanted a while back