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

[feat]: support accept function as filetype value #73

Closed JuanZoran closed 1 year ago

JuanZoran commented 1 year ago

Sometimes it will be helpful to dynamically generate runner commands for different case

I think it should accept a function that returns a string as a runner command

maybe it also can accept some args like project name or etc...

CRAG666 commented 1 year ago

That is already implemented, or maybe you refer to another functionality, but in any case you can assign functions in your file types, in fact in my dotfiles I do that, as for the projects it is possible to assign projects in the same way

CRAG666 commented 1 year ago

@JuanZoran I currently use this for markdown

      markdown = function(...)
        markdownCompileOptions = {
          Normal = "pdf",
          Presentation = "beamer",
          Slides = "",
        }
        vim.ui.select(vim.tbl_keys(markdownCompileOptions), {
          prompt = "Select preview mode:",
        }, function(opt, _)
          if opt then
            if opt == "Slides" then
              local filename = vim.fn.expand "%:p"
              os.execute("kitty slides " .. filename .. " &> /dev/null &")
              return
            end
            require("code_runner.hooks.preview_pdf").run {
              command = "pandoc",
              args = { "$fileName", "-o", "$tmpFile", "-t", markdownCompileOptions[opt] },
              preview_cmd = "/bin/zathura --fork",
            }
          else
            print "Not Preview"
          end
        end)
      end,
JuanZoran commented 1 year ago

Thanks, I will read the code later, really a nice plugin!