mirror of
https://github.com/nvimdev/lspsaga.nvim.git
synced 2024-09-16 14:24:08 +02:00
fix #375
This commit is contained in:
parent
afd297ca6c
commit
16f1007df5
8 changed files with 88 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
|||
column_width = 120
|
||||
column_width = 100
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
|
|
|
@ -58,9 +58,16 @@ function def.preview_definition(timeout_ms)
|
|||
start_line = range.start.line
|
||||
end
|
||||
|
||||
local content =
|
||||
vim.api.nvim_buf_get_lines(bufnr, start_line, range['end'].line + 1 + config.max_preview_lines, false)
|
||||
content = vim.list_extend({ config.definition_preview_icon .. 'Definition Preview: ' .. short_name, '' }, content)
|
||||
local content = vim.api.nvim_buf_get_lines(
|
||||
bufnr,
|
||||
start_line,
|
||||
range['end'].line + 1 + config.max_preview_lines,
|
||||
false
|
||||
)
|
||||
content = vim.list_extend(
|
||||
{ config.definition_preview_icon .. 'Definition Preview: ' .. short_name, '' },
|
||||
content
|
||||
)
|
||||
|
||||
local opts = {
|
||||
relative = 'cursor',
|
||||
|
@ -112,8 +119,13 @@ function def.scroll_in_def_preview(direction)
|
|||
if not has_preview then
|
||||
return
|
||||
end
|
||||
local current_win_lnum = scroll_in_win(pdata[1], direction, pdata[2], config.max_preview_lines, pdata[4])
|
||||
api.nvim_buf_set_var(0, 'lspsaga_def_preview', { pdata[1], current_win_lnum, config.max_preview_lines, pdata[4] })
|
||||
local current_win_lnum =
|
||||
scroll_in_win(pdata[1], direction, pdata[2], config.max_preview_lines, pdata[4])
|
||||
api.nvim_buf_set_var(
|
||||
0,
|
||||
'lspsaga_def_preview',
|
||||
{ pdata[1], current_win_lnum, config.max_preview_lines, pdata[4] }
|
||||
)
|
||||
end
|
||||
|
||||
return def
|
||||
|
|
|
@ -141,7 +141,9 @@ local function show_diagnostics(opts, get_diagnostics)
|
|||
-- diagnostic window
|
||||
local has_var, diag_float_winid = pcall(api.nvim_buf_get_var, 0, 'diagnostic_float_window')
|
||||
if has_var and diag_float_winid ~= nil then
|
||||
if api.nvim_win_is_valid(diag_float_winid[1]) and api.nvim_win_is_valid(diag_float_winid[2]) then
|
||||
if
|
||||
api.nvim_win_is_valid(diag_float_winid[1]) and api.nvim_win_is_valid(diag_float_winid[2])
|
||||
then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -165,7 +167,8 @@ local function show_diagnostics(opts, get_diagnostics)
|
|||
return
|
||||
end
|
||||
|
||||
local sorted_diagnostics = severity_sort and table.sort(diagnostics, comp_severity_asc) or diagnostics
|
||||
local sorted_diagnostics = severity_sort and table.sort(diagnostics, comp_severity_asc)
|
||||
or diagnostics
|
||||
|
||||
local severities = vim.diagnostic.severity
|
||||
for i, diagnostic in ipairs(sorted_diagnostics) do
|
||||
|
|
|
@ -63,7 +63,7 @@ function Finder:word_symbol_kind()
|
|||
local method = 'textDocument/documentSymbol'
|
||||
if client ~= nil then
|
||||
local params = { textDocument = lsp.util.make_text_document_params() }
|
||||
local results = lsp.buf_request_sync(current_buf, method, params, 500)
|
||||
local results = lsp.buf_request_sync(current_buf, method, params, 800)
|
||||
if results ~= nil then
|
||||
result = results[client].result
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ function Finder:word_symbol_kind()
|
|||
end
|
||||
|
||||
local index = 0
|
||||
if next(result) ~= nil then
|
||||
if result ~= nil and next(result) ~= nil then
|
||||
for i, val in pairs(result) do
|
||||
if val.name:find(current_word) then
|
||||
index = i
|
||||
|
@ -118,7 +118,9 @@ function Finder:create_finder_contents(result, method, root_dir)
|
|||
-- remove definition in references
|
||||
if self.short_link ~= nil and self.short_link[3] ~= nil then
|
||||
local start = result[1].range.start
|
||||
if start.line == self.short_link[3].row - 1 and start.character == self.short_link[3].col - 1 then
|
||||
if
|
||||
start.line == self.short_link[3].row - 1 and start.character == self.short_link[3].col - 1
|
||||
then
|
||||
table.remove(result, 1)
|
||||
end
|
||||
end
|
||||
|
@ -183,7 +185,12 @@ function Finder:create_finder_contents(result, method, root_dir)
|
|||
target_lnum = target_lnum + 1
|
||||
-- max_preview_lines
|
||||
local max_preview_lines = config.max_preview_lines
|
||||
local lines = api.nvim_buf_get_lines(bufnr, range.start.line - 0, range['end'].line + 1 + max_preview_lines, false)
|
||||
local lines = api.nvim_buf_get_lines(
|
||||
bufnr,
|
||||
range.start.line - 0,
|
||||
range['end'].line + 1 + max_preview_lines,
|
||||
false
|
||||
)
|
||||
|
||||
self.short_link[target_lnum] = {
|
||||
link = link,
|
||||
|
@ -372,8 +379,22 @@ function Finder:lsp_finder_highlight()
|
|||
api.nvim_buf_add_highlight(self.bufnr, -1, 'Definitions', 0, #icons.def, #icons.def + def_len)
|
||||
api.nvim_buf_add_highlight(self.bufnr, -1, 'DefinitionCount', 0, #icons.def + def_len, -1)
|
||||
api.nvim_buf_add_highlight(self.bufnr, -1, 'ReferencesIcon', 3 + def_uri_count, 0, #icons.ref)
|
||||
api.nvim_buf_add_highlight(self.bufnr, -1, 'References', 3 + def_uri_count, #icons.ref, #icons.ref + ref_len)
|
||||
api.nvim_buf_add_highlight(self.bufnr, -1, 'ReferencesCount', 3 + def_uri_count, #icons.ref + ref_len, -1)
|
||||
api.nvim_buf_add_highlight(
|
||||
self.bufnr,
|
||||
-1,
|
||||
'References',
|
||||
3 + def_uri_count,
|
||||
#icons.ref,
|
||||
#icons.ref + ref_len
|
||||
)
|
||||
api.nvim_buf_add_highlight(
|
||||
self.bufnr,
|
||||
-1,
|
||||
'ReferencesCount',
|
||||
3 + def_uri_count,
|
||||
#icons.ref + ref_len,
|
||||
-1
|
||||
)
|
||||
end
|
||||
|
||||
function Finder:set_cursor()
|
||||
|
@ -519,7 +540,8 @@ function Finder:scroll_in_preview(direction)
|
|||
end
|
||||
|
||||
local current_win_lnum, last_lnum = pdata[2], pdata[3]
|
||||
current_win_lnum = scroll_in_win(pdata[1], direction, current_win_lnum, last_lnum, config.max_preview_lines)
|
||||
current_win_lnum =
|
||||
scroll_in_win(pdata[1], direction, current_win_lnum, last_lnum, config.max_preview_lines)
|
||||
api.nvim_win_set_var(0, 'saga_finder_preview', { pdata[1], current_win_lnum, last_lnum })
|
||||
end
|
||||
|
||||
|
|
|
@ -75,12 +75,17 @@ function hover.scroll_in_hover(direction)
|
|||
if not has_hover_win then
|
||||
return
|
||||
end
|
||||
local hover_win, height, current_win_lnum, last_lnum = hover_data[1], hover_data[2], hover_data[3], hover_data[4]
|
||||
local hover_win, height, current_win_lnum, last_lnum =
|
||||
hover_data[1], hover_data[2], hover_data[3], hover_data[4]
|
||||
if not api.nvim_win_is_valid(hover_win) then
|
||||
return
|
||||
end
|
||||
current_win_lnum = action.scroll_in_win(hover_win, direction, current_win_lnum, last_lnum, height)
|
||||
api.nvim_win_set_var(0, 'lspsaga_hoverwin_data', { hover_win, height, current_win_lnum, last_lnum })
|
||||
api.nvim_win_set_var(
|
||||
0,
|
||||
'lspsaga_hoverwin_data',
|
||||
{ hover_win, height, current_win_lnum, last_lnum }
|
||||
)
|
||||
end
|
||||
|
||||
return hover
|
||||
|
|
|
@ -36,8 +36,12 @@ function implement.lspsaga_implementation(timeout_ms)
|
|||
start_line = range.start.line
|
||||
end
|
||||
|
||||
local content =
|
||||
vim.api.nvim_buf_get_lines(bufnr, start_line, range['end'].line + 1 + config.max_preview_lines, false)
|
||||
local content = vim.api.nvim_buf_get_lines(
|
||||
bufnr,
|
||||
start_line,
|
||||
range['end'].line + 1 + config.max_preview_lines,
|
||||
false
|
||||
)
|
||||
content = vim.list_extend({ config.definition_preview_icon .. 'Lsp Implements', '' }, content)
|
||||
local filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
|
||||
|
||||
|
@ -91,6 +95,10 @@ function implement.scroll_in_implement(direction)
|
|||
return
|
||||
end
|
||||
current_win_lnum = action.scroll_in_win(hover_win, direction, current_win_lnum, last_lnum, height)
|
||||
api.nvim_win_set_var(0, 'lspsaga_implement_preview', { hover_win, height, current_win_lnum, last_lnum })
|
||||
api.nvim_win_set_var(
|
||||
0,
|
||||
'lspsaga_implement_preview',
|
||||
{ hover_win, height, current_win_lnum, last_lnum }
|
||||
)
|
||||
end
|
||||
return implement
|
||||
|
|
|
@ -62,7 +62,15 @@ local function apply_syntax_to_region(ft, start, finish)
|
|||
if not pcall(vim.cmd, string.format('syntax include %s syntax/%s.vim', lang, ft)) then
|
||||
return
|
||||
end
|
||||
vim.cmd(string.format('syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s', name, start, finish + 1, lang))
|
||||
vim.cmd(
|
||||
string.format(
|
||||
'syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s',
|
||||
name,
|
||||
start,
|
||||
finish + 1,
|
||||
lang
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
local function focusable_preview(unique_name, fn)
|
||||
|
|
|
@ -361,7 +361,15 @@ function M.fancy_floating_markdown(contents, opts)
|
|||
if not pcall(vim.cmd, string.format('syntax include %s syntax/%s.vim', lang, ft)) then
|
||||
return
|
||||
end
|
||||
vim.cmd(string.format('syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s', name, start, finish + 1, lang))
|
||||
vim.cmd(
|
||||
string.format(
|
||||
'syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s',
|
||||
name,
|
||||
start,
|
||||
finish + 1,
|
||||
lang
|
||||
)
|
||||
)
|
||||
end
|
||||
-- Previous highlight region.
|
||||
-- TODO(ashkan): this wasn't working for some reason, but I would like to
|
||||
|
|
Loading…
Reference in a new issue