Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zen-mode-nvim): add integration with vim-matchup if enabled #485

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lua/astrocommunity/editing-support/zen-mode-nvim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

🧘 Distraction-free coding for Neovim

Disables diagnostics, indentation, and winbar when entering Zen Mode.

Optionally disables [mini.indentscope](https://github.com/echasnovski/mini.indentscope) and offscreen matchups for [vim-matchup](https://github.com/andymass/vim-matchup), if installed.

**Repository:** <https://github.com/folke/zen-mode.nvim>
18 changes: 16 additions & 2 deletions lua/astrocommunity/editing-support/zen-mode-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local utils = require "astronvim.utils"

return {
"folke/zen-mode.nvim",
cmd = "ZenMode",
Expand All @@ -21,7 +23,7 @@ return {
laststatus = 0,
},
},
on_open = function() -- disable diagnostics, indent blankline, and winbar
on_open = function() -- disable diagnostics, indent blankline, winbar, and offscreen matchup
vim.g.diagnostics_mode_old = vim.g.diagnostics_mode
vim.g.diagnostics_mode = 0
vim.diagnostic.config(require("astronvim.utils.lsp").diagnostics[vim.g.diagnostics_mode])
Expand All @@ -38,8 +40,15 @@ return {
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.",
})

if utils.is_available "vim-matchup" then
vim.cmd.NoMatchParen()
vim.g.matchup_matchparen_offscreen_old = vim.g.matchup_matchparen_offscreen
vim.g.matchup_matchparen_offscreen = {}
vim.cmd.DoMatchParen()
end
end,
on_close = function() -- restore diagnostics, indent blankline, and winbar
on_close = function() -- restore diagnostics, indent blankline, winbar, and offscreen matchup
vim.g.diagnostics_mode = vim.g.diagnostics_mode_old
vim.diagnostic.config(require("astronvim.utils.lsp").diagnostics[vim.g.diagnostics_mode])

Expand All @@ -49,6 +58,11 @@ return {

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

if utils.is_available "vim-matchup" then
vim.g.matchup_matchparen_offscreen = vim.g.matchup_matchparen_offscreen_old
vim.cmd.DoMatchParen()
end
end,
},
}