From 7758ef1a0cf42fe4211c84732b37241a668ae47f Mon Sep 17 00:00:00 2001 From: EthanJWright Date: Wed, 18 Aug 2021 20:19:27 -0600 Subject: [PATCH 1/2] feat: run command after sending to buffer --- lua/harpoon/init.lua | 1 + lua/harpoon/term.lua | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index ca09891..ae184ad 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -156,6 +156,7 @@ M.setup = function(config) global_settings = { ["save_on_toggle"] = false, ["save_on_change"] = true, + ["enter_on_sendcmd"] = false, }, }, expand_dir( c_config diff --git a/lua/harpoon/term.lua b/lua/harpoon/term.lua index 0c63699..71c2dd9 100644 --- a/lua/harpoon/term.lua +++ b/lua/harpoon/term.lua @@ -1,5 +1,6 @@ local harpoon = require("harpoon") local log = require("harpoon.dev").log +local global_config = harpoon.get_global_settings() local M = {} local terminals = {} @@ -66,6 +67,10 @@ M.sendCommand = function(idx, cmd, ...) cmd = harpoon.get_term_config().cmds[cmd] end + if global_config.enter_on_sendcmd then + cmd = cmd .. "\n" + end + if cmd then log.debug("sendCommand:", cmd) vim.api.nvim_chan_send(term_handle.term_id, string.format(cmd, ...)) From 7670f8d7a96f0aa3b5a7489c196d198839ff4ee1 Mon Sep 17 00:00:00 2001 From: EthanJWright Date: Wed, 18 Aug 2021 20:24:03 -0600 Subject: [PATCH 2/2] fix: add docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1993467..37c9c1d 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ require("harpoon").setup({ global_settings = { save_on_toggle = false, save_on_change = true, + enter_on_sendcmd = false, }, ... your other configs ... }) @@ -148,6 +149,8 @@ require("harpoon").setup({ enable this option (on by default) harpoon will not save any changes to your file. It is very unreliable to save your harpoon on exit (at least that is what I have found). +* `enter_on_sendcmd` will set harpoon to run the command immediately as it's + passed to the terminal when calling `sendCommand`. #### Preconfigured Terminal Commands These are project specific commands that you wish to execute on the regular.