Skip to content

Open terminal in split and execute commands on buffer save

Notifications You must be signed in to change notification settings

catgoose/coderunner.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

coderunner.nvim

Open terminal in a configurable split and execute commands on buffer save.

Default configuration

  langs = {
   ruby = {
    { "ruby", "[#file]" },
   },
   lua = {
    { "lua", "[#file]" },
   },
   python = {
    { "python3", "[#file]" },
   },
   javascript = {
    { "clear" }, -- each table is a separate commands
    { "node", "[#file]" },
   },
   cpp = {
    { "clear" }, -- 3 commands are ran.
    -- ctrl-p/n can be used to cycle history.
    { "make", { "[#ask]", "Enter make argument" } },
    { { "[#ask]", "Command to run after make" } },
   },
  },
  split = "horizontal", -- vertical or horizontal
  scale = 0.25,
  filetype = "coderunner",
 },
  • Each key in langs table expects a table of commands.
  • [#file] tag is replaced by the current filename.
  • { "[#ask]", "Ask text } Table prompts for input.

API

require("coderunner").run({{split = "horizontal"}})
require("coderunner").run({{split = "vertical"}})

Example setup with lazy.nvim

local opts = {
  split = "vertical",
  scale = 0.25,
}

return {
  "catgoose/coderunner.nvim",
  opts - opts,
  event = "BufReadPre",
  keys = {
    {"<leader>cc", [[require("coderunner").run({split = "horizontal"})]]),
    {"<leader>cv", [[require("coderunner").run({split = "vertical"})]])},
  }

Todo

  • Allow defining a table of actions to perform as a token

About

Open terminal in split and execute commands on buffer save

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages