Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use nvim_get_option_value and nvim_set_option_value #1319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lua/lualine/utils/nvim_opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,40 @@ end
--- when nil it's treated as {global = true}
function M.set(name, val, opts)
if opts == nil or opts.global then
set_opt(name, val, vim.api.nvim_get_option, vim.api.nvim_set_option, options.global)
set_opt(name, val, function(nm)
return vim.api.nvim_get_option_value(nm, {scope = 'global'}) end,
function(nm, vl)
vim.api.nvim_set_option_value(nm, vl, {scope = 'global'})
end, options.global)
elseif opts.buffer then
if options.buffer[opts.buffer] == nil then
options.buffer[opts.buffer] = {}
end
set_opt(name, val, function(nm)
return vim.api.nvim_buf_get_option(opts.buffer, nm)
return vim.api.nvim_get_option_value(nm, {
scope = 'local',
buf = opts.buffer
})
end, function(nm, vl)
vim.api.nvim_buf_set_option(opts.buffer, nm, vl)
vim.api.nvim_set_option_value(nm, vl, {
scope = 'local',
buf = opts.buffer
})
end, options.buffer[opts.buffer])
elseif opts.window then
if options.window[opts.window] == nil then
options.window[opts.window] = {}
end
set_opt(name, val, function(nm)
return vim.api.nvim_win_get_option(opts.window, nm)
return vim.api.nvim_get_option_value(nm, {
scope = 'local',
win = opts.window
})
end, function(nm, vl)
vim.api.nvim_win_set_option(opts.window, nm, vl)
vim.api.nvim_set_option_value(nm, vl, {
scope = 'local',
win = opts.window
})
end, options.window[opts.window])
end
end
Expand Down
Loading