aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/log.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /runtime/lua/vim/lsp/log.lua
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'runtime/lua/vim/lsp/log.lua')
-rw-r--r--runtime/lua/vim/lsp/log.lua30
1 files changed, 12 insertions, 18 deletions
diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua
index d1a78572aa..6d2e0bc292 100644
--- a/runtime/lua/vim/lsp/log.lua
+++ b/runtime/lua/vim/lsp/log.lua
@@ -2,14 +2,12 @@
local log = {}
--- FIXME: DOC
--- Should be exposed in the vim docs.
---
--- Log level dictionary with reverse lookup as well.
---
--- Can be used to lookup the number from the name or the name from the number.
--- Levels by name: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"
--- Level numbers begin with "TRACE" at 0
+--- Log level dictionary with reverse lookup as well.
+---
+--- Can be used to lookup the number from the name or the name from the number.
+--- Levels by name: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"
+--- Level numbers begin with "TRACE" at 0
+--- @nodoc
log.levels = vim.deepcopy(vim.log.levels)
-- Default log level is warn.
@@ -20,7 +18,6 @@ local format_func = function(arg)
end
do
- ---@private
local function notify(msg, level)
if vim.in_fast_event() then
vim.schedule(function()
@@ -31,8 +28,7 @@ do
end
end
- local path_sep = vim.loop.os_uname().version:match('Windows') and '\\' or '/'
- ---@private
+ local path_sep = vim.uv.os_uname().version:match('Windows') and '\\' or '/'
local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), path_sep)
end
@@ -44,13 +40,12 @@ do
vim.fn.mkdir(vim.fn.stdpath('log'), 'p')
--- Returns the log filename.
- ---@returns (string) log filename
+ ---@return string log filename
function log.get_filename()
return logfilename
end
local logfile, openerr
- ---@private
--- Opens log file. Returns true if file is open, false on error
local function open_logfile()
-- Try to open file only once
@@ -68,7 +63,7 @@ do
return false
end
- local log_info = vim.loop.fs_stat(logfilename)
+ local log_info = vim.uv.fs_stat(logfilename)
if log_info and log_info.size > 1e9 then
local warn_msg = string.format(
'LSP client log is large (%d MB): %s',
@@ -141,7 +136,7 @@ end
vim.tbl_add_reverse_lookup(log.levels)
--- Sets the current log level.
----@param level (string|number) One of `vim.lsp.log.levels`
+---@param level (string|integer) One of `vim.lsp.log.levels`
function log.set_level(level)
if type(level) == 'string' then
current_log_level =
@@ -154,7 +149,7 @@ function log.set_level(level)
end
--- Gets the current log level.
----@return string current log level
+---@return integer current log level
function log.get_level()
return current_log_level
end
@@ -167,11 +162,10 @@ function log.set_format_func(handle)
end
--- Checks whether the level is sufficient for logging.
----@param level number log level
+---@param level integer log level
---@returns (bool) true if would log, false if not
function log.should_log(level)
return level >= current_log_level
end
return log
--- vim:sw=2 ts=2 et