Skip to content

Commit

Permalink
fix(zen-mode-nvim): ensure winbar stays disabled and restore old mini…
Browse files Browse the repository at this point in the history
….indentscope options (#439)
  • Loading branch information
Subjective authored and mehalter committed Jul 15, 2023
1 parent 60b95d3 commit 6bc9421
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions lua/astrocommunity/editing-support/zen-mode-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,32 @@ return {
},
on_open = function() -- disable diagnostics, indent blankline, and winbar
vim.g.diagnostics_mode_old = vim.g.diagnostics_mode
vim.g.indent_blankline_enabled_old = vim.g.indent_blankline_enabled
vim.g.winbar_old = vim.wo.winbar
vim.g.diagnostics_mode = 0
vim.g.indent_blankline_enabled = false
vim.b.miniindentscope_disable = true
vim.wo.winbar = nil
vim.diagnostic.config(require("astronvim.utils.lsp").diagnostics[vim.g.diagnostics_mode])

vim.g.indent_blankline_enabled_old = vim.g.indent_blankline_enabled
vim.g.indent_blankline_enabled = false
vim.g.miniindentscope_disable_old = vim.g.miniindentscope_disable
vim.g.miniindentscope_disable = true

vim.g.winbar_old = vim.wo.winbar
vim.api.nvim_create_autocmd({ "BufWritePost", "BufWinEnter", "BufNew" }, {
pattern = "*",
callback = function() vim.wo.winbar = nil end,
group = vim.api.nvim_create_augroup("disable_winbar", { clear = true }),
desc = "Ensure winbar stays disabled when writing to file, switching buffers, opening floating windows, etc.",
})
end,
on_close = function() -- restore diagnostics, indent blankline, and winbar
vim.g.diagnostics_mode = vim.g.diagnostics_mode_old
vim.g.indent_blankline_enabled = vim.g.indent_blankline_enabled_old
vim.b.miniindentscope_disable = false
vim.wo.winbar = vim.g.winbar_old
vim.diagnostic.config(require("astronvim.utils.lsp").diagnostics[vim.g.diagnostics_mode])

vim.g.indent_blankline_enabled = vim.g.indent_blankline_enabled_old
vim.g.miniindentscope_disable = vim.g.miniindentscope_disable_old
if vim.g.indent_blankline_enabled_old then vim.cmd "IndentBlanklineRefresh" end

vim.api.nvim_clear_autocmds { group = "disable_winbar" }
vim.wo.winbar = vim.g.winbar_old
end,
},
}

0 comments on commit 6bc9421

Please sign in to comment.