@@ -116,17 +116,29 @@ local function pick_win_id()
116
116
-- Setup UI
117
117
for _ , id in ipairs (selectable ) do
118
118
local char = M .window_picker .chars :sub (i , i )
119
- local ok_status , statusline = pcall (vim .api .nvim_win_get_option , id , " statusline" )
120
- local ok_hl , winhl = pcall (vim .api .nvim_win_get_option , id , " winhl" )
119
+
120
+ local ok_status , statusline , ok_hl , winhl
121
+ if vim .fn .has " nvim-0.10" == 1 then
122
+ ok_status , statusline = pcall (vim .api .nvim_get_option_value , " statusline" , { win = id })
123
+ ok_hl , winhl = pcall (vim .api .nvim_get_option_value , " winhl" , { win = id })
124
+ else
125
+ ok_status , statusline = pcall (vim .api .nvim_win_get_option , id , " statusline" ) --- @diagnostic disable-line : deprecated
126
+ ok_hl , winhl = pcall (vim .api .nvim_win_get_option , id , " winhl" ) --- @diagnostic disable-line : deprecated
127
+ end
121
128
122
129
win_opts [id ] = {
123
130
statusline = ok_status and statusline or " " ,
124
131
winhl = ok_hl and winhl or " " ,
125
132
}
126
133
win_map [char ] = id
127
134
128
- vim .api .nvim_win_set_option (id , " statusline" , " %=" .. char .. " %=" )
129
- vim .api .nvim_win_set_option (id , " winhl" , " StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker" )
135
+ if vim .fn .has " nvim-0.10" == 1 then
136
+ vim .api .nvim_set_option_value (" statusline" , " %=" .. char .. " %=" , { win = id })
137
+ vim .api .nvim_set_option_value (" winhl" , " StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker" , { win = id })
138
+ else
139
+ vim .api .nvim_win_set_option (id , " statusline" , " %=" .. char .. " %=" ) --- @diagnostic disable-line : deprecated
140
+ vim .api .nvim_win_set_option (id , " winhl" , " StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker" ) --- @diagnostic disable-line : deprecated
141
+ end
130
142
131
143
i = i + 1
132
144
if i > # M .window_picker .chars then
@@ -145,14 +157,22 @@ local function pick_win_id()
145
157
-- Restore window options
146
158
for _ , id in ipairs (selectable ) do
147
159
for opt , value in pairs (win_opts [id ]) do
148
- vim .api .nvim_win_set_option (id , opt , value )
160
+ if vim .fn .has " nvim-0.10" == 1 then
161
+ vim .api .nvim_set_option_value (opt , value , { win = id })
162
+ else
163
+ vim .api .nvim_win_set_option (id , opt , value ) --- @diagnostic disable-line : deprecated
164
+ end
149
165
end
150
166
end
151
167
152
168
if laststatus == 3 then
153
169
for _ , id in ipairs (not_selectable ) do
154
170
for opt , value in pairs (win_opts [id ]) do
155
- vim .api .nvim_win_set_option (id , opt , value )
171
+ if vim .fn .has " nvim-0.10" == 1 then
172
+ vim .api .nvim_set_option_value (opt , value , { win = id })
173
+ else
174
+ vim .api .nvim_win_set_option (id , opt , value ) --- @diagnostic disable-line : deprecated
175
+ end
156
176
end
157
177
end
158
178
end
0 commit comments