Skip to content

Commit

Permalink
Clean up how disable-relative-line-numbers and disable-line-numbers are
Browse files Browse the repository at this point in the history
used in buffer class
  • Loading branch information
CKolkey committed Oct 20, 2024
1 parent 12fdc8c commit d598bde
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions lua/neogit/lib/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ local Path = require("plenary.path")
---@field ui Ui
---@field kind string
---@field name string
---@field disable_line_numbers boolean
---@field disable_relative_line_numbers boolean
local Buffer = {
kind = "split",
disable_line_numbers = true,
disable_relative_line_numbers = true,
}
Buffer.__index = Buffer

Expand Down Expand Up @@ -354,16 +350,6 @@ function Buffer:show()
win = content_window
end

api.nvim_win_call(win, function()
if self.disable_line_numbers then
vim.cmd("setlocal nonu")
end

if self.disable_relative_line_numbers then
vim.cmd("setlocal nornu")
end
end)

-- Workaround UFO getting folds wrong.
local ok, ufo = pcall(require, "ufo")
if ok and type(ufo.detach) == "function" then
Expand Down Expand Up @@ -623,9 +609,6 @@ function Buffer.create(config)

buffer.name = config.name
buffer.kind = config.kind or "split"
buffer.disable_line_numbers = (config.disable_line_numbers == nil) or config.disable_line_numbers
buffer.disable_relative_line_numbers = (config.disable_relative_line_numbers == nil)
or config.disable_relative_line_numbers

if config.load then
logger.debug("[BUFFER:" .. buffer.handle .. "] Loading content from file: " .. config.name)
Expand Down Expand Up @@ -707,6 +690,14 @@ function Buffer.create(config)
vim.opt_local.fillchars:append("fold: ")
end)

if (config.disable_line_numbers == nil) or config.disable_line_numbers then
buffer:set_window_option("number", false)
end

if (config.disable_relative_line_numbers == nil) or config.disable_relative_line_numbers then
buffer:set_window_option("relativenumber", false)
end

buffer:set_window_option("spell", config.spell_check or false)
buffer:set_window_option("wrap", false)
buffer:set_window_option("foldmethod", "manual")
Expand Down

0 comments on commit d598bde

Please sign in to comment.