dressing.nvim/doc/dressing.txt

216 lines
6.7 KiB
Plaintext
Raw Normal View History

2021-12-03 01:43:52 +00:00
*dressing.txt*
*Dressing* *dressing* *dressing.nvim*
===============================================================================
CONFIGURATION *dressing-configuration*
Configure dressing.nvim by calling the setup() function.
2023-09-02 15:57:46 +00:00
>lua
2021-12-03 01:43:52 +00:00
require('dressing').setup({
input = {
-- Set to false to disable the vim.ui.input implementation
enabled = true,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Default prompt string
2024-01-14 17:15:24 +00:00
default_prompt = "Input",
-- Trim trailing `:` from prompt
trim_prompt = true,
2023-09-02 15:57:46 +00:00
-- Can be 'left', 'right', or 'center'
title_pos = "left",
2023-09-02 15:57:46 +00:00
-- When true, input will start in insert mode.
start_in_insert = true,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "cursor",
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- 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 },
2023-09-02 15:57:46 +00:00
buf_options = {},
win_options = {
-- Disable line wrapping
wrap = false,
-- Indicator for when text exceeds window
list = true,
listchars = "precedes:…,extends:…",
-- Increase this for more context when text scrolls off the window
sidescrolloff = 0,
},
2023-09-02 15:57:46 +00:00
-- Set to `false` to disable
mappings = {
n = {
["<Esc>"] = "Close",
["<CR>"] = "Confirm",
},
i = {
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
["<Up>"] = "HistoryPrev",
["<Down>"] = "HistoryNext",
},
},
2023-09-02 15:57:46 +00:00
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,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- see :help dressing_get_config
get_config = nil,
},
select = {
-- Set to false to disable the vim.ui.select implementation
enabled = true,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Priority list of preferred vim.select implementations
backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },
2023-09-02 15:57:46 +00:00
-- Trim trailing `:` from prompt
trim_prompt = true,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Options for telescope selector
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Options for fzf selector
fzf = {
window = {
width = 0.5,
height = 0.4,
},
2021-12-03 01:43:52 +00:00
},
2023-09-02 15:57:46 +00:00
-- Options for fzf-lua
fzf_lua = {
-- winopts = {
-- height = 0.5,
-- width = 0.5,
-- },
},
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Options for nui Menu
nui = {
position = "50%",
size = nil,
relative = "editor",
border = {
style = "rounded",
},
buf_options = {
swapfile = false,
filetype = "DressingSelect",
},
win_options = {
winblend = 0,
},
2021-12-03 01:43:52 +00:00
max_width = 80,
max_height = 40,
min_width = 40,
min_height = 10,
2021-12-03 01:43:52 +00:00
},
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- Options for built-in selector
builtin = {
2023-09-05 05:38:53 +00:00
-- Display numbers for options and set up keymaps
show_numbers = true,
2021-12-03 01:43:52 +00:00
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "editor",
2023-09-02 15:57:46 +00:00
buf_options = {},
win_options = {
cursorline = true,
cursorlineopt = "both",
},
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- 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"
2021-12-03 01:43:52 +00:00
width = nil,
max_width = { 140, 0.8 },
min_width = { 40, 0.2 },
2021-12-03 01:43:52 +00:00
height = nil,
max_height = 0.9,
min_height = { 10, 0.2 },
2023-09-02 15:57:46 +00:00
-- Set to `false` to disable
mappings = {
["<Esc>"] = "Close",
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
},
2023-09-02 15:57:46 +00:00
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,
2021-12-03 01:43:52 +00:00
},
2023-09-02 15:57:46 +00:00
-- Used to override format_item. See :help dressing-format
format_item_override = {},
2023-09-02 15:57:46 +00:00
2021-12-03 01:43:52 +00:00
-- see :help dressing_get_config
get_config = nil,
},
})
dressing.get_config() *dressing_get_config()*
For each of the `input` and `select` configs, there is an option
`get_config`. This can be a function that accepts the `opts` parameter that
is passed in to `vim.select` or `vim.input`. It must return either `nil` (to
no-op) or config values to use in place of the global config values for that
module.
For example, if you want to use a specific configuration for code actions:
2023-09-02 15:57:46 +00:00
>lua
2021-12-03 01:43:52 +00:00
require('dressing').setup({
select = {
get_config = function(opts)
if opts.kind == 'codeaction' then
return {
backend = 'nui',
nui = {
relative = 'cursor',
max_width = 40,
}
}
end
end
}
})
===============================================================================
*dressing-format*
Sometimes you may wish to change how choices are displayed for
`vim.ui.select`. The calling function can pass a specific "kind" to the select
function (for example, code actions from |vim.lsp.buf.code_action|
use kind="codeaction"). You can, in turn, specify an override for the
"format_item" function when selecting for that kind. For example, this
configuration will display the name of the language server next to code
actions:
2023-09-02 15:57:46 +00:00
>lua
format_item_override = {
codeaction = function(action_tuple)
local title = action_tuple[2].title:gsub("\r\n", "\\r\\n")
local client = vim.lsp.get_client_by_id(action_tuple[1])
return string.format("%s\t[%s]", title:gsub("\n", "\\n"), client.name)
end,
}
2021-12-03 01:43:52 +00:00
===============================================================================
vim:ft=help:et:ts=2:sw=2:sts=2:norl