diff options
Diffstat (limited to '.config/nvim/lua/utils.lua')
-rw-r--r-- | .config/nvim/lua/utils.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua new file mode 100644 index 0000000..c4ead42 --- /dev/null +++ b/.config/nvim/lua/utils.lua @@ -0,0 +1,53 @@ +local lualine = require("lualine") +local gitsigns = require("gitsigns") +local ibl = require("ibl") +local marks = require("marks") + +-- https://github.com/chentoast/marks.nvim/issues/38#issuecomment-1059736459 +local function marks_set_buf_state(bufnr, state) + if bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end + if marks.mark_state ~= nil then + marks.mark_state.opt.buf_signs[bufnr] = state + marks.bookmark_state.opt.buf_signs[bufnr] = state + marks.refresh(true) + end +end + +local function toggle_plain() + if vim.g.__plain then + gitsigns.toggle_current_line_blame(false) + vim.o.number = false + vim.o.relativenumber = false + vim.o.cursorline = false + vim.o.list = false + vim.o.foldenable = false + vim.o.foldcolumn = "0" + vim.o.laststatus = 0 + vim.diagnostic.disable() + gitsigns.toggle_numhl(false) + gitsigns.toggle_signs(false) + marks_set_buf_state(0, false) + ibl.update({ enabled = false }) + lualine.hide() + if vim.fn.exists(":TSContextDisable") > 0 then vim.cmd [[ TSContextDisable ]] end + else + gitsigns.toggle_current_line_blame(true) + vim.o.number = true + vim.o.relativenumber = true + vim.o.cursorline = true + vim.o.list = true + vim.o.foldenable = true + vim.o.foldcolumn = "1" + vim.o.laststatus = 2 + vim.diagnostic.enable() + gitsigns.toggle_numhl(true) + gitsigns.toggle_signs(true) + lualine.hide({ unhide = true }) + marks_set_buf_state(0, true) + ibl.update({ enabled = true }) + if vim.fn.exists(":TSContextEnable") > 0 then vim.cmd [[ TSContextEnable ]] end + end + -- vim.cmd [[ BufferLineGroupToggle ungrouped ]] +end + +return { toggle_plain = toggle_plain } |