diff options
Diffstat (limited to '.config/nvim/lua/core/terminal.lua')
-rw-r--r-- | .config/nvim/lua/core/terminal.lua | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/.config/nvim/lua/core/terminal.lua b/.config/nvim/lua/core/terminal.lua index ff3f95e..80dc9d0 100644 --- a/.config/nvim/lua/core/terminal.lua +++ b/.config/nvim/lua/core/terminal.lua @@ -1,9 +1,9 @@ local M = {} -local Log = require "core.log" local utils = require "utils" M.config = function() options.builtin["terminal"] = { + on_config_done = nil, -- size can be a number or function which is passed the current terminal size = 20, -- open_mapping = [[<c-\>]], @@ -46,20 +46,15 @@ M.config = function() end M.setup = function() - local status_ok, terminal = pcall(require, "toggleterm") - if not status_ok then - Log:get_default().error "Failed to load toggleterm" - print(terminal) - return - end + local terminal = require "toggleterm" for _, exec in pairs(options.builtin.terminal.execs) do require("core.terminal").add_exec(exec[1], exec[2], exec[3]) end terminal.setup(options.builtin.terminal) -end -local function is_installed(exe) - return vim.fn.executable(exe) == 1 + if options.builtin.terminal.on_config_done then + options.builtin.terminal.on_config_done(terminal) + end end M.add_exec = function(exec, keymap, name) @@ -85,12 +80,9 @@ end M._exec_toggle = function(exec) local binary = M._split(exec)[1] - if is_installed(binary) ~= true then - print( - "Please install executable " - .. binary - .. ". Check documentation for more information" - ) + if vim.fn.executable(binary) ~= 1 then + local Log = require "core.log" + Log:get_default().error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.") return end local Terminal = require("toggleterm.terminal").Terminal |