Skip to content

Commit bbe032f

Browse files
committed
fix: deprecate and add use_nerd
1 parent c27118b commit bbe032f

5 files changed

Lines changed: 24 additions & 12 deletions

File tree

lua/lspsaga/codeaction/lightbulb.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ local function render(bufnr)
5656
local row = api.nvim_win_get_cursor(0)[1] - 1
5757
local params = lsp.util.make_range_params()
5858
params.context = {
59-
diagnostics = lsp.diagnostic.get_line_diagnostics(bufnr),
59+
diagnostics = vim.diagnostic.get(bufnr, { lnum = row + 1 }),
6060
}
6161

6262
lsp.buf_request(bufnr, 'textDocument/codeAction', params, function(_, result, _)
@@ -72,7 +72,7 @@ local function render(bufnr)
7272
end)
7373
end
7474

75-
local timer = uv.new_timer()
75+
local timer = assert(uv.new_timer())
7676

7777
local function update(buf)
7878
timer:stop()

lua/lspsaga/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ local default_config = {
1515
kind = nil,
1616
button = { '', '' },
1717
imp_sign = '󰳛 ',
18+
use_nerd = true,
1819
},
1920
hover = {
2021
max_width = 0.9,

lua/lspsaga/lspkind.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,19 @@ local function get_kind()
7171
return kind
7272
end
7373

74-
local kind = get_kind()
74+
local kind = ui.use_nerd and get_kind() or {}
75+
76+
local function get_kind_icon(idx)
77+
if not kind[idx] then
78+
if ui.use_nerd then
79+
vim.notify_once(('%d is missing in kind'):format(idx), vim.log.levels.WARN, {})
80+
end
81+
return { '', '' }
82+
end
83+
return { kind[idx][1], kind[idx][2] }
84+
end
7585

7686
return {
7787
kind = kind,
88+
get_kind_icon = get_kind_icon,
7889
}

lua/lspsaga/symbol/outline.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local ot = {}
22
local api, fn = vim.api, vim.fn
33
---@diagnostic disable-next-line: deprecated
44
local uv = vim.version().minor >= 10 and vim.uv or vim.loop
5-
local kind = require('lspsaga.lspkind').kind
5+
local get_kind_icon = require('lspsaga.lspkind').get_kind_icon
66
local config = require('lspsaga').config
77
local util = require('lspsaga.util')
88
local symbol = require('lspsaga.symbol')
@@ -124,8 +124,9 @@ function ot:parse(symbols, curline)
124124
end
125125
end
126126

127+
local hl, icon = unpack(get_kind_icon(node.kind))
127128
buf_set_extmark(self.bufnr, ns, row - 1, #indent - 2, {
128-
virt_text = { { kind[node.kind][2], 'Saga' .. kind[node.kind][1] } },
129+
virt_text = { { icon, 'Saga' .. hl } },
129130
virt_text_pos = 'overlay',
130131
})
131132
local inlevel = 4 + 2 * level
@@ -214,7 +215,7 @@ function ot:collapse(node, curlnum)
214215
local tmp = node.next
215216

216217
while tmp do
217-
local icon = kind[tmp.value.kind][2]
218+
local hl, icon = unpack(get_kind_icon(tmp.value.kind))
218219
local level = tmp.value.inlevel
219220
buf_set_lines(
220221
self.bufnr,
@@ -229,7 +230,7 @@ function ot:collapse(node, curlnum)
229230
tmp.value.expand = true
230231
end
231232
buf_set_extmark(self.bufnr, ns, row, level - 2, {
232-
virt_text = { { icon, 'Saga' .. kind[tmp.value.kind][1] } },
233+
virt_text = { { icon, 'Saga' .. hl } },
233234
virt_text_pos = 'overlay',
234235
})
235236
local has_child = tmp.next and tmp.next.value.inlevel > level

lua/lspsaga/symbol/winbar.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local config = require('lspsaga').config.symbol_in_winbar
33
local ui = require('lspsaga').config.ui
44
local util = require('lspsaga.util')
55
local symbol = require('lspsaga.symbol')
6-
local kind = require('lspsaga.lspkind').kind
6+
local get_kind_icon = require('lspsaga.lspkind').get_kind_icon
77

88
local function bar_prefix()
99
return {
@@ -23,7 +23,7 @@ local function path_in_bar(buf)
2323
local items = {}
2424
local folder
2525
if ui.foldericon then
26-
folder = kind[302][2]
26+
folder = get_kind_icon(302)[2]
2727
end
2828

2929
for item in util.path_itera(buf) do
@@ -91,16 +91,15 @@ end
9191
-- pylsp
9292
local function has_container(node, elements)
9393
local bar = bar_prefix()
94-
local type, icon = kind[5][1], kind[5][2]
94+
local type, icon = unpack(get_kind_icon(5))
9595
elements[#elements + 1] = string.format('%s%s#%s%s', bar.prefix, type, icon, node.containerName)
9696
end
9797

9898
local function insert_elements(buf, node, elements)
9999
if config.hide_keyword and symbol:node_is_keyword(buf, node) then
100100
return
101101
end
102-
local type = kind[node.kind][1]
103-
local icon = kind[node.kind][2]
102+
local type, icon = unpack(get_kind_icon(node.kind))
104103
local bar = bar_prefix()
105104
if node.name:find('%%') then
106105
node.name = stl_escape(node.name)

0 commit comments

Comments
 (0)