Skip to content

Commit 4e6531d

Browse files
authored
lsp: use vim.tbl_isempty to check sign (neovim#12190)
ref: neovim#12164 fix neovim#12201 sign_getdefined() returns a list, {} if the sign is not defined.
1 parent 9d0222e commit 4e6531d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

runtime/lua/vim/lsp.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,21 +1017,18 @@ function lsp.get_log_path()
10171017
return log.get_filename()
10181018
end
10191019

1020-
local function define_default_sign(name, properties)
1021-
if not vim.fn.sign_getdefined(name) then
1022-
vim.fn.sign_define(name, properties)
1023-
end
1024-
end
1025-
10261020
-- Define the LspDiagnostics signs if they're not defined already.
1027-
local function define_default_lsp_diagnostics_signs()
1021+
do
1022+
local function define_default_sign(name, properties)
1023+
if vim.tbl_isempty(vim.fn.sign_getdefined(name)) then
1024+
vim.fn.sign_define(name, properties)
1025+
end
1026+
end
10281027
define_default_sign('LspDiagnosticsErrorSign', {text='E', texthl='LspDiagnosticsError', linehl='', numhl=''})
10291028
define_default_sign('LspDiagnosticsWarningSign', {text='W', texthl='LspDiagnosticsWarning', linehl='', numhl=''})
10301029
define_default_sign('LspDiagnosticsInformationSign', {text='I', texthl='LspDiagnosticsInformation', linehl='', numhl=''})
10311030
define_default_sign('LspDiagnosticsHintSign', {text='H', texthl='LspDiagnosticsHint', linehl='', numhl=''})
10321031
end
10331032

1034-
define_default_lsp_diagnostics_signs()
1035-
10361033
return lsp
10371034
-- vim:sw=2 ts=2 et

src/nvim/eval/funcs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8489,6 +8489,7 @@ static void f_sign_define(typval_T *argvars, typval_T *rettv, FunPtr fptr)
84898489
xfree(linehl);
84908490
xfree(text);
84918491
xfree(texthl);
8492+
xfree(numhl);
84928493
}
84938494

84948495
/// "sign_getdefined()" function

0 commit comments

Comments
 (0)