diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 48c09f0..08406de 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -86,6 +86,7 @@ "rainbow-delimiters.nvim": { "branch": "master", "commit": "1ab18259472d9fe5756750fec722c31bab1712da" }, "render-markdown.nvim": { "branch": "main", "commit": "6d03af10063d5a2fadec3559de5dfa68da7d00ef" }, "smartcolumn.nvim": { "branch": "main", "commit": "d01b99355c7fab13233f48d0f28dc097e68a03f7" }, + "stay-centered.nvim": { "branch": "main", "commit": "e1a63ccaf2584e97c0ef8e64f9654c9a80d983f6" }, "stickybuf.nvim": { "branch": "master", "commit": "2160fcd536d81f5fa43f7167dba6634e814e3154" }, "texpresso.vim": { "branch": "main", "commit": "907838c08bbf99ad6bed3c908f1d0551a92ab4e0" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, diff --git a/nvim/.config/nvim/lua/plugins/base.lua b/nvim/.config/nvim/lua/plugins/base.lua index 7c7e190..cc70347 100644 --- a/nvim/.config/nvim/lua/plugins/base.lua +++ b/nvim/.config/nvim/lua/plugins/base.lua @@ -210,8 +210,45 @@ return { "echasnovski/mini.nvim", event = { "InsertEnter", "VeryLazy" }, config = function() - -- manually create lazy loading scenarios - require("mini.ai").setup() + local ai = require("mini.ai") + local function ai_buffer(ai_type) + local start_line, end_line = 1, vim.fn.line("$") + if ai_type == "i" then + -- Skip first and last blank lines for `i` textobject + local first_nonblank, last_nonblank = vim.fn.nextnonblank(start_line), vim.fn.prevnonblank(end_line) + -- Do nothing for buffer with all blanks + if first_nonblank == 0 or last_nonblank == 0 then + return { from = { line = start_line, col = 1 } } + end + start_line, end_line = first_nonblank, last_nonblank + end + + local to_col = math.max(vim.fn.getline(end_line):len(), 1) + return { from = { line = start_line, col = 1 }, to = { line = end_line, col = to_col } } + end + ai.setup({ + custom_textobjects = { + c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }), -- class + d = { "%f[%d]%d+" }, -- digits + e = { -- single part of MultiCaseWords + { + "%u[%l%d]+%f[^%l%d]", + "%f[%S][%l%d]+%f[^%l%d]", + "%f[%P][%l%d]+%f[^%l%d]", + "^[%l%d]+%f[^%l%d]", + }, + "^().*()$", + }, + f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }), -- function + g = ai_buffer, -- buffer with or without whitespace + o = ai.gen_spec.treesitter({ -- current 'codeblock' + a = { "@block.outer", "@conditional.outer", "@loop.outer" }, + i = { "@block.inner", "@conditional.inner", "@loop.inner" }, + }), + u = ai.gen_spec.function_call(), -- function [u]sage + U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- function [U]sage of last dot element + }, + }) -- Align tables and other alignable things require("mini.align").setup({}) diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 6166751..9a39ff9 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -33,10 +33,28 @@ local prose_plugs = { "folke/zen-mode.nvim", config = true, cmd = { "ZenMode" }, - dependencies = { "folke/twilight.nvim" }, + dependencies = { "folke/twilight.nvim", { "arnamak/stay-centered.nvim", opts = { enabled = false } } }, keys = { { "[sz", + function() + require("zen-mode").close() + require("stay-centered").disable() + end, + silent = true, + desc = "stop center zen mode", + }, + { + "]sz", + function() + require("zen-mode").open() + require("stay-centered").enable() + end, + silent = true, + desc = "start center zen mode", + }, + { + "[sZ", function() require("zen-mode").close() end, @@ -44,7 +62,7 @@ local prose_plugs = { desc = "stop zen mode", }, { - "]sz", + "]sZ", function() require("zen-mode").open() end,