Open chilljalapeno opened 8 months ago
Hey, does this flutter log go to a common buffer or to the quickfix?
from what I can see and research it is a normal buffer , as the developer says here. https://github.com/akinsho/flutter-tools.nvim/issues/137#issuecomment-1059227705
Update: The plugin now colorizes the output fine but I can not get rid of the ansicodes, no matter how I try.
vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = "__FLUTTER_DEV_LOG__",
callback = function()
vim.o.modifiable = true
require("baleia")
.setup({ log = "DEBUG", strip_ansi_codes = false, line_starts_at = 9 })
.automatically(vim.fn.bufnr(vim.fn.expand("%")))
vim.o.modifiable = false
end,
})
Ahh, I see it was not modifiable before. I'm sorry for taking so long to answer you, I was on holidays.
Try setting strip_ansi_codes
to true
(or simply removing it since true
is the default value)
If it does not work please share the logs
Oh, I see you are creating a new instance of baleia every time you enter the buffer. It would be better if you created the baleia table only once, outside of the event, and then just use it on the event
Hi, I have followed your advice and I get colors in the buffer but it still does not strip the ansi_codes, and the output is not colored correctly.
local baleia = require("baleia").setup({ line_starts_at = 6 })
vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = "__FLUTTER_DEV_LOG__",
callback = function()
vim.o.modifiable = true
baleia.automatically(vim.fn.bufnr(vim.fn.expand("%")))
vim.o.modifiable = false
end,
})
Could you please share some logs?
vim.g.baleia = require("baleia").setup({ log = "INFO", line_starts_at = 6 })
vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = "__FLUTTER_DEV_LOG__",
callback = function()
vim.o.modifiable = true
vim.g.baleia.automatically(vim.api.nvim_get_current_buf())
vim.o.modifiable = false
end,
})
vim.api.nvim_create_user_command("BaleiaLogs", vim.g.baleia.logger.show, { bang = true })
just run BaleiaLogs
I get a lot of these errors each time the FLUTTER_DEV_LOG changes ERROR vim.api.nvim_buf_set_text | { | params = { | buffer = 157, | end_col = 7, | end_row = 66, | lines = { "Exited." }, | start_col = 0, | start_row = 66 | }, | result = "Buffer is not 'modifiable'" | } This is what I get for now, furthermore, something weird happens again. I am using https://github.com/Pheon-Dev/buffalo-nvim to switch my buffers and for some reason if I run baleia I get an error when I try to use it.
I think I understand what is going on: vim.g.baleia.automatically
register an event that colorizes and strips ansi codes, but this event is probably triggered after you set the buffer as non modifiable. Could you please try again but without vim.o.modifiable = false
ERROR vim.api.nvim_buf_set_text
| {
| params = {
| buffer = 146,
| end_col = 46,
| end_row = 161,
| lines = { "[log] ⛔ Login Form is invalid" },
| start_col = 0,
| start_row = 161
| },
| result = "Buffer is not 'modifiable'"
| }
This is what I get now, somehow it does not set my start_col, sorry for the late response, and thank you for taking the time to help me out. Removing the vim.o.modifiable = false
fixes my problem with buffalo-nvim though
Yeah, I think your flutter plugin is setting the modifiable option later on. Are you able to configure it so it does not set the buffer as non-modifiable? If you think about it, the flutter plugin does not want/allow other plugins to touch the buffer... why?
Hi, I am using another plugin akinsho/flutter-tools and I am trying to colorize the logs. I have tried to configure your plugin but I can't seem to make it work. I have seen a similar issue but it has been inactive for quite some time now.
This is the most I could do. I am using LazyVim configuration and here is the autocommand
that I have set that does not seem to work at all. The above screenshot is made by using
lua lua require('baleia').setup({log ="DEBUG"}).automatically(vim.fn.bufnr(vim.fn.expand('%')))
. I have tried looking up for logs but there are none.