Переглянути джерело

fix: use the correct API for the log-viewer (#1564)

kylo252 3 роки тому
батько
коміт
9257e68c05
2 змінених файлів з 9 додано та 8 видалено
  1. 5 4
      lua/core/terminal.lua
  2. 4 4
      lua/core/which-key.lua

+ 5 - 4
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

+ 4 - 4
lua/core/which-key.lua

@@ -198,16 +198,16 @@ M.config = function()
             "<cmd>lua require('core.terminal').toggle_log_view('lunarvim')<cr>",
             "view default log",
           },
-          D = { "<cmd>edit ~/.cache/nvim/lunarvim.log<cr>", "Open the default logfile" },
+          D = { "<cmd>exe 'edit '.stdpath('cache').'/lunarvim.log'<cr>", "Open the default logfile" },
           n = { "<cmd>lua require('core.terminal').toggle_log_view('lsp')<cr>", "view lsp log" },
-          N = { "<cmd>edit ~/.cache/nvim/log<cr>", "Open the Neovim logfile" },
+          N = { "<cmd>edit $NVIM_LOG_FILE<cr>", "Open the Neovim logfile" },
           l = { "<cmd>lua require('core.terminal').toggle_log_view('nvim')<cr>", "view neovim log" },
-          L = { "<cmd>edit ~/.cache/nvim/lsp.log<cr>", "Open the LSP logfile" },
+          L = { "<cmd>exe 'edit '.stdpath('cache').'/lsp.log'<cr>", "Open the LSP logfile" },
           p = {
             "<cmd>lua require('core.terminal').toggle_log_view('packer.nvim')<cr>",
             "view packer log",
           },
-          P = { "<cmd>edit ~/.cache/nvim/packer.nvim.log<cr>", "Open the Packer logfile" },
+          P = { "<cmd>exe 'edit '.stdpath('cache').'/packer.nvim.log'<cr>", "Open the Packer logfile" },
         },
         r = { "<cmd>lua require('utils').reload_lv_config()<cr>", "Reload configurations" },
       },