@@ -26,7 +26,13 @@ local function usable_win_ids()
2626 return vim .tbl_filter (function (id )
2727 local bufid = vim .api .nvim_win_get_buf (id )
2828 for option , v in pairs (M .window_picker .exclude ) do
29- local ok , option_value = pcall (vim .api .nvim_buf_get_option , bufid , option )
29+ local ok , option_value
30+ if vim .fn .has " nvim-0.10" == 1 then
31+ ok , option_value = pcall (vim .api .nvim_get_option_value , option , { buf = bufid })
32+ else
33+ ok , option_value = pcall (vim .api .nvim_buf_get_option , bufid , option ) --- @diagnostic disable-line : deprecated
34+ end
35+
3036 if ok and vim .tbl_contains (v , option_value ) then
3137 return false
3238 end
@@ -83,33 +89,56 @@ local function pick_win_id()
8389
8490 if laststatus == 3 then
8591 for _ , win_id in ipairs (not_selectable ) do
86- local ok_status , statusline = pcall (vim .api .nvim_win_get_option , win_id , " statusline" )
87- local ok_hl , winhl = pcall (vim .api .nvim_win_get_option , win_id , " winhl" )
92+ local ok_status , statusline , ok_hl , winhl
93+
94+ if vim .fn .has " nvim-0.10" == 1 then
95+ ok_status , statusline = pcall (vim .api .nvim_get_option_value , " statusline" , { win = win_id })
96+ ok_hl , winhl = pcall (vim .api .nvim_get_option_value , " winhl" , { win = win_id })
97+ else
98+ ok_status , statusline = pcall (vim .api .nvim_win_get_option , win_id , " statusline" ) --- @diagnostic disable-line : deprecated
99+ ok_hl , winhl = pcall (vim .api .nvim_win_get_option , win_id , " winhl" ) --- @diagnostic disable-line : deprecated
100+ end
88101
89102 win_opts [win_id ] = {
90103 statusline = ok_status and statusline or " " ,
91104 winhl = ok_hl and winhl or " " ,
92105 }
93106
94107 -- Clear statusline for windows not selectable
95- vim .api .nvim_win_set_option (win_id , " statusline" , " " )
108+ if vim .fn .has " nvim-0.10" == 1 then
109+ vim .api .nvim_set_option_value (" statusline" , " " , { win = win_id })
110+ else
111+ vim .api .nvim_win_set_option (win_id , " statusline" , " " ) --- @diagnostic disable-line : deprecated
112+ end
96113 end
97114 end
98115
99116 -- Setup UI
100117 for _ , id in ipairs (selectable ) do
101118 local char = M .window_picker .chars :sub (i , i )
102- local ok_status , statusline = pcall (vim .api .nvim_win_get_option , id , " statusline" )
103- 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
104128
105129 win_opts [id ] = {
106130 statusline = ok_status and statusline or " " ,
107131 winhl = ok_hl and winhl or " " ,
108132 }
109133 win_map [char ] = id
110134
111- vim .api .nvim_win_set_option (id , " statusline" , " %=" .. char .. " %=" )
112- 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
113142
114143 i = i + 1
115144 if i > # M .window_picker .chars then
@@ -128,14 +157,22 @@ local function pick_win_id()
128157 -- Restore window options
129158 for _ , id in ipairs (selectable ) do
130159 for opt , value in pairs (win_opts [id ]) do
131- 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
132165 end
133166 end
134167
135168 if laststatus == 3 then
136169 for _ , id in ipairs (not_selectable ) do
137170 for opt , value in pairs (win_opts [id ]) do
138- 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
139176 end
140177 end
141178 end
@@ -258,7 +295,15 @@ local function open_in_new_window(filename, mode)
258295 -- If `hidden` is not enabled, check if buffer in target window is
259296 -- modified, and create new split if it is.
260297 local target_bufid = vim .api .nvim_win_get_buf (target_winid )
261- if vim .api .nvim_buf_get_option (target_bufid , " modified" ) then
298+
299+ local modified
300+ if vim .fn .has " nvim-0.10" == 1 then
301+ modified = vim .api .nvim_get_option_value (" modified" , { buf = target_bufid })
302+ else
303+ modified = vim .api .nvim_buf_get_option (target_bufid , " modified" ) --- @diagnostic disable-line : deprecated
304+ end
305+
306+ if modified then
262307 if not mode :match " split$" then
263308 mode = " vsplit"
264309 end
0 commit comments