mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-31 07:09:23 +02:00
[Refactor] Clean-up redundant module-load checks (#1011)
This commit is contained in:
parent
f36fd1907f
commit
6eb75c5678
8 changed files with 15 additions and 57 deletions
|
@ -1,5 +1,4 @@
|
|||
local M = {}
|
||||
local Log = require "core.log"
|
||||
local utils = require "utils"
|
||||
|
||||
M.config = function()
|
||||
|
@ -46,22 +45,13 @@ 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(lvim.builtin.terminal.execs) do
|
||||
require("core.terminal").add_exec(exec[1], exec[2], exec[3])
|
||||
end
|
||||
terminal.setup(lvim.builtin.terminal)
|
||||
end
|
||||
|
||||
local function is_installed(exe)
|
||||
return vim.fn.executable(exe) == 1
|
||||
end
|
||||
|
||||
M.add_exec = function(exec, keymap, name)
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
|
@ -85,8 +75,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue