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 ++------------------------ lua/core/which-key.lua | 13 ++++++++----- 2 files changed, 10 insertions(+), 29 deletions(-) (limited to 'lua/core') 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 diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 2e528048..27cec37c 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -199,14 +199,17 @@ M.config = function() l = { name = "+logs", d = { - "lua require('core.terminal').toggle_log_view('lunarvim')", + "lua require('core.terminal').toggle_log_view(require('core.log').get_path())", "view default log", }, - D = { "exe 'edit '.stdpath('cache').'/lunarvim.log'", "Open the default logfile" }, - n = { "lua require('core.terminal').toggle_log_view('lsp')", "view lsp log" }, + D = { "lua vim.fn.execute('edit ' .. require('core.log').get_path())", "Open the default logfile" }, + l = { "lua require('core.terminal').toggle_log_view(vim.lsp.get_log_path())", "view lsp log" }, + L = { "lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())", "Open the LSP logfile" }, + n = { + "lua require('core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))", + "view neovim log", + }, N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, - l = { "lua require('core.terminal').toggle_log_view('nvim')", "view neovim log" }, - L = { "exe 'edit '.stdpath('cache').'/lsp.log'", "Open the LSP logfile" }, p = { "lua require('core.terminal').toggle_log_view('packer.nvim')", "view packer log", -- cgit v1.2.3