Initial commit
This commit is contained in:
92
home/apps/nvim/lua/center/init.lua
Normal file
92
home/apps/nvim/lua/center/init.lua
Normal file
@@ -0,0 +1,92 @@
|
||||
local M = {}
|
||||
|
||||
M.cfg = {
|
||||
skip_filetypes = {},
|
||||
enabled = true,
|
||||
}
|
||||
|
||||
M.setup = function(ctx)
|
||||
if ctx == nil then
|
||||
return
|
||||
end
|
||||
|
||||
M.cfg.skip_filetypes = ctx.skip_filetypes or {}
|
||||
if type(ctx.enabled) == "boolean" then
|
||||
M.cfg.enabled = ctx.enabled
|
||||
end
|
||||
end
|
||||
|
||||
local function must_skip_file(skip_filetypes, current_type)
|
||||
if skip_filetypes == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
for _, value in ipairs(skip_filetypes) do
|
||||
if value == current_type then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function stay_centered(ctx)
|
||||
if not ctx.cfg.enabled then
|
||||
return
|
||||
end
|
||||
if must_skip_file(ctx.cfg.skip_filetypes, vim.bo.filetype) then
|
||||
return
|
||||
end
|
||||
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
if line ~= vim.b.last_line then
|
||||
vim.cmd("norm! zz")
|
||||
-- vim.b.last_line = line
|
||||
-- if ctx.mode == "insert" then
|
||||
-- local column = vim.fn.getcurpos()[5]
|
||||
-- vim.fn.cursor({ line, column })
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
local add_group = vim.api.nvim_create_augroup
|
||||
local group = add_group("StayCentered", { clear = true })
|
||||
|
||||
local add_command = vim.api.nvim_create_autocmd
|
||||
add_command("CursorMovedI", {
|
||||
group = group,
|
||||
callback = function()
|
||||
stay_centered({ mode = "insert", cfg = M.cfg })
|
||||
end,
|
||||
})
|
||||
add_command("CursorMoved", {
|
||||
group = group,
|
||||
callback = function()
|
||||
stay_centered({ mode = "other", cfg = M.cfg })
|
||||
end,
|
||||
})
|
||||
add_command("BufEnter", {
|
||||
group = group,
|
||||
callback = function()
|
||||
stay_centered({ mode = "other", cfg = M.cfg })
|
||||
end,
|
||||
})
|
||||
|
||||
M.enable = function()
|
||||
M.cfg.enabled = true
|
||||
stay_centered({ mode = "other", cfg = M.cfg })
|
||||
end
|
||||
|
||||
M.disable = function()
|
||||
M.cfg.enabled = false
|
||||
end
|
||||
|
||||
M.toggle = function()
|
||||
if M.cfg.enabled then
|
||||
M.disable()
|
||||
else
|
||||
M.enable()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
32
home/apps/nvim/lua/digraphs.lua
Normal file
32
home/apps/nvim/lua/digraphs.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
return {
|
||||
{ "ps", "+" },
|
||||
{ "ms", "-" },
|
||||
{ "eq", "=" },
|
||||
{ "pw", "^" },
|
||||
{ "mt", "*" },
|
||||
{ "hs", "#" },
|
||||
{ "md", "%" },
|
||||
{ "bt", "`" },
|
||||
{ "pp", "|" },
|
||||
{ "td", "~" },
|
||||
{ "fs", "/" },
|
||||
{ "bs", "\\" },
|
||||
{ "us", "_" },
|
||||
{ "qm", "?" },
|
||||
{ "xm", "!" },
|
||||
{ "at", "@" },
|
||||
{ "sn", ";" },
|
||||
{ "qt", "'" },
|
||||
{ "dq", "\"" },
|
||||
{ "cn", ":" },
|
||||
{ "ds", "$" },
|
||||
{ "as", "&" },
|
||||
{ "lp", "(" },
|
||||
{ "rp", ")" },
|
||||
{ "lb", "{" },
|
||||
{ "rb", "}" },
|
||||
{ "ls", "[" },
|
||||
{ "rs", "]" },
|
||||
{ "la", "<" },
|
||||
{ "ra", ">" },
|
||||
}
|
||||
31
home/apps/nvim/lua/globals.lua
Normal file
31
home/apps/nvim/lua/globals.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local M = {}
|
||||
|
||||
local create_alternate = function(border_chars)
|
||||
return {
|
||||
border_chars[2],
|
||||
border_chars[4],
|
||||
border_chars[6],
|
||||
border_chars[8],
|
||||
border_chars[1],
|
||||
border_chars[3],
|
||||
border_chars[5],
|
||||
border_chars[7],
|
||||
}
|
||||
end
|
||||
|
||||
-- M.border_chars = { "┌", "─", "┐", "│", "┘", "─", "└", "│" }
|
||||
-- M.border_chars_telescope_results = create_alternate({ "├", "─", "┤", "│", "┘", "─", "└", "│" })
|
||||
-- M.border_chars_telescope_prompt = create_alternate({ "┌", "─", "┐", "│", "┤", "─", "├", "│" })
|
||||
|
||||
M.border_chars = { "┏", "━", "┓", "┃", "┛", "━", "┗", "┃" }
|
||||
M.border_chars_telescope_results = create_alternate({ "┣", "━", "┫", "┃", "┛", "━", "┗", "┃" })
|
||||
M.border_chars_telescope_prompt = create_alternate({ "┏", "━", "┓", "┃", "┫", "━", "┣", "┃" })
|
||||
|
||||
-- M.border_chars = { "╔", "═", "╗", "║", "╝", "═", "╚", "║" }
|
||||
-- M.border_chars_telescope_results = create_alternate({ "╠", "═", "╣", "║", "╝", "═", "╚", "║" })
|
||||
-- M.border_chars_telescope_prompt = create_alternate({ "╔", "═", "╗", "║", "╣", "═", "╠", "║" })
|
||||
|
||||
|
||||
M.border_chars_alternate = create_alternate(M.border_chars)
|
||||
|
||||
return M
|
||||
7
home/apps/nvim/lua/marks.lua
Normal file
7
home/apps/nvim/lua/marks.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local low = function(i) return string.char(string.byte("a")+i) end
|
||||
local upp = function(i) return string.char(string.byte("A")+i) end
|
||||
|
||||
for i=0,25 do vim.keymap.set("n", "m"..low(i), "m"..upp(i)) end
|
||||
for i=0,25 do vim.keymap.set("n", "m"..upp(i), "m"..low(i)) end
|
||||
for i=0,25 do vim.keymap.set("n", "'"..low(i), "'"..upp(i)) end
|
||||
for i=0,25 do vim.keymap.set("n", "'"..upp(i), "'"..low(i)) end
|
||||
210
home/apps/nvim/lua/multiline/init.lua
Normal file
210
home/apps/nvim/lua/multiline/init.lua
Normal file
@@ -0,0 +1,210 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function(opts)
|
||||
M.max_new_lines = opts.max_new_lines or 1000
|
||||
M.keep_existing = opts.keep_existing or true
|
||||
M.void_bounds = opts.void_bounds or true
|
||||
end
|
||||
|
||||
M.nlines = function(count)
|
||||
-- Please, tell me there is a better way
|
||||
local output = {}
|
||||
for _ = 1, count do
|
||||
table.insert(output, "")
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
M.remove_surround = function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local lines = vim.api.nvim_buf_line_count(0)
|
||||
|
||||
local count = math.max(1, vim.v.count)
|
||||
|
||||
-- Bottom pad
|
||||
local delete_bottom = 0
|
||||
for _ = 1, count do
|
||||
local delete_line = line + delete_bottom
|
||||
if delete_line == lines then
|
||||
break
|
||||
end
|
||||
local next_line = vim.api.nvim_buf_get_lines(0, delete_line, delete_line + 1, false)[1]
|
||||
if vim.trim(next_line) ~= "" then
|
||||
break
|
||||
end
|
||||
delete_bottom = delete_bottom + 1
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line, line + delete_bottom, false, {})
|
||||
|
||||
-- Top pad
|
||||
local delete_top = 0
|
||||
for _ = 1, count do
|
||||
local delete_line = line - delete_top
|
||||
if delete_line == 1 then
|
||||
break
|
||||
end
|
||||
local prev_line = vim.api.nvim_buf_get_lines(0, delete_line - 2, delete_line - 1, false)[1]
|
||||
if vim.trim(prev_line) ~= "" then
|
||||
break
|
||||
end
|
||||
delete_top = delete_top + 1
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line - delete_top - 1, line - 1, false, {})
|
||||
end
|
||||
|
||||
M.remove_all_surround = function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local lines = vim.api.nvim_buf_line_count(0)
|
||||
|
||||
-- Bottom pad
|
||||
local delete_bottom = 0
|
||||
while true do
|
||||
local delete_line = line + delete_bottom
|
||||
if delete_line == lines then
|
||||
break
|
||||
end
|
||||
local next_line = vim.api.nvim_buf_get_lines(0, delete_line, delete_line + 1, false)[1]
|
||||
if vim.trim(next_line) ~= "" then
|
||||
break
|
||||
end
|
||||
delete_bottom = delete_bottom + 1
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line, line + delete_bottom, false, {})
|
||||
|
||||
-- Top pad
|
||||
local delete_top = 0
|
||||
while true do
|
||||
local delete_line = line - delete_top
|
||||
if delete_line == 1 then
|
||||
break
|
||||
end
|
||||
local prev_line = vim.api.nvim_buf_get_lines(0, delete_line - 2, delete_line - 1, false)[1]
|
||||
if vim.trim(prev_line) ~= "" then
|
||||
break
|
||||
end
|
||||
delete_top = delete_top + 1
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line - delete_top - 1, line - 1, false, {})
|
||||
end
|
||||
|
||||
M.surround_newlines = function(input)
|
||||
return function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local lines = vim.api.nvim_buf_line_count(0)
|
||||
|
||||
local count = math.min(math.max(1, vim.v.count), M.max_new_lines)
|
||||
|
||||
-- Bottom pad
|
||||
local add_bottom = count
|
||||
if M.keep_existing then
|
||||
for i = 1, count do
|
||||
if line + i - 1 == lines then
|
||||
if M.void_bounds then
|
||||
add_bottom = 0
|
||||
end
|
||||
break
|
||||
end
|
||||
local next_line = vim.api.nvim_buf_get_lines(0, line + i - 1, line + i, false)[1]
|
||||
if vim.trim(next_line) == "" then
|
||||
add_bottom = add_bottom - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line, line, false, M.nlines(add_bottom))
|
||||
|
||||
-- Top pad
|
||||
local add_top = count
|
||||
if M.keep_existing then
|
||||
for i = 1, count do
|
||||
if line - i + 1 == 1 then
|
||||
if M.void_bounds then
|
||||
add_top = 0
|
||||
end
|
||||
break
|
||||
end
|
||||
local prev_line = vim.api.nvim_buf_get_lines(0, line - i - 1, line - i, false)[1]
|
||||
if vim.trim(prev_line) == "" then
|
||||
add_top = add_top - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(0, line - 1, line - 1, false, M.nlines(add_top))
|
||||
|
||||
if input ~= "" then
|
||||
vim.api.nvim_input(input)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.next_surround = function(input)
|
||||
return function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local count = math.min(math.max(1, vim.v.count), M.max_new_lines)
|
||||
vim.api.nvim_buf_set_lines(0, line, line, false, M.nlines(count))
|
||||
vim.api.nvim_win_set_cursor(0, { line + count, 0 })
|
||||
if input ~= "" then
|
||||
vim.api.nvim_input(input)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.prev_surround = function(input)
|
||||
return function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local count = math.min(math.max(1, vim.v.count), M.max_new_lines)
|
||||
vim.api.nvim_buf_set_lines(0, line - 1, line - 1, false, M.nlines(count))
|
||||
vim.api.nvim_win_set_cursor(0, { line, 0 })
|
||||
if input ~= "" then
|
||||
vim.api.nvim_input(input)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.set_surround = function()
|
||||
M.remove_all_surround()
|
||||
M.surround_newlines("")()
|
||||
end
|
||||
|
||||
-- Breaking lines with whitespace is a bit wonky but I don't care
|
||||
M.break_into_lines = function()
|
||||
local v_start = vim.fn.getpos("v")
|
||||
local v_end = vim.fn.getpos(".")
|
||||
if (v_end[2] < v_start[2]) or (v_end[2] == v_start[2] and v_end[3] < v_start[3]) then
|
||||
v_start, v_end = v_end, v_start
|
||||
end
|
||||
|
||||
-- End split
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, v_end[2] - 1, v_end[2], false)[1]
|
||||
if v_end[3] < #end_line then
|
||||
local line_start = end_line:sub(1, v_end[3]):gsub("%s+$", "")
|
||||
local line_end = end_line:sub(v_end[3] + 1):gsub("^%s+", "")
|
||||
local pad = line_start:match("^%s+") or ""
|
||||
vim.api.nvim_buf_set_lines(0, v_end[2] - 1, v_end[2], false, {
|
||||
line_start,
|
||||
pad .. line_end
|
||||
})
|
||||
end
|
||||
|
||||
-- Start split
|
||||
local start_line = vim.api.nvim_buf_get_lines(0, v_start[2] - 1, v_start[2], false)[1]
|
||||
if v_start[3] > 1 then
|
||||
local line_start = start_line:sub(1, v_start[3] - 1):gsub("%s+$", "")
|
||||
local line_end = start_line:sub(v_start[3]):gsub("^%s+", "")
|
||||
local pad = line_start:match("^%s+") or ""
|
||||
vim.api.nvim_buf_set_lines(0, v_end[2] - 1, v_end[2], false, {
|
||||
line_start,
|
||||
pad .. line_end
|
||||
})
|
||||
vim.api.nvim_win_set_cursor(0, { v_start[2] + 1, vim.v.maxcol })
|
||||
else
|
||||
vim.api.nvim_win_set_cursor(0, { v_start[2], vim.v.maxcol })
|
||||
end
|
||||
|
||||
vim.api.nvim_input("<Esc>>>")
|
||||
end
|
||||
|
||||
return M
|
||||
104
home/apps/nvim/lua/plugins/colors.lua
Normal file
104
home/apps/nvim/lua/plugins/colors.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
return {
|
||||
{
|
||||
"rebelot/kanagawa.nvim",
|
||||
lazy = false,
|
||||
priority = 1024,
|
||||
config = function()
|
||||
local transparent = true
|
||||
if vim.g.neovide then
|
||||
transparent = false
|
||||
end
|
||||
local color_overrides = {}
|
||||
if transparent then
|
||||
color_overrides = { theme = { all = { ui = { bg_gutter = "NONE" } } } }
|
||||
end
|
||||
require("kanagawa").setup({
|
||||
transparent = transparent,
|
||||
compile = false,
|
||||
undercurl = false,
|
||||
commentStyle = { italic = false, bold = false },
|
||||
keywordStyle = { italic = false, bold = false },
|
||||
statementStyle = { italic = false, bold = false },
|
||||
colors = color_overrides,
|
||||
overrides = function(colors)
|
||||
return {
|
||||
["Boolean"] = { bold = false },
|
||||
["Todo"] = { bold = false },
|
||||
["@variable.builtin"] = { italic = false },
|
||||
["@string.escape"] = { bold = false },
|
||||
["@keyword.operator"] = { bold = false },
|
||||
["@comment.error"] = { bold = false },
|
||||
["@comment.warning"] = { bold = false },
|
||||
["@comment.note"] = { bold = false },
|
||||
["Conceal"] = { bold = false },
|
||||
["CursorLineNr"] = { bold = false },
|
||||
["CurSearch"] = { bold = false },
|
||||
["MatchParen"] = { bold = false },
|
||||
["ModeMsg"] = { bold = false },
|
||||
["FloatTitle"] = { bold = false },
|
||||
["Title"] = { bold = false },
|
||||
["LinePad"] = { fg = colors.theme.ui.nontext, bg = colors.theme.ui.bg_gutter },
|
||||
["FloatBorder"] = { fg = colors.theme.ui.float.fg_border, bg = not transparent and colors.theme.ui.bg or "NONE" },
|
||||
["CmdlineCommand"] = { fg = colors.theme.diag.warning, bg = colors.theme.ui.bg },
|
||||
["Pmenu"] = { bg = colors.theme.ui.bg_m3 },
|
||||
["PmenuSbar"] = { bg = colors.theme.ui.bg_m1 },
|
||||
["PmenuThumb"] = { bg = colors.theme.term[9] },
|
||||
["PmenuSel"] = { bg = colors.theme.bg_visual },
|
||||
["NormalFloat"] = { bg = not transparent and colors.theme.ui.float.bg or "NONE" },
|
||||
["Whitespace"] = { fg = "#606060" },
|
||||
["NonText"] = { fg = "#606060" },
|
||||
-- Markdown
|
||||
["RenderMarkdownUnchecked"] = { fg = "#54546d" },
|
||||
["RenderMarkdownChecked"] = { fg = "#54546D" },
|
||||
["RenderMarkdownWip"] = { fg = "#7FB4CA" },
|
||||
["RenderMarkdownCanceled"] = { fg = "#54546D" },
|
||||
["RenderMarkdownImportant"] = { fg = "#FFA066" },
|
||||
["RenderMarkdownUnknown"] = { fg = "#727169" },
|
||||
["RenderMarkdownIdea"] = { fg = "#FFA066" },
|
||||
["RenderMarkdownStar"] = { fg = "#FFA066" },
|
||||
["RenderMarkdownPositive"] = { link = "@diff.plus" },
|
||||
["RenderMarkdownNegative"] = { link = "@diff.minus" },
|
||||
["RenderMarkdownCheckedScope"] = { fg = "#54546D", strikethrough = true },
|
||||
["RenderMarkdownH1"] = { fg = "#957FB8", bg = "#2A2A37" },
|
||||
["RenderMarkdownH1Bg"] = { fg = "#957FB8", bg = "#2A2A37" },
|
||||
["RenderMarkdownH2"] = { fg = "#98BB6C", bg = "#2A2A37" },
|
||||
["RenderMarkdownH2Bg"] = { fg = "#98BB6C", bg = "#2A2A37" },
|
||||
["RenderMarkdownH3"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH3Bg"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH4"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH4Bg"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH5"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH5Bg"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH6"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownH6Bg"] = { fg = "#7FB4CA", bg = "#2A2A37" },
|
||||
["RenderMarkdownCode"] = { bg = "#24252D" },
|
||||
["RenderMarkdownCodeInline"] = { bg = "#24252D" },
|
||||
}
|
||||
end,
|
||||
})
|
||||
local termcolors = {
|
||||
"#282A2E",
|
||||
"#A54242",
|
||||
"#8C9440",
|
||||
"#DE935F",
|
||||
"#5F819D",
|
||||
"#85678F",
|
||||
"#5E8D87",
|
||||
"#707880",
|
||||
"#373B41",
|
||||
"#FF5555",
|
||||
"#B5BD68",
|
||||
"#F0C674",
|
||||
"#81A2BE",
|
||||
"#B294BB",
|
||||
"#8ABEB7",
|
||||
"#C5C8C6",
|
||||
}
|
||||
vim.cmd("colorscheme kanagawa-wave")
|
||||
for i, color in ipairs(termcolors) do
|
||||
vim.g["terminal_color_" .. i - 1] = color
|
||||
end
|
||||
vim.api.nvim_set_hl(0, "ExchangeRegion", { link = "CursorLine" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
107
home/apps/nvim/lua/plugins/editing.lua
Normal file
107
home/apps/nvim/lua/plugins/editing.lua
Normal file
@@ -0,0 +1,107 @@
|
||||
return {
|
||||
{
|
||||
name = "scripter",
|
||||
dir = vim.fn.stdpath("config") .. "/lua/scripter",
|
||||
keys = {
|
||||
{ "<leader>ss", desc = "Reset Scripter" },
|
||||
{ "<leader>sr", desc = "Temporarily Set Scripter to Cyrillic" },
|
||||
{ "<leader>sR", desc = "Set Scripter to Cyrillic" },
|
||||
},
|
||||
config = function()
|
||||
local scripter = require("scripter")
|
||||
local presets = require("scripter.presets")
|
||||
scripter.setup({
|
||||
consume = false,
|
||||
})
|
||||
vim.keymap.set("n", "<leader>ss", scripter.mapping.set_script({}))
|
||||
vim.keymap.set("n", "<leader>sr", scripter.mapping.set_script(presets.cyrillic, true))
|
||||
vim.keymap.set("n", "<leader>sR", scripter.mapping.set_script(presets.cyrillic, false))
|
||||
vim.keymap.set("i", "<bs>", function()
|
||||
scripter.reset()
|
||||
vim.api.nvim_feedkeys("\b", "n", false);
|
||||
end)
|
||||
end
|
||||
},
|
||||
{
|
||||
name = "multiline",
|
||||
dir = vim.fn.stdpath("config") .. "/lua/multiline",
|
||||
keys = {
|
||||
{ "<C-n>", desc = "Surround with newlines" },
|
||||
{ "o", desc = "Begin a new line below" },
|
||||
{ "O", desc = "Begin a new line above" },
|
||||
{ "yo", desc = "Begin a new line below and repeat it [count] times" },
|
||||
{ "yO", desc = "Begin a new line above and repeat it [count] times" },
|
||||
{ "<C-n>d", desc = "Remove newline surround" },
|
||||
{ "<C-n>D", desc = "Remove all newline surround" },
|
||||
{ "<C-n>f", desc = "Set newline surround" },
|
||||
{ "<C-n>b", desc = "Break selection into a new line" },
|
||||
},
|
||||
config = function()
|
||||
local multiline = require("multiline")
|
||||
multiline.setup({})
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<C-n>", multiline.surround_newlines(""), {})
|
||||
vim.keymap.set("n", "o", multiline.next_surround("\"_S"), {})
|
||||
vim.keymap.set("n", "O", multiline.prev_surround("\"_S"), {})
|
||||
vim.keymap.set("n", "yo", "o")
|
||||
vim.keymap.set("n", "yO", "O")
|
||||
vim.keymap.set("n", "<C-n>d", multiline.remove_surround, {})
|
||||
vim.keymap.set("n", "<C-n>D", multiline.remove_all_surround, {})
|
||||
vim.keymap.set("n", "<C-n>f", multiline.set_surround, {})
|
||||
vim.keymap.set("v", "<C-n>b", multiline.break_into_lines, {})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"tommcdo/vim-exchange",
|
||||
keys = {
|
||||
{ "cxx", desc = "Exchange line" },
|
||||
{ "cx", desc = "Exchange motion" },
|
||||
{ "X", desc = "Exchange selection" },
|
||||
{ "cxc", desc = "Clear exchange" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"echasnovski/mini.surround",
|
||||
keys = {
|
||||
{ "ss", desc = "Surround: Add", mode = { "n", "v" } },
|
||||
{ "sd", desc = "Surround: Delete" },
|
||||
{ "sf", desc = "Surround: Find (right)" },
|
||||
{ "sF", desc = "Surround: Find (left)" },
|
||||
{ "sr", desc = "Surround: Replace" },
|
||||
},
|
||||
opts = {
|
||||
mappings = {
|
||||
add = "ss",
|
||||
delete = "sd",
|
||||
find = "sf",
|
||||
find_left = "sF",
|
||||
highlight = "",
|
||||
replace = "sr",
|
||||
update_n_lines = "sn",
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
"nmac427/guess-indent.nvim",
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<leader>gi", "<cmd>GuessIndent<cr>", "Guess Indentation" },
|
||||
},
|
||||
opts = {
|
||||
auto_cmd = true,
|
||||
on_tab_options = {
|
||||
["expandtab"] = false,
|
||||
},
|
||||
on_space_options = {
|
||||
["expandtab"] = true,
|
||||
["tabstop"] = "detected",
|
||||
["shiftwidth"] = "detected",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
217
home/apps/nvim/lua/plugins/lsp.lua
Normal file
217
home/apps/nvim/lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,217 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {},
|
||||
build = ":TSUpdate",
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<leader>w", "<cmd>Format<cr>", desc = "Format" },
|
||||
{ "<leader>W", "<cmd>Format<cr><cmd>write<cr>", desc = "Format & Write" },
|
||||
},
|
||||
config = function()
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- TODO: Gotta make this into an quick toggle
|
||||
|
||||
-- vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- callback = function(args)
|
||||
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
--
|
||||
-- if client and client.server_capabilities.inlayHintProvider then
|
||||
-- vim.lsp.inlay_hint.enable(true, { bufnr = args.buf })
|
||||
-- end
|
||||
-- end
|
||||
-- })
|
||||
require("lspconfig").lua_ls.setup({
|
||||
on_init = function(client)
|
||||
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
|
||||
runtime = { version = "LuaJIT" },
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = { vim.env.VIMRUNTIME },
|
||||
},
|
||||
})
|
||||
end,
|
||||
settings = { Lua = {} },
|
||||
capabilities = capabilities,
|
||||
})
|
||||
local lsp_servers = {
|
||||
"rust_analyzer",
|
||||
"clangd",
|
||||
"pylsp",
|
||||
"marksman",
|
||||
"taplo",
|
||||
"zls",
|
||||
"ts_ls",
|
||||
"gopls",
|
||||
"texlab",
|
||||
"qmlls",
|
||||
}
|
||||
local lsp_config = require("lspconfig")
|
||||
for _, lsp_server in ipairs(lsp_servers) do
|
||||
lsp_config[lsp_server].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
vim.api.nvim_buf_create_user_command(ev.buf, "Format", function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = "Format current buffer with LSP" })
|
||||
end
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
"hrsh7th/cmp-emoji",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"L3MON4D3/LuaSnip",
|
||||
},
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local kinds = {
|
||||
Field = { " Field", "Identifier" },
|
||||
Class = { " Type", "Type" },
|
||||
Variable = { " Variable", "Statement" },
|
||||
Method = { " Method", "Function" },
|
||||
Function = { " Function", "Function" },
|
||||
Enum = { " Enum", "Boolean" },
|
||||
Keyword = { " Keyword", "Keyword" },
|
||||
Constant = { " Const", "Boolean" },
|
||||
Struct = { " Struct", "Type" },
|
||||
Interface = { " Trait", "Type" },
|
||||
Module = { " Module", "Statement" },
|
||||
EnumMember = { " Value", "Boolean" },
|
||||
File = { " File", "Statement" },
|
||||
Snippet = { " Snippet", "Keyword" },
|
||||
Value = { " Value", "Number" },
|
||||
Property = { " Field", "Identifier" },
|
||||
Reference = { " Reference", "Statement" },
|
||||
Text = { " Text", "String" },
|
||||
Folder = { " Folder", "Statement" },
|
||||
-- Left as an exercise to the reader
|
||||
-- Constructor = "",
|
||||
-- Unit = "",
|
||||
-- Color = "",
|
||||
-- Event = "",
|
||||
-- Operator = "",
|
||||
-- TypeParameter = "",
|
||||
}
|
||||
for kind, link in pairs(kinds) do
|
||||
vim.api.nvim_set_hl(0, "CmpItemKind" .. kind, { link = link[2] })
|
||||
end
|
||||
local omnicomplete = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.mapping.confirm({ select = true })(fallback)
|
||||
else
|
||||
cmp.mapping.complete()(fallback)
|
||||
end
|
||||
end
|
||||
local formatting = {
|
||||
format = function(_, vim_item)
|
||||
local custom = kinds[vim_item.kind]
|
||||
if custom then
|
||||
vim_item.kind = string.format("%-12s", custom[1])
|
||||
else
|
||||
vim_item.kind = string.format("%-12s", vim_item.kind)
|
||||
end
|
||||
if vim_item.abbr then
|
||||
local content = vim_item.abbr
|
||||
local fixed_width = 32
|
||||
if #content > fixed_width then
|
||||
local ellipsis = ""
|
||||
vim_item.abbr = " " .. vim.fn.strcharpart(content, 0, fixed_width - 1) .. ellipsis
|
||||
else
|
||||
vim_item.abbr = " " .. string.format("%-32s", content)
|
||||
end
|
||||
end
|
||||
vim_item.menu = ""
|
||||
return vim_item
|
||||
end,
|
||||
fields = {
|
||||
"abbr",
|
||||
"kind",
|
||||
},
|
||||
}
|
||||
local mapping = ({
|
||||
-- QWERTY mappings
|
||||
["<C-h>"] = { i = omnicomplete, c = omnicomplete },
|
||||
["<C-j>"] = { i = cmp.mapping.select_next_item(), c = cmp.mapping.select_next_item() },
|
||||
["<C-k>"] = { i = cmp.mapping.select_prev_item(), c = cmp.mapping.select_prev_item() },
|
||||
["<C-l>"] = { i = cmp.mapping.abort(), c = cmp.mapping.abort() },
|
||||
["<A-j>"] = { i = cmp.mapping.scroll_docs(6), c = cmp.mapping.scroll_docs(6) },
|
||||
["<A-k>"] = { i = cmp.mapping.scroll_docs(-6), c = cmp.mapping.scroll_docs(-6) },
|
||||
-- Colemak mappings
|
||||
["<C-n>"] = { i = omnicomplete, c = omnicomplete },
|
||||
["<C-e>"] = { i = cmp.mapping.select_next_item(), c = cmp.mapping.select_next_item() },
|
||||
["<C-i>"] = { i = cmp.mapping.select_prev_item(), c = cmp.mapping.select_prev_item() },
|
||||
["<C-o>"] = { i = cmp.mapping.abort(), c = cmp.mapping.abort() },
|
||||
["<A-e>"] = { i = cmp.mapping.scroll_docs(6), c = cmp.mapping.scroll_docs(6) },
|
||||
["<A-i>"] = { i = cmp.mapping.scroll_docs(-6), c = cmp.mapping.scroll_docs(-6) },
|
||||
})
|
||||
local window = {
|
||||
completion = {
|
||||
side_padding = 0,
|
||||
},
|
||||
documentation = {
|
||||
max_width = 64,
|
||||
max_height = 16,
|
||||
},
|
||||
}
|
||||
cmp.setup({
|
||||
-- completion = {
|
||||
-- autocomplete = true,
|
||||
-- completeopt = "menu,menuone",
|
||||
-- },
|
||||
formatting = formatting,
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
-- FIXME: Suggestion sorting is bogus;
|
||||
-- All the useful suggestions are at the bottom
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "nvim_lsp_signature_help" },
|
||||
{ name = "buffer" },
|
||||
{ name = "render-markdown" },
|
||||
{ name = "emoji" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
mapping = mapping,
|
||||
window = window,
|
||||
})
|
||||
cmp.setup.cmdline("/", {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
mapping = mapping,
|
||||
})
|
||||
cmp.setup.cmdline(":", {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
{
|
||||
name = 'cmdline',
|
||||
option = { ignore_cmds = { 'Man', '!' } }
|
||||
},
|
||||
}),
|
||||
mapping = mapping,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
71
home/apps/nvim/lua/plugins/lualine.lua
Normal file
71
home/apps/nvim/lua/plugins/lualine.lua
Normal file
@@ -0,0 +1,71 @@
|
||||
local lualine_pad = {
|
||||
"",
|
||||
separator = { left = "", right = "" },
|
||||
padding = 0,
|
||||
color = "Normal",
|
||||
fmt = function(input, context)
|
||||
local winnr = vim.fn.tabpagewinnr(context.tabnr)
|
||||
return string.rep("⠀", require("winpad").get_pad_size(winnr)) .. input
|
||||
end
|
||||
}
|
||||
return {
|
||||
{
|
||||
"letieu/harpoon-lualine",
|
||||
dependencies = {
|
||||
{
|
||||
"ThePrimeagen/harpoon",
|
||||
branch = "harpoon2",
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"winpad",
|
||||
"letieu/harpoon-lualine",
|
||||
},
|
||||
config = true,
|
||||
opts = {
|
||||
options = {
|
||||
theme = "auto",
|
||||
refresh = { statusline = 1000, tabline = 1000, winbar = 1000 },
|
||||
section_separators = { left = "▌", right = "▐" },
|
||||
component_separators = { left = "", right = "" },
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
lualine_pad,
|
||||
{
|
||||
"mode",
|
||||
separator = { left = "" },
|
||||
},
|
||||
},
|
||||
lualine_b = { "filename", "diff" },
|
||||
lualine_c = {},
|
||||
lualine_x = {
|
||||
{
|
||||
"harpoon2",
|
||||
icon = "",
|
||||
indicators = { "1", "2", "3", "4", "5" },
|
||||
active_indicators = { "1", "2", "3", "4", "5" },
|
||||
color = { fg = "#a0a0c0" },
|
||||
color_active = { fg = "#fc6346" },
|
||||
},
|
||||
-- It's him! The legendary cat2!
|
||||
{ function() return "🐈" end }, "diagnostics"
|
||||
},
|
||||
lualine_y = { "branch" },
|
||||
lualine_z = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = { lualine_pad },
|
||||
lualine_b = { "filename" },
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = { function() return "👀" end },
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
31
home/apps/nvim/lua/plugins/markdown.lua
Normal file
31
home/apps/nvim/lua/plugins/markdown.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
return {
|
||||
"MeanderingProgrammer/render-markdown.nvim",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
||||
opts = {
|
||||
checkbox = {
|
||||
position = "inline",
|
||||
unchecked = {
|
||||
icon = " [ ]",
|
||||
},
|
||||
checked = {
|
||||
icon = " []",
|
||||
scope_highlight = "RenderMarkdownCheckedScope",
|
||||
},
|
||||
custom = {
|
||||
in_progress = { raw = "[/]", rendered = " []", highlight = "RenderMarkdownWip", scope_highlight = nil },
|
||||
todo = { raw = "[-]", rendered = " []", highlight = "RenderMarkdownCanceled", scope_highlight = "RenderMarkdownCheckedScope" },
|
||||
important = { raw = "[!]", rendered = " []", highlight = "RenderMarkdownImportant", scope_highlight = nil },
|
||||
unknown = { raw = "[?]", rendered = " []", highlight = "RenderMarkdownUnknown", scope_highlight = nil },
|
||||
idea = { raw = "[@]", rendered = " []", highlight = "RenderMarkdownIdea", scope_highlight = nil },
|
||||
starred = { raw = "[*]", rendered = " []", highlight = "RenderMarkdownStar", scope_highlight = nil },
|
||||
positive = { raw = "[+]", rendered = " [+]", highlight = "RenderMarkdownPositive", scope_highlight = nil },
|
||||
negative = { raw = "[=]", rendered = " [-]", highlight = "RenderMarkdownNegative", scope_highlight = nil },
|
||||
},
|
||||
},
|
||||
code = {
|
||||
above = "█",
|
||||
below = "█",
|
||||
inline_pad = 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
175
home/apps/nvim/lua/plugins/misc.lua
Normal file
175
home/apps/nvim/lua/plugins/misc.lua
Normal file
@@ -0,0 +1,175 @@
|
||||
return {
|
||||
{
|
||||
"akinsho/toggleterm.nvim",
|
||||
keys = {
|
||||
{ "<C-Space>", desc = "Toggle Terminal" },
|
||||
{ "<leader>mr", "<cmd>TermExec cmd=\"make run\"<cr>", desc = "Make (run)" },
|
||||
{ "<leader>mb", "<cmd>TermExec cmd=\"make build\"<cr>", desc = "Make (build)" },
|
||||
{ "<leader>mc", "<cmd>TermExec cmd=\"make clean\"<cr>", desc = "Make (clean)" },
|
||||
{ "<leader>mt", "<cmd>TermExec cmd=\"make test\"<cr>", desc = "Make (test)" },
|
||||
},
|
||||
opts = {
|
||||
autochdir = true,
|
||||
open_mapping = "<C-Space>",
|
||||
direction = "float",
|
||||
shade_terminals = false,
|
||||
float_opts = {
|
||||
border = require("globals").border_chars,
|
||||
},
|
||||
highlights = {
|
||||
["FloatBorder"] = {
|
||||
link = "FloatBorder"
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "winpad",
|
||||
dir = vim.fn.stdpath("config") .. "/lua/winpad",
|
||||
config = function()
|
||||
local winpad = require("winpad")
|
||||
winpad.setup({
|
||||
enabled = true,
|
||||
})
|
||||
vim.keymap.set("n", "<leader>x", winpad.toggle, { desc = "Toggle Window Padding" })
|
||||
end
|
||||
},
|
||||
{
|
||||
"backdround/global-note.nvim",
|
||||
keys = {
|
||||
{ "<leader>nn", "<cmd>ProjectNote<cr>", desc = "Project Note" },
|
||||
{ "<leader>nf", "<cmd>FileNote<cr>", desc = "File Note" },
|
||||
{ "<leader>N", "<cmd>GlobalNote<cr>", desc = "Global Note" },
|
||||
},
|
||||
config = function()
|
||||
local global_note = require("global-note")
|
||||
global_note.setup({
|
||||
title = "Global Note",
|
||||
directory = "~/Documents/Notes/Repos",
|
||||
filename = "global_note.md",
|
||||
command_name = "GlobalNote",
|
||||
window_config = function()
|
||||
local window_height = vim.api.nvim_list_uis()[1].height
|
||||
local window_width = vim.api.nvim_list_uis()[1].width
|
||||
return {
|
||||
relative = "editor",
|
||||
border = require("globals").border_chars,
|
||||
title = "Note",
|
||||
title_pos = "center",
|
||||
width = math.floor(0.7 * window_width),
|
||||
height = math.floor(0.85 * window_height),
|
||||
row = math.floor(0.05 * window_height),
|
||||
col = math.floor(0.15 * window_width),
|
||||
}
|
||||
end,
|
||||
additional_presets = {
|
||||
project = {
|
||||
title = "Project Note",
|
||||
command_name = "ProjectNote",
|
||||
filename = function()
|
||||
local repo = vim.system({
|
||||
"git",
|
||||
"rev-parse",
|
||||
"--show-toplevel",
|
||||
}, {
|
||||
text = true,
|
||||
}):wait()
|
||||
if repo.stderr ~= "" then
|
||||
vim.notify(repo.stderr, vim.log.levels.WARN)
|
||||
return nil
|
||||
end
|
||||
|
||||
local project_name = vim.fs.basename(repo.stdout:gsub("\n", ""))
|
||||
if project_name == nil then
|
||||
vim.notify("Unable to get project name ", vim.log.levels.WARN)
|
||||
return nil
|
||||
end
|
||||
|
||||
return project_name .. ".md"
|
||||
end,
|
||||
},
|
||||
file = {
|
||||
title = "File Note",
|
||||
command_name = "FileNote",
|
||||
directory = vim.fn.getcwd,
|
||||
filename = "notes.md",
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
},
|
||||
{
|
||||
"moll/vim-bbye",
|
||||
keys = {
|
||||
{ "<leader>bd", "<cmd>Bdelete<cr>", desc = "Delete current buffer" },
|
||||
{ "<leader>bD", "<cmd>Bwipeout<cr>", desc = "Delete all buffers" },
|
||||
{ "<leader>bc", desc = "Clean buffers" }, -- TODO: Implement the thing
|
||||
},
|
||||
},
|
||||
{
|
||||
"stevearc/oil.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
keys = {
|
||||
{ "<leader>e", "<cmd>Oil<cr>", desc = "File Explorer" },
|
||||
{ "<leader>E", "<cmd>Oil ./<cr>", desc = "CWD Explorer" },
|
||||
},
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"ThePrimeagen/harpoon",
|
||||
branch = "harpoon2",
|
||||
requires = { "nvim-lua/plenary.nvim" },
|
||||
keys = {
|
||||
{ "<leader>za", desc = "Add buffer to harpoon" },
|
||||
{ "<leader>zs", desc = "Seek harpoon buffers" },
|
||||
{ "<leader>zd", desc = "Remove buffer from harpoon" },
|
||||
{ "<leader>zx", desc = "Previous harpoon buffer" },
|
||||
{ "<leader>zc", desc = "Next harpoon buffer" },
|
||||
{ "<leader>1" },
|
||||
{ "<leader>2" },
|
||||
{ "<leader>3" },
|
||||
{ "<leader>4" },
|
||||
},
|
||||
config = function()
|
||||
local harpoon = require("harpoon")
|
||||
harpoon:setup({
|
||||
settings = { save_on_ui_close = true, save_on_toggle = true },
|
||||
})
|
||||
vim.keymap.set("n", "<leader>za", function() harpoon:list():add() end)
|
||||
vim.keymap.set("n", "<leader>zs",
|
||||
function()
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list(), {
|
||||
border = require("globals").border_chars,
|
||||
title = " Buffers ",
|
||||
title_pos = "center",
|
||||
})
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>zd", function() harpoon:list():remove() end)
|
||||
vim.keymap.set("n", "<leader>zx", function() harpoon:list():prev() end)
|
||||
vim.keymap.set("n", "<leader>zc", function() harpoon:list():next() end)
|
||||
local keys = "1234567890"
|
||||
for i = 1, #keys do
|
||||
local key = keys:sub(i, i)
|
||||
vim.keymap.set("n", string.format("<leader>%s", key), function()
|
||||
harpoon:list():select(i)
|
||||
end)
|
||||
end
|
||||
harpoon:extend({
|
||||
UI_CREATE = function(cx)
|
||||
for i = 1, #keys do
|
||||
local key = keys:sub(i, i)
|
||||
vim.keymap.set("n", key, function()
|
||||
harpoon:list():select(i)
|
||||
end, { buffer = cx.bufnr })
|
||||
end
|
||||
vim.keymap.set("n", "<C-v>", function()
|
||||
harpoon.ui:select_menu_item({ vsplit = true })
|
||||
end, { buffer = cx.bufnr })
|
||||
vim.keymap.set("n", "<C-s>", function()
|
||||
harpoon.ui:select_menu_item({ split = true })
|
||||
end, { buffer = cx.bufnr })
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
||||
89
home/apps/nvim/lua/plugins/motion.lua
Normal file
89
home/apps/nvim/lua/plugins/motion.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
return {
|
||||
{
|
||||
"xiaoshihou514/squirrel.nvim",
|
||||
keys = {
|
||||
{ "<C-m>", desc = "Hop" },
|
||||
},
|
||||
config = function()
|
||||
require("squirrel.utils").key_iter.keys = "ntesiroa"
|
||||
vim.keymap.set({ "n", "v" }, "<C-m>", function()
|
||||
vim.cmd(".mark '")
|
||||
require("squirrel.hop").hop()
|
||||
end)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"ggandor/leap.nvim",
|
||||
keys = {
|
||||
{ "M", "<Plug>(leap)", desc = "Leap" },
|
||||
},
|
||||
config = function()
|
||||
local leap = require("leap")
|
||||
leap.opts.safe_lables = ""
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
branch = "main",
|
||||
config = function()
|
||||
local move_actions = {
|
||||
["f"] = "function",
|
||||
["t"] = "class",
|
||||
["r"] = "return",
|
||||
["a"] = "parameter",
|
||||
["d"] = "comment",
|
||||
}
|
||||
local goto_next_start = {}
|
||||
local goto_next_end = {}
|
||||
local goto_previous_start = {}
|
||||
local goto_previous_end = {}
|
||||
for letter, action in pairs(move_actions) do
|
||||
local letter_lower = string.lower(letter)
|
||||
local letter_upper = string.upper(letter)
|
||||
goto_next_start["]" .. letter_lower] = {
|
||||
query = string.format("@%s.outer", action),
|
||||
desc = string.format("Next %s start", action),
|
||||
}
|
||||
goto_next_end["]" .. letter_upper] = {
|
||||
query = string.format("@%s.outer", action),
|
||||
desc = string.format("Next %s end", action),
|
||||
}
|
||||
goto_previous_start["[" .. letter_lower] = {
|
||||
query = string.format("@%s.outer", action),
|
||||
desc = string.format("Previous %s start", action),
|
||||
}
|
||||
goto_previous_end["[" .. letter_upper] = {
|
||||
query = string.format("@%s.outer", action),
|
||||
desc = string.format("Previous %s end", action),
|
||||
}
|
||||
end
|
||||
require("nvim-treesitter-textobjects").setup({
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["af"] = { query = "@function.outer", desc = "function" },
|
||||
["if"] = { query = "@function.inner", desc = "function" },
|
||||
["at"] = { query = "@class.outer", desc = "type" },
|
||||
["it"] = { query = "@class.inner", desc = "type" },
|
||||
["aa"] = { query = "@parameter.outer", desc = "parameter" },
|
||||
["ia"] = { query = "@parameter.inner", desc = "parameter" },
|
||||
["ac"] = { query = "@call.outer", desc = "call" },
|
||||
["ic"] = { query = "@call.inner", desc = "call" },
|
||||
["ad"] = { query = "@comment.outer", desc = "comment" },
|
||||
["id"] = { query = "@comment.inner", desc = "comment" },
|
||||
},
|
||||
include_surrounding_whitespace = true,
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true,
|
||||
goto_next_start = goto_next_start,
|
||||
goto_next_end = goto_next_end,
|
||||
goto_previous_start = goto_previous_start,
|
||||
goto_previous_end = goto_previous_end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
29
home/apps/nvim/lua/plugins/snip.lua
Normal file
29
home/apps/nvim/lua/plugins/snip.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
return {
|
||||
"L3MON4D3/LuaSnip",
|
||||
keys = {
|
||||
{ "<C-q>", desc = "Expand Snippet", mode = "i" },
|
||||
},
|
||||
config = function()
|
||||
local ls = require("luasnip")
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<C-q>", function() ls.expand_or_jump() end, { silent = true })
|
||||
-- vim.keymap.set({ "i", "s" }, "<Tab>", function() ls.jump(1) end, { silent = true })
|
||||
-- vim.keymap.set({ "i", "s" }, "<S-Tab>", function() ls.jump(-1) end, { silent = true })
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<Tab>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
else
|
||||
vim.api.nvim_feedkeys("\t", "n", false);
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
ls.setup({
|
||||
link_roots = true,
|
||||
keep_roots = true,
|
||||
delete_check_events = "TextChanged",
|
||||
})
|
||||
|
||||
require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath('config') .. "/snippets" })
|
||||
end,
|
||||
}
|
||||
204
home/apps/nvim/lua/plugins/telescope.lua
Normal file
204
home/apps/nvim/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,204 @@
|
||||
return {
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>t", desc = "Resume Search" },
|
||||
{ "<leader>f", desc = "Find All Files" },
|
||||
{ "<leader>F", desc = "Find Git Files" },
|
||||
{ "<leader>/", desc = "FZF In File" },
|
||||
{ "<leader>G", desc = "Grep Text" },
|
||||
{ "<leader>Z", desc = "Buffer Telescope Menu" },
|
||||
{ "<leader>d", desc = "Local Diagnostics" },
|
||||
{ "<leader>D", desc = "Global Diagnostics" },
|
||||
{ "<leader>gc", desc = "List Commits" },
|
||||
{ "<leader>gC", desc = "List All Commits" },
|
||||
{ "<leader>gs", desc = "Git Status" },
|
||||
{ "<leader>hk", desc = "Search keymaps" },
|
||||
{ "gO", desc = "Local Symbols" },
|
||||
{ "gS", desc = "Global Symbols" },
|
||||
{ "grr", desc = "References" },
|
||||
{ "gri", desc = "Definitions" },
|
||||
},
|
||||
config = function()
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
require('telescope.pickers.layout_strategies').horizontal_merged =
|
||||
function(picker, max_columns, max_lines, layout_config)
|
||||
local layout = require('telescope.pickers.layout_strategies').horizontal(picker, max_columns,
|
||||
max_lines,
|
||||
layout_config)
|
||||
local overdraw_chars = require("globals").border_chars_joined
|
||||
|
||||
layout.results.line = layout.results.line - 1
|
||||
layout.results.height = layout.results.height + 1
|
||||
layout.results.title = ''
|
||||
layout.results.borderchars = require("globals").border_chars_telescope_results
|
||||
|
||||
layout.prompt.borderchars = require("globals").border_chars_telescope_prompt
|
||||
|
||||
if layout.preview then
|
||||
layout.preview.title = ''
|
||||
end
|
||||
return layout
|
||||
end
|
||||
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
prompt_prefix = " ",
|
||||
selection_caret = "👉",
|
||||
sorting_strategy = "ascending",
|
||||
layout_config = {
|
||||
width = 0.90,
|
||||
height = 0.90,
|
||||
prompt_position = "top",
|
||||
preview_width = 0.5,
|
||||
},
|
||||
layout_strategy = "horizontal_merged",
|
||||
wrap_results = true,
|
||||
borderchars = require("globals").border_chars_alternate,
|
||||
default_mappings = {
|
||||
n = {
|
||||
["<Esc>"] = actions.close,
|
||||
["j"] = actions.move_selection_next,
|
||||
["k"] = actions.move_selection_previous,
|
||||
["h"] = actions.select_default,
|
||||
["l"] = actions.close,
|
||||
["H"] = actions.move_to_top,
|
||||
["L"] = actions.move_to_bottom,
|
||||
["<M-j>"] = actions.preview_scrolling_down,
|
||||
["<M-k>"] = actions.preview_scrolling_up,
|
||||
["<M-h>"] = actions.preview_scrolling_left,
|
||||
["<M-l>"] = actions.preview_scrolling_right,
|
||||
},
|
||||
i = {
|
||||
["<Esc>"] = false,
|
||||
["<C-c>"] = false,
|
||||
-- QWERTY mappings
|
||||
["<C-h>"] = actions.select_default,
|
||||
["<C-j>"] = actions.move_selection_next,
|
||||
["<C-k>"] = actions.move_selection_previous,
|
||||
["<C-l>"] = actions.close,
|
||||
["<M-j>"] = actions.preview_scrolling_down,
|
||||
["<M-k>"] = actions.preview_scrolling_up,
|
||||
["<M-h>"] = actions.preview_scrolling_left,
|
||||
["<M-l>"] = actions.preview_scrolling_right,
|
||||
-- Colemak mappings
|
||||
["<C-n>"] = actions.select_default,
|
||||
["<C-e>"] = actions.move_selection_next,
|
||||
["<C-i>"] = actions.move_selection_previous,
|
||||
["<C-o>"] = actions.close,
|
||||
["<M-e>"] = actions.preview_scrolling_down,
|
||||
["<M-i>"] = actions.preview_scrolling_up,
|
||||
["<M-n>"] = actions.preview_scrolling_left,
|
||||
["<M-o>"] = actions.preview_scrolling_right,
|
||||
-- TODO: actions.select_{horizontal, vertical, tab}
|
||||
},
|
||||
},
|
||||
initial_mode = "insert",
|
||||
},
|
||||
pickers = {
|
||||
diagnostics = {
|
||||
disable_coordinates = true,
|
||||
},
|
||||
find_files = {
|
||||
hidden = true,
|
||||
file_ignore_patterns = { "^%.git" },
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").load_extension("fzf")
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>t", builtin.resume, {})
|
||||
vim.keymap.set("n", "<leader>f", builtin.find_files, {})
|
||||
vim.keymap.set("n", "<leader>F", builtin.git_files, {})
|
||||
vim.keymap.set("n", "<leader>/", builtin.current_buffer_fuzzy_find, {})
|
||||
vim.keymap.set("n", "<leader>G", builtin.live_grep, {})
|
||||
vim.keymap.set("n", "<leader>Z", builtin.buffers, {})
|
||||
vim.keymap.set("n", "<leader>d", function()
|
||||
builtin.diagnostics({
|
||||
bufnr = 0,
|
||||
severity_bound = 0,
|
||||
})
|
||||
end, {})
|
||||
vim.keymap.set("n", "<leader>D", builtin.diagnostics, {})
|
||||
vim.keymap.set("n", "<leader>gc", builtin.git_bcommits, {})
|
||||
vim.keymap.set("n", "<leader>gC", builtin.git_commits, {})
|
||||
vim.keymap.set("n", "<leader>gs", builtin.git_status, {})
|
||||
vim.keymap.set("n", "<leader>hk", builtin.keymaps, {})
|
||||
vim.keymap.set("n", "gO", builtin.lsp_document_symbols, {})
|
||||
vim.keymap.set("n", "gS", builtin.lsp_workspace_symbols, {})
|
||||
vim.keymap.set("n", "grr", builtin.lsp_references, {})
|
||||
vim.keymap.set("n", "gri", builtin.lsp_definitions, {})
|
||||
vim.api.nvim_set_hl(0, "TelescopeBorder", { link = "FloatBorder" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"aznhe21/actions-preview.nvim",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
keys = {
|
||||
{ "gra", desc = "Code Actions" },
|
||||
},
|
||||
config = function()
|
||||
require("actions-preview").setup({
|
||||
diff = {
|
||||
ctxlen = 2,
|
||||
algorithm = "histogram",
|
||||
},
|
||||
backend = { "telescope" },
|
||||
telescope = {
|
||||
sorting_strategy = "ascending",
|
||||
layout_strategy = "cursor",
|
||||
layout_config = {
|
||||
preview_width = 0.6,
|
||||
width = 0.8,
|
||||
height = 16,
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.keymap.set({ "n", "v" }, "gra", require("actions-preview").code_actions)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
event = "BufEnter",
|
||||
opts = {
|
||||
signs = true,
|
||||
keywords = {
|
||||
ERROR = {
|
||||
icon = "🐈",
|
||||
color = "error",
|
||||
alt = { "ISSUE", "FUCK" },
|
||||
},
|
||||
TODO = {
|
||||
icon = "📝",
|
||||
color = "info",
|
||||
alt = { "NOTE" },
|
||||
},
|
||||
FIX = {
|
||||
icon = "👀",
|
||||
color = "warning",
|
||||
alt = { "WARN", "FIXME" },
|
||||
},
|
||||
},
|
||||
color = {
|
||||
error = { "DiagnosticError" },
|
||||
warning = { "DiagnosticWarning" },
|
||||
info = { "DiagnosticInfo" },
|
||||
},
|
||||
highlight = {
|
||||
keyword = "fg",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
40
home/apps/nvim/lua/plugins/visual.lua
Normal file
40
home/apps/nvim/lua/plugins/visual.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
name = "center",
|
||||
dir = vim.fn.stdpath("config") .. "/lua/center",
|
||||
config = function()
|
||||
require("center").setup({
|
||||
enabled = true,
|
||||
skip_filetypes = {
|
||||
"buffer_manager",
|
||||
},
|
||||
})
|
||||
end
|
||||
},
|
||||
{
|
||||
"stevearc/dressing.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
input = {
|
||||
border = require("globals").border_chars,
|
||||
},
|
||||
select = {
|
||||
builtin = {
|
||||
border = require("globals").border_chars,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
opts = {
|
||||
color_icons = true,
|
||||
default = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
142
home/apps/nvim/lua/scripter/init.lua
Normal file
142
home/apps/nvim/lua/scripter/init.lua
Normal file
@@ -0,0 +1,142 @@
|
||||
local presets = require("scripter.presets")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.resolve = function(char)
|
||||
local check = string.lower(char)
|
||||
if check ~= char then
|
||||
M.upper = true
|
||||
end
|
||||
local next = M.current_script[check]
|
||||
if type(next) == "table" then
|
||||
if next.stop then
|
||||
local stopper = next.stopper
|
||||
if stopper then
|
||||
M.backlog = ""
|
||||
M.current_script = M.script
|
||||
local upper = M.upper
|
||||
M.upper = false
|
||||
return stopper[upper and 2 or 1]
|
||||
else
|
||||
M.current_script = M.script
|
||||
M.upper = false
|
||||
if M.consume then
|
||||
M.backlog = ""
|
||||
return ""
|
||||
else
|
||||
local backlog = M.backlog
|
||||
M.backlog = ""
|
||||
return backlog .. char
|
||||
end
|
||||
end
|
||||
else
|
||||
M.backlog = M.backlog .. char
|
||||
M.current_script = next
|
||||
return ""
|
||||
end
|
||||
end
|
||||
if type(next) == "nil" then
|
||||
local stopper = M.current_script.stopper
|
||||
if stopper then
|
||||
M.backlog = ""
|
||||
M.current_script = M.script
|
||||
local upper = M.upper
|
||||
M.upper = false
|
||||
return stopper[upper and 2 or 1] .. M.resolve(char)
|
||||
else
|
||||
M.current_script = M.script
|
||||
M.upper = false
|
||||
if M.consume then
|
||||
M.backlog = ""
|
||||
return ""
|
||||
else
|
||||
local backlog = M.backlog
|
||||
M.backlog = ""
|
||||
return backlog .. char
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.setup = function(opts)
|
||||
M.default = opts.default or presets.none
|
||||
M.script = M.default
|
||||
M.current_script = M.default
|
||||
M.consume = opts.consume or false
|
||||
M.backlog = ""
|
||||
M.mark_namespace = vim.api.nvim_create_namespace("Scripter")
|
||||
M.mark_id = nil
|
||||
M.highlight = opts.highlight or "@comment"
|
||||
M.temporary = false
|
||||
local group = vim.api.nvim_create_augroup("Scripter", {})
|
||||
M.group = group
|
||||
vim.api.nvim_create_autocmd({ "InsertCharPre" }, {
|
||||
group = group,
|
||||
callback = function(_)
|
||||
vim.v.char = M.resolve(vim.v.char)
|
||||
M.upadte_mark()
|
||||
end
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "InsertLeavePre" }, {
|
||||
group = group,
|
||||
callback = function(_)
|
||||
M.reset()
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
M.disable = function()
|
||||
vim.api.nvim_buf_del_extmark(0, M.mark_namespace, M.mark_id)
|
||||
vim.api.nvim_del_augroup_by_id(M.group)
|
||||
M.group = nil
|
||||
end
|
||||
|
||||
M.upadte_mark = function()
|
||||
if M.mark_id ~= nil then
|
||||
vim.api.nvim_buf_del_extmark(0, M.mark_namespace, M.mark_id)
|
||||
M.mark_id = nil
|
||||
end
|
||||
if M.current_script.stopper ~= nil then
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
M.mark_id = vim.api.nvim_buf_set_extmark(
|
||||
0,
|
||||
M.mark_namespace,
|
||||
cursor[1] - 1,
|
||||
cursor[2],
|
||||
{
|
||||
virt_text = { { M.current_script.stopper[M.upper and 2 or 1], M.highlight } },
|
||||
virt_text_pos = "overlay",
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
M.reset = function()
|
||||
if M.current_script.stopper then
|
||||
vim.api.nvim_put({ M.current_script.stopper[M.upper and 2 or 1] }, "c", false, true)
|
||||
print(M.current_script.stopper)
|
||||
end
|
||||
if M.temporary then
|
||||
M.script = M.default
|
||||
M.temporary = false
|
||||
end
|
||||
M.current_script = M.script
|
||||
M.backlog = ""
|
||||
M.upper = false
|
||||
M.upadte_mark()
|
||||
end
|
||||
|
||||
M.set_script = function(script, temporary)
|
||||
M.script = script
|
||||
M.current_script = script
|
||||
M.temporary = temporary
|
||||
end
|
||||
|
||||
M.mapping = {}
|
||||
M.mapping.set_script = function(script, temporary)
|
||||
return function()
|
||||
M.set_script(script, temporary)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
22
home/apps/nvim/lua/scripter/presets/auto.lua
Normal file
22
home/apps/nvim/lua/scripter/presets/auto.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
local M = {}
|
||||
|
||||
M.autoscript = function(table)
|
||||
local output = {}
|
||||
for i = 1, #table, 3 do
|
||||
local path = table[i]
|
||||
local cmod = output
|
||||
for j = 1, string.len(path) do
|
||||
local dir = string.sub(path, j, j)
|
||||
if cmod[dir] == nil then
|
||||
cmod[dir] = { stop = string.len(path) == j }
|
||||
else
|
||||
cmod[dir].stop = false
|
||||
end
|
||||
cmod = cmod[dir]
|
||||
end
|
||||
cmod.stopper = { table[i + 1], table[i + 2] }
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
return M
|
||||
37
home/apps/nvim/lua/scripter/presets/cyrillic.lua
Normal file
37
home/apps/nvim/lua/scripter/presets/cyrillic.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local auto = require("scripter.presets.auto")
|
||||
|
||||
return auto.autoscript({
|
||||
"zh", "ж", "Ж",
|
||||
"ch", "ч", "Ч",
|
||||
"sh", "ш", "Ш",
|
||||
"sh'", "щ", "Щ",
|
||||
"yi", "ы", "Ы",
|
||||
"j", "ë", "Ë",
|
||||
"''", "ъ", "Ъ",
|
||||
"c", "ц", "Ц",
|
||||
"ye", "э", "Э",
|
||||
"yu", "ю", "Ю",
|
||||
"ya", "я", "Я",
|
||||
"a", "а", "А",
|
||||
"b", "б", "Б",
|
||||
"v", "в", "В",
|
||||
"g", "г", "Г",
|
||||
"d", "д", "Д",
|
||||
"e", "е", "Е",
|
||||
"z", "з", "З",
|
||||
"i", "и", "И",
|
||||
"y", "й", "Й",
|
||||
"k", "к", "К",
|
||||
"l", "л", "Л",
|
||||
"m", "м", "М",
|
||||
"n", "н", "Н",
|
||||
"o", "о", "О",
|
||||
"p", "п", "П",
|
||||
"r", "р", "Р",
|
||||
"s", "с", "С",
|
||||
"t", "т", "Т",
|
||||
"u", "у", "У",
|
||||
"f", "ф", "Ф",
|
||||
"h", "х", "Х",
|
||||
"'", "ь", "Ь",
|
||||
})
|
||||
6
home/apps/nvim/lua/scripter/presets/init.lua
Normal file
6
home/apps/nvim/lua/scripter/presets/init.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
M.cyrillic = require("scripter.presets.cyrillic")
|
||||
M.none = require("scripter.presets.none")
|
||||
|
||||
return M
|
||||
3
home/apps/nvim/lua/scripter/presets/none.lua
Normal file
3
home/apps/nvim/lua/scripter/presets/none.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
stop = true,
|
||||
}
|
||||
93
home/apps/nvim/lua/winpad/init.lua
Normal file
93
home/apps/nvim/lua/winpad/init.lua
Normal file
@@ -0,0 +1,93 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function(opts)
|
||||
M.enabled = false
|
||||
M.pad_target = opts.pad_target or 35
|
||||
M.pad_min_width = opts.pad_min_width or 120
|
||||
if opts.enabled then
|
||||
M.enable_pad()
|
||||
end
|
||||
end
|
||||
|
||||
M.toggle = function()
|
||||
if M.enabled then
|
||||
M.disable_pad()
|
||||
else
|
||||
M.enable_pad()
|
||||
end
|
||||
end
|
||||
|
||||
M.disable_pad = function()
|
||||
if not M.enabled then
|
||||
return
|
||||
end
|
||||
vim.api.nvim_del_augroup_by_id(M.group)
|
||||
M.enabled = false
|
||||
M.pad_all_windows()
|
||||
end
|
||||
|
||||
M.enable_pad = function()
|
||||
if M.enabled then
|
||||
return
|
||||
end
|
||||
local group = vim.api.nvim_create_augroup("PadGroup", {})
|
||||
M.group = group
|
||||
vim.api.nvim_create_autocmd({ "WinResized", "WinNew", "VimEnter", "BufEnter" }, {
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
if ev.event == "WinResized" then
|
||||
for _, window in ipairs(vim.v.event.windows) do
|
||||
M.pad_window(window)
|
||||
end
|
||||
else
|
||||
M.pad_all_windows()
|
||||
end
|
||||
end
|
||||
})
|
||||
M.enabled = true
|
||||
M.pad_all_windows()
|
||||
end
|
||||
|
||||
M.update_pad_size = function(win)
|
||||
local position = vim.api.nvim_win_get_position(win)
|
||||
local target_pad = math.max(0, M.pad_target - position[2])
|
||||
local width = vim.api.nvim_win_get_width(win)
|
||||
local ui_width = vim.api.nvim_list_uis()[1].width
|
||||
local min_left = math.max(math.floor(ui_width / 2), M.pad_min_width)
|
||||
local max_pad = math.max(0, width - min_left)
|
||||
local total_pad = math.min(max_pad, target_pad)
|
||||
M.set_pad_size(win, total_pad)
|
||||
return total_pad
|
||||
end
|
||||
|
||||
M.set_pad_size = function(win, pad)
|
||||
vim.api.nvim_win_set_var(win, "pad_size", pad)
|
||||
end
|
||||
M.get_pad_size = function(win)
|
||||
return vim.api.nvim_win_get_var(win, "pad_size") or 0
|
||||
end
|
||||
|
||||
M.pad_window = function(win)
|
||||
if #vim.api.nvim_win_get_config(win).relative > 0 then
|
||||
return
|
||||
end
|
||||
if not M.enabled then
|
||||
M.set_pad_size(win, 0)
|
||||
vim.api.nvim_set_option_value("statuscolumn", "%#LineNr#%2.2s%4.4l%#LinePad#%{\"┃\"}", { win = win })
|
||||
else
|
||||
local total_pad = M.update_pad_size(win)
|
||||
vim.api.nvim_set_option_value("statuscolumn",
|
||||
"%#Normal#%{\"" ..
|
||||
-- Sometimes I feel like I shouldn't be allowed to touch computers...
|
||||
string.rep("⠀", total_pad) .. "\"}%#LineNr# %2.2s%4.4l%#LinePad#%{v:virtnum<=0?\"┃\":\"⠀⠀⠀⠀┃\"}",
|
||||
{ win = win })
|
||||
end
|
||||
end
|
||||
|
||||
M.pad_all_windows = function()
|
||||
for _, window in ipairs(vim.api.nvim_list_wins()) do
|
||||
M.pad_window(window)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user