diff options
author | Luca Matei Pintilie <luca@lucamatei.com> | 2024-04-25 18:34:05 +0000 |
---|---|---|
committer | Luca Matei Pintilie <luca@lucamatei.com> | 2024-04-25 18:34:05 +0000 |
commit | 568d423fd328b9373048688259f4b5ff251abd20 (patch) | |
tree | 4b6aec21e3d5ddbcaa429db548c03da2d3bb1472 /.config | |
parent | 8ba5131012d0b6adebe4d113aed66236eed19b78 (diff) | |
download | dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar.gz dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar.bz2 dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar.lz dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar.xz dotfiles-568d423fd328b9373048688259f4b5ff251abd20.tar.zst dotfiles-568d423fd328b9373048688259f4b5ff251abd20.zip |
Add utils file
Diffstat (limited to '.config')
-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 } |