stevearc / dressing.nvim

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

Add start_in_insert option #49

Closed mbenford closed 2 years ago

mbenford commented 2 years ago

Add a new option, start_in_insert, that defaults to true and controls whether the input will start in insert or normal mode.

Context

I'd like to conditionally enable normal mode when certain criteria are met, e.g. when using vim.ui.input with LSP rename.

Description

This PR introduces an option that controls whether insert mode will be activated or not, and it can be used along with get_config for conditional behavior. For instance:

require('dressing').setup({
  input = {
    ...
    get_config = function(opts)
      return {
        start_in_insert = #(opts.default or '') == 0,
      }
    end,
  }
})

Test Plan

Test case 1

Test case 2

stevearc commented 2 years ago

Looks good, thanks for the PR!