Merge remote-tracking branch 'upstream/master' into nil-check

* upstream/master:
  [docgen] Update README.md skip-checks: true
  feat: set unique filetype on built-in modals (#3)
  feat(input): option to allow normal mode (#3)
This commit is contained in:
William Boman 2021-12-06 18:24:39 +01:00
commit 14780e4b7d
5 changed files with 16 additions and 7 deletions

View File

@ -113,6 +113,9 @@ require('dressing').setup({
-- Default prompt string
default_prompt = "➤ ",
-- When true, <Esc> will close the modal
insert_only = true,
-- These are passed to nvim_open_win
anchor = "SW",
relative = "cursor",

View File

@ -10,6 +10,9 @@ Configure dressing.nvim by calling the setup() function.
-- Default prompt string
default_prompt = "➤ ",
-- When true, <Esc> will close the modal
insert_only = true,
-- These are passed to nvim_open_win
anchor = "SW",
relative = "cursor",

View File

@ -3,6 +3,9 @@ local default_config = {
-- Default prompt string
default_prompt = "",
-- When true, <Esc> will close the modal
insert_only = true,
-- These are passed to nvim_open_win
anchor = "SW",
relative = "cursor",

View File

@ -148,14 +148,13 @@ setmetatable(M, {
vim.api.nvim_buf_set_option(bufnr, "buftype", "prompt")
vim.api.nvim_buf_set_option(bufnr, "swapfile", false)
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(bufnr, "filetype", "DressingInput")
local keyopts = { silent = true, noremap = true }
vim.api.nvim_buf_set_keymap(
bufnr,
"i",
"<Esc>",
"<cmd>lua require('dressing.input').confirm()<CR>",
keyopts
)
local close_rhs = "<cmd>lua require('dressing.input').confirm()<CR>"
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Esc>", close_rhs, keyopts)
if config.insert_only then
vim.api.nvim_buf_set_keymap(bufnr, "i", "<Esc>", close_rhs, keyopts)
end
vim.fn.prompt_setprompt(bufnr, prompt)
-- Would prefer to use v:lua directly here, but it doesn't work :(
vim.fn.prompt_setcallback(bufnr, "dressing#prompt_confirm")

View File

@ -43,6 +43,7 @@ M.select = function(config, items, opts, on_choice)
vim.api.nvim_win_set_option(winnr, "winblend", config.winblend)
vim.api.nvim_win_set_option(winnr, "cursorline", true)
pcall(vim.api.nvim_win_set_option, winnr, "cursorlineopt", "both")
vim.api.nvim_buf_set_option(bufnr, "filetype", "DressingSelect")
-- Create the title window once the main window is placed.
-- Have to defer here or the title will be in the wrong location