refactor: move away from depreated neovim API functions

This commit is contained in:
raf 2024-05-19 02:33:52 +03:00
parent 30a4c18276
commit 9444b5df95
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29

View file

@ -29,13 +29,13 @@ function M.should_show_specs(start_win_id)
end end
local buftype, filetype, ok local buftype, filetype, ok
ok, buftype = pcall(vim.api.nvim_buf_get_option, 0, 'buftype') ok, buftype = pcall(vim.api.nvim_get_option_value, 'buftype', { buf = 0 })
if ok and opts.ignore_buftypes[buftype] then if ok and opts.ignore_buftypes[buftype] then
return false return false
end end
ok, filetype = pcall(vim.api.nvim_buf_get_option, 0, 'filetype') ok, filetype = pcall(vim.api.nvim_get_option_value, 'filetype', { buf = 0 })
if ok and opts.ignore_filetypes[filetype] then if ok and opts.ignore_filetypes[filetype] then
return false return false
@ -71,8 +71,8 @@ function M.show_specs(popup)
}) })
vim.api.nvim_set_option_value('filetype', 'specs.nvim', { buf = bufh }) vim.api.nvim_set_option_value('filetype', 'specs.nvim', { buf = bufh })
vim.api.nvim_win_set_option(win_id, 'winhl', 'Normal:' .. _opts.popup.winhl) vim.api.nvim_set_option_value('winhl', 'Normal:' .. _opts.popup.winhl, { win = win_id })
vim.api.nvim_win_set_option(win_id, "winblend", _opts.popup.blend) vim.api.nvim_set_option_value("winblend", _opts.popup.blend, { win = win_id })
local cnt = 0 local cnt = 0
local config = vim.api.nvim_win_get_config(win_id) local config = vim.api.nvim_win_get_config(win_id)
@ -98,7 +98,7 @@ function M.show_specs(popup)
local dm = _opts.popup.resizer(_opts.popup.width, cursor_col, cnt) local dm = _opts.popup.resizer(_opts.popup.width, cursor_col, cnt)
if bl ~= nil then if bl ~= nil then
vim.api.nvim_win_set_option(win_id, "winblend", bl) vim.api.nvim_set_option_value("winblend", bl, { win = win_id })
end end
if dm ~= nil then if dm ~= nil then
config["col"][false] = dm[2] config["col"][false] = dm[2]