-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
nvim_win_get_config
returns table value for row
and col
instead of number
#24430
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
The As a Vim script number would still be accepted as a float value in the API, preserving this information doesn't seem too useful here? |
I don't think this behavior should be changed. The same behavior also applies to other functions like See also
|
Thank you for the comments. It took me a couple times of reading this and the docs to understand what is going on so I'll put my understanding here in case it helps anyone else who comes across this in the future. Given the result: col = {
[false] = 10,
[true] = 3
}, Reading help example {[vim.type_idx]=vim.types.float, [vim.val_idx]=1}` is converted to
a floating-point 1.0. This looks confusing at first, but those are just variables.
So, given a lua table with two elements that have the keys Back to the example, col = { col = { col = {
[false] = 10, -> [vim.val_idx] = 10, -> [vim.val_idx] = 10,
[true] = 3 -> [vim.type_idx] = 3 -> [vim.type_idx] = vim.types.float
}, }, }, col is a special table, with a value of 10 and a type of float. |
For anyone else ending up here like I did. If you need the row, col values from local config = vim.api.nvim_win_get_config(winnr)
local row = config.row[vim.val_idx]
local col = config.col[vim.val_idx] |
Fixed by #27284 |
Problem
vim.api.nvim_win_get_config
returns table values forrow
andcol
:You have to access
row[false]
andcol[false]
to get the real value.Steps to reproduce
Write to file:
Run the file:
nvim -u NORC -c 'luafile %' config_test.lua
Expected behavior
I expect
row
andcol
to be numbers, not tables.Neovim version (nvim -v)
0.9.1
Vim (not Nvim) behaves the same?
n/a
Operating system/version
Arch Linux (kernel version 6.4.4-arch1-1)
Terminal name/version
kitty 0.28.1
$TERM environment variable
tmux-256color
Installation
Arch Extra repo
The text was updated successfully, but these errors were encountered: