Closed liuerfire closed 9 months ago
I'm getting the exact same error
I've got the same error and here is how I've solved it:
lualine_c = {
function()
local fn = vim.fn.expand('%:~:.')
if vim.startswith(fn, "jdt://") then
fn = string.sub(fn, 0, string.find(fn, "?") - 1)
end
if fn == '' then
fn = '[No Name]'
end
if vim.bo.modified then
fn = fn .. ' [+]'
end
if vim.bo.modifiable == false or vim.bo.readonly == true then
fn = fn .. ' [-]'
end
local tfn = vim.fn.expand('%')
if tfn ~= '' and vim.bo.buftype == '' and vim.fn.filereadable(tfn) == 0 then
fn = fn .. ' [New]'
end
return fn
end
},
For some reason writing the same logic in an fmt
function didn't prevent the error from happening.
@ramanenka I figured out why fmt
isn't working. What you get in that function is probably already shortened and looks like this:
j//c/j/j/N/%/h/k/.g/c/m/f/j/j/2/8/j/g/m/=/o/%%5C/WEB-INF%%5C/lib=/%%3Cjavax.persistence(NoResultException.class
So your prefix check doesn't even work in there.
Hi,
(I just encountered this issue. Took a quick peek at the code, so apologies if I'm incorrect).
Looks like there's already a check in-place to escape %
in filenames.
https://github.com/nvim-lualine/lualine.nvim/blob/4bfc6bc4f38355d570e56fed69e01c073d2b6a64/lua/lualine/components/filename.lua#L89
However, this seems to be an edge case trigged by the shorting_target
block.
https://github.com/nvim-lualine/lualine.nvim/blob/4bfc6bc4f38355d570e56fed69e01c073d2b6a64/lua/lualine/components/filename.lua#L95-L100
So, shouldn't this get fixed by simply moving that check after this block?
Thanks
I've got the same error and here is how I've solved it:
lualine_c = { function() local fn = vim.fn.expand('%:~:.') if vim.startswith(fn, "jdt://") then fn = string.sub(fn, 0, string.find(fn, "?") - 1) end if fn == '' then fn = '[No Name]' end if vim.bo.modified then fn = fn .. ' [+]' end if vim.bo.modifiable == false or vim.bo.readonly == true then fn = fn .. ' [-]' end local tfn = vim.fn.expand('%') if tfn ~= '' and vim.bo.buftype == '' and vim.fn.filereadable(tfn) == 0 then fn = fn .. ' [New]' end return fn end },
For some reason writing the same logic in an
fmt
function didn't prevent the error from happening.
I just had the same error, thanks for the this workaround fix probably it would be better to fix this issue in lualine I guess long term
I've got the same error and here is how I've solved it:
[snip]
For some reason writing the same logic in an
fmt
function didn't prevent the error from happening.
Thanks to your input, I was able to fix it using the fmt
parameter, without altering the already existing configuration nor the default behavior of lualine.
{
"filename",
path = 1,
symbols = { modified = " ", readonly = " ", unnamed = " " },
--- @param str string
fmt = function(str)
--- @type string
local fn = vim.fn.expand("%:~:.")
if vim.startswith(fn, "jdt://") then
return fn:gsub("?.*$", "")
end
return str
end,
},
Self Checks
How to reproduce the problem
set
path
to any value (1, 2 or 3) except the default 0 in filename section.Install https://github.com/mfussenegger/nvim-jdtls and jump to the definition of a class.
Expected behaviour
no errors
Actual behaviour
Aditional information
The full path of this file is: