CRAG666/code_runner.nvim

[feat]: support accept function as filetype value

Closed this issue · 3 comments

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...

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

@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,

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