From 8eed75d67f9cbcefb91c4cb5aac0ffd013be25cc Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:28:15 +0200 Subject: refactor: use more flexible paths (#1381) --- lua/core/terminal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/core/terminal.lua') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index f9be8734..87053412 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -95,7 +95,7 @@ local function get_log_path(name) local logger = require "core.log" local file if name == "nvim" then - file = CACHE_PATH .. "/log" + file = utils.join_paths(get_cache_dir(), "log") else file = logger:new({ plugin = name }):get_path() end -- cgit v1.2.3 From 9257e68c05eff293ea15a484d994b83fd7c610d8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 17 Sep 2021 08:29:35 +0200 Subject: fix: use the correct API for the log-viewer (#1564) --- lua/core/terminal.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lua/core/terminal.lua') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 87053412..4525ca63 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,5 +1,6 @@ local M = {} local utils = require "utils" +local Log = require "core.log" M.config = function() lvim.builtin["terminal"] = { @@ -81,7 +82,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 @@ -92,12 +92,13 @@ 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 = utils.join_paths(get_cache_dir(), "log") + file = utils.join_paths(vim.fn.stdpath "cache", "log") + elseif name == "packer.nvim" then + file = utils.join_paths(vim.fn.stdpath "cache", "packer.nvim.log") else - file = logger:new({ plugin = name }):get_path() + file = Log:get_path() end if utils.is_file(file) then return file -- cgit v1.2.3 From 35d5615ecc2366ec5de4ce0fecd75fb426216ea0 Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Thu, 30 Sep 2021 13:42:10 +0800 Subject: fix: can't open lvim log file cause by `lvim.log.viewer.cmd` (#1638) --- lua/core/terminal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua/core/terminal.lua') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 4525ca63..418dc2c4 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -112,8 +112,14 @@ M.toggle_log_view = function(name) if not logfile then return end + + 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 -- cgit v1.2.3 From 3e1cd1ec235404ae96ed2d0756729cf44ae48f3e Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 3 Oct 2021 14:32:09 +0200 Subject: fix: add missing lsp.log entry in log_viewer (#1666) --- lua/core/terminal.lua | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'lua/core/terminal.lua') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 418dc2c4..3a0c6e46 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,5 +1,4 @@ local M = {} -local utils = require "utils" local Log = require "core.log" M.config = function() @@ -90,29 +89,9 @@ M._exec_toggle = function(exec) exec_term:toggle() end -local function get_log_path(name) - --handle custom paths not managed by Plenary.log - local file - if name == "nvim" then - file = utils.join_paths(vim.fn.stdpath "cache", "log") - elseif name == "packer.nvim" then - file = utils.join_paths(vim.fn.stdpath "cache", "packer.nvim.log") - else - file = Log: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 - end - +---@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" @@ -129,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 -- cgit v1.2.3