j-hui / fidget.nvim

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

Disable linting and format messages #198

Closed bhattkacode closed 2 months ago

bhattkacode commented 8 months ago

When I open a python file: image

and when I type somehthing: image So this message keeps popping up when I type anything new It also shows a message when I format.(format: autopep8)

I want to disable just these linting and format messages (but keep the messages that comes up when i open a file) and I can't see any option for that(setting suppres on insert just shows the messages after I go to normal mode)

Note that this only happens in python files. In lua files, it shows message once when opened

j-hui commented 8 months ago

This only happens in Python because this is the behavior of pylsp.

With the update_hook feature I pushed recently, you should be able to selectively hide notifications based on their content, e.g.,

{ -- In options table:
  progress = {
    display = {
      overrides = {
        pylsp = {
          update_hook = function(item)
            require("fidget.notification").set_content_key(item)
            if item.hidden == nil and string.match(item.annote, "lint: ") then
              -- Hide any items whose annotation contains "lint: "
              item.hidden = true
            end
          end,
        },
      },
    },
  },
}

Note that you can make the string matching logic whatever you want it to be (and also check more things other than item.annote).

However, this will also suppress the notifications that appear on startup. I have a few ideas for implementing that logic, such as checking how long it has been since attaching an LSP client, or checking whether you're in insert mode, but I'm not entirely sure what works best for you.

j-hui commented 2 months ago

I just pushed a feature that should make this simpler: a01443a

You should just be able to add a filter function to your progress.ignore, something like this:

progress.ignore = { -- NOTE: this is short-hand, not the actual syntax for specifying a nested table
  function(msg)
    return msg.lsp_client.name == "pylsp" and string.find(msg.title, "lint:")
  end,
}

I'm going to close this issue now since I think that is a satisfying solution. Feel free to re-open if you feel otherwise!