mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
This commit is contained in:

committed by
Famiu Haque

parent
e3e6fadfd8
commit
1fe1bb084d
@@ -401,7 +401,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
vim.fn.bufload(bufnr)
|
||||
end
|
||||
api.nvim_buf_set_option(bufnr, 'buflisted', true)
|
||||
vim.bo[bufnr].buflisted = true
|
||||
|
||||
-- Fix reversed range and indexing each text_edits
|
||||
local index = 0
|
||||
@@ -530,11 +530,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
|
||||
|
||||
-- Remove final line if needed
|
||||
local fix_eol = has_eol_text_edit
|
||||
fix_eol = fix_eol
|
||||
and (
|
||||
api.nvim_buf_get_option(bufnr, 'eol')
|
||||
or (api.nvim_buf_get_option(bufnr, 'fixeol') and not api.nvim_buf_get_option(bufnr, 'binary'))
|
||||
)
|
||||
fix_eol = fix_eol and (vim.bo[bufnr].eol or (vim.bo[bufnr].fixeol and not vim.bo[bufnr].binary))
|
||||
fix_eol = fix_eol and get_line(bufnr, max - 1) == ''
|
||||
if fix_eol then
|
||||
api.nvim_buf_set_lines(bufnr, -2, -1, false, {})
|
||||
@@ -1076,7 +1072,7 @@ function M.make_floating_popup_options(width, height, opts)
|
||||
|
||||
local wincol = opts.relative == 'mouse' and vim.fn.getmousepos().column or vim.fn.wincol()
|
||||
|
||||
if wincol + width + (opts.offset_x or 0) <= api.nvim_get_option('columns') then
|
||||
if wincol + width + (opts.offset_x or 0) <= vim.o.columns then
|
||||
anchor = anchor .. 'W'
|
||||
col = 0
|
||||
else
|
||||
@@ -1142,7 +1138,7 @@ function M.show_document(location, offset_encoding, opts)
|
||||
or focus and api.nvim_get_current_win()
|
||||
or create_window_without_focus()
|
||||
|
||||
api.nvim_buf_set_option(bufnr, 'buflisted', true)
|
||||
vim.bo[bufnr].buflisted = true
|
||||
api.nvim_win_set_buf(win, bufnr)
|
||||
if focus then
|
||||
api.nvim_set_current_win(win)
|
||||
@@ -1201,12 +1197,12 @@ function M.preview_location(location, opts)
|
||||
end
|
||||
local range = location.targetRange or location.range
|
||||
local contents = api.nvim_buf_get_lines(bufnr, range.start.line, range['end'].line + 1, false)
|
||||
local syntax = api.nvim_buf_get_option(bufnr, 'syntax')
|
||||
local syntax = vim.bo[bufnr].syntax
|
||||
if syntax == '' then
|
||||
-- When no syntax is set, we use filetype as fallback. This might not result
|
||||
-- in a valid syntax definition. See also ft detection in stylize_markdown.
|
||||
-- An empty syntax is more common now with TreeSitter, since TS disables syntax.
|
||||
syntax = api.nvim_buf_get_option(bufnr, 'filetype')
|
||||
syntax = vim.bo[bufnr].filetype
|
||||
end
|
||||
opts = opts or {}
|
||||
opts.focus_id = 'location'
|
||||
@@ -1665,7 +1661,7 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
contents = M.stylize_markdown(floating_bufnr, contents, opts)
|
||||
else
|
||||
if syntax then
|
||||
api.nvim_buf_set_option(floating_bufnr, 'syntax', syntax)
|
||||
vim.bo[floating_bufnr].syntax = syntax
|
||||
end
|
||||
api.nvim_buf_set_lines(floating_bufnr, 0, -1, true, contents)
|
||||
end
|
||||
@@ -1681,16 +1677,16 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
local float_option = M.make_floating_popup_options(width, height, opts)
|
||||
local floating_winnr = api.nvim_open_win(floating_bufnr, false, float_option)
|
||||
if do_stylize then
|
||||
api.nvim_win_set_option(floating_winnr, 'conceallevel', 2)
|
||||
api.nvim_win_set_option(floating_winnr, 'concealcursor', 'n')
|
||||
vim.wo[floating_winnr].conceallevel = 2
|
||||
vim.wo[floating_winnr].concealcursor = 'n'
|
||||
end
|
||||
-- disable folding
|
||||
api.nvim_win_set_option(floating_winnr, 'foldenable', false)
|
||||
vim.wo[floating_winnr].foldenable = false
|
||||
-- soft wrapping
|
||||
api.nvim_win_set_option(floating_winnr, 'wrap', opts.wrap)
|
||||
vim.wo[floating_winnr].wrap = opts.wrap
|
||||
|
||||
api.nvim_buf_set_option(floating_bufnr, 'modifiable', false)
|
||||
api.nvim_buf_set_option(floating_bufnr, 'bufhidden', 'wipe')
|
||||
vim.bo[floating_bufnr].modifiable = false
|
||||
vim.bo[floating_bufnr].bufhidden = 'wipe'
|
||||
api.nvim_buf_set_keymap(
|
||||
floating_bufnr,
|
||||
'n',
|
||||
|
Reference in New Issue
Block a user