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
539 stars 38 forks source link

ERR: Not an editor command: Runcode #105

Closed Wangch29 closed 8 months ago

Wangch29 commented 8 months ago

What's that?

MusherM commented 3 months ago

I have to say I don't understand why the author provides key mappings with "RunCode" command but do not provide cmd option. Maybe because I'm new to nvim, but this is really messing up with me. I finally got it fixed by adding a line like cmd="RunCode", and put this in your plugins folder should get it done:

return {
  "CRAG666/code_runner.nvim",
  cmd = "RunCode",
  config = function()
    require("code_runner").setup {
      filetype = {
        java = {
          "cd $dir &&",
          "javac $fileName &&",
          "java $fileNameWithoutExt",
        },
        python = "python3 -u",
        typescript = "deno run",
        javascript = "node",
        rust = {
          "cd $dir &&",
          "rustc $fileName &&",
          "$dir/$fileNameWithoutExt",
        },
        c = function(...)
          c_base = {
            "cd $dir &&",
            "gcc $fileName -o",
            "/tmp/$fileNameWithoutExt",
          }
          local c_exec = {
            "&& /tmp/$fileNameWithoutExt &&",
            "rm /tmp/$fileNameWithoutExt",
          }
          vim.ui.input({ prompt = "Add more args:" }, function(input)
            c_base[4] = input
            vim.print(vim.tbl_extend("force", c_base, c_exec))
            require("code_runner.commands").run_from_fn(vim.list_extend(c_base, c_exec))
          end)
        end,
      },
    }
  end,
}