Skip to content

Commit

Permalink
fix: deprecate and add use_nerd
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Aug 2, 2024
1 parent c27118b commit bbe032f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lua/lspsaga/codeaction/lightbulb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ local function render(bufnr)
local row = api.nvim_win_get_cursor(0)[1] - 1
local params = lsp.util.make_range_params()
params.context = {
diagnostics = lsp.diagnostic.get_line_diagnostics(bufnr),
diagnostics = vim.diagnostic.get(bufnr, { lnum = row + 1 }),
}

lsp.buf_request(bufnr, 'textDocument/codeAction', params, function(_, result, _)
Expand All @@ -72,7 +72,7 @@ local function render(bufnr)
end)
end

local timer = uv.new_timer()
local timer = assert(uv.new_timer())

local function update(buf)
timer:stop()
Expand Down
1 change: 1 addition & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local default_config = {
kind = nil,
button = { '', '' },
imp_sign = '󰳛 ',
use_nerd = true,
},
hover = {
max_width = 0.9,
Expand Down
13 changes: 12 additions & 1 deletion lua/lspsaga/lspkind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,19 @@ local function get_kind()
return kind
end

local kind = get_kind()
local kind = ui.use_nerd and get_kind() or {}

local function get_kind_icon(idx)
if not kind[idx] then
if ui.use_nerd then
vim.notify_once(('%d is missing in kind'):format(idx), vim.log.levels.WARN, {})
end
return { '', '' }
end
return { kind[idx][1], kind[idx][2] }
end

return {
kind = kind,
get_kind_icon = get_kind_icon,
}
9 changes: 5 additions & 4 deletions lua/lspsaga/symbol/outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local ot = {}
local api, fn = vim.api, vim.fn
---@diagnostic disable-next-line: deprecated
local uv = vim.version().minor >= 10 and vim.uv or vim.loop
local kind = require('lspsaga.lspkind').kind
local get_kind_icon = require('lspsaga.lspkind').get_kind_icon
local config = require('lspsaga').config
local util = require('lspsaga.util')
local symbol = require('lspsaga.symbol')
Expand Down Expand Up @@ -124,8 +124,9 @@ function ot:parse(symbols, curline)
end
end

local hl, icon = unpack(get_kind_icon(node.kind))
buf_set_extmark(self.bufnr, ns, row - 1, #indent - 2, {
virt_text = { { kind[node.kind][2], 'Saga' .. kind[node.kind][1] } },
virt_text = { { icon, 'Saga' .. hl } },
virt_text_pos = 'overlay',
})
local inlevel = 4 + 2 * level
Expand Down Expand Up @@ -214,7 +215,7 @@ function ot:collapse(node, curlnum)
local tmp = node.next

while tmp do
local icon = kind[tmp.value.kind][2]
local hl, icon = unpack(get_kind_icon(tmp.value.kind))
local level = tmp.value.inlevel
buf_set_lines(
self.bufnr,
Expand All @@ -229,7 +230,7 @@ function ot:collapse(node, curlnum)
tmp.value.expand = true
end
buf_set_extmark(self.bufnr, ns, row, level - 2, {
virt_text = { { icon, 'Saga' .. kind[tmp.value.kind][1] } },
virt_text = { { icon, 'Saga' .. hl } },
virt_text_pos = 'overlay',
})
local has_child = tmp.next and tmp.next.value.inlevel > level
Expand Down
9 changes: 4 additions & 5 deletions lua/lspsaga/symbol/winbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local config = require('lspsaga').config.symbol_in_winbar
local ui = require('lspsaga').config.ui
local util = require('lspsaga.util')
local symbol = require('lspsaga.symbol')
local kind = require('lspsaga.lspkind').kind
local get_kind_icon = require('lspsaga.lspkind').get_kind_icon

local function bar_prefix()
return {
Expand All @@ -23,7 +23,7 @@ local function path_in_bar(buf)
local items = {}
local folder
if ui.foldericon then
folder = kind[302][2]
folder = get_kind_icon(302)[2]
end

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

local function insert_elements(buf, node, elements)
if config.hide_keyword and symbol:node_is_keyword(buf, node) then
return
end
local type = kind[node.kind][1]
local icon = kind[node.kind][2]
local type, icon = unpack(get_kind_icon(node.kind))
local bar = bar_prefix()
if node.name:find('%%') then
node.name = stl_escape(node.name)
Expand Down

1 comment on commit bbe032f

@gregorias
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit introduced #1478.

Please sign in to comment.