Skip to content

Commit 7f4da7d

Browse files
committedJun 12, 2023
fix(ui): set wo options with local. don't use vim.wo. See #829
1 parent 6781795 commit 7f4da7d

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed
 

Diff for: ‎lua/lazy/util.lua

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ function M.float(opts)
1010
return require("lazy.view.float")(opts)
1111
end
1212

13+
function M.wo(win, k, v)
14+
if vim.api.nvim_set_option_value then
15+
vim.api.nvim_set_option_value(k, v, { scope = "local", win = win })
16+
else
17+
vim.wo[win][k] = v
18+
end
19+
end
20+
1321
function M.open(uri)
1422
if M.file_exists(uri) then
1523
return M.float({ style = "", file = uri })
@@ -180,9 +188,9 @@ function M.markdown(msg, opts)
180188
vim.tbl_deep_extend("force", {
181189
title = "lazy.nvim",
182190
on_open = function(win)
183-
vim.wo[win].conceallevel = 3
184-
vim.wo[win].concealcursor = "n"
185-
vim.wo[win].spell = false
191+
M.wo(win, "conceallevel", 3)
192+
M.wo(win, "concealcursor", "n")
193+
M.wo(win, "spell", false)
186194

187195
vim.treesitter.start(vim.api.nvim_win_get_buf(win), "markdown")
188196
end,

Diff for: ‎lua/lazy/view/float.lua

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local Config = require("lazy.core.config")
22
local ViewConfig = require("lazy.view.config")
3+
local Util = require("lazy.util")
34

45
---@class LazyFloatOptions
56
---@field buf? number
@@ -124,12 +125,12 @@ function M:mount()
124125

125126
local function opts()
126127
vim.bo[self.buf].bufhidden = self.opts.persistent and "hide" or "wipe"
127-
vim.wo[self.win].conceallevel = 3
128-
vim.wo[self.win].foldenable = false
129-
vim.wo[self.win].spell = false
130-
vim.wo[self.win].wrap = true
131-
vim.wo[self.win].winhighlight = "Normal:LazyNormal"
132-
vim.wo[self.win].colorcolumn = ""
128+
Util.wo(self.win, "conceallevel", 3)
129+
Util.wo(self.win, "foldenable", false)
130+
Util.wo(self.win, "spell", false)
131+
Util.wo(self.win, "wrap", true)
132+
Util.wo(self.win, "winhighlight", "Normal:LazyNormal")
133+
Util.wo(self.win, "colorcolumn", "")
133134
end
134135
opts()
135136

Diff for: ‎lua/lazy/view/init.lua

+4-5
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ function M.create()
5757
})
5858

5959
if Config.options.ui.wrap then
60-
vim.wo[self.win].wrap = true
61-
vim.wo[self.win].linebreak = true
62-
vim.wo[self.win].breakindent = true
63-
-- vim.wo[self.win].breakindentopt = "shift:8"
60+
Util.wo(self.win, "wrap", true)
61+
Util.wo(self.win, "linebreak", true)
62+
Util.wo(self.win, "breakindent", true)
6463
else
65-
vim.wo[self.win].wrap = false
64+
Util.wo(self.win, "wrap", false)
6665
end
6766

6867
self.state = vim.deepcopy(default_state)

0 commit comments

Comments
 (0)
Please sign in to comment.