diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2024-07-15 20:05:47 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2024-07-15 20:05:47 +0100 |
commit | 522d56557b00246286d803425751a4334f3a94a5 (patch) | |
tree | 23ca335a3526197c2a6327ce10bfd58411b0a609 /start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua | |
parent | a7b72fc27edac2305dbf0af807981bd703835b25 (diff) |
indent-blankline is probably old because I've actually been using it for
ages, but I have a strict if-it-ain't-broke policy, so I'm not going to
update it.
lspconfig *was* broke though with nvim 0.10, so now it's fixed.
Diffstat (limited to 'start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua')
-rw-r--r-- | start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua b/start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua new file mode 100644 index 0000000..263d332 --- /dev/null +++ b/start/indent-blankline-2.20.4/lua/indent_blankline/commands.lua @@ -0,0 +1,58 @@ +local M = {} + +M.refresh = function(bang, scroll) + scroll = scroll or false + if bang then + local win = vim.api.nvim_get_current_win() + vim.cmd(string.format([[noautocmd windo lua require("indent_blankline").refresh(%s)]], tostring(scroll))) + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_set_current_win(win) + end + else + require("indent_blankline").refresh(scroll) + end +end + +M.enable = function(bang) + if bang then + vim.g.indent_blankline_enabled = true + local win = vim.api.nvim_get_current_win() + vim.cmd [[noautocmd windo lua require("indent_blankline").refresh(false)]] + vim.api.nvim_set_current_win(win) + else + vim.b.indent_blankline_enabled = true + require("indent_blankline").refresh(false) + end +end + +M.disable = function(bang) + if bang then + vim.g.indent_blankline_enabled = false + local buffers = vim.api.nvim_list_bufs() + for _, buffer in pairs(buffers) do + vim.api.nvim_buf_clear_namespace(buffer, vim.g.indent_blankline_namespace, 1, -1) + end + else + vim.b.indent_blankline_enabled = false + vim.b.__indent_blankline_active = false + vim.api.nvim_buf_clear_namespace(0, vim.g.indent_blankline_namespace, 1, -1) + end +end + +M.toggle = function(bang) + if bang then + if vim.g.indent_blankline_enabled then + M.disable(bang) + else + M.enable(bang) + end + else + if vim.b.__indent_blankline_active then + M.disable(bang) + else + M.enable(bang) + end + end +end + +return M |