j-hui / fidget.nvim

💫 Extensible UI for Neovim notifications and LSP progress messages.
MIT License
2.01k stars 58 forks source link

Updating config from legacy config to v1.4 #247

Open daUnknownCoder opened 5 months ago

daUnknownCoder commented 5 months ago

I m way back and using the old config, and there are some options such as poll_rate which went over my head and there are a few missing options...

this is my feature ~rich~ old config:

return {
  "j-hui/fidget.nvim",
  event = "LspAttach",
  config = function()
    local icons_ok, icons = pcall(require, "NeutronVim.core.icons")
    if not icons_ok then
      print("Unable to import icons!")
    end
    local fidget_status_ok, fidget = pcall(require, "fidget")
    if not fidget_status_ok then
      print("fidget not found!")
    end
    fidget.setup({
      text = {
        --stylua: ignore
        spinner = { "⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾" },
        done = icons.ui.Check .. "Successfully Initialized:",
        commenced = icons.ui.CircleSmallEmpty, -- CircleSmallEmpty = "○ ",
        completed = icons.ui.CircleSmall, -- CircleSmall = "● ",
      },
      timer = {
        spinner_rate = 200,
        fidget_decay = 3000,
        task_decay = 3000,
      },
      window = {
        relative = "editor",
        blend = 0,
        border = "rounded",
      },
      debug = {
        logging = true,
        strict = true,
      },
    })
  end,
  lazy = true,
}

so can you pls help me?

j-hui commented 5 months ago

Roughly speaking:

The config seems much more complicated now because it allows for much more fine-grained configuration, and the usage of Fidget as a UI for more things than just LSP progress notifications (e.g., as the default vim.notify backend). Unfortunately this means some options are buried deeper, but that's the cost of flexibility (which you might not get the benefit of, but I hope you do through exploring some of the more recent features 🙂).

A couple more things:

daUnknownCoder commented 5 months ago

text.spinner => progress.display.progress_icon; you can just use the existing "dots_negative" pattern

if you see my config, you might notice the pattern is _dotspositive so if you might add that ... and if not can i pass a table as i used to?

I don't recommend lazy-loading Fidget on the LspAttach event since it is supposed to be used for more than just LSP.

Earlier it was just used for LSP so...

You shouldn't need to guard the require calls with pcall if dependencies are managed correct

every plugin i use has this should i replace with barren requires? does it tend to increase startuptime?

alright ig moving from legacy to upstream has its consequences and i have to spend some hours reconfiguring stuff...

j-hui commented 4 months ago

Sorry for not responding sooner, a lot of stuff came up.

if you see my config, you might notice the pattern is dots_positive so if you might add that ... and if not can i pass a table as i used to?

You can certainly customize this, though admittedly the configuration interface is not very user-friendly. I'm working on improving the situation in #251 but it's still a work in progress. The changes I might not be backwards compatible, so I'll refrain from giving concrete instructions lest it break imminently.

Earlier it was just used for LSP so...

I understand, but my recommendation applies to Fidget as it is written now, which handles more than LSP progress.

every plugin i use has this should i replace with barren requires? does it tend to increase startuptime?

I'm not sure about pcall's effect on startuptime---you will need to benchmark this---but that's not my point. Rather, my point is, if you're going to catch an error, you should probably handle it. That's not what you're doing---you just print a message and continue execution, so it will still crash later.

alright ig moving from legacy to upstream has its consequences and i have to spend some hours reconfiguring stuff...

Yeah, sorry. I promise I'm not just introducing breaking changes to make your life difficult, but please understand that spending hours configuring stuff comes with the territory, at least in my view.

daUnknownCoder commented 4 months ago

Yeah, sorry. I promise I'm not just introducing breaking changes to make your life difficult, but please understand that spending hours configuring stuff comes with the territory, at least in my view.

oh i never was complaining dont take it that way, i was just a little busy myself making my neovim distro... contributing to open source itself is a breaking change from closed source sh!t (imo)

if you're going to catch an error, you should probably handle it.

so are you saying me to do something like this? :

local status_ok, fidget = pcall(require, "fidget")
if not status_ok then
  print("fidget not found")
else
  -- my config
end

is this what you are asking me?

j-hui commented 4 months ago

is this what you are asking me?

Not really. My suggestion is much simpler:

local fidget = require("fidget")
local icons = require("NeutronVim.core.icons")

fidget.setup(--[[ your config ]])

If require fails it will complain loudly and throw an error. I'm suggesting there's no point pcalling around this behavior because this is the behavior you want: Fidget, the icons pack, and Lazy (used to download Fidget) are all part of your distribution, so none of them should be missing. And if they are missing for some reason, you should throw an ugly error to prevent yourself from releasing this error as part of your distribution.

vuxuanhungg commented 4 months ago
  • I don't recommend lazy-loading Fidget on the LspAttach event since it is supposed to be used for more than just LSP.

For someone obsessed with lazy-loading and low startup time, which events do you recommend for Fidget? Could it be "BufReadPre" and "BufNewFile"? As a sidenote, I used to set it to "LspAttach" on neovim v0.9.5 and occasionally I encoutered fidget errors on quiting neovim. I haven't tried that on v0.10 though.

daUnknownCoder commented 4 months ago
  • I don't recommend lazy-loading Fidget on the LspAttach event since it is supposed to be used for more than just LSP.

For someone obsessed with lazy-loading and low startup time, which events do you recommend for Fidget? Could it be "BufReadPre" and "BufNewFile"? As a sidenote, I used to set it to "LspAttach" on neovim v0.9.5 and occasionally I encoutered fidget errors on quiting neovim. I haven't tried that on v0.10 though.

i use VeryLazy