Skip to content

Commit

Permalink
fix(ui): set wo options with local. don't use vim.wo. See #829
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 12, 2023
1 parent 6781795 commit 7f4da7d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
14 changes: 11 additions & 3 deletions lua/lazy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ function M.float(opts)
return require("lazy.view.float")(opts)
end

function M.wo(win, k, v)
if vim.api.nvim_set_option_value then
vim.api.nvim_set_option_value(k, v, { scope = "local", win = win })
else
vim.wo[win][k] = v
end
end

function M.open(uri)
if M.file_exists(uri) then
return M.float({ style = "", file = uri })
Expand Down Expand Up @@ -180,9 +188,9 @@ function M.markdown(msg, opts)
vim.tbl_deep_extend("force", {
title = "lazy.nvim",
on_open = function(win)
vim.wo[win].conceallevel = 3
vim.wo[win].concealcursor = "n"
vim.wo[win].spell = false
M.wo(win, "conceallevel", 3)
M.wo(win, "concealcursor", "n")
M.wo(win, "spell", false)

vim.treesitter.start(vim.api.nvim_win_get_buf(win), "markdown")
end,
Expand Down
13 changes: 7 additions & 6 deletions lua/lazy/view/float.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local Config = require("lazy.core.config")
local ViewConfig = require("lazy.view.config")
local Util = require("lazy.util")

---@class LazyFloatOptions
---@field buf? number
Expand Down Expand Up @@ -124,12 +125,12 @@ function M:mount()

local function opts()
vim.bo[self.buf].bufhidden = self.opts.persistent and "hide" or "wipe"
vim.wo[self.win].conceallevel = 3
vim.wo[self.win].foldenable = false
vim.wo[self.win].spell = false
vim.wo[self.win].wrap = true
vim.wo[self.win].winhighlight = "Normal:LazyNormal"
vim.wo[self.win].colorcolumn = ""
Util.wo(self.win, "conceallevel", 3)
Util.wo(self.win, "foldenable", false)
Util.wo(self.win, "spell", false)
Util.wo(self.win, "wrap", true)
Util.wo(self.win, "winhighlight", "Normal:LazyNormal")
Util.wo(self.win, "colorcolumn", "")
end
opts()

Expand Down
9 changes: 4 additions & 5 deletions lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ function M.create()
})

if Config.options.ui.wrap then
vim.wo[self.win].wrap = true
vim.wo[self.win].linebreak = true
vim.wo[self.win].breakindent = true
-- vim.wo[self.win].breakindentopt = "shift:8"
Util.wo(self.win, "wrap", true)
Util.wo(self.win, "linebreak", true)
Util.wo(self.win, "breakindent", true)
else
vim.wo[self.win].wrap = false
Util.wo(self.win, "wrap", false)
end

self.state = vim.deepcopy(default_state)
Expand Down

0 comments on commit 7f4da7d

Please sign in to comment.