summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/terminal.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/core/terminal.lua')
-rw-r--r--.config/nvim/lua/core/terminal.lua37
1 files changed, 13 insertions, 24 deletions
diff --git a/.config/nvim/lua/core/terminal.lua b/.config/nvim/lua/core/terminal.lua
index 01b7709..1a7b0bc 100644
--- a/.config/nvim/lua/core/terminal.lua
+++ b/.config/nvim/lua/core/terminal.lua
@@ -1,5 +1,5 @@
local M = {}
-local utils = require "utils"
+local Log = require "core.log"
M.config = function()
options.builtin["terminal"] = {
@@ -81,8 +81,11 @@ 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.")
+ Log:error(
+ "Unable to run executable "
+ .. binary
+ .. ". Please make sure it is installed properly."
+ )
return
end
local Terminal = require("toggleterm.terminal").Terminal
@@ -90,29 +93,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 = options.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", options.builtin.terminal, {
- cmd = options.log.viewer.cmd .. " " .. logfile,
+ cmd = log_viewer,
open_mapping = options.log.viewer.layout_config.open_mapping,
direction = options.log.viewer.layout_config.direction,
-- TODO: this might not be working as expected
@@ -122,7 +112,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