summaryrefslogtreecommitdiff
path: root/lua/core/terminal.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-10-09 22:17:30 +0200
committerkylo252 <[email protected]>2021-10-09 22:17:30 +0200
commitcaf62bcfed4fc6cfed26164e39d22a568d21f9d0 (patch)
tree47f7ddcbe7ef10b6cffd8398dbfc215d94fc2fae /lua/core/terminal.lua
parent4126e5765d69840660fab2a05bbc664ad0117b95 (diff)
parent82b7a35858479223c1e34bea2f64451ecf1e5f66 (diff)
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'lua/core/terminal.lua')
-rw-r--r--lua/core/terminal.lua31
1 files changed, 8 insertions, 23 deletions
diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua
index f9be8734..3a0c6e46 100644
--- a/lua/core/terminal.lua
+++ b/lua/core/terminal.lua
@@ -1,5 +1,5 @@
local M = {}
-local utils = require "utils"
+local Log = require "core.log"
M.config = function()
lvim.builtin["terminal"] = {
@@ -81,7 +81,6 @@ end
M._exec_toggle = function(exec)
local binary = M._split(exec)[1]
if vim.fn.executable(binary) ~= 1 then
- local Log = require "core.log"
Log:error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.")
return
end
@@ -90,29 +89,16 @@ M._exec_toggle = function(exec)
exec_term:toggle()
end
-local function get_log_path(name)
- --handle custom paths not managed by Plenary.log
- local logger = require "core.log"
- local file
- if name == "nvim" then
- file = CACHE_PATH .. "/log"
- else
- file = logger:new({ plugin = name }):get_path()
- end
- if utils.is_file(file) then
- return file
- end
-end
-
---Toggles a log viewer according to log.viewer.layout_config
----@param name can be the name of any of the managed logs, e,g. "lunarvim" or the default ones {"nvim", "lsp", "packer.nvim"}
-M.toggle_log_view = function(name)
- local logfile = get_log_path(name)
- if not logfile then
- return
+---@param logfile string the fullpath to the logfile
+M.toggle_log_view = function(logfile)
+ local log_viewer = lvim.log.viewer.cmd
+ if vim.fn.executable(log_viewer) ~= 1 then
+ log_viewer = "less +F"
end
+ log_viewer = log_viewer .. " " .. logfile
local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, {
- cmd = lvim.log.viewer.cmd .. " " .. logfile,
+ cmd = log_viewer,
open_mapping = lvim.log.viewer.layout_config.open_mapping,
direction = lvim.log.viewer.layout_config.direction,
-- TODO: this might not be working as expected
@@ -122,7 +108,6 @@ M.toggle_log_view = function(name)
local Terminal = require("toggleterm.terminal").Terminal
local log_view = Terminal:new(term_opts)
- -- require("core.log"):debug("term", vim.inspect(term_opts))
log_view:toggle()
end