stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.73k stars 32 forks source link

Ability to use the default `vim.ui.input` based on filetype? #29

Closed axieax closed 2 years ago

axieax commented 2 years ago

Following https://github.com/kyazdani42/nvim-tree.lua/pull/1097, vim.ui.input with the popup doesn't look very good on top of a NvimTree buffer. Is it possible to be able to specify default filetypes / conditions for disabling this UI tweak (e.g. just for NvimTree)?

stevearc commented 2 years ago

Tweaking the appearance for a specific filetype would be much easier than disabling it, so before I add that functionality I'd like to see if there's a way we can make it look better. What is currently the issue? Is it the placement? That's fairly easy to adjust. For example, to place it in the lower left of the editor:

require("dressing").setup({
  input = {
    override = function(opt)
      if vim.api.nvim_buf_get_option(0, "filetype") == "NvimTree" then
        opt.anchor = "SW"
        opt.col = 1
        opt.row = vim.o.lines - vim.o.cmdheight - 1
        opt.relative = "editor"
      end
    end,
  },
})
axieax commented 2 years ago

I mean the default vim.ui.input is in the command mode bar (so no popup is what I'm trying to achieve).

stevearc commented 2 years ago

I've added the ability to change enabled on the fly using get_config

require("dressing").setup({
  input = {
    get_config = function()
      if vim.api.nvim_buf_get_option(0, "filetype") == "NvimTree" then
        return { enabled = false }
      end
    end,
  },
})
axieax commented 2 years ago

Works like a charm! Thanks for spending the extra time to implement this :))