Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible regression / API breakage / lack of deprecation warnings: 'opts.window' not being respected since commit eb3ad2eb #696

Closed
3 tasks done
sleeptightAnsiC opened this issue Jul 15, 2024 · 6 comments · Fixed by #688
Labels
bug Something isn't working

Comments

@sleeptightAnsiC
Copy link

sleeptightAnsiC commented Jul 15, 2024

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1720049189

Operating system/version

6.9.8-arch1-1 x86_64 GNU/Linux

Describe the bug

This might not be a bug but I'll report it anyway as it is a super annoying and possibly a bigger problem. Please, take your time to read it (even though my report may seem rude, I didn't mean it, apologies...)

window options were valid back in v2.1.0 according to readme:

which-key.nvim/README.md

Lines 123 to 130 in 0539da0

window = {
border = "none", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size.
padding = { 1, 2, 1, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent
zindex = 1000, -- positive value to position WhichKey above other floating windows.
},

in v3.3.0 all functionality still seems to be there, just a little bit changed:

which-key.nvim/README.md

Lines 128 to 145 in f0e99d4

win = {
-- don't allow the popup to overlap with the cursor
no_overlap = true,
-- width = 1,
-- height = { min = 4, max = 25 },
-- col = 0,
-- row = math.huge,
-- border = "none",
padding = { 1, 2 }, -- extra window padding [top/bottom, right/left]
title = true,
title_pos = "center",
zindex = 1000,
-- Additional vim.wo and vim.bo options
bo = {},
wo = {
-- winblend = 10, -- value between 0-100 0 for fully opaque and 100 for fully transparent
},
},

So before around eb3ad2e using the repro.lua provided in this report was fine, after said patch the options are just being ignored. There is no depreciation message about this, nothing appears in :mess and :checkhealth which-key that would indicate something being wrong with the options, nothing even in ~/wk.log. Latest README tells only about mappings spec changed in v3, nothing about options. Just the the WhichKey prompt appears as the default one.

If this is not intentional regression then I'm happy that I took my time to report it 😃
but if it's NOT, then please take into consideration that I had to:
(a) sandbox the plugin, (b) test which options were broken, (c) see recent changelogs, (d) bisect the git repo, (e) read the documentation yet again, (f) report this.
If I did all of this just to find out that the API has changed, then I have a really bad day today 😢

It would be really nice to prevent such situations in the future. I understand that there were 4 major releases in past month that could potentially break the API but this is just a terrible user experience.

Steps To Reproduce

  1. copy paste the attached lua script into ~/repro.lua
  2. $ nvim --clean -u ~/repro.lua
  3. press any key to invoke whichkey, e.g. v

Expected Behavior

WhichKey should honor opts.window, OR there should be any kind of deprecation warning mentioning that said option has been dropped

Health

==============================================================================
which-key: require("which-key.health").check()

- OK Most of these checks are for informational purposes only.
  WARNINGS should be treated as a warning, and don't necessarily indicate a problem with your config.
  Please |DON't| report these warnings as an issue.
- WARNING |mini.icons| is not installed
- WARNING |nvim-web-devicons| is not installed
- WARNING Keymap icon support will be limited.

Checking for issues with your mappings ~
- OK No issues reported

checking for overlapping keymaps ~
- WARNING In mode `n`, <gc> overlaps with <gcc>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
- OK Overlapping keymaps are only reported for informational purposes.
  This doesn't necessarily mean there is a problem with your config.

Checking for duplicate mappings ~
- OK No duplicate mappings found

Log

Debug Started for v3.3.0
on_key: v
ModeChanged(n:v)
State(start): { "Mode(x)", "Node()", { update = true } }
  continue: { "", "Mode(x)" }
  getchar
  on_key: <Esc>
  got: <Esc>
ModeChanged(v:n)
not safe
on_key: Z
on_key: Z

Repro

local lazy_plugins = {
	"folke/which-key.nvim",
	lazy = false,
	opts = {
		window = {
			border = "shadow",
			position = "top",
			margin = { 3, 3, 3, 3 },
			padding = { 3, 3, 3, 3 },
			winblend = 50,
			zindex = 100,
		},
		debug = true,
	}
}

local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazy_path) then
	assert(vim.system({"git", "--version"}):wait().code == 0, "where's git, brah?")
	vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", "https://github.com/folke/lazy.nvim.git", lazy_path})
end
vim.opt.rtp:prepend(lazy_path)
require("lazy").setup(lazy_plugins)
@sleeptightAnsiC sleeptightAnsiC added the bug Something isn't working label Jul 15, 2024
@folke
Copy link
Owner

folke commented Jul 15, 2024

First of all, it does indeed make sense to show a message when using an old option.

But I don't get:

I had to:
(a) sandbox the plugin, (b) test which options were broken, (c) see recent changelogs, (d) bisect the git repo, (e) read the > documentation yet again, (f) report this.
If I did all of this just to find out that the API has changed, then I have a really bad day today 😢

The valid options are all clearly documented in the config section of the readme.
Anything that is not there is not supported.

@sleeptightAnsiC
Copy link
Author

Hey @folke,

But I don't get:

I had to:
(a) sandbox the plugin, (b) test which options were broken, (c) see recent changelogs, (d) bisect the git repo, (e) read the > documentation yet again, (f) report this.
If I did all of this just to find out that the API has changed, then I have a really bad day today 😢

The valid options are all clearly documented in the config section of the readme. Anything that is not there is not supported.

This was just to explain why "read the friendly manual" is not always so obvious and simple, and that I DID in fact read it. Due to the lack of deprecation message I thought it's more possible there was a regression than the API has changed. After all (if I understand right) the docs are assembled by CI so this was possible.

Anyway, you've accepted the my ticket, so thanks for taking care of this man!

Fix confirmed on my side:

image

@max397574
Copy link
Contributor

also the healtheck (:checkhealth which-key) is really useful here

@sleeptightAnsiC
Copy link
Author

sleeptightAnsiC commented Jul 15, 2024

:checkhealth still doesn't tell about deprecation, at least not on my side.
Even after 81413ef output looks exactly the same as the one attached to this ticket.

@folke
Copy link
Owner

folke commented Jul 15, 2024

I'll add it to healthcheck too, but it already shows when opening

@max397574
Copy link
Contributor

:checkhealth still doesn't tell about deprecation, at least not on my side. Even after 81413ef output looks exactly the same as the one attached to this ticket.

well I wasn't referring to this specific thing
just in general healthcheck might be something useful to figure out if something changed
and otherwise just read the new docs 🤷

folke pushed a commit that referenced this issue Jul 15, 2024
🤖 I have created a release *beep* *boop*
---


##
[3.4.0](v3.3.0...v3.4.0)
(2024-07-15)


### Features

* added icons for function keys
([9222280](9222280))
* **mode:** allow certain modes to start hidden and only show after
keypress. See [#690](#690)
([b4fa48f](b4fa48f))
* **presets:** added gw
([09b80a6](09b80a6))
* **presets:** better padding defaults for helix preset
([4c36b9b](4c36b9b))
* **presets:** increase default height for helix
([df0ad20](df0ad20))
* simplified/documented/fixed mappings sorting. Closes
[#694](#694)
([eb73f7c](eb73f7c))
* **state:** skip mouse keys in debug
([5f85b77](5f85b77))
* **ui:** show keys/help in an overlay and added scrolling hint
([50b2c43](50b2c43))
* **view:** get parent icon if possible
([b9de927](b9de927))


### Bug Fixes

* **buf:** always detach " when executing keys. Fixes
[#689](#689)
([d36f722](d36f722))
* **config:** set expand=0 by default. Fixes
[#693](#693)
([89434aa](89434aa))
* **config:** warn when deprecated config options were used. Fixes
[#696](#696)
([81413ef](81413ef))
* **health:** move deprecated option check to health
([af7a30f](af7a30f))
* **mappings:** allow creating keymaps without desc. Fixes
[#695](#695)
([c442aaa](c442aaa))
* **plugins:** add existing keymaps to plugin view. Fixes
[#681](#681)
([26f6fd2](26f6fd2))
* **presets:** don't override title setting for classic. See
[#649](#649)
([9a53c1f](9a53c1f))
* **presets:** shorter descriptions
([20600e4](20600e4))
* **state:** always do full update on BufReadPost since buffer-local
keymaps would be deleted. Fixes
[#709](#709)
([6068887](6068887))
* **state:** don't show when coming from cmdline mode. Fixes
[#692](#692)
([8cba66b](8cba66b))
* **state:** honor timeoutlen and nowait. Fixes
[#648](#648). Closes
[#697](#697)
([80f20ee](80f20ee))
* **state:** properly disable which-key when recording macros. Fixes
[#702](#702)
([b506275](b506275))
* **state:** scrolling
([dce9167](dce9167))
* **tree:** rawget for existing plugin node children
([c77cda8](c77cda8))
* **util:** when no clipboard provider exists, use the " register as
default. Fixes
[#687](#687)
([d077a3f](d077a3f))
* **view:** disable footer on Neovim &lt; 0.10
([6d544a4](6d544a4))
* **view:** ensure highlights get set for title padding
([#684](#684))
([2e4f7af](2e4f7af))
* **view:** hide existing title/footer when no trail
([4f589a1](4f589a1))
* **view:** include group keymaps in expand results. See
[#682](https://github.com/folke/which-key.nvim/issues/682)
([39e703c](39e703c))
* **view:** overlap protection should keep at least 4 lines
([0d89475](0d89475))
* **view:** padding & column spacing. Fixes
[#704](#704)
([11eec49](11eec49))
* **view:** spacing when more than one box
([89568f3](89568f3))
* **view:** special handling of `&lt;NL&gt;/<C-J>`. Fixes
[#706](#706)
([f8c91b2](f8c91b2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants