Code Monkey home page Code Monkey logo

dressing.nvim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dressing.nvim's Issues

Rename is not working as expected

I have a keymap set to <cmd>lua vim.lsp.buf.rename()<CR>. When I invoke it dressing shows the float input as expected. When I hit enter to make the rename it changes only the position where I invoked instead of all occurrences.

When I removed dressing and it went back to the traditional input method it worked as expected.

I don't know if it happens with all LSP servers, but I tested with rust.

Telescope doesn't show all items in selection menu

Describe the bug
The telescope front-end seems to omit one entry from the selection menu every time.

System information

  • OS: linux
  • Neovim version: NVIM v0.8.0-dev-910-gc086bf6079
  • Issue arises when using telescope for vim.ui.select
  • Dressing config:
 require('dressing').setup {
    input = {
        winblend = 0,
    },
}

Example

vim.ui.select({'Hello', 'World'}, {}, function () end)

Screenshots
image

Set `ui.select` window height according to number of items

Describe the bug
The select box is taking way more space that necessary.
It would be nice to have an option that sets the window height depending on how many items there are.

System information

  • OS: linux
  • Neovim version: v0.8.0-dev+468-ge694e5642
  • Builtin Backend

Screenshots
image

Incorrect title position with `vim.ui.input` inside command preview callback

Describe the bug
When using vim.ui.input inside a command preview callback, the window title is not immediately positioned at the correct position.

System information

  • OS: Linux
  • Neovim version: NVIM v0.8.0-dev-1020-gea10e0c10
  • Dressing config: not relevant

To Reproduce
Steps to reproduce the behavior:

  1. Define a user command such as the following which calls vim.ui.input inside the preview callback:
vim.api.nvim_create_user_command("X", function() end, {
  preview = function()
    vim.ui.input({}, function() end)
  end,
  nargs = 1,
  addr = "lines",
})
  1. Type :X. Notice how the title is positioned at the top left of the screen:
    image

  2. Type (space). The title has now moved to the correct position:
    image

Additional context
It seems like Nvim only executes one "step" of the window creation, while the last "step" of moving the title (which I believe is also a window) is scheduled to run later. Though I'm not exactly sure what causes this (probably somewhere in add_title_to_win).

Text Artifacts in Rename Window with Rust Attributes

Describe the bug

I just tried out dressing and I'm getting text artifacts in the rename window when the line above the to be renamed item has Rust attributes. See below for example code.

The green text below is the artifact, it should just say Webpage.
The extra text is overwritten and disappears when typing over it.

2022-04-14T18:26:28+02:00

System information

  • OS: Linux
  • Neovim version: 0.6.1
  • Dressing config: default config, no changes
require('dressing').setup({})

To Reproduce
Steps to reproduce the behavior:

  1. Open a Rust file
  2. Trigger lsp rename (on Webpage below)
#[derive(Serialize, Deserialize, Entity, Clone)]
#[factor(namespace = "semantic")]
pub struct Webpage {
}

Additional context

The relevant LSP is rust-analyzer, if that makes any difference.

add support for type `q` to quit the window

As the title say, I wanna press q to quit window like telescope in the following configuration

local actions = require("telescope.actions")
local telescope = require("telescope")
telescope.setup({
    defaults = {
        mappings = {
            n = {
                ["q"] = actions.close,
            },
        },
    },
})

Close input on <Esc>

This plugin looks great! I have a hard time canceling a rename operation though, pressing Escape just changes to normal mode but doesn't close the rename input modal. Seems like I need to explicitly close the window for that. Am I missing something? I think pressing Escape should close the window and cancel the renaming.

Enhancement: expose ID of window created by `vim.ui.input`

Hi,
I'm currently trying to add proper support for dressing.nvim in my plugin inc-rename.nvim (the current implementation has issues, see smjonas/inc-rename.nvim#17). Basically, I need to control the window created by dressing.nvim from the command line and change the input text while the user is typing. For this to work, I need to get the ID of the window created by vim.ui.input.

At the moment, I am doing the following to find the ID:

-- Open the input window and find the buffer and window IDs
vim.ui.input({}, function() end)
vim.schedule(function()
  for _, win_id in ipairs(vim.api.nvim_list_wins()) do
    local bufnr = vim.api.nvim_win_get_buf(win_id)
    if vim.bo[bufnr].filetype == "DressingInput" then
      -- found the window ID
    end
  end
end)

This almost works but using vim.schedule is problematic as that doesn't work well with Nvim's command preview callback. Omitting vim.schedule won't work because you use schedule_wrap in input.lua here (so I need to schedule my code to run after yours):

__call = vim.schedule_wrap(function(_, opts, on_confirm)

Therefore, I am proposing the following enhancements:

  • add support for a boolean parameter no_schedule / synchronous / sync passed to the opts key in vim.ui.input which won't schedule wrap the function if set to true (let me know which name you'd prefer)
  • if no_schedule / synchronous / sync is set, return the window ID from vim.ui.input

Please let me know if you have any another ideas / suggestions! I can send a PR if you want :)

Difficult to see Input border and title

System information

  • OS: mac
  • Neovim version: 0.7
  • Dressing config:
require('dressing').setup({
  input = {
    -- Set to false to disable the vim.ui.input implementation
    enabled = true,

    -- Default prompt string
    default_prompt = "Input:",

    -- Can be 'left', 'right', or 'center'
    prompt_align = "left",

    -- When true, <Esc> will close the modal
    insert_only = true,

    -- These are passed to nvim_open_win
    anchor = "SW",
    border = "rounded",
    -- 'editor' and 'win' will default to being centered
    relative = "cursor",

    -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
    prefer_width = 40,
    width = nil,
    -- min_width and max_width can be a list of mixed types.
    -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
    max_width = { 140, 0.9 },
    min_width = { 80, 0.2 },

    -- Window transparency (0-100)
    winblend = 0,
    -- Change default highlight groups (see :help winhl)
    winhighlight = "",

    override = function(conf)
      -- This is the config that will be passed to nvim_open_win.
      -- Change values here to customize the layout
      return conf
    end,

    -- see :help dressing_get_config
    get_config = nil,
  },
  select = {
    -- Set to false to disable the vim.ui.select implementation
    enabled = true,

    -- Priority list of preferred vim.select implementations
    backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },

    -- Trim trailing `:` from prompt
    trim_prompt = true,

    -- Options for telescope selector
    -- These are passed into the telescope picker directly. Can be used like:
    -- telescope = require('telescope.themes').get_ivy({...})
    telescope = require('telescope.themes').get_cursor({ winblend = 5 }),

    -- Used to override format_item. See :help dressing-format
    format_item_override = {},

    -- see :help dressing_get_config
    get_config = nil,
  },
})

To Reproduce
Steps to reproduce the behavior:

  1. Use onedark vim theme (https://github.com/joshdick/onedark.vim)

Screenshots
image

I've tried out a few colorschemes with dressing.nvim but cant seem to find a suitably visible border and title theme.
Is it possible to change the input theme in the dressing config?

NUI backend breaks with winbar

Describe the bug
A clear and concise description of what the bug is.

System information

  • OS: MacOS
  • Neovim version: NVIM v0.8.0-dev+1816-g9745941ef
  • Is this related to a specific vim.ui.select backend? If so, which one? nui
  • Dressing config:
require('dressing').setup({
  input = {
    -- Set to false to disable the vim.ui.input implementation
    enabled = true,

    -- Default prompt string
    default_prompt = "Input:",

    -- Can be 'left', 'right', or 'center'
    prompt_align = "left",

    -- When true, <Esc> will close the modal
    insert_only = true,

    -- These are passed to nvim_open_win
    anchor = "SW",
    border = EcoVim.ui.float.border or "rounded",
    -- 'editor' and 'win' will default to being centered
    relative = "cursor",

    -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
    prefer_width = 40,
    width = nil,
    -- min_width and max_width can be a list of mixed types.
    -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
    max_width = { 140, 0.9 },
    min_width = { 20, 0.2 },

    -- Window transparency (0-100)
    winblend = 0,
    -- Change default highlight groups (see :help winhl)
    winhighlight = "",

    override = function(conf)
      -- This is the config that will be passed to nvim_open_win.
      -- Change values here to customize the layout
      return conf
    end,

    -- see :help dressing_get_config
    get_config = nil,
  },

  select = {
    -- Set to false to disable the vim.ui.select implementation
    enabled = true,

    -- Priority list of preferred vim.select implementations
    backend = { "telescope", "nui", "fzf", "builtin" },

    -- Options for nui Menu
    nui = {
      position = {
        row = 1,
        col = 0,
      },
      size = nil,
      relative = "cursor",
      border = {
        style = EcoVim.ui.float.border or "rounded",
        text = {
          top_align = "right",
        },
      },
      max_width = 80,
      max_height = 40,
    },


    -- see :help dressing_get_config
    get_config = function(opts)
      if opts.kind == 'codeaction' then
        return {
          backend = 'nui',
          nui = {
            relative = 'cursor',
            max_width = 80,
          }
        }
      end
    end
  },
})

To Reproduce
Steps to reproduce the behavior:

  1. Use winbar of nvim 0.8

If possible, provide a minimal file that will trigger the issue (see
tests/manual
for examples of short ways to call vim.ui.*):

Somehow it works good with test. Just breaks when using my config and code actions/rename.
image

Screenshots
image

Additional context
I have winbar configured with nvim 0.8 and then nui backed stops working and each time I try to use code action with vim.ui.select or rename with vim.ui.input it throws error.

Looks like winbar is trying to be attached to nui window and it doesn't have enough space or sth like that.
I've added "DressingInput" filetype and "DressingSelect" filetype to excluded of winbar but it still doesn't work. I can tell that it works great with Telescope (which has filetype of TelescopePrompt) added to excluded filetypes.

My autocmd for winbar:

vim.api.nvim_create_autocmd({ "CursorMoved", "BufWinEnter", "BufFilePost" }, {
  callback = function()
    local winbar_filetype_exclude = {
      "help",
      "startify",
      "dashboard",
      "packer",
      "neogitstatus",
      "NvimTree",
      "Trouble",
      "alpha",
      "lir",
      "Outline",
      "spectre_panel",
      "toggleterm",
      "TelescopePrompt",
      "DressingInput",
      "DressingSelect",
    }

    if vim.tbl_contains(winbar_filetype_exclude, vim.bo.filetype) then
      vim.opt_local.winbar = nil
      return
    end

    local value = require("winbar").gps()

    if value == nil then
      value = require("winbar").filename()
    end

    vim.opt_local.winbar = value
  end,
})

I also realized that if the error shows, sometimes "Code actions" are showing and when I click enter everything seems to work fine. Just error is showing each time:

image

Then press enter and it shows correctly:
image

Same with vim.ui.input.

Does anyone else have this issue when using winbar with nui prompt?

Error running vim.ui.select in the fzf_lua backend the first time since nvim startup

Describe the bug
The first time I use vim.ui.select after starting Nvim, I get an error similar to the following:

Error executing vim.schedule lua callback: ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: attempt to call a nil value                                              
stack traceback:
        ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: in function 'select'
        .../packer/start/dressing.nvim/lua/dressing/select/init.lua:63: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

This was triggered by using the :lua vim.ui.select({1,2,3}, {}, function(opt)end) command. Running the command again will work correctly

System information

  • OS: Artix Linux
  • Neovim version: 0.7.2
  • Is this related to a specific vim.ui.select backend? If so, which one? Fzf_lua
  • Dressing config: Default configuration

To Reproduce
Steps to reproduce the behavior:

  1. Start Nvim
  2. Use the following command :lua vim.ui.select({1,2,3}, {}, function(opt)end)
  3. Dressing crashes
  4. If you use the same command again, the command goes through correctly

Additional context
I'm using the following lua plugin related to FZF:

Telescope not focused when vim.ui.select is triggered by autocmd

Describe the bug

When setting up an autocmd to automatically format the buffer on save with the LSP, if there are multiple formatting capable language servers vim.ui.select is called to select the correct one. The Telescope selection window appears but it not in focus

System information

  • OS: linux
  • Neovim version:

    NVIM v0.7.2
    Build type: Release
    LuaJIT 2.1.0-beta3

  • Is this related to a specific vim.ui.select backend? If so, which one? Yes, telescope
  • Dressing config:
require("dressing").setup({
  input = {
    enabled = ui_opts.nui_input,
    default_prompt = "",
    winhighlight = "Normal:Normal,NormalNC:Normal",
  },
  select = {
    enabled = ui_opts.telescope_select,
    backend = { "telescope", "builtin" },
    builtin = { winhighlight = "Normal:Normal,NormalNC:Normal" },
  },
})

To Reproduce
Steps to reproduce the behavior:

  1. Set up dressing
  2. Add an autocmd to format synchronously on save (BufWritePre)
on_attach = function(client, bufnr)
  if client.resolved_capabilities.document_formatting then
    vim.api.nvim_create_autocmd("BufWritePre", {
      desc = "Auto format before save",
      pattern = "<buffer>",
      callback = function() vim.lsp.buf.formatting_sync() end,
    })
  end
end,
  1. Have multiple language servers with formatting capabilities. For example sumneko_lua and stylua (with null-ls)
  2. Open a file using at least 2 format capable language servers and save the file.

Screenshots

https://asciinema.org/a/86k1OuM0mj4hi8fQLTt7qz6B5

[Config related] `vim.ui.input` size issues

Describe the bug
When opening a vim.ui.input prompt via telescope, its size is way too big.

System information

  • OS: Linux
  • Neovim version: 0.7.0
  • Is this related to a specific vim.ui.select backend? If so, which one? Yes, telescope. No.
  • Dressing config:
  local present, dressing = pcall(require, "dressing")
  if not present then
    print("dressing not found")
    return
  end
  dressing.setup({
    input = {
      max_width = { 140, 0.9 },
      min_width = { 10, 0.1 },
    },
    select = {
      backend = { "telescope", "builtin" },
      telescope = require('telescope.themes').get_ivy(),
      builtin = {
        width = nil,
        max_width = { 140, 0.8 },
        min_width = { 40, 0.2 },
        height = nil,
        max_height = 0.9,
        min_height = { 10, 0.2 },
      },
    },

To Reproduce
Steps to reproduce the behavior:

  1. Open any vim.ui.input prompt
  2. Get Eye Cancer

If possible, provide a minimal file that will trigger the issue (see
tests/manual
for examples of short ways to call vim.ui.*):

vim.ui.input("Enter stuff", function(stuff) print("Stuff: " .. stuff) end)

Screenshots

recording.mp4

EDIT: I thought that vim.ui.input was handled by telescope. It's not as I just realised.

[Bug] telescope theme deprecation notice shown continuously

Describe the bug
The recent telescope theme deprecation warning is shown continuously because the telescope theme object itself actually has a key called theme, so this wrongly reports that a user hasn't migrated despite having done so.

System information

  • OS: [windows/linux/mac] macOS
  • Neovim version: nightly
  • Is this related to a specific vim.ui.select backend? If so, which one? Telescope
  • Dressing config:
use {
      'stevearc/dressing.nvim',
      after = 'telescope.nvim',
      config = function()
        require('dressing').setup {
          input = {
            insert_only = false,
            winblend = 2,
          },
          select = {
            telescope = require('telescope.themes').get_cursor { -- <--- This function returns an object with a theme key
              layout_config = {
                height = function(self, _, max_lines)
                  local results = #self.finder.results
                  return (results <= max_lines and results or max_lines - 10) + 4 -- 4 is the size of the window
                end,
              },
            },
          },
        }
      end

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

  telescope = {                                                                                                                                                                      
    borderchars = {                                                                                                                                                                  
      preview = { "", "", "", "", "", "", "", "" },                                                                                                                          
      prompt = { "", "", " ", "", "", "", "", "" },                                                                                                                           
      results = { "", "", "", "", "", "", "", "" }                                                                                                                           
    },                                                                                                                                                                               
    layout_config = {                                                                                                                                                                
      height = <function 2>,                                                                                                                                                         
      width = 80                                                                                                                                                                     
    },                                                                                                                                                                               
    layout_strategy = "cursor",                                                                                                                                                      
    results_title = false,                                                                                                                                                           
    sorting_strategy = "ascending",                                                                                                                                                  
    theme = "cursor"                                                                                                                                                                 
  } 

Telescope File Browser appears above dressing and dressing UI does not get focus

Describe the bug
When using Telescope File Browser the Dressing UI appears behind the Telescope File Browser UI, and doesn't receive focus. Unsure if this problem is Dressing, Telescope File Browser, or my config related — usually it's me but I am just using defaults. :)

Sincere apologies in advance if it turns out to be the latter!

System information

  • OS: mac 12.4
  • Neovim version:
  • NVIM v0.7.0
    Build type: Release
    LuaJIT 2.1.0-beta3
    Compiled by brew@Monterey
  • Is this related to a specific vim.ui.select backend? If so, which one?
  • Dressing config:
use({ "stevearc/dressing.nvim" })

To Reproduce
Steps to reproduce the behavior:

  1. Use Telescope File Browser and duplicate/rename a file
  2. Observe that dressing UI is behind the File Browser and doesn't receive focus

Screenshots

rename.mov

Custom sorter based on `kind` for `vim.ui.select()`?

Is it possible to use a custom sorter if the kind option is a certain value, otherwise use the default sorter?

For example, I want to be able to sort user created items to be before builtin items in my plugin legendary.nvim.

I think this could probably be done via the get_config option of dressing.nvim?

Select opens in normal mode when using a range code action

When opening a select from normal/insert mode, the telescope UI gets used correctly. When doing a visual selection and calling vim.lsp.buf.range_code_action() the telescope UI gets opened in normal mode, making it necessary to press <Esc> before trying to select any option

Question: Can the `vim.ui.input` span across buffers?

I'm wondering if it is possible to have the vim.ui.input popup span across buffers. I am running into an issue where the pop up is getting cut off in a small sidebar like split when there is plenty of room:
2022-03-29_13:14:24_screenshot

With larger width:
2022-03-29_13:15:06_screenshot

Other things like nui have this, but I'm not sure if that's because they are separate from the vim.ui.input. nui example:

2022-03-29_13:15:59_screenshot

Add normal mode for input.

I've seen #1.
But I see value in having ESC exiting insert mode.
Pressing ESC again would then close the prompt.

I guess it wouldn't be too alienating for many users since this is his telescope works as well.
Ideally this would be an option which could be set in get_config for input.

On another note, is there a filetype assigned to the input buffer which can be used to apply custom mappings?
This might not "fix" but help with #2.

Making `code_action` next to the cursor.

Currently rename opens nicely where the given symbol is, but code action, regardless of the chosen selector opens in the middle.

Is it possible to make it open next to the cursor, where the code action is performed, like lspsaga does?

It would be way more convenient.

Feature request: more general support for external auto-completion

Right now plugin's vim.ui.input defines its own completion. It seems to conflict with other external (auto-)completion functionality. This is vaguely confirmed by hard-coded 'nvim-cmp' disabling. I understand that 'nvim-cmp' is the completion engine right now, but it would be nice to at least have notice somewhere that external completion engine should be disabled in specified buffer. For example, this caused a hard-to-find behavior in 'mini.completion' (echasnovski/mini.nvim#68).

Misbehaviour when using with autocommands

Greetings, thanks for making this plugin.

I've been trying to port one of my plugins from VimScript to Lua using vim.ui.select and I came across the following issue: when I use any floating window via vim.ui + Dressing coming from an autocommand (In this specific case BufNewFile) the floating window appears but the document is actually selected and insert mode is active.

I managed to reproduce it with the following config (besides plenary, telescope and dressing as installed plugins):

lua << EOF
function test()
   vim.ui.select({"echo 'Hi'"}, {}, function(item, _) if item then vim.cmd(item) end end)
end

vim.cmd([[autocmd BufNewFile * lua test()]])
EOF

I'm sorry if something I wrote is wrong, I'm not an expert in either VimScript or Lua. Seems that the standard vim.ui works correctly, as long as i set shortmess-=F (which doesn't help with dressing).

I'm ready to answer any question, if needed. Thank you in advance!

Center input?

Hello @stevearc, smart plugin. great work.

I'm currently testing it for inputs but I fail to make the window center, relative to the buffer or the window. I wonder there is away to do this or an option available

Thanks ❤️

Make `vim.ui.input` completion engines friendly

Hi, I'm a bit confused as to how one would re-enable completion engines such as cmp and mini as both are currently explicitly disabled with no option to prevent that.

Additionally and ideally there would be a hook of some sort that users can setup their completion engines within per vim.ui.input call.
That way for example when vim.ui.input is used to do an LSP rename, one could enable cmp with sources that make sense in that context (buffer, spell, rg .. etc) which aid in the operation of LSP renaming.

It really sounds like I'm asking for some hooks per vim.ui.input call here but I didn't want to be vague in order to eliminate any chance of having an XY problem here.

I might be missing something obvious here, wdyt?

Highlights

Is it possible to set highlights for insert/select floating windows borders and text messages?

Compatibility issue with telescope-file-browser

Using dressing.nvim and telescope-file-browser at the same time seems to not be possible at the moment, see this issue:
nvim-telescope/telescope-file-browser.nvim#66

It seems that the issue is that dressing triggers a BufLeave event which closes the telescope buffer. I'm not sure how easy that could be to fix but an alternative could maybe be to have the ability to disable dressing under certain circumstances, eg for telescope buffers.

LSP Code Action Source

Hello,
Just wondering if there is a way to include code action source names with vim.lsp.buf.code_action(), similar to Telescope's builtin lsp_code_actions.

vim-ui-select (with dressing.nvim)
image

Telescope
image

vim.ui.input reports nil for empty string

Describe the bug

The following code

vim.ui.input({ prompt = 'Data: ' }, function(data) vim.notify(vim.inspect(data)) end)

prints nil for both cancelled dialog and empty input. I would expect to have an empty string on empty input.

System information

  • OS: linux
  • Neovim version: 0.7
  • Dressing config: defaults

To Reproduce
Steps to reproduce the behavior:

  1. :vim.ui.input({ prompt = 'Data: ' }, function(data) vim.notify(vim.inspect(data)) end)
  2. Press <CR>

`vim.ui.input` is showing listchars after the available width

Describe the bug
vim.ui.input shows listchars eol when the width of the text goes beyond
the available width of the input.

image

System information

  • OS: linux
  • Neovim version:
NVIM v0.7.0-dev+1287-g315858bf6
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by lalitmee@pop-os

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info
  • Is this related to a specific vim.ui.select backend? If so, which one? No.
  • Dressing config:
-- Paste your call to require("dressing").setup(...) in here
dressing.setup({
  input = { insert_only = false, winblend = 2 },
  select = {
    winblend = 2,
    telescope = require("telescope.themes").get_cursor({
      layout_config = {
        -- NOTE: the limit is half the max lines because this is the cursor theme so
        -- unless the cursor is at the top or bottom it realistically most often will
        -- only have half the screen available
        height = function(self, _, max_lines)
          local results = #self.finder.results
          local PADDING = 4 -- this represents the size of the telescope window
          local LIMIT = math.floor(max_lines / 2)
          return (results <= (LIMIT - PADDING) and results + PADDING or LIMIT)
        end,
      },
    }),
  },
})

To Reproduce
Steps to reproduce the behavior:

  1. find something which is big in width more than the vim.ui.input width
  2. open to rename or open nvim-tree.lua to rename or create a file

If possible, provide a minimal file that will trigger the issue (see
tests/manual
for examples of short ways to call vim.ui.*):

-- minimal code not required

Screenshots
dressing

Additional context
I tried to setup setlocal noeol in the DressingInput on the basis of Filetype in an autocmd but
it didn't work.

Open menu before loading buffer

I am using a language server that I need to make a selection for before starting the server. Currently I can use the default way to select my option first and then the buffer loads. When using this plugin the buffer is not blocked from loading and I am unable to make the selection before the language server starts.

Is there anyway to expose an option to have the menu block loading a buffer until after the selection is made?

buffer is not loaded yet, there is time to make selection
image

buffer already loaded, too late to make selection
image

Run FZF cancel callback based on v:event

Inspired by this plugin, I'm experimenting with fzf#run myself, and its terminal command returns 1 if there's an error with the command or 130 if nothing is chosen (I tested pressing both Esc and Ctrl+C).

Therefore, you can check v:event to capture the fzf command exit status and only run the cancel callback when the status is not 0 (or only when it's 130 depending on how you want to handle errors). You can do that in a TermClose autocmd, instead of deferring a callback using BufLeave.

Allow settings mappings for `vim.ui.input`

I there any way to configure key mappings for vim.ui.input? I would like to be able to use <C-k>/<C-j> to move up/down in history by mapping them to <Up>/<Down>.

I tried using an autocmd FileType DressingInput to set the mappings buffer-locally but for some reason it didn't work for me. The autocommand gets triggered but the mappings don't appear.

Stack overflow in Telescope

Bug

After the commit cc1a3440, the ._close function has been deprecated. Now it just calls .close.

I use legendary.nvim, and when I close the telescope prompt, I get a stack overflow.

E5108: Error executing lua ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:55: stack overflow
stack traceback:
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:55: in function '_close'
        ...cker/opt/dressing.nvim/lua/dressing/select/telescope.lua:59: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'close'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:363: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function '_close'
        ...cker/opt/dressing.nvim/lua/dressing/select/telescope.lua:59: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'close'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:363: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function '_close'
        ...cker/opt/dressing.nvim/lua/dressing/select/telescope.lua:59: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'close'
        ...
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:363: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function '_close'
        ...cker/opt/dressing.nvim/lua/dressing/select/telescope.lua:59: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'close'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:363: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function '_close'
        ...cker/opt/dressing.nvim/lua/dressing/select/telescope.lua:59: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...ack/packer/opt/telescope.nvim/lua/telescope/mappings.lua:242: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

I've noticed that the cause of the problem are the following lines in dressing.nvim:

actions.close:replace(function()
  actions._close(prompt_bufnr, false)
  on_choice(nil, nil)
end)

When the lines are deleted, everything still seems to work just fine. I'm not sure if they are needed, or need to be changed.

Neovim

NVIM v0.7.0-dev+1443-gdbd5242d8
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az32-353

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Dressing Configuration

Config
  require("dressing").setup {
    input = {
      -- Set to false to disable the vim.ui.input implementation
      enabled = true,

      -- Default prompt string
      default_prompt = "",

      -- When true, <Esc> will close the modal
      insert_only = true,

      -- These are passed to nvim_open_win
      anchor = "SW",
      border = "rounded",
      -- 'editor' and 'win' will default to being centered
      relative = "cursor",

      -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
      prefer_width = 40,
      width = nil,
      -- min_width and max_width can be a list of mixed types.
      -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
      max_width = { 140, 0.9 },
      min_width = { 20, 0.2 },

      -- Window transparency (0-100)
      winblend = 10,
      -- Change default highlight groups (see :help winhl)
      winhighlight = "",

      override = function(conf)
        -- This is the config that will be passed to nvim_open_win.
        -- Change values here to customize the layout
        return conf
      end,

      -- see :help dressing_get_config
      get_config = nil,
    },
    select = {
      -- Set to false to disable the vim.ui.select implementation
      enabled = true,

      -- Priority list of preferred vim.select implementations
      backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },

      -- Options for telescope selector
      -- These are passed into the telescope picker directly. Can be used like:
      -- telescope = require('telescope.themes').get_ivy({}),
      telescope = require('telescope.themes').get_dropdown({}),
      -- telescope = require("telescope.themes").get_cursor({}),

      -- Options for fzf selector
      fzf = { window = { width = 0.5, height = 0.4 } },

      -- Options for fzf_lua selector
      fzf_lua = { winopts = { width = 0.5, height = 0.4 } },

      -- Options for nui Menu
      nui = {
        position = "50%",
        size = nil,
        relative = "editor",
        border = { style = "rounded" },
        max_width = 80,
        max_height = 40,
      },

      -- Options for built-in selector
      builtin = {
        -- These are passed to nvim_open_win
        anchor = "NW",
        border = "rounded",
        -- 'editor' and 'win' will default to being centered
        relative = "editor",

        -- Window transparency (0-100)
        winblend = 10,
        -- Change default highlight groups (see :help winhl)
        winhighlight = "",

        -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
        -- the min_ and max_ options can be a list of mixed types.
        -- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total"
        width = nil,
        max_width = { 140, 0.8 },
        min_width = { 40, 0.2 },
        height = nil,
        max_height = 0.9,
        min_height = { 10, 0.2 },

        override = function(conf)
          -- This is the config that will be passed to nvim_open_win.
          -- Change values here to customize the layout
          return conf
        end,
      },

      -- Used to override format_item. See :help dressing-format
      format_item_override = {},

      -- see :help dressing_get_config
      get_config = nil,
    },
  }

Usage question

Hello,
I want to use vim.ui.input() to set path to executable for nvim-dap. I managed to do it with default vim.ui.input() (which simply calls vim.fn.input() as I understand) as follows:

dap.configurations.cpp = {
  {
    program = function()
        local path_to_program = '???'
        vim.ui.input({
            prompt = 'Path to executable: ',
            default = vim.fn.getcwd() .. '/',
            completion = 'file',
        },
        function(input)
            path_to_program = input
        end
        )
        return path_to_program
    end,
  },
}

But when I tried to use dressing.nvim implementation of vim.ui.input() in the same manner I faced two issues:

  1. After calling <cmd>lua require'dap'.continue()<cr> popup window that serves for setting path to executable opens as expected but then it immediately closes so I cannot write anything in there.
  2. on_confirm function changes path_to_program variable as expected inside its scope but in the end when the variable has to be returned it equals '???' as before the change. So change of the variable inside on_confirm does not take effect.

Could you please help me to figure out how to properly use vim.ui.input() in this case?

Edit: I use NVIM v0.6.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.