Skip to content

Commit

Permalink
Overlength feature
Browse files Browse the repository at this point in the history
  • Loading branch information
NonlinearFruit committed Aug 6, 2024
1 parent f237a71 commit d4b3c01
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions nvim/lua/plugins/overlength.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local api = vim.api
local overlength_active = false
local config = {
column_length = 120, -- Default column length
terminal_background = "darkgrey", -- Default background color for terminal
gui_background = "#592929", -- Default background color for GUI
}

local function enable_overlength_mode()
vim.cmd(string.format("highlight OverLength ctermbg=%s guibg=%s", config.terminal_background, config.gui_background))
vim.opt.colorcolumn = tostring(config.column_length)
vim.fn.matchadd("OverLength", string.format("\\%%%dv.\\+", config.column_length + 1))
overlength_active = false
end

local function disable_overlength_mode()
vim.cmd("highlight clear OverLength")
vim.opt.colorcolumn = "0"
overlength_active = true
end

local function configure()
api.nvim_create_user_command("OverlengthEnable", enable_overlength_mode, {})
api.nvim_create_user_command("OverlengthDisable", disable_overlength_mode, {})
end

return {
"prototypes/overlength",
config = configure,
dev = true,
}
4 changes: 2 additions & 2 deletions nvim/lua/plugins/typewriter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ local function disable_typewriter_mode()
end

local function configure()
api.nvim_create_user_command("TWEnable", enable_typewriter_mode, {})
api.nvim_create_user_command("TWDisable", disable_typewriter_mode, {})
api.nvim_create_user_command("TypewriterEnable", enable_typewriter_mode, {})
api.nvim_create_user_command("TyperwriterDisable", disable_typewriter_mode, {})
end

return {
Expand Down

0 comments on commit d4b3c01

Please sign in to comment.