fix: add version check for nvim_set_option_value and nvim_get_option_value

This commit is contained in:
27Onion Nebell
2025-04-18 16:33:09 +08:00
parent 7d2387dc12
commit e93286a489
11 changed files with 110 additions and 51 deletions

View File

@@ -123,4 +123,54 @@ function M.deepcopy_excluding(t, keys)
return res
end
--- Get option value of given buffer.
--- @param bufnr integer
--- @param name string
--- @return any
function M.buf_get_option(bufnr, name)
if _G._outline_nvim_has[10] then
return vim.api.nvim_get_option_value(name, { buf = bufnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_get_option(bufnr, name)
end
end
--- Set option value of given buffer.
--- @param bufnr integer
--- @param name string
function M.buf_set_option(bufnr, name, value)
if _G._outline_nvim_has[10] then
return vim.api.nvim_set_option_value(name, value, { buf = bufnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_set_option(bufnr, name, value)
end
end
--- Get option value of given window.
--- @param winnr integer
--- @param name string
--- @return any
function M.win_get_option(winnr, name)
if _G._outline_nvim_has[10] then
return vim.api.nvim_get_option_value(name, { win = winnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_get_option(winnr, name)
end
end
--- Set option value of given window.
--- @param winnr integer
--- @param name string
function M.win_set_option(winnr, name, value)
if _G._outline_nvim_has[10] then
return vim.api.nvim_set_option_value(name, value, { win = winnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_win_set_option(winnr, name, value)
end
end
return M

View File

@@ -1,4 +1,5 @@
local config = require('outline.config')
local utils = require('outline.utils')
local M = {}
@@ -14,7 +15,7 @@ function M.is_buf_attached_to_lsp(bufnr)
end
function M.is_buf_markdown(bufnr)
return vim.api.nvim_get_option_value('ft', { buf = bufnr }) == 'markdown'
return utils.buf_get_option(bufnr, 'ft') == 'markdown'
end
--- Merge all client token lists in an LSP response