Closed ternenges closed 2 years ago
The same issue was happening to me whenever I saved a file. The suggested workaround solved it for me also.
I ran an update today then i got this
then this on buffline
i removed ui folder from plugins intallation path then cloned this repo to replace it. now every thing i alright
[ QUESTION ] is it possible to modify status line icons without modifying the source.
I have come to notice that doing this will break down nvchad so I resolved it by adding this field to
plugins/init.lua ->
[NvChad/ui ] = { ... commit = "6d18c5482b30bbcb02ac20049f2b0b67be9ea164", ... }
this will will lock to that particular head .
ok got the culprit, this is causing it
-- check for same buffer names under different dirs
for _, value in ipairs(vim.t.bufs) do
if name == fn.fnamemodify(api.nvim_buf_get_name(value), ":t") and value ~= bufnr then
name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
end
end
@siduck You can adopt my method
and check :messages
why buflist
function is called more times if open more files
@siduck You can adopt my method and check :messages why
buflist
function is called more times if open more files
i dont understand your method!!
i said ,you can print the method result first . the method just records duplicate values
the reason I wrote it this way, because bufferflist
function is called more times
i said ,you can print the method result first . the method just records duplicate values
that just prints stuff to the cmdline area
check :messages
ok can u provide a git diff of the changes that could be done now, your way also contains other un-needed stuffs too so i cant read the code properly
+ local buf = vim.g.bufnrs[name]
+ if not buf then
+ vim.g.bufnrs[name] = {id = bufnr, num = 0}
+ elseif buf.id ~= bufnr and buf.num == 0 then
+ buf.num = buf.num + 1
+ elseif buf.num > 0 then
+ name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
+ end
new_cmd("Tbufclose", function()
+ vim.g.bufnrs = {}
require("core.utils").close_buffer()
end, {})
now bufferline doesnt start
hold on ,i will check that
sorry, forgot init bufnrs table, check :messages, hold on ,i wll rewrite it .
You can't use vim global here, just use local bufnrs:
local buf = bufnrs[name]
if not buf then
bufnrs[name] = {id = bufnr, dup = false}
elseif buf.id ~= bufnr and not buf.dup then
buf.dup = true
elseif buf.dup then
name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
end
+local bufnrs = {}
new_cmd("Tbufclose", function()
+ bufnrs = {}
require("core.utils").close_buffer()
end, {})
ok error is gone but when there's just one buffer, it doesnt update the value
i said before , map <leader>x
to Tbufclose
ok done, now the dirname updates only when i cycle through buffer or when i open telescope
even tho i redrawtabline
i dont understand your mean ,i just test it by opening the same name files using nvim-tree, can you give me your reproduce steps ?
oh ,i got it ,i will check that
I already know why that is,
This is because this bufferlist
function is only called once, when the file is opened from telescope result list
i will check why that is
I already know why that is, This is because this
bufferlist
function is only called once, when the file is opened from telescope result list
maybe, then why did my method worked? :thinking:
only such:
elseif buf.id ~= bufnr and not buf.dup then
buf.dup = true
+ name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
after going to next buffer
i know , why is your method working?
i know , why is your method working?
idk :thinking: , try it yourself
@siduck look this: , i open three files , and print open
at bufferlist
function top,i dont cycle through buffer and dont open telescope, i think it should print two or three open
.And your method works is because vim.t.bufs contains all buffer ids
@tomasky what to do then :thinking:
my method isnt that heavy, it will stop looping when the result is found but it breaks whole bufferline when format on save
no, you need to break foreach , because there may be three of the same file names, i dont know why the bufferlist function is called only once when opening from telescope. if it is called twice ,my method will work
no, you need to break foreach , because there may be three of the same file names, i dont know why the bufferlist function is called only once when opening from telescope. if it is called twice ,my method will work
3 files will still work with my method, try
i know it works, but you need to break foreach
i know it works, but you need to break foreach
yes we need a working alternative for it
why i cant reproduce the problem of your method?
why i cant reproduce the problem of your method?
add this in your null-ls setup and try to save
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()"
end
end,
ok fixed it
for _, nr in ipairs(vim.t.bufs) do
if name == fn.fnamemodify(fn.bufname(nr), ":t") and nr ~= bufnr then
name = fn.bufname(bufnr):match "[^/]*/?[^/]*$"
end
end
i used bufname function instead of api_nvim_get_buf_name
for _, nr in ipairs(vim.t.bufs) do
if name == fn.fnamemodify(fn.bufname(nr), ":t") and nr ~= bufnr then
name = fn.bufname(bufnr):match "[^/]*/?[^/]*$"
+ break
end
end
for _, value in ipairs(vim.t.bufs) do if name == fn.fnamemodify(api.nvim_buf_get_name(value), ":t") and value ~= bufnr then name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$" end end
yea thats better
@tomasky invalid bufname is causing this, whenever formatting lsp stuff does some shady stuff in the background
not sure how fn.bufname handles this
my method can work, but needs more refactoring of file tabufline/modules.lua, also because i dont known when is the bufferlist
called . I am troubled by this problem
my method can work, but needs more refactoring of file tabufline/modules.lua, also because i dont known when is the
bufferlist
called . I am troubled by this problem
it needs more work, u told me to clear the buf table in tbufclose command but if i close buffers by clicking their close buttons then this wont work cuz they dont use tbufclose command at all, they use the core utils function directly
my method can work, but needs more refactoring of file tabufline/modules.lua, also because i dont known when is the
bufferlist
called . I am troubled by this problemit needs more work, u told me to clear the buf table in tbufclose command but if i close buffers by clicking their close buttons then this wont work cuz they dont use tbufclose command at all, they use the core utils function directly
yea, so i said , map <leader>x
to tbufclose
my method can work, but needs more refactoring of file tabufline/modules.lua, also because i dont known when is the
bufferlist
called . I am troubled by this problemit needs more work, u told me to clear the buf table in tbufclose command but if i close buffers by clicking their close buttons then this wont work cuz they dont use tbufclose command at all, they use the core utils function directly
yea, so i said , map
<leader>x
totbufclose
that will work for current buffer only, if i click other buffer's close btn then it wont work and those who lazyload tbufline wont have tbufclose command unless tabufline starts
both work but which is faster? @max397574 @tomasky
for _, nr in ipairs(vim.t.bufs) do
if name == fn.fnamemodify(fn.bufname(nr), ":t") and nr ~= bufnr then
name = fn.bufname(bufnr):match "[^/]*/?[^/]*$"
break
end
end
for _, value in ipairs(vim.t.bufs) do
if api.nvim_buf_is_valid(value) then
if name == fn.fnamemodify(api.nvim_buf_get_name(value), ":t") and value ~= bufnr then
name = api.nvim_buf_get_name(bufnr):match "[^/]*/?[^/]*$"
break
end
end
end
Why didn't the first one check nvim_buf_is_valid
, if the buf not valid , what is its significance
Why didn't the first one check
nvim_buf_is_valid
, if the buf not valid , what is it significance
i asked someone and he told me that it just returns some empty string
I ran an update today then i got this
then this on buffline
i removed ui folder from plugins intallation path then cloned this repo to replace it. now every thing i alright
[ QUESTION ] is it possible to modify status line icons without modifying the source.