1

Refresh generated neovim config

This commit is contained in:
2024-08-15 13:01:03 +02:00
parent 64b51cf53a
commit f5af8e2b28
1836 changed files with 38979 additions and 31094 deletions

View File

@ -6,7 +6,10 @@ body:
- type: markdown
attributes:
value: |
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/noice.nvim) and search [existing issues](https://github.com/folke/noice.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/noice.nvim/discussions) and will be closed.
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/noice.nvim)
and search [existing issues](https://github.com/folke/noice.nvim/issues).
Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/noice.nvim/discussions) and will be closed.
- type: checkboxes
attributes:
label: Did you check docs and existing issues?
@ -14,6 +17,8 @@ body:
options:
- label: I have read all the noice.nvim docs
required: true
- label: I have updated the plugin to the latest version before submitting this issue
required: true
- label: I have searched the existing issues of noice.nvim
required: true
- label: I have searched the existing issues of plugins related to this issue
@ -57,33 +62,15 @@ body:
label: Repro
description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
value: |
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
"folke/noice.nvim",
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
require("lazy.minit").repro({
spec = {
{ "folke/noice.nvim", opts = {} },
-- add any other plugins here
},
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
render: Lua
render: lua
validations:
required: false

View File

@ -1,72 +1,14 @@
name: CI
on:
push:
branches: [main, master]
pull_request:
jobs:
tests:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
[ ! -d tests ] && exit 0
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
docs:
runs-on: ubuntu-latest
needs: tests
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: noice.nvim
version: "Neovim >= 0.8.0"
demojify: true
treesitter: true
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(build): auto-generate vimdoc"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- docs
- tests
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
package-name: noice.nvim
- uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d stable || true
git push origin :stable || true
git tag -a stable -m "Last Stable Release"
git push origin stable
ci:
uses: folke/github/.github/workflows/ci.yml@main
secrets: inherit
with:
plugin: noice.nvim
repo: folke/noice.nvim

View File

@ -1,8 +1,9 @@
tt.*
.tests
doc/tags
debug
.repro
foo.*
*.log
data
/.repro
/.tests
/build
/debug
/doc/tags
foo.*
node_modules
tt.*

View File

@ -1,5 +1,103 @@
# Changelog
## [4.5.0](https://github.com/folke/noice.nvim/compare/v4.4.7...v4.5.0) (2024-07-25)
### Features
* redraw improvements ([1698725](https://github.com/folke/noice.nvim/commit/1698725a663aca56bcd07a0e405bc441a5f6613b))
## [4.4.7](https://github.com/folke/noice.nvim/compare/v4.4.6...v4.4.7) (2024-07-24)
### Bug Fixes
* **hacks:** better on_module ([c2ba96e](https://github.com/folke/noice.nvim/commit/c2ba96e09c7544e0ebba2120765fb2a081983d7f))
## [4.4.6](https://github.com/folke/noice.nvim/compare/v4.4.5...v4.4.6) (2024-07-24)
### Bug Fixes
* **health:** dont check health on startup ([9df2913](https://github.com/folke/noice.nvim/commit/9df2913ee9b6440f65d4debf8d2eeec07c249dea))
* **text:** deal with invalid extmark offsets. Fixes [#875](https://github.com/folke/noice.nvim/issues/875) ([15d63b8](https://github.com/folke/noice.nvim/commit/15d63b8da0a2c6b7ad2d3dbe7b473b78710c90f3))
## [4.4.5](https://github.com/folke/noice.nvim/compare/v4.4.4...v4.4.5) (2024-07-22)
### Bug Fixes
* **hacks:** cmp loading ([4f5d1b8](https://github.com/folke/noice.nvim/commit/4f5d1b89daa5b5db4a85f3badf35d0e7eea86308))
## [4.4.4](https://github.com/folke/noice.nvim/compare/v4.4.3...v4.4.4) (2024-07-21)
### Bug Fixes
* **hacks:** schedule fixing cmp. Fixes [#910](https://github.com/folke/noice.nvim/issues/910) ([b7515c0](https://github.com/folke/noice.nvim/commit/b7515c038ad9047e0332ca379a71d7640f53c919))
* remove a bunch of hacks that are no longer needed ([5e55d0d](https://github.com/folke/noice.nvim/commit/5e55d0d46f672077f6ae0b69f4f6dfeb63b9ea33))
### Performance Improvements
* **scrollbar:** only show when needed ([7723c2b](https://github.com/folke/noice.nvim/commit/7723c2b1e699708dbe3b2717b21088a09f0eec75))
## [4.4.3](https://github.com/folke/noice.nvim/compare/v4.4.2...v4.4.3) (2024-07-16)
### Bug Fixes
* **mini:** no need to show scrollbar ([c661f95](https://github.com/folke/noice.nvim/commit/c661f955055b7341768b044160002b25bddd24af))
* **syntax:** prevent invalid group names. Closes [#903](https://github.com/folke/noice.nvim/issues/903) ([3b5ea55](https://github.com/folke/noice.nvim/commit/3b5ea551448bd769976428458c11ae3f5849b7ba))
## [4.4.2](https://github.com/folke/noice.nvim/compare/v4.4.1...v4.4.2) (2024-07-15)
### Performance Improvements
* **message:** replace vim.b.messages with lua variable ([#898](https://github.com/folke/noice.nvim/issues/898)) ([7ecc05d](https://github.com/folke/noice.nvim/commit/7ecc05d44c3ed8b9bfa5f6196c0da41d58f93218))
## [4.4.1](https://github.com/folke/noice.nvim/compare/v4.4.0...v4.4.1) (2024-07-12)
### Bug Fixes
* **views:** show confirm at the top so it doesn't obscure the buffer ([2a97893](https://github.com/folke/noice.nvim/commit/2a9789310b6b87e197f27c36e5667a9f1bb4bb24))
## [4.4.0](https://github.com/folke/noice.nvim/compare/v4.3.1...v4.4.0) (2024-07-06)
### Features
* **popupmenu:** add option to hide scrollbar in popupmenu views. ([#686](https://github.com/folke/noice.nvim/issues/686)) ([cd0cd97](https://github.com/folke/noice.nvim/commit/cd0cd97c40fd8594bc727edab16c9e4a0e43dce0))
### Bug Fixes
* **popupmenu:** respect noselect. Fixes [#758](https://github.com/folke/noice.nvim/issues/758) ([d27b118](https://github.com/folke/noice.nvim/commit/d27b118dac86d3a01b025f8a26a33683125ee69e))
## [4.3.1](https://github.com/folke/noice.nvim/compare/v4.3.0...v4.3.1) (2024-06-27)
### Bug Fixes
* **pkg:** and don't set event either ([01d57f9](https://github.com/folke/noice.nvim/commit/01d57f9666a4f2a22f9c1f4e549946083f8a827b))
* **pkg:** don't set `opts = {}`. Too many people manually call setup, so that would break their setup. Sigh.. ([bf971a9](https://github.com/folke/noice.nvim/commit/bf971a9072e738d543aaa8e1fc4b653cebc64db9))
## [4.3.0](https://github.com/folke/noice.nvim/compare/v4.2.2...v4.3.0) (2024-06-23)
### Features
* allow to press Enter to open a window to view message content in telescope ([#796](https://github.com/folke/noice.nvim/issues/796)) ([88ac368](https://github.com/folke/noice.nvim/commit/88ac36864b5976a64b14a8f156c616f41b32f228))
### Bug Fixes
* **cmdline_input:** force a border. Set cmdline input view to something else if you don't want inputprompt in a title. Closes [#866](https://github.com/folke/noice.nvim/issues/866) ([d38ca25](https://github.com/folke/noice.nvim/commit/d38ca2535fb750b835bbfff1948f7f729494b804))
* **mini:** update view options of underlying view. See [#685](https://github.com/folke/noice.nvim/issues/685) ([7ee3649](https://github.com/folke/noice.nvim/commit/7ee3649b9b5f4df5b44ae63ed85b2c9fc834a124))
* **scrollbar:** fix scrollbar. Fixes [#759](https://github.com/folke/noice.nvim/issues/759). Fixes [#727](https://github.com/folke/noice.nvim/issues/727) ([e292a01](https://github.com/folke/noice.nvim/commit/e292a011d5cf331f35e4d0ffdd6bd6e644a1fcef))
## [4.2.2](https://github.com/folke/noice.nvim/compare/v4.2.1...v4.2.2) (2024-06-16)

View File

@ -1,4 +1,4 @@
*noice.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 June 18
*noice.nvim.txt* For Neovim Last change: 2024 July 25
==============================================================================
Table of Contents *noice.nvim-table-of-contents*

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Manager = require("noice.message.manager")
local Config = require("noice.config")
local Manager = require("noice.message.manager")
---@type NoiceFilter
local nothing = { ["not"] = {} }

View File

@ -1,11 +1,11 @@
local require = require("noice.util.lazy")
local View = require("noice.view")
local Manager = require("noice.message.manager")
local Config = require("noice.config")
local Util = require("noice.util")
local Manager = require("noice.message.manager")
local Message = require("noice.message")
local Router = require("noice.message.router")
local Util = require("noice.util")
local View = require("noice.view")
---@class NoiceCommand: NoiceRouteConfig
---@field filter_opts NoiceMessageOpts

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local Util = require("noice.util")
---@class NoicePreset: NoiceConfig
---@field enabled? boolean

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local Util = require("noice.util")
local M = {}
@ -241,7 +241,7 @@ M.defaults = {
zindex = 210,
format = { "{confirm}" },
position = {
row = "50%",
row = 3,
col = "50%",
},
size = "auto",

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local Lsp = require("noice.lsp")
local Treesitter = require("noice.text.treesitter")
local Util = require("noice.util")
local start = vim.health.start or vim.health.report_start
local ok = vim.health.ok or vim.health.report_ok
@ -227,7 +227,6 @@ function M.get_source(fn)
end
return ret
end
M.check({ checkhealth = false })
M.checker = Util.interval(1000, function()
if Config.is_running() then

View File

@ -1,8 +1,8 @@
local require = require("noice.util.lazy")
local Health = require("noice.health")
local Api = require("noice.api")
local Config = require("noice.config")
local Health = require("noice.health")
local M = {}

View File

@ -1,8 +1,8 @@
local require = require("noice.util.lazy")
local Manager = require("noice.message.manager")
local Util = require("noice.util")
local Message = require("noice.message")
local Util = require("noice.util")
local M = {}

View File

@ -1,5 +1,5 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local require = require("noice.util.lazy")
local Markdown = require("noice.text.markdown")

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Config = require("noice.config")
local Docs = require("noice.lsp.docs")
local Format = require("noice.lsp.format")
local Util = require("noice.util")
local Docs = require("noice.lsp.docs")
local Config = require("noice.config")
local M = {}

View File

@ -1,10 +1,10 @@
local require = require("noice.util.lazy")
local Markdown = require("noice.text.markdown")
local require = require("noice.util.lazy")
local Config = require("noice.config")
local Format = require("noice.lsp.format")
local Message = require("noice.message")
local Hacks = require("noice.util.hacks")
local Message = require("noice.message")
local M = {}

View File

@ -1,10 +1,10 @@
local require = require("noice.util.lazy")
local Message = require("noice.message")
local Manager = require("noice.message.manager")
local Router = require("noice.message.router")
local Format = require("noice.text.format")
local Config = require("noice.config")
local Format = require("noice.text.format")
local Manager = require("noice.message.manager")
local Message = require("noice.message")
local Router = require("noice.message.router")
local Util = require("noice.util")
local M = {}
@ -16,7 +16,7 @@ M._running = false
---@param data {client_id: integer, params: lsp.ProgressParams}
function M.progress(data)
local client_id = data.client_id
local params = data.params or data.result -- TODO: Remove data.result after nvim 0.10 release
local params = data.params or data.result -- TODO: Remove data.result after nvim 0.10 release
local id = client_id .. "." .. params.token
local message = M._progress[id]

View File

@ -1,11 +1,11 @@
local require = require("noice.util.lazy")
local NoiceText = require("noice.text")
local Config = require("noice.config")
local Docs = require("noice.lsp.docs")
local Format = require("noice.lsp.format")
local Markdown = require("noice.text.markdown")
local Config = require("noice.config")
local NoiceText = require("noice.text")
local Util = require("noice.util")
local Docs = require("noice.lsp.docs")
---@class SignatureInformation
---@field label string

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Manager = require("noice.message.manager")
local Util = require("noice.util")
local M = {}

View File

@ -18,10 +18,19 @@ local _id = 0
---@field cmdline? NoiceCmdline
---@field _debug? boolean
---@field opts table<string, any>
---@field _buf_messages table<integer, table<number, true>>
---@overload fun(event: NoiceEvent, kind?: NoiceKind, content?: NoiceContent|NoiceContent[]): NoiceMessage
---@diagnostic disable-next-line: undefined-field
local Message = Block:extend("NoiceBlock")
Message._buf_messages = {}
vim.api.nvim_create_autocmd("BufDelete", {
group = vim.api.nvim_create_augroup("noice.message", { clear = true }),
callback = function(args)
Message._buf_messages[args.buf] = nil
end,
})
---@param event NoiceEvent
---@param kind? NoiceKind
---@param content? NoiceContent|NoiceContent[]
@ -74,9 +83,7 @@ end
function Message:on_remove()
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if self:on_buf(buf) then
vim.b[buf].messages = vim.tbl_filter(function(b)
return b ~= buf
end, vim.b[buf].messages)
self._buf_messages[buf][self.id] = nil
end
end
end
@ -86,13 +93,13 @@ function Message:on_win(win)
end
function Message:on_buf(buf)
return vim.b[buf].messages and vim.tbl_contains(vim.b[buf].messages, self.id)
return self._buf_messages[buf] and not not self._buf_messages[buf][self.id]
end
function Message:_add_buf(buf)
local bufs = vim.b[buf].messages or {}
table.insert(bufs, self.id)
vim.b[buf].messages = bufs
local msgs = self._buf_messages[buf] or {}
msgs[self.id] = true
self._buf_messages[buf] = msgs
end
---@param bufnr number buffer number

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Config = require("noice.config")
local Manager = require("noice.message.manager")
local Util = require("noice.util")
local View = require("noice.view")
local Manager = require("noice.message.manager")
---@class NoiceRoute
---@field view NoiceView
@ -107,18 +107,6 @@ function M.setup()
end
end
function M.check_redraw()
if Util.is_blocking() and M._need_redraw then
-- 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
function M.view_stats()
local views = M.get_views()
---@type table<string,number>
@ -168,7 +156,6 @@ function M.update()
-- only update on changes
if M._tick == Manager.tick() then
M.check_redraw()
return
end
@ -239,7 +226,6 @@ function M.update()
M._need_redraw = true
end
M.check_redraw()
M._updating = false
end

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Message = require("noice.message")
local Manager = require("noice.message.manager")
local Message = require("noice.message")
local Router = require("noice.message.router")
local Util = require("noice.util")

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local NoiceText = require("noice.text")
local Util = require("noice.util")
local M = {}

View File

@ -1,10 +1,10 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local FormatConfig = require("noice.config.format")
local Formatters = require("noice.text.format.formatters")
local NuiText = require("nui.text")
local Util = require("noice.util")
local M = {}

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local NuiText = require("nui.text")
local Treesitter = require("noice.text.treesitter")
local Syntax = require("noice.text.syntax")
local Markdown = require("noice.text.markdown")
local NuiText = require("nui.text")
local Syntax = require("noice.text.syntax")
local Treesitter = require("noice.text.treesitter")
---@class NoiceExtmark
---@field col? number
@ -113,7 +113,7 @@ function NoiceText:highlight(bufnr, ns_id, linenr, byte_start)
end
if self.enabled ~= false then
NoiceText.super.highlight(self, bufnr, ns_id, linenr, byte_start)
pcall(NoiceText.super.highlight, self, bufnr, ns_id, linenr, byte_start)
end
if self.on_render then

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local NoiceText = require("noice.text")
local Config = require("noice.config")
local NoiceText = require("noice.text")
---@alias MarkdownBlock {line:string}
---@alias MarkdownCodeBlock {code:string[], lang:string}

View File

@ -1,5 +1,9 @@
local M = {}
local function fix(str)
return str:gsub("[^%w_%.%-]+", "_")
end
--- Highlights a region of the buffer with a given language
---@param buf buffer buffer to highlight. Defaults to the current buffer if 0
---@param ns number namespace for the highlights
@ -7,6 +11,7 @@ local M = {}
---@param lang string treesitter language
function M.highlight(buf, ns, range, lang)
vim.api.nvim_buf_call(buf, function()
lang = fix(lang)
local group = "@" .. lang:upper()
-- HACK: reset current_syntax, since some syntax files like markdown won't load if it is already set

View File

@ -34,6 +34,7 @@
---@field border? _.NuiBorder
---@field anchor? NuiAnchor|"auto"
---@field focusable boolean
---@field scrollbar? boolean
---@field zindex? number
---@class NuiPopupOptions: NuiBaseOptions,_.NuiPopupOptions

View File

@ -1,10 +1,10 @@
local require = require("noice.util.lazy")
local Message = require("noice.message")
local Manager = require("noice.message.manager")
local Config = require("noice.config")
local NoiceText = require("noice.text")
local Hacks = require("noice.util.hacks")
local Manager = require("noice.message.manager")
local Message = require("noice.message")
local NoiceText = require("noice.text")
local Object = require("nui.object")
local M = {}
@ -35,7 +35,7 @@ M.real_cursor = vim.api.nvim__redraw ~= nil
---@field prompt string
---@field indent number
---@field level number
---@field block table
---@field block? table
---@class CmdlineFormat
---@field name string
@ -229,27 +229,24 @@ end
M.position = nil
function M.fix_cursor()
if not M.position then
local win = M.win()
if not win or not M.real_cursor 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 })
local cursor = { vim.api.nvim_buf_line_count(M.position.buf), M.position.cursor }
vim.api.nvim_win_set_cursor(win, cursor)
local leftcol = math.max(cursor[2] - vim.api.nvim_win_get_width(win) + 1, 0)
local view = vim.api.nvim_win_call(win, vim.fn.winsaveview)
if view.leftcol ~= leftcol then
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
vim.api.nvim__redraw({ cursor = true, win = win })
end
function M.win()
return M.position and M.position.win and vim.api.nvim_win_is_valid(M.position.win) and M.position.win or nil
end
---@param buf number

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Config = require("noice.config")
local Util = require("noice.util")
local Router = require("noice.message.router")
local Manager = require("noice.message.manager")
local Router = require("noice.message.router")
local Util = require("noice.util")
---@alias NoiceEvent MsgEvent|CmdlineEvent|NotifyEvent|LspEvent
---@alias NoiceKind MsgKind|NotifyLevel|LspKind

View File

@ -1,10 +1,10 @@
local require = require("noice.util.lazy")
local Cmdline = require("noice.ui.cmdline")
local Hacks = require("noice.util.hacks")
local Manager = require("noice.message.manager")
local Message = require("noice.message")
local Hacks = require("noice.util.hacks")
local State = require("noice.ui.state")
local Cmdline = require("noice.ui.cmdline")
local M = {}

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local Util = require("noice.util")
local M = {}

View File

@ -1,12 +1,12 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Config = require("noice.config")
local Menu = require("nui.menu")
local Api = require("noice.api")
local Config = require("noice.config")
local Highlights = require("noice.config.highlights")
local Menu = require("nui.menu")
local NuiLine = require("nui.line")
local Scrollbar = require("noice.view.scrollbar")
local Highlights = require("noice.config.highlights")
local Util = require("noice.util")
local M = {}
---@type NuiMenu|NuiTree
@ -206,12 +206,11 @@ function M.show(state)
M.create(items, opts)
end
M.on_select(state, false)
-- redraw is needed when in blocking mode
if Util.is_blocking() then
Util.redraw()
end
M.on_select(state)
end
---@param opts _.NuiPopupOptions
@ -225,12 +224,15 @@ function M.create(items, opts)
if M.menu.border then
Util.tag(M.menu.border.bufnr, "popupmenu.border")
end
vim.wo[M.menu.winid].cursorline = false
M.scroll = Scrollbar({
winnr = M.menu.winid,
padding = Util.nui.normalize_padding(opts.border),
})
M.scroll:mount()
if opts.scrollbar ~= false then
M.scroll = Scrollbar({
winnr = M.menu.winid,
padding = Util.nui.normalize_padding(opts.border),
})
M.scroll:mount()
end
end
---@param state Popupmenu
@ -239,10 +241,19 @@ function M.on_show(state)
end
---@param state Popupmenu
function M.on_select(state)
if M.menu and state.selected ~= -1 then
vim.api.nvim_win_set_cursor(M.menu.winid, { state.selected + 1, 0 })
vim.api.nvim_exec_autocmds("WinScrolled", { modeline = false })
---@param redraw? boolean
function M.on_select(state, redraw)
if M.menu then
if state.selected == -1 then
vim.wo[M.menu.winid].cursorline = false
else
vim.wo[M.menu.winid].cursorline = true
vim.api.nvim_win_set_cursor(M.menu.winid, { state.selected + 1, 0 })
vim.api.nvim_exec_autocmds("WinScrolled", { modeline = false })
if redraw ~= false and Util.is_blocking() then
Util.redraw()
end
end
end
end

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local Router = require("noice.message.router")
local Api = require("noice.api")
local Cmdline = require("noice.ui.cmdline")
local Util = require("noice.util")
local uv = vim.uv or vim.loop
-- HACK: a bunch of hacks to make Noice behave
local M = {}
@ -17,11 +17,9 @@ end
function M.enable()
M.reset_augroup()
M.fix_input()
M.fix_redraw()
M.fix_cmp()
M.fix_vim_sleuth()
-- M.fix_cmdpreview()
M.fix_redraw()
-- Hacks for Neovim < 0.10
if vim.fn.has("nvim-0.10") == 0 then
@ -29,6 +27,28 @@ function M.enable()
end
end
function M.fix_redraw()
local timer = uv.new_timer()
timer:start(
0,
30,
vim.schedule_wrap(function()
if not Util.is_search() then
if vim.api.nvim__redraw then
vim.api.nvim__redraw({ flush = true, cursor = true })
else
vim.cmd.redraw()
end
end
Cmdline.fix_cursor()
end)
)
table.insert(M._disable, function()
timer:stop()
timer:close()
end)
end
function M.fix_vim_sleuth()
vim.g.sleuth_noice_heuristics = 0
end
@ -57,15 +77,6 @@ function M.fix_nohlsearch()
M.fix_nohlsearch()
end
---@see https://github.com/neovim/neovim/issues/20793
function M.draw_cursor()
if vim.api.nvim__redraw then
vim.api.nvim__redraw({ cursor = true })
else
require("noice.util.ffi").setcursor_mayforce(true)
end
end
---@see https://github.com/neovim/neovim/issues/17810
function M.fix_incsearch()
---@type integer|nil
@ -92,123 +103,6 @@ function M.fix_incsearch()
})
end
-- we need to intercept redraw so we can safely ignore message triggered by redraw
-- This wraps vim.cmd, nvim_cmd, nvim_command and nvim_exec
---@see https://github.com/neovim/neovim/issues/20416
M.inside_redraw = false
function M.fix_redraw()
local nvim_cmd = vim.api.nvim_cmd
local function wrap(fn, ...)
local inside_redraw = M.inside_redraw
M.inside_redraw = true
---@type boolean, any
local ok, ret = pcall(fn, ...)
-- check if the ui needs updating
Util.try(Router.update)
if not inside_redraw then
M.inside_redraw = false
end
if ok then
return ret
end
error(ret)
end
vim.api.nvim_cmd = function(cmd, ...)
if type(cmd) == "table" and cmd.cmd and cmd.cmd == "redraw" then
return wrap(nvim_cmd, cmd, ...)
else
return nvim_cmd(cmd, ...)
end
end
local nvim_command = vim.api.nvim_command
vim.api.nvim_command = function(cmd, ...)
if cmd == "redraw" then
return wrap(nvim_command, cmd, ...)
else
return nvim_command(cmd, ...)
end
end
local nvim_exec = vim.api.nvim_exec
vim.api.nvim_exec = function(cmd, ...)
if type(cmd) == "string" and cmd:find("redraw") then
-- WARN: this will potentially lose messages before or after the redraw ex command
-- example: echo "foo" | redraw | echo "bar"
-- the 'foo' message will be lost
return wrap(nvim_exec, cmd, ...)
else
return nvim_exec(cmd, ...)
end
end
table.insert(M._disable, function()
vim.api.nvim_cmd = nvim_cmd
vim.api.nvim_command = nvim_command
vim.api.nvim_exec = nvim_exec
end)
end
---@see https://github.com/neovim/neovim/issues/20311
M.before_input = false
function M.fix_input()
local function wrap(fn, skip)
return function(...)
if skip and skip(...) then
return fn(...)
end
-- make sure the cursor is drawn before blocking
M.draw_cursor()
local Manager = require("noice.message.manager")
-- do any updates now before blocking
M.before_input = true
Router.update()
---@type boolean, any
local ok, ret = pcall(fn, ...)
-- clear any message right after input
Manager.clear({ event = "msg_show", kind = { "echo", "echomsg", "" } })
M.before_input = false
if ok then
return ret
end
error(ret)
end
end
local function skip(expr)
return expr ~= nil
end
local getchar = vim.fn.getchar
local getcharstr = vim.fn.getcharstr
local inputlist = vim.fn.inputlist
-- local confirm = vim.fn.confirm
vim.fn.getchar = wrap(vim.fn.getchar, skip)
vim.fn.getcharstr = wrap(vim.fn.getcharstr, skip)
vim.fn.inputlist = wrap(vim.fn.inputlist, nil)
-- vim.fn.confirm = wrap(vim.fn.confirm, nil)
table.insert(M._disable, function()
vim.fn.getchar = getchar
vim.fn.getcharstr = getcharstr
vim.fn.inputlist = inputlist
-- vim.fn.confirm = confirm
end)
end
-- Fixes cmp cmdline position
function M.fix_cmp()
M.on_module("cmp.utils.api", function(api)
@ -242,19 +136,8 @@ function M.fix_cmp()
end)
end
function M.fix_cmdpreview()
vim.api.nvim_create_autocmd("CmdlineChanged", {
group = M.group,
callback = function()
local ffi = require("noice.util.ffi")
ffi.cmdpreview = false
vim.cmd([[redraw]])
Util.try(require("noice.message.router").update)
end,
})
end
M.SPECIAL = "Þ"
---@deprecated
function M.cmdline_force_redraw()
if vim.fn.has("nvim-0.11") == 1 then
-- no longer needed on nightly
@ -270,6 +153,7 @@ end
---@type string?
M._guicursor = nil
---@deprecated
function M.hide_cursor()
if M._guicursor == nil then
M._guicursor = vim.go.guicursor
@ -283,6 +167,7 @@ function M.hide_cursor()
M._disable.guicursor = M.show_cursor
end
---@deprecated
function M.show_cursor()
if M._guicursor then
if not Util.is_exiting() then
@ -299,22 +184,18 @@ function M.show_cursor()
end
end
---@param modname string
---@param fn fun(mod)
function M.on_module(module, fn)
if package.loaded[module] then
return fn(package.loaded[module])
function M.on_module(modname, fn)
if type(package.loaded[modname]) == "table" then
return fn(package.loaded[modname])
end
package.preload[module] = function()
package.preload[module] = nil
for _, loader in pairs(package.loaders) do
local ret = loader(module)
if type(ret) == "function" then
local mod = ret()
fn(mod)
return mod
end
end
package.preload[modname] = function()
package.preload[modname] = nil
package.loaded[modname] = nil
local mod = require(modname)
fn(mod)
return mod
end
end

View File

@ -1,7 +1,7 @@
local require = require("noice.util.lazy")
local Hacks = require("noice.util.hacks")
local Config = require("noice.config")
local Hacks = require("noice.util.hacks")
local M = {}
@ -244,8 +244,6 @@ function M.is_blocking(opts)
local reason = opts.blocking and mode.blocking and "blocking"
or opts.mode and blocking_mode and ("mode:" .. mode.mode)
or opts.input and Hacks.before_input and "input"
or opts.redraw and Hacks.inside_redraw and "redraw"
or #require("noice.ui.cmdline").cmdlines > 0 and "cmdline"
or nil
return reason ~= nil, reason

View File

@ -1,8 +1,8 @@
local require = require("noice.util.lazy")
local View = require("noice.view")
local NuiView = require("noice.view.nui")
local Util = require("noice.util")
local View = require("noice.view")
---@class NoiceMiniOptions
---@field timeout integer
@ -13,7 +13,7 @@ local defaults = { timeout = 5000 }
---@field active table<number, NoiceMessage>
---@field super NoiceView
---@field view? NuiView
---@field timers table<number, vim.loop.Timer>
---@field timers table<number, uv_timer_t>
---@diagnostic disable-next-line: undefined-field
local MiniView = View:extend("MiniView")
@ -26,11 +26,12 @@ function MiniView:init(opts)
view_opts.type = "popup"
view_opts.format = { "{message}" }
view_opts.timeout = nil
view_opts.scrollbar = false
self.view = NuiView(view_opts)
end
function MiniView:update_options()
self._opts = vim.tbl_deep_extend("force", defaults, self._opts)
self._opts = vim.tbl_deep_extend("force", defaults, self._opts) --[[@as NoiceViewOptions]]
if self.view then
self.view:update_options()
end

View File

@ -1,9 +1,9 @@
local require = require("noice.util.lazy")
local Util = require("noice.util")
local View = require("noice.view")
local Manager = require("noice.message.manager")
local NuiText = require("nui.text")
local Util = require("noice.util")
local View = require("noice.view")
---@class NoiceNotifyOptions
---@field title string
@ -126,7 +126,6 @@ function NotifyView:_notify(msg)
local opts = {
title = msg.title or self._opts.title,
animate = not Util.is_blocking(),
timeout = self._opts.timeout,
replace = self._opts.replace and self.notif,
keep = function()

View File

@ -2,9 +2,10 @@ local require = require("noice.util.lazy")
local Config = require("noice.config")
local ConfigViews = require("noice.config.views")
local Util = require("noice.util")
local Object = require("nui.object")
local Format = require("noice.text.format")
local Message = require("noice.message")
local Object = require("nui.object")
local Util = require("noice.util")
---@class NoiceViewBaseOptions
---@field buf_options? table<string,any>
@ -255,7 +256,7 @@ function View:render(buf, opts)
end
vim.api.nvim_buf_clear_namespace(buf, Config.ns, linenr - 1, -1)
vim.b[buf].messages = {}
Message._buf_messages[buf] = {}
---@type number?
local win = vim.fn.bufwinid(buf)

View File

@ -1,8 +1,8 @@
local require = require("noice.util.lazy")
local View = require("noice.view")
local Util = require("noice.util")
local Scrollbar = require("noice.view.scrollbar")
local Util = require("noice.util")
local View = require("noice.view")
local uv = vim.uv or vim.loop
@ -290,8 +290,11 @@ function NuiView:show()
end
if self._scroll then
self._scroll.winnr = self._nui.winid
self._scroll:show()
if self._scroll.winnr ~= self._nui.winid then
self._scroll.winnr = self._nui.winid
self._scroll:mount()
end
self._scroll:update()
end
self:fix_border()
self:autohide()

View File

@ -39,7 +39,12 @@ function Scrollbar:init(opts)
end
function Scrollbar:mount()
self.autocmd_id = vim.api.nvim_create_autocmd({ "WinScrolled", "CursorMoved" }, {
if self.autocmd_id then
vim.api.nvim_del_autocmd(self.autocmd_id)
self.autocmd_id = nil
end
self.autocmd_id = vim.api.nvim_create_autocmd("WinScrolled", {
pattern = tostring(self.winnr),
callback = function()
self:update()
end,
@ -158,7 +163,7 @@ function Scrollbar:_open_win(opts)
noautocmd = true,
}),
}
vim.api.nvim_win_set_option(ret.winnr, "winhighlight", "Normal:" .. opts.normal)
vim.api.nvim_set_option_value("winhighlight", "Normal:" .. opts.normal, { win = ret.winnr })
return ret
end

View File

@ -1,14 +1,14 @@
local require = require("noice.util.lazy")
local Config = require("noice.config")
local Manager = require("noice.message.manager")
local Format = require("noice.text.format")
local pickers = require("telescope.pickers")
local Manager = require("noice.message.manager")
local finders = require("telescope.finders")
local pickers = require("telescope.pickers")
local conf = require("telescope.config").values
local previewers = require("telescope.previewers")
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local actions = require("telescope.actions")
local previewers = require("telescope.previewers")
local M = {}
@ -66,10 +66,12 @@ function M.mappings()
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
if selection == nil then return end
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 })
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)
@ -81,7 +83,6 @@ function M.mappings()
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",
@ -93,7 +94,7 @@ function M.mappings()
})
vim.api.nvim_win_set_option(win, "wrap", true)
vim.api.nvim_buf_set_option(buf, 'modifiable', false)
vim.api.nvim_buf_set_option(buf, "modifiable", false)
end)
return true

View File

@ -1 +1,4 @@
std="vim"
[lints]
mixed_table="allow"

View File

@ -1,3 +1,6 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
column_width = 120
[sort_requires]
enabled = true

View File

@ -1,35 +0,0 @@
local M = {}
function M.root(root)
local f = debug.getinfo(1, "S").source:sub(2)
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
end
---@param plugin string
function M.load(plugin)
local name = plugin:match(".*/(.*)")
local package_root = M.root(".tests/site/pack/deps/start/")
if not vim.loop.fs_stat(package_root .. name) then
print("Installing " .. plugin)
vim.fn.mkdir(package_root, "p")
vim.fn.system({
"git",
"clone",
"--depth=1",
"https://github.com/" .. plugin .. ".git",
package_root .. "/" .. name,
})
end
end
function M.setup()
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.opt.runtimepath:append(M.root())
vim.opt.packpath = { M.root(".tests/site") }
M.load("MunifTanjim/nui.nvim")
M.load("nvim-lua/plenary.nvim")
M.load("rcarriga/nvim-notify")
end
M.setup()

View File

@ -1,3 +0,0 @@
#!/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/sh
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"

View File

@ -5,42 +5,17 @@ name = "vim"
[vim]
any = true
[[describe.args]]
type = "string"
[[describe.args]]
type = "function"
[[it.args]]
type = "string"
[[it.args]]
type = "function"
[[before_each.args]]
type = "function"
[[after_each.args]]
type = "function"
[assert.is_not]
[jit]
any = true
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
required = false
[assert]
any = true
[[assert.same.args]]
type = "any"
[[assert.same.args]]
type = "any"
[describe]
any = true
[[assert.truthy.args]]
type = "any"
[it]
any = true
[[assert.spy.args]]
type = "any"
[[assert.stub.args]]
type = "any"
[before_each.args]
any = true