Refresh generated neovim config
This commit is contained in:
@ -1,5 +1,77 @@
|
||||
# Changelog
|
||||
|
||||
## [4.2.2](https://github.com/folke/noice.nvim/compare/v4.2.1...v4.2.2) (2024-06-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **hover:** ignore invalid markup. Fixes [#819](https://github.com/folke/noice.nvim/issues/819) ([59e633f](https://github.com/folke/noice.nvim/commit/59e633ff95be85cf65ac5dc5ece2a89c2b6c403d))
|
||||
* **msg:** clear existing confirm messages. Fixes [#302](https://github.com/folke/noice.nvim/issues/302) ([d3d8329](https://github.com/folke/noice.nvim/commit/d3d83292c15cb8a72e1e421ddf5a0aac7812cb9c))
|
||||
|
||||
## [4.2.1](https://github.com/folke/noice.nvim/compare/v4.2.0...v4.2.1) (2024-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cmdline:** only use cmdline_input for short prompts without newline. Fixes [#856](https://github.com/folke/noice.nvim/issues/856) ([d46c4ba](https://github.com/folke/noice.nvim/commit/d46c4ba67670037bc67af843b95314749caeebf8))
|
||||
|
||||
## [4.2.0](https://github.com/folke/noice.nvim/compare/v4.1.0...v4.2.0) (2024-06-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **cmdline:** icon for cmdline input ([d21d1d6](https://github.com/folke/noice.nvim/commit/d21d1d633762fe51efb6521ddd19942d40911c12))
|
||||
* **cmdline:** use cmdline prompt as title. Noice is now great for vim.ui.input out of the box ([4c1efad](https://github.com/folke/noice.nvim/commit/4c1efadccc5d4568e3abf0afdd3ee0c5c27b4be9))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cmdline_input:** put in same position as cmdline_popup ([e55ce94](https://github.com/folke/noice.nvim/commit/e55ce94a1e4b1b5388e11965072e0cde129604bd))
|
||||
* **cmdline:** allow overriding title hl ([a5aa639](https://github.com/folke/noice.nvim/commit/a5aa639fb802391293585fca81ac10ecacc5e646))
|
||||
* **cmdline:** do fix_cursor **after** calculating cmdline position ([ba79352](https://github.com/folke/noice.nvim/commit/ba79352af1527283682fe7b7b049e6c7967cd037))
|
||||
* **cmdline:** reset title when needed ([edd14df](https://github.com/folke/noice.nvim/commit/edd14df3515b106202fd0def749c3f1206c3bd8c))
|
||||
* **fzf:** message id ([a9fa1a2](https://github.com/folke/noice.nvim/commit/a9fa1a2ace124fcb752e356b3c52e962c3dcb8b8))
|
||||
* **nui:** redo layout when border changes ([0327de8](https://github.com/folke/noice.nvim/commit/0327de8b300d81f778b77f9178dec6ba41a0a4af))
|
||||
|
||||
## [4.1.0](https://github.com/folke/noice.nvim/compare/v4.0.1...v4.1.0) (2024-06-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added integrations for fzf-lua ([1605be3](https://github.com/folke/noice.nvim/commit/1605be38bdaa94bc6891e7d310585a9cb16b9dcb))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cmdline:** make sure search always uses correct view. Fixes [#841](https://github.com/folke/noice.nvim/issues/841) ([6a8a6de](https://github.com/folke/noice.nvim/commit/6a8a6de79223ac15d8ff5477358e343ae6a6ee51))
|
||||
* **cmdline:** separate cmdline input view ([07e8f9c](https://github.com/folke/noice.nvim/commit/07e8f9c7dfb01405f8b1173f1d3939b41753779d))
|
||||
* **fzf:** use --with-nth and skip message id in the display ([ac01164](https://github.com/folke/noice.nvim/commit/ac0116435e53c586a23302650dca73862a251108))
|
||||
|
||||
## [4.0.1](https://github.com/folke/noice.nvim/compare/v4.0.0...v4.0.1) (2024-06-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cmdline:** use real cursors on Neovim >= 0.10 ([5b5fa91](https://github.com/folke/noice.nvim/commit/5b5fa91be6848583cbf824c69e67e26acf609ada))
|
||||
* disable noice on VimLeavePre so that the user can see exit errors ([31ec80c](https://github.com/folke/noice.nvim/commit/31ec80c99ee699ea4e90248c2e87e5a669be5e93))
|
||||
* fixup ([cfd7aa4](https://github.com/folke/noice.nvim/commit/cfd7aa4617024a9bd4f6409463c73f91a7f411b8))
|
||||
* fixup ([2bf0429](https://github.com/folke/noice.nvim/commit/2bf04290b32dc5b1a002a4888c95147bb91ec6f2))
|
||||
* reduce flickering when searching. See [#679](https://github.com/folke/noice.nvim/issues/679) ([4e1f9f1](https://github.com/folke/noice.nvim/commit/4e1f9f198226aea5b82a6df75e9913b49796cdda))
|
||||
* remove smart_move ([b6ae820](https://github.com/folke/noice.nvim/commit/b6ae820190dd166d6ebae408d65f2551e37c7bf2))
|
||||
* search IS blocking, but shouldnt trigger redraw. Fixes [#345](https://github.com/folke/noice.nvim/issues/345) ([b3f08e6](https://github.com/folke/noice.nvim/commit/b3f08e6cf0fd30847f299cc94707563920fd2139))
|
||||
|
||||
## [4.0.0](https://github.com/folke/noice.nvim/compare/v3.0.2...v4.0.0) (2024-05-29)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* remove cmdpreview hack for nigytly since it's no longer needed there. Update your Nightlies!!
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **markdown:** ignore empty completion documentation tables ([#820](https://github.com/folke/noice.nvim/issues/820)) ([f119045](https://github.com/folke/noice.nvim/commit/f119045f38792ad5311e5f9be7a879e4c1a95fe0))
|
||||
* remove cmdpreview hack for nigytly since it's no longer needed there. Update your Nightlies!! ([49caf99](https://github.com/folke/noice.nvim/commit/49caf99d6253a43bf55ea055f7fba6c4eb78be20))
|
||||
|
||||
## [3.0.2](https://github.com/folke/noice.nvim/compare/v3.0.1...v3.0.2) (2024-05-22)
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ Highly experimental plugin that completely replaces the UI for `messages`, `cmdl
|
||||
- 💻 fully customizable **cmdline** with icons
|
||||
- 💅 **syntax highlighting** for `vim` and `lua` on the **cmdline**
|
||||
- 🚥 **statusline** components
|
||||
- 🔭 open message history in [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
|
||||
- 🔭 open message history in [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) or [fzf-lua](https://github.com/ibhagwan/fzf-lua)
|
||||
|
||||
## 🔥 Status
|
||||
|
||||
@ -123,7 +123,7 @@ Check the [wiki](https://github.com/folke/noice.nvim/wiki/Configuration-Recipes)
|
||||
filter = { pattern = "^:%s*!", icon = "$", lang = "bash" },
|
||||
lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = "", lang = "lua" },
|
||||
help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
|
||||
input = {}, -- Used by input()
|
||||
input = { view = "cmdline_input", icon = " " }, -- Used by input()
|
||||
-- lua = false, -- to disable a format, set to `false`
|
||||
},
|
||||
},
|
||||
@ -283,12 +283,6 @@ Check the [wiki](https://github.com/folke/noice.nvim/wiki/Configuration-Recipes)
|
||||
health = {
|
||||
checker = true, -- Disable if you don't want health checks to run
|
||||
},
|
||||
smart_move = {
|
||||
-- noice tries to move out of the way of existing floating windows.
|
||||
enabled = true, -- you can disable this behaviour here
|
||||
-- add any filetypes here, that shouldn't trigger smart move.
|
||||
excluded_filetypes = { "cmp_menu", "cmp_docs", "notify" },
|
||||
},
|
||||
---@type NoicePresets
|
||||
presets = {
|
||||
-- you can enable a preset by setting it to true, or a table that will override the preset config
|
||||
@ -530,6 +524,8 @@ Formatters are used in `format` definitions. **Noice** includes the following bu
|
||||
},
|
||||
telescope = ..., -- formatter used to display telescope results
|
||||
telescope_preview = ..., -- formatter used to preview telescope results
|
||||
fzf = ..., -- formatter used to display fzf results
|
||||
fzf_preview = ..., -- formatter used to preview fzf results
|
||||
lsp_progress = ..., -- formatter used by lsp progress
|
||||
lsp_progress_done = ..., -- formatter used by lsp progress
|
||||
}
|
||||
@ -640,6 +636,11 @@ require("lualine").setup({
|
||||
|
||||
</details>
|
||||
|
||||
## 🔭 Pickers
|
||||
|
||||
For convenience, you can do `:Noice pick`, which will open a picker with all the messages in the history,
|
||||
either with `telescope` or `fzf-lua`.
|
||||
|
||||
## 🔭 Telescope
|
||||
|
||||
In order to use **Noice** in **Telescope**, you can either do `:Noice telescope`,
|
||||
@ -650,6 +651,11 @@ The results panel is formatted using `config.format.formatters.telescope`. The p
|
||||
require("telescope").load_extension("noice")
|
||||
```
|
||||
|
||||
## 🔭 Fzf Lua
|
||||
|
||||
In order to use **Noice** in **FzfLua**, you can do `:Noice fzf`.
|
||||
The results panel is formatted using `config.format.formatters.fzf`. The preview is formatted with `config.format.formatters.telescope_fzf`
|
||||
|
||||
## 🚀 Usage
|
||||
|
||||
- `:Noice` or `:Noice history` shows the message history
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
*noice.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 May 23
|
||||
*noice.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 June 18
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *noice.nvim-table-of-contents*
|
||||
@ -14,7 +14,9 @@ Table of Contents *noice.nvim-table-of-contents*
|
||||
- Formatting |noice.nvim-noice-(nice,-noise,-notice)-formatting|
|
||||
- Routes |noice.nvim-noice-(nice,-noise,-notice)-routes|
|
||||
- Statusline Components|noice.nvim-noice-(nice,-noise,-notice)-statusline-components|
|
||||
- Pickers |noice.nvim-noice-(nice,-noise,-notice)-pickers|
|
||||
- Telescope |noice.nvim-noice-(nice,-noise,-notice)-telescope|
|
||||
- Fzf Lua |noice.nvim-noice-(nice,-noise,-notice)-fzf-lua|
|
||||
- Usage |noice.nvim-noice-(nice,-noise,-notice)-usage|
|
||||
- Highlight Groups |noice.nvim-noice-(nice,-noise,-notice)-highlight-groups|
|
||||
2. Links |noice.nvim-links|
|
||||
@ -39,7 +41,7 @@ FEATURES *noice.nvim-noice-(nice,-noise,-notice)-features*
|
||||
- fully customizable **cmdline** with icons
|
||||
- **syntax highlighting** for `vim` and `lua` on the **cmdline**
|
||||
- **statusline** components
|
||||
- open message history in telescope.nvim <https://github.com/nvim-telescope/telescope.nvim>
|
||||
- open message history in telescope.nvim <https://github.com/nvim-telescope/telescope.nvim> or fzf-lua <https://github.com/ibhagwan/fzf-lua>
|
||||
|
||||
|
||||
STATUS *noice.nvim-noice-(nice,-noise,-notice)-status*
|
||||
@ -149,7 +151,7 @@ for configuration recipes.
|
||||
filter = { pattern = "^:%s*!", icon = "$", lang = "bash" },
|
||||
lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = "", lang = "lua" },
|
||||
help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
|
||||
input = {}, -- Used by input()
|
||||
input = { view = "cmdline_input", icon = " " }, -- Used by input()
|
||||
-- lua = false, -- to disable a format, set to `false`
|
||||
},
|
||||
},
|
||||
@ -309,12 +311,6 @@ for configuration recipes.
|
||||
health = {
|
||||
checker = true, -- Disable if you don't want health checks to run
|
||||
},
|
||||
smart_move = {
|
||||
-- noice tries to move out of the way of existing floating windows.
|
||||
enabled = true, -- you can disable this behaviour here
|
||||
-- add any filetypes here, that shouldn't trigger smart move.
|
||||
excluded_filetypes = { "cmp_menu", "cmp_docs", "notify" },
|
||||
},
|
||||
---@type NoicePresets
|
||||
presets = {
|
||||
-- you can enable a preset by setting it to true, or a table that will override the preset config
|
||||
@ -590,6 +586,8 @@ built-in formats:
|
||||
},
|
||||
telescope = ..., -- formatter used to display telescope results
|
||||
telescope_preview = ..., -- formatter used to preview telescope results
|
||||
fzf = ..., -- formatter used to display fzf results
|
||||
fzf_preview = ..., -- formatter used to preview fzf results
|
||||
lsp_progress = ..., -- formatter used by lsp progress
|
||||
lsp_progress_done = ..., -- formatter used by lsp progress
|
||||
}
|
||||
@ -708,6 +706,12 @@ Example of configuring lualine.nvim ~
|
||||
<
|
||||
|
||||
|
||||
PICKERS *noice.nvim-noice-(nice,-noise,-notice)-pickers*
|
||||
|
||||
For convenience, you can do `:Noice pick`, which will open a picker with all
|
||||
the messages in the history, either with `telescope` or `fzf-lua`.
|
||||
|
||||
|
||||
TELESCOPE *noice.nvim-noice-(nice,-noise,-notice)-telescope*
|
||||
|
||||
In order to use **Noice** in **Telescope**, you can either do `:Noice
|
||||
@ -720,6 +724,13 @@ formatted with `config.format.formatters.telescope_preview`
|
||||
<
|
||||
|
||||
|
||||
FZF LUA *noice.nvim-noice-(nice,-noise,-notice)-fzf-lua*
|
||||
|
||||
In order to use **Noice** in **FzfLua**, you can do `:Noice fzf`. The results
|
||||
panel is formatted using `config.format.formatters.fzf`. The preview is
|
||||
formatted with `config.format.formatters.telescope_fzf`
|
||||
|
||||
|
||||
USAGE *noice.nvim-noice-(nice,-noise,-notice)-usage*
|
||||
|
||||
- `:Noice` or `:Noice history` shows the message history
|
||||
|
||||
@ -4,8 +4,10 @@ noice.nvim-noice-(nice,-noise,-notice)-configuration noice.nvim.txt /*noice.nvim
|
||||
noice.nvim-noice-(nice,-noise,-notice)-features noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-features*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-filters noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-filters*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-formatting noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-formatting*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-fzf-lua noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-fzf-lua*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-highlight-groups noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-highlight-groups*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-installation noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-installation*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-pickers noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-pickers*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-requirements noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-requirements*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-routes noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-routes*
|
||||
noice.nvim-noice-(nice,-noise,-notice)-status noice.nvim.txt /*noice.nvim-noice-(nice,-noise,-notice)-status*
|
||||
|
||||
@ -58,6 +58,18 @@ function M.setup()
|
||||
telescope = function()
|
||||
require("telescope").extensions.noice.noice({})
|
||||
end,
|
||||
fzf = function()
|
||||
require("noice.integrations.fzf").open({})
|
||||
end,
|
||||
pick = function()
|
||||
if pcall(_G.require, "telescope.config") then
|
||||
require("telescope").extensions.noice.noice({})
|
||||
elseif pcall(_G.require, "fzf-lua") then
|
||||
require("noice.integrations.fzf").open({})
|
||||
else
|
||||
Util.error("No picker available")
|
||||
end
|
||||
end,
|
||||
stats = function()
|
||||
Manager.add(Util.stats.message())
|
||||
end,
|
||||
|
||||
@ -20,9 +20,13 @@ function M.setup()
|
||||
local hl_group_border = "CmdlinePopupBorder" .. kind_cc
|
||||
Highlights.add(hl_group_border, "NoiceCmdlinePopupBorder")
|
||||
|
||||
local hl_group_title = "CmdlinePopupTitle" .. kind_cc
|
||||
Highlights.add(hl_group_title, "Noice" .. hl_group_border)
|
||||
|
||||
format = vim.tbl_deep_extend("force", {
|
||||
name = name,
|
||||
conceal = format.conceal ~= false,
|
||||
kind = kind,
|
||||
kind = name,
|
||||
icon_hl_group = "Noice" .. hl_group_icon,
|
||||
view = Config.options.cmdline.view,
|
||||
lang = format.lang or format.ft,
|
||||
@ -36,6 +40,7 @@ function M.setup()
|
||||
win_options = {
|
||||
winhighlight = {
|
||||
FloatBorder = "Noice" .. hl_group_border,
|
||||
FloatTitle = "Noice" .. hl_group_title,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -45,7 +50,7 @@ function M.setup()
|
||||
table.insert(Config.options.routes, {
|
||||
view = format.view,
|
||||
opts = format.opts,
|
||||
filter = { event = "cmdline", kind = format.kind },
|
||||
filter = { event = "cmdline", kind = name },
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,6 +30,22 @@ M.builtin = {
|
||||
"\n",
|
||||
"{message}",
|
||||
},
|
||||
fzf = {
|
||||
"{level} ",
|
||||
"{date} ",
|
||||
"{title} ",
|
||||
"{message}",
|
||||
},
|
||||
fzf_preview = {
|
||||
"{level} ",
|
||||
"{date} ",
|
||||
"{event}",
|
||||
{ "{kind}", before = { ".", hl_group = "NoiceFormatKind" } },
|
||||
"\n",
|
||||
"{title}\n",
|
||||
"\n",
|
||||
"{message}",
|
||||
},
|
||||
lsp_progress = {
|
||||
{
|
||||
"{progress} ",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
---@diagnostic disable: missing-fields
|
||||
local require = require("noice.util.lazy")
|
||||
|
||||
local Routes = require("noice.config.routes")
|
||||
@ -27,7 +28,7 @@ function M.defaults()
|
||||
lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = "", lang = "lua" },
|
||||
help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
|
||||
calculator = { pattern = "^=", icon = "", lang = "vimnormal" },
|
||||
input = {}, -- Used by input()
|
||||
input = { view = "cmdline_input", icon = " " }, -- Used by input()
|
||||
-- lua = false, -- to disable a format, set to `false`
|
||||
},
|
||||
},
|
||||
@ -186,12 +187,6 @@ function M.defaults()
|
||||
health = {
|
||||
checker = true, -- Disable if you don't want health checks to run
|
||||
},
|
||||
smart_move = {
|
||||
-- noice tries to move out of the way of existing floating windows.
|
||||
enabled = true, -- you can disable this behaviour here
|
||||
-- add any filetypes here, that shouldn't trigger smart move.
|
||||
excluded_filetypes = { "cmp_menu", "cmp_docs", "notify" },
|
||||
},
|
||||
---@type NoicePresets
|
||||
presets = {
|
||||
-- you can enable a preset by setting it to true, or a table that will override the preset config
|
||||
|
||||
@ -225,6 +225,13 @@ M.defaults = {
|
||||
cursorline = false,
|
||||
},
|
||||
},
|
||||
cmdline_input = {
|
||||
view = "cmdline_popup",
|
||||
border = {
|
||||
style = "rounded",
|
||||
padding = { 0, 1 },
|
||||
},
|
||||
},
|
||||
confirm = {
|
||||
backend = "popup",
|
||||
relative = "editor",
|
||||
|
||||
@ -53,6 +53,14 @@ function M.cmd(name)
|
||||
end
|
||||
|
||||
function M.enable()
|
||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||
group = vim.api.nvim_create_augroup("NoiceVimLeavePre", { clear = true }),
|
||||
callback = function()
|
||||
if Config.is_running() then
|
||||
pcall(M.disable)
|
||||
end
|
||||
end,
|
||||
})
|
||||
Config._running = true
|
||||
if Config.options.notify.enabled then
|
||||
require("noice.source.notify").enable()
|
||||
|
||||
@ -29,12 +29,8 @@ function M.format_markdown(contents)
|
||||
table.insert(parts, ("```\n%s\n```"):format(content.value))
|
||||
elseif Util.islist(content) then
|
||||
vim.list_extend(parts, M.format_markdown(content))
|
||||
elseif type(content) == "table" and next(content) == nil then
|
||||
goto continue
|
||||
else
|
||||
error("Unknown markup " .. vim.inspect(content))
|
||||
end
|
||||
::continue::
|
||||
-- ignore other types of content (invalid content)
|
||||
end
|
||||
|
||||
return vim.split(table.concat(parts, "\n"), "\n")
|
||||
|
||||
@ -9,6 +9,7 @@ local _id = 0
|
||||
---@field super NoiceBlock
|
||||
---@field id number
|
||||
---@field event NoiceEvent
|
||||
---@field title? string
|
||||
---@field ctime number
|
||||
---@field mtime number
|
||||
---@field tick number
|
||||
|
||||
@ -109,9 +109,13 @@ end
|
||||
|
||||
function M.check_redraw()
|
||||
if Util.is_blocking() and M._need_redraw then
|
||||
-- NOTE: set to false before actually calling redraw to prevent a loop with ui
|
||||
M._need_redraw = false
|
||||
Util.redraw()
|
||||
-- don't do full redraw during search
|
||||
if not (Util.is_search() and require("noice.ui.cmdline").real_cursor) then
|
||||
-- NOTE: set to false before actually calling redraw to prevent a loop with ui
|
||||
M._need_redraw = false
|
||||
Util.redraw()
|
||||
end
|
||||
require("noice.ui.cmdline").fix_cursor()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ local Markdown = require("noice.text.markdown")
|
||||
|
||||
---@class NoiceText: NuiText
|
||||
---@field super NuiText
|
||||
---@field enabled? boolean
|
||||
---@field on_render? fun(text: NoiceText, buf:number, line: number, byte:number, col:number)
|
||||
---@overload fun(content:string, highlight?:string|NoiceExtmark):NoiceText
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
@ -111,7 +112,9 @@ function NoiceText:highlight(bufnr, ns_id, linenr, byte_start)
|
||||
extmark.col = nil
|
||||
end
|
||||
|
||||
NoiceText.super.highlight(self, bufnr, ns_id, linenr, byte_start)
|
||||
if self.enabled ~= false then
|
||||
NoiceText.super.highlight(self, bufnr, ns_id, linenr, byte_start)
|
||||
end
|
||||
|
||||
if self.on_render then
|
||||
self.on_render(self, bufnr, linenr, byte_start_orig, col_start)
|
||||
|
||||
@ -24,6 +24,7 @@ M.events = {
|
||||
|
||||
---@type NoiceCmdline?
|
||||
M.active = nil
|
||||
M.real_cursor = vim.api.nvim__redraw ~= nil
|
||||
|
||||
---@alias NoiceCmdlineFormatter fun(cmdline: NoiceCmdline): {icon?:string, offset?:number, view?:NoiceViewOptions}
|
||||
|
||||
@ -37,6 +38,7 @@ M.active = nil
|
||||
---@field block table
|
||||
|
||||
---@class CmdlineFormat
|
||||
---@field name string
|
||||
---@field kind string
|
||||
---@field pattern? string|string[]
|
||||
---@field view string
|
||||
@ -112,19 +114,28 @@ end
|
||||
function Cmdline:format(message, text_only)
|
||||
local format = self:get_format()
|
||||
message.fix_cr = false
|
||||
message.title = nil
|
||||
|
||||
if format.icon then
|
||||
local use_input = self.state.prompt ~= ""
|
||||
and format.view == "cmdline_input"
|
||||
and #self.state.prompt <= 60
|
||||
and not self.state.prompt:find("\n")
|
||||
|
||||
if format.icon and (format.name ~= "input" or use_input) then
|
||||
message:append(NoiceText.virtual_text(format.icon, format.icon_hl_group))
|
||||
message:append(" ")
|
||||
end
|
||||
|
||||
if not text_only then
|
||||
message.kind = format.kind
|
||||
message.kind = format.name
|
||||
end
|
||||
|
||||
-- FIXME: prompt
|
||||
if self.state.prompt ~= "" then
|
||||
message:append(self.state.prompt, "NoiceCmdlinePrompt")
|
||||
if use_input then
|
||||
message.title = " " .. self.state.prompt:gsub("%s*:%s*$", "") .. " "
|
||||
else
|
||||
message:append(self.state.prompt, "NoiceCmdlinePrompt")
|
||||
end
|
||||
end
|
||||
|
||||
if not format.conceal then
|
||||
@ -142,6 +153,7 @@ function Cmdline:format(message, text_only)
|
||||
if not text_only then
|
||||
local cursor = NoiceText.cursor(-self:length() + self.state.pos)
|
||||
cursor.on_render = M.on_render
|
||||
cursor.enabled = not M.real_cursor
|
||||
message:append(cursor)
|
||||
end
|
||||
end
|
||||
@ -211,10 +223,35 @@ end
|
||||
---@class CmdlinePosition
|
||||
---@field win number Window containing the cmdline
|
||||
---@field buf number Buffer containing the cmdline
|
||||
---@field cursor number
|
||||
---@field bufpos {row:number, col:number} (1-0)-indexed position of the cmdline in the buffer
|
||||
---@field screenpos {row:number, col:number} (1-0)-indexed screen position of the cmdline
|
||||
M.position = nil
|
||||
|
||||
function M.fix_cursor()
|
||||
if not M.position then
|
||||
return
|
||||
end
|
||||
local win = M.position.win
|
||||
local cursor = M.position.cursor
|
||||
if vim.api.nvim_win_is_valid(win) then
|
||||
local height = vim.api.nvim_buf_line_count(M.position.buf)
|
||||
vim.api.nvim_win_set_cursor(win, { height, cursor })
|
||||
vim.api.nvim_win_call(win, function()
|
||||
local width = vim.api.nvim_win_get_width(win)
|
||||
local leftcol = math.max(cursor - width + 1, 0)
|
||||
vim.fn.winrestview({ leftcol = leftcol })
|
||||
end)
|
||||
if M.real_cursor then
|
||||
vim.cmd.redrawstatus()
|
||||
vim.api.nvim__redraw({
|
||||
cursor = true,
|
||||
win = win,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param buf number
|
||||
---@param line number
|
||||
---@param byte number
|
||||
@ -227,19 +264,10 @@ function M.on_render(_, buf, line, byte)
|
||||
local cmdline_start = byte - (M.last():length() - M.last().offset)
|
||||
|
||||
local cursor = byte - M.last():length() + M.last().state.pos
|
||||
vim.schedule(function()
|
||||
if vim.api.nvim_win_is_valid(win) then
|
||||
vim.api.nvim_win_set_cursor(win, { 1, cursor })
|
||||
vim.api.nvim_win_call(win, function()
|
||||
local width = vim.api.nvim_win_get_width(win)
|
||||
local leftcol = math.max(cursor - width + 1, 0)
|
||||
vim.fn.winrestview({ leftcol = leftcol })
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
local pos = vim.fn.screenpos(win, line, cmdline_start)
|
||||
M.position = {
|
||||
cursor = cursor,
|
||||
buf = buf,
|
||||
win = win,
|
||||
bufpos = {
|
||||
@ -251,6 +279,7 @@ function M.on_render(_, buf, line, byte)
|
||||
col = pos.col - 1,
|
||||
},
|
||||
}
|
||||
pcall(M.fix_cursor)
|
||||
end
|
||||
end
|
||||
|
||||
@ -265,11 +294,15 @@ function M.update()
|
||||
|
||||
if cmdline then
|
||||
cmdline:format(M.message)
|
||||
Hacks.hide_cursor()
|
||||
if not M.real_cursor then
|
||||
Hacks.hide_cursor()
|
||||
end
|
||||
Manager.add(M.message)
|
||||
else
|
||||
Manager.remove(M.message)
|
||||
Hacks.show_cursor()
|
||||
if not M.real_cursor then
|
||||
Hacks.show_cursor()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -153,6 +153,10 @@ function M.on_confirm(event, kind, content)
|
||||
if State.skip(event, kind, content) then
|
||||
return
|
||||
end
|
||||
local prev = Manager.get({ event = event, kind = kind }, { history = true })[1]
|
||||
if prev then
|
||||
Manager.remove(prev)
|
||||
end
|
||||
local message = Message(event, kind, content)
|
||||
if not message:content():find("%s+$") then
|
||||
message:append(" ")
|
||||
|
||||
@ -256,6 +256,10 @@ end
|
||||
|
||||
M.SPECIAL = "Þ"
|
||||
function M.cmdline_force_redraw()
|
||||
if vim.fn.has("nvim-0.11") == 1 then
|
||||
-- no longer needed on nightly
|
||||
return
|
||||
end
|
||||
if not require("noice.util.ffi").cmdpreview then
|
||||
return
|
||||
end
|
||||
|
||||
@ -217,6 +217,14 @@ function M._diff(a, b)
|
||||
return false
|
||||
end
|
||||
|
||||
function M.is_search()
|
||||
local cmdline = require("noice.ui.cmdline")
|
||||
local c = cmdline.active
|
||||
if c and (c.state.firstc == "/" or c.state.firstc == "?") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
---@param opts? {blocking:boolean, mode:boolean, input:boolean, redraw:boolean}
|
||||
function M.is_blocking(opts)
|
||||
opts = vim.tbl_deep_extend("force", {
|
||||
|
||||
@ -236,17 +236,17 @@ function M.anchor(width, height)
|
||||
end
|
||||
|
||||
function M.scroll(win, delta)
|
||||
local info = vim.fn.getwininfo(win)[1] or {}
|
||||
local top = info.topline or 1
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
Util.wo(win, { scrolloff = 0 })
|
||||
local view = vim.api.nvim_win_call(win, vim.fn.winsaveview)
|
||||
local height = vim.api.nvim_win_get_height(win)
|
||||
local top = view.topline
|
||||
top = top + delta
|
||||
top = math.max(top, 1)
|
||||
top = math.min(top, M.win_buf_height(win) - info.height + 1)
|
||||
top = math.min(top, M.win_buf_height(win) - height + 1)
|
||||
|
||||
vim.defer_fn(function()
|
||||
vim.api.nvim_buf_call(buf, function()
|
||||
vim.api.nvim_command("noautocmd silent! normal! " .. top .. "zt")
|
||||
vim.api.nvim_exec_autocmds("WinScrolled", { modeline = false })
|
||||
vim.api.nvim_win_call(win, function()
|
||||
vim.fn.winrestview({ topline = top, lnum = top })
|
||||
end)
|
||||
end, 0)
|
||||
end
|
||||
|
||||
@ -31,6 +31,9 @@ end
|
||||
|
||||
function MiniView:update_options()
|
||||
self._opts = vim.tbl_deep_extend("force", defaults, self._opts)
|
||||
if self.view then
|
||||
self.view:update_options()
|
||||
end
|
||||
end
|
||||
|
||||
---@param message NoiceMessage
|
||||
|
||||
@ -3,21 +3,22 @@ local require = require("noice.util.lazy")
|
||||
local View = require("noice.view")
|
||||
local Util = require("noice.util")
|
||||
local Scrollbar = require("noice.view.scrollbar")
|
||||
local Config = require("noice.config")
|
||||
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
---@class NuiView: NoiceView
|
||||
---@field _nui? NuiPopup|NuiSplit
|
||||
---@field _loading? boolean
|
||||
---@field super NoiceView
|
||||
---@field _hider fun()
|
||||
---@field _timeout_timer vim.loop.Timer
|
||||
---@field _timeout_timer uv_timer_t
|
||||
---@field _scroll NoiceScrollbar
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local NuiView = View:extend("NuiView")
|
||||
|
||||
function NuiView:init(opts)
|
||||
NuiView.super.init(self, opts)
|
||||
self._timer = vim.loop.new_timer()
|
||||
self._timer = uv.new_timer()
|
||||
end
|
||||
|
||||
function NuiView:autohide()
|
||||
@ -47,7 +48,19 @@ function NuiView:update_options()
|
||||
},
|
||||
}, self._opts, self:get_layout())
|
||||
|
||||
local title = {} ---@type string[]
|
||||
for _, m in ipairs(self._messages) do
|
||||
if m.title then
|
||||
title[#title + 1] = m.title
|
||||
end
|
||||
end
|
||||
|
||||
self._opts = Util.nui.normalize(self._opts)
|
||||
if #title > 0 then
|
||||
self._opts.border = self._opts.border or {}
|
||||
self._opts.border.text = self._opts.border.text or {}
|
||||
self._opts.border.text.top = table.concat(title, " | ")
|
||||
end
|
||||
if self._opts.anchor == "auto" then
|
||||
if self._opts.type == "popup" and self._opts.size then
|
||||
local width = self._opts.size.width
|
||||
@ -69,55 +82,6 @@ function NuiView:update_options()
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if other floating windows are overlapping and move out of the way
|
||||
function NuiView:smart_move()
|
||||
if not Config.options.smart_move.enabled then
|
||||
return
|
||||
end
|
||||
if not (self._opts.type == "popup" and self._opts.relative and self._opts.relative.type == "editor") then
|
||||
return
|
||||
end
|
||||
if not (self._nui.winid and vim.api.nvim_win_is_valid(self._nui.winid)) then
|
||||
return
|
||||
end
|
||||
if not (self._nui.border.winid and vim.api.nvim_win_is_valid(self._nui.border.winid)) then
|
||||
return
|
||||
end
|
||||
|
||||
local nui_win = self._nui.border._.type == "complex" and self._nui.border.winid or self._nui.winid
|
||||
|
||||
local wins = vim.tbl_filter(function(win)
|
||||
local ft = vim.bo[vim.api.nvim_win_get_buf(win)].filetype
|
||||
return win ~= self._nui.winid
|
||||
and ft ~= "noice"
|
||||
and not vim.tbl_contains(Config.options.smart_move.excluded_filetypes, ft)
|
||||
and not (self._nui.border and self._nui.border.winid == win)
|
||||
and vim.api.nvim_win_is_valid(win)
|
||||
and vim.api.nvim_win_get_config(win).relative == "editor"
|
||||
and Util.nui.overlap(nui_win, win) > 0.3
|
||||
end, vim.api.nvim_list_wins())
|
||||
|
||||
if #wins > 0 then
|
||||
-- local info = vim.tbl_map(function(win)
|
||||
-- local buf = vim.api.nvim_win_get_buf(win)
|
||||
-- return {
|
||||
-- win = win,
|
||||
-- buftype = vim.bo[buf].buftype,
|
||||
-- ft = vim.bo[buf].filetype,
|
||||
-- syntax = vim.bo[buf].syntax,
|
||||
-- text = table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, false), "\n"),
|
||||
-- name = vim.api.nvim_buf_get_name(buf),
|
||||
-- -- config = vim.api.nvim_win_get_config(win),
|
||||
-- area = Util.nui.overlap(nui_win, win),
|
||||
-- }
|
||||
-- end, wins)
|
||||
-- dumpp(info)
|
||||
local layout = self:get_layout()
|
||||
layout.position.row = 2
|
||||
self._nui:update_layout(layout)
|
||||
end
|
||||
end
|
||||
|
||||
function NuiView:create()
|
||||
if self._loading then
|
||||
return
|
||||
@ -323,7 +287,6 @@ function NuiView:show()
|
||||
if not self._visible then
|
||||
self:set_win_options(self._nui.winid)
|
||||
self:update_layout()
|
||||
self:smart_move()
|
||||
end
|
||||
|
||||
if self._scroll then
|
||||
|
||||
@ -124,7 +124,9 @@ function Scrollbar:update()
|
||||
local thumb_height = math.floor(dim.height * dim.height / buf_height + 0.5)
|
||||
thumb_height = math.max(1, thumb_height)
|
||||
|
||||
local pct = vim.api.nvim_win_get_cursor(self.winnr)[1] / buf_height
|
||||
local view = vim.api.nvim_win_call(self.winnr, vim.fn.winsaveview)
|
||||
|
||||
local pct = math.min(view.topline / (buf_height - dim.height + 1), 1)
|
||||
|
||||
local thumb_offset = math.floor(pct * (dim.height - thumb_height) + 0.5)
|
||||
|
||||
|
||||
@ -7,6 +7,8 @@ local pickers = require("telescope.pickers")
|
||||
local finders = require("telescope.finders")
|
||||
local conf = require("telescope.config").values
|
||||
local previewers = require("telescope.previewers")
|
||||
local actions = require("telescope.actions")
|
||||
local action_state = require("telescope.actions.state")
|
||||
|
||||
local M = {}
|
||||
|
||||
@ -59,6 +61,45 @@ function M.previewer()
|
||||
})
|
||||
end
|
||||
|
||||
function M.mappings()
|
||||
return function(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
if selection == nil then return end
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_keymap(buf, 'n', 'q', ':q<CR>', { silent = true })
|
||||
|
||||
local message = Format.format(selection.message, "telescope_preview")
|
||||
message:render(buf, Config.ns)
|
||||
|
||||
local lines = vim.opt.lines:get()
|
||||
local cols = vim.opt.columns:get()
|
||||
local width = math.ceil(cols * 0.8)
|
||||
local height = math.ceil(lines * 0.8 - 4)
|
||||
local left = math.ceil((cols - width) * 0.5)
|
||||
local top = math.ceil((lines - height) * 0.5)
|
||||
|
||||
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
style = "minimal",
|
||||
width = width,
|
||||
height = height,
|
||||
col = left,
|
||||
row = top,
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
vim.api.nvim_win_set_option(win, "wrap", true)
|
||||
vim.api.nvim_buf_set_option(buf, 'modifiable', false)
|
||||
end)
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function M.telescope(opts)
|
||||
pickers
|
||||
.new(opts, {
|
||||
@ -67,6 +108,7 @@ function M.telescope(opts)
|
||||
finder = M.finder(),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
previewer = M.previewer(),
|
||||
attach_mappings = M.mappings(),
|
||||
})
|
||||
:find()
|
||||
end
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
#!/nix/store/306znyj77fv49kwnkpxmb0j2znqpa8bj-bash-5.2p26/bin/sh
|
||||
#!/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/sh
|
||||
|
||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
||||
|
||||
Reference in New Issue
Block a user