dotfiles/nvim/.config/nvim/lua/modules/base.lua

390 lines
9.9 KiB
Lua

return {
-- allow seamless navigation between vim buffers and tmux/wezterm splits
{
"numToStr/Navigator.nvim",
branch = "master",
config = true,
event = "VeryLazy",
keys = {
{
"<c-w>h",
function()
require("Navigator").left()
end,
{ silent = true },
},
{
"<c-w>k",
function()
require("Navigator").up()
end,
{ silent = true },
},
{
"<c-w>l",
function()
require("Navigator").right()
end,
{ silent = true },
},
{
"<c-w>j",
function()
require("Navigator").down()
end,
{ silent = true },
},
{
"<c-w>p",
function()
require("Navigator").previous()
end,
{ silent = true },
},
},
},
-- jump between letters with improved fFtT quicksearch, mimics sneak
{
"folke/flash.nvim",
event = "VeryLazy",
opts = {
modes = {
search = {
enabled = false,
},
},
},
keys = {
{
"s",
mode = { "n", "x" },
function()
require("flash").jump()
end,
desc = "Flash",
},
{
"S",
mode = { "n", "x", "o" },
function()
require("flash").treesitter()
end,
desc = "Flash Treesitter",
},
{
"r",
mode = "o",
function()
require("flash").remote()
end,
desc = "Remote Flash",
},
},
},
-- generic tool installer; automatic external dependency mgmt for neovim
-- used in my config for LSPs, formatters and linters
{
"williamboman/mason.nvim",
cmd = {
"Mason",
"MasonInstall",
"MasonUninstall",
"MasonUninstallAll",
"MasonLog",
"MasonUpdate",
},
opts = {},
build = ":MasonUpdate",
keys = {
{ "<leader>vm", ":Mason<cr>", desc = "Mason" },
},
},
-- personal dict improvements for git sync
{ "micarmst/vim-spellsync", event = "VeryLazy" },
{
"folke/which-key.nvim",
event = "CursorHold",
opts = { icons = { mappings = false } },
},
-- collection of plugins
{
"echasnovski/mini.base16",
dependencies = { "rktjmp/fwatch.nvim" }, -- for colorscheme updating
event = "VimEnter",
config = function()
-- automatic callback to invoke 'mini.base16' when colorscheme file is changed
local colorsfile = vim.fn.stdpath("state") .. "/colorscheme.lua"
local function source_colors()
if vim.fn.filereadable(colorsfile) == 1 then
vim.cmd("source " .. colorsfile)
end
end
-- set on startup
source_colors()
-- continuously watch colors file for changes
local fwatch = require("fwatch")
fwatch.watch(colorsfile, {
on_event = vim.schedule_wrap(function()
source_colors()
end),
})
end,
},
{
"echasnovski/mini.starter",
event = "StartScreen",
config = function()
local starter = require("mini.starter")
starter.setup({
evaluate_single = true,
items = {
starter.sections.builtin_actions(),
{
name = "Scratchpad",
action = "lua require('personal.scratchpad').create()",
section = "Builtin actions",
},
starter.sections.recent_files(10, true),
starter.sections.recent_files(10, false),
-- Use this if you set up 'mini.sessions'
-- starter.sections.sessions(),
starter.sections.telescope(),
},
content_hooks = {
starter.gen_hook.adding_bullet(),
starter.gen_hook.padding(3, 2),
starter.gen_hook.aligning("center", "center"),
},
})
end,
keys = {
{
"<leader>ss",
function()
require("mini.starter").open()
end,
silent = true,
desc = "startpage",
},
},
},
{
"echasnovski/mini.files",
event = { "VeryLazy" },
config = function()
require("mini.files").setup({
mappings = {
synchronize = "S",
go_in = "L", -- switch go-ins around
go_in_plus = "l",
go_out = "H",
go_out_plus = "h",
},
options = {
use_as_default_explorer = true,
},
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesWindowUpdate",
callback = function(args)
local win_id = args.data.win_id
vim.wo[win_id].number = true
end,
})
end,
keys = {
{
"<leader>e",
function()
local mf = require("mini.files")
if not mf.close() then
mf.open()
end
end,
desc = "floating file browser",
},
},
},
{
"echasnovski/mini.nvim",
event = { "InsertEnter", "VeryLazy" },
config = function()
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({})
require("mini.bracketed").setup({
buffer = { suffix = "b", options = {} },
comment = { suffix = "k", options = {} },
conflict = { suffix = "" }, -- disable to use git-conflict instead
diagnostic = { suffix = "e", options = {} },
file = { suffix = "f", options = {} },
indent = { suffix = "" }, -- disable since we use indentscope
jump = { suffix = "j", options = {} },
location = { suffix = "l", options = {} },
oldfile = { suffix = "o", options = {} },
quickfix = { suffix = "q", options = {} },
treesitter = { suffix = "t", options = {} },
undo = { suffix = "" }, -- disable since I don't need it
window = { suffix = "w", options = {} },
yank = { suffix = "y", options = {} },
})
require("mini.comment").setup({
hooks = {
pre = function()
-- use treesitter commentstring functionality if it's installed
if require("core.util").is_available("ts_context_commentstring") then
require("ts_context_commentstring.internal").update_commentstring()
end
end,
},
})
require("mini.cursorword").setup({ delay = 500 })
vim.api.nvim_set_hl(0, "MiniCursorword", { bold = true, underline = false })
vim.api.nvim_set_hl(0, "MiniCursorwordCurrent", { bold = true, underline = false })
require("mini.fuzzy").setup()
require("mini.indentscope").setup({
symbol = "",
draw = { animation = require("mini.indentscope").gen_animation.none() },
options = { indent_at_cursor = false, n_lines = 2000 },
})
-- disable indentlines for terminals
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "*",
callback = function()
vim.b.miniindentscope_disable = true
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"lazy",
"mason",
"help",
"lspinfo",
"packer",
"checkhealth",
"man",
"gitcommit",
"TelescopePrompt",
"TelescopeResults",
"trouble",
},
callback = function()
vim.b.miniindentscope_disable = true
end,
})
require("mini.map").setup()
require("mini.move").setup()
require("mini.operators").setup()
require("mini.pairs").setup({
mappings = {
-- these mappings ensure that when trying to _close_ any of the pairs
-- it will not double insert:
-- " <- you are here. Normal pairs will do """. This config will do "".
['"'] = {
action = "closeopen",
pair = '""',
neigh_pattern = '[^\\"].',
register = { cr = false },
},
["'"] = {
action = "closeopen",
pair = "''",
neigh_pattern = "[^%a\\'].",
register = { cr = false },
},
["`"] = {
action = "closeopen",
pair = "``",
neigh_pattern = "[^\\`].",
register = { cr = false },
},
["<"] = { action = "open", pair = "<>", neigh_pattern = "\r." },
[">"] = { action = "close", pair = "<>" },
},
})
require("mini.trailspace").setup()
end,
keys = {
{
"<leader>sm",
function()
require("mini.map").toggle()
end,
silent = true,
desc = "minimap",
},
{
"<localleader>w",
function()
require("mini.trailspace").trim()
end,
desc = "Trim trailing whitespace",
},
{
"[si",
function()
local c = vim.api.nvim_get_hl(0, { name = "Comment" })
vim.api.nvim_set_hl(0, "Comment", vim.tbl_extend("force", c, { italic = false }))
end,
desc = "no italic comments",
},
{
"]si",
function()
local c = vim.api.nvim_get_hl(0, { name = "Comment" })
vim.api.nvim_set_hl(0, "Comment", vim.tbl_extend("force", {}, c, { italic = true }))
end,
desc = "italic comments",
},
},
},
-- try to avoid putting files in util buffers, e.g. filetree, aerial, undotree, ..
{ "stevearc/stickybuf.nvim", config = true },
-- make it a little less painful to open really big (>2mb) files by disabling features
-- { "LunarVim/bigfile.nvim", lazy = false },
-- set plenary to follow master branch here, but let individual plugins actually load it
{ "nvim-lua/plenary.nvim", version = false, optional = true },
}