Skip to content

Commit

Permalink
neovim 0.10 first line is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Nov 12, 2023
1 parent d2d64ec commit 1fba8f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions lua/lsp_signature/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,12 @@ helper.highlight_parameter = function(s, l)
end
if vim.fn.has('nvim-0.10') == 1 then
local lines = vim.api.nvim_buf_get_lines(_LSP_SIG_CFG.bufnr, 0, 3, false)
if lines[1]:find([[```]]) then -- it is strange that the first line is not signatures, it is ```language_id
if lines[1]:find([[```]]) then -- it is strange that the first line is not signatures, it is ```language_id
-- open_floating_preview changed display ```language_id
log("Check: first line is ```language_id, it may not be behavior of release version of nvim")
log("first two lines: ", lines)
log(
'Check: first line is ```language_id, it may not be behavior of release version of nvim'
)
log('first two lines: ', lines)
line = 1
end
end
Expand Down Expand Up @@ -753,7 +755,7 @@ end
helper.trim_empty_lines = function(lines)
local new_list = {}
for i, str in ipairs(lines) do
if str ~= "" and str then
if str ~= '' and str then
table.insert(new_list, str)
end
end
Expand All @@ -768,7 +770,7 @@ helper.get_mardown_syntax = function(lines)
return 'markdown'
end

function helper.try_trim_markdown_code_blocks(lines)
function helper.try_trim_markdown_code_blocks(lines)
local language_id = lines[1]:match('^```(.*)')
if language_id then
local has_inner_code_fence = false
Expand All @@ -789,7 +791,6 @@ end
return 'markdown'
end


local validate = vim.validate
local default_border = {
{ '', 'NormalFloat' },
Expand Down
6 changes: 3 additions & 3 deletions lua/lsp_signature/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ local function virtual_hint(hint, off_y)
pl = pl or ''
local pad = ''
local offset = r[2]
if _LSP_SIG_CFG.hint_inline() == false then
local inline_display = _LSP_SIG_CFG.hint_inline()
if inline_display == false then
local line_to_cursor_width = dwidth(line_to_cursor)
local pl_width = dwidth(pl)
if show_at ~= cur_line and line_to_cursor_width > pl_width + 1 then
Expand Down Expand Up @@ -200,8 +201,6 @@ local function virtual_hint(hint, off_y)
return -- no offset found
end
local vt = { pad .. _LSP_SIG_CFG.hint_prefix .. hint, _LSP_SIG_CFG.hint_scheme }
local inline_display = _LSP_SIG_CFG.hint_inline()
-- if inline_display then
if inline_display then
if type(inline_display) == 'boolean' then
inline_display = 'inline'
Expand All @@ -216,6 +215,7 @@ local function virtual_hint(hint, off_y)
{ -- Note: the vt was put after of cursor.
-- this seems eaiser to handle in the code also easy to read
virt_text_pos = inline_display,
-- virt_text_pos = 'right_align',
virt_text = { vt },
hl_mode = 'combine',
ephemeral = false,
Expand Down

0 comments on commit 1fba8f4

Please sign in to comment.