Skip to content

Commit

Permalink
Use vim.b to store buffer state
Browse files Browse the repository at this point in the history
  • Loading branch information
m4xshen committed Mar 21, 2023
1 parent cb7875f commit 531c68f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lua/smartcolumn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ local function exceed(buf, win, min_colorcolumn)
return not is_disabled() and max_column > min_colorcolumn
end

local buf_states = {}
local function update()
local buf_filetype = vim.api.nvim_buf_get_option(0, "filetype")
local colorcolumns =
Expand All @@ -56,8 +55,8 @@ local function update()
local buf = vim.api.nvim_win_get_buf(win)
if buf == current_buf then
local current_state = exceed(buf, win, min_colorcolumn)
if current_state ~= buf_states[buf] then
buf_states[buf] = current_state
if current_state ~= vim.b.prev_state then
vim.b.prev_state = current_state
if current_state then
if type(colorcolumns) == "table" then
vim.wo[win].colorcolumn = table.concat(colorcolumns, ",")
Expand Down

0 comments on commit 531c68f

Please sign in to comment.