refactor: move .config and start.sh outside home/ folder
This commit is contained in:
8
.config/nvim/lua/config/autocmds.lua
Executable file
8
.config/nvim/lua/config/autocmds.lua
Executable file
@ -0,0 +1,8 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
--
|
||||
-- Add any additional autocmds here
|
||||
-- with `vim.api.nvim_create_autocmd`
|
||||
--
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
15
.config/nvim/lua/config/keymaps.lua
Executable file
15
.config/nvim/lua/config/keymaps.lua
Executable file
@ -0,0 +1,15 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"]<space>",
|
||||
':<C-u>call append(line("."), repeat([""], v:count1))<CR>',
|
||||
{ silent = true, desc = "Add line below" }
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"[<space>",
|
||||
':<C-u>call append(line(".")-1, repeat([""], v:count1))<CR>',
|
||||
{ silent = true, desc = "Add line above" }
|
||||
)
|
53
.config/nvim/lua/config/lazy.lua
Executable file
53
.config/nvim/lua/config/lazy.lua
Executable file
@ -0,0 +1,53 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- import/override with your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
install = { missing = true, colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = {
|
||||
enabled = false, -- check for plugin updates periodically
|
||||
notify = false, -- notify on update
|
||||
}, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
4
.config/nvim/lua/config/options.lua
Executable file
4
.config/nvim/lua/config/options.lua
Executable file
@ -0,0 +1,4 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
vim.opt.clipboard = "unnamedplus"
|
12
.config/nvim/lua/plugins/colorscheme.lua
Executable file
12
.config/nvim/lua/plugins/colorscheme.lua
Executable file
@ -0,0 +1,12 @@
|
||||
return {
|
||||
-- catppuccin
|
||||
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
|
||||
|
||||
-- Configure LazyVim to load gruvbox
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "catppuccin",
|
||||
},
|
||||
},
|
||||
}
|
208
.config/nvim/lua/plugins/diffview.lua
Executable file
208
.config/nvim/lua/plugins/diffview.lua
Executable file
@ -0,0 +1,208 @@
|
||||
return {
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
dependencies = { "sindrets/diffview.nvim" },
|
||||
---@type snacks.Config
|
||||
opts = {
|
||||
picker = {
|
||||
sources = {
|
||||
git_diff_any = {
|
||||
finder = function()
|
||||
local cmd = {
|
||||
"git",
|
||||
"log",
|
||||
"--branches",
|
||||
"--remotes",
|
||||
"--oneline",
|
||||
"--decorate=short",
|
||||
"--color=never",
|
||||
"--pretty=format:%h%x1f%D%x1f%s%x1f%ch",
|
||||
}
|
||||
local raw = vim.fn.systemlist(cmd)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.notify("Failed to load git log", vim.log.levels.ERROR)
|
||||
return {}
|
||||
end
|
||||
|
||||
local items = {}
|
||||
for i, record in ipairs(raw) do
|
||||
if record ~= "" then
|
||||
-- split on our unit‐separator
|
||||
local parts = vim.split(record, "\x1f", { plain = true })
|
||||
local sha = parts[1]
|
||||
local decorate = parts[2]:gsub("^%s*(.-)%s*$", "%1") -- trim
|
||||
local msg = parts[3]
|
||||
local rel_date = parts[4]
|
||||
-- rebuild a nice display string
|
||||
local display = string.format("%s %s %s (%s)", sha, decorate ~= "" and decorate or "", msg, rel_date)
|
||||
|
||||
items[#items + 1] = {
|
||||
idx = i, -- required
|
||||
score = 0, -- required
|
||||
text = display, -- shown in the list
|
||||
commit = sha, -- for later Diffview use
|
||||
branch = decorate,
|
||||
msg = msg,
|
||||
date = rel_date,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
return items
|
||||
end,
|
||||
|
||||
format = function(item, picker)
|
||||
local util = Snacks.picker.util
|
||||
local hl = Snacks.picker.highlight
|
||||
local a = util.align
|
||||
local ret = {}
|
||||
|
||||
-- 1) Commit icon + SHA
|
||||
ret[#ret + 1] = { picker.opts.icons.git.commit, "SnacksPickerGitCommit" }
|
||||
ret[#ret + 1] = { a(item.commit, 8, { truncate = true }), "SnacksPickerGitCommit" }
|
||||
ret[#ret + 1] = { " " }
|
||||
|
||||
-- 2) Relative date
|
||||
ret[#ret + 1] = { a(item.date, 16), "SnacksPickerGitDate" }
|
||||
ret[#ret + 1] = { " " }
|
||||
|
||||
-- 3) Branch/Tag decorate info (if any)
|
||||
if item.branch and item.branch ~= "" then
|
||||
-- local truncated = a(item.branch, 20, { truncate = true })
|
||||
local truncated = item.branch
|
||||
ret[#ret + 1] = { "[" .. truncated .. "]", "SnacksPickerGitBranch" }
|
||||
ret[#ret + 1] = { " " }
|
||||
end
|
||||
|
||||
-- 4) Conventional-commit parsing: type, scope, breaking, and body
|
||||
local msg = item.msg
|
||||
local typ, scope, breaking, body = msg:match("^(%S+)%s*(%b())(!?):%s*(.*)$")
|
||||
if not typ then
|
||||
typ, breaking, body = msg:match("^(%S+)(!?):%s*(.*)$")
|
||||
end
|
||||
|
||||
local msg_hl = "SnacksPickerGitMsg"
|
||||
if typ and body then
|
||||
local dimmed = vim.tbl_contains({ "chore", "bot", "build", "ci", "style", "test" }, typ)
|
||||
msg_hl = dimmed and "SnacksPickerDimmed" or "SnacksPickerGitMsg"
|
||||
|
||||
-- type
|
||||
local type_hl = breaking ~= "" and "SnacksPickerGitBreaking"
|
||||
or dimmed and "SnacksPickerBold"
|
||||
or "SnacksPickerGitType"
|
||||
ret[#ret + 1] = { typ, type_hl }
|
||||
|
||||
-- scope
|
||||
if scope and scope ~= "" then
|
||||
ret[#ret + 1] = { scope, "SnacksPickerGitScope" }
|
||||
end
|
||||
|
||||
-- breaking "!"
|
||||
if breaking ~= "" then
|
||||
ret[#ret + 1] = { "!", "SnacksPickerGitBreaking" }
|
||||
end
|
||||
|
||||
-- delimiter
|
||||
ret[#ret + 1] = { ": ", "SnacksPickerDelim" }
|
||||
msg = body
|
||||
end
|
||||
|
||||
-- 5) The rest of the message
|
||||
ret[#ret + 1] = { msg, msg_hl }
|
||||
|
||||
-- 6) Markdown-style inline formatting & issue hyperlinked
|
||||
hl.markdown(ret)
|
||||
hl.highlight(ret, { ["#%d+"] = "SnacksPickerGitIssue" })
|
||||
|
||||
return ret
|
||||
end,
|
||||
|
||||
preview = "git_show",
|
||||
|
||||
matcher = { fuzzy = true },
|
||||
sort = { fields = { "idx" } },
|
||||
|
||||
title = "Select commits to diff",
|
||||
|
||||
confirm = function(picker)
|
||||
local sel = picker:selected()
|
||||
picker:close()
|
||||
|
||||
local function open_single(s)
|
||||
local parents = vim.fn.systemlist("git rev-list --parents -n 1 " .. s)[1] or ""
|
||||
if parents:find(" ") then
|
||||
vim.cmd("DiffviewOpen " .. s .. "^.." .. s)
|
||||
else
|
||||
vim.cmd("DiffviewOpen " .. s)
|
||||
end
|
||||
end
|
||||
|
||||
if #sel == 1 then
|
||||
open_single(sel[1].commit)
|
||||
elseif #sel == 2 then
|
||||
vim.cmd("DiffviewOpen " .. sel[2].commit .. ".." .. sel[1].commit)
|
||||
else
|
||||
vim.notify("Select maximum two commits", vim.log.levels.ERROR)
|
||||
end
|
||||
end,
|
||||
},
|
||||
git_diff_branches = {
|
||||
finder = "git_branches",
|
||||
format = "git_branch",
|
||||
preview = "git_log",
|
||||
|
||||
matcher = { fuzzy = true },
|
||||
sort = { fields = { "idx" } },
|
||||
|
||||
title = "Select branches to diff",
|
||||
|
||||
confirm = function(picker)
|
||||
local sel = picker:selected()
|
||||
picker:close()
|
||||
|
||||
local function open_single(s)
|
||||
local parents = vim.fn.systemlist("git rev-list --parents -n 1 " .. s)[1] or ""
|
||||
if parents:find(" ") then
|
||||
vim.cmd("DiffviewOpen " .. s .. "^.." .. s)
|
||||
else
|
||||
vim.cmd("DiffviewOpen " .. s)
|
||||
end
|
||||
end
|
||||
|
||||
if #sel == 1 then
|
||||
open_single(sel[1].branch)
|
||||
elseif #sel == 2 then
|
||||
vim.cmd("DiffviewOpen " .. sel[2].branch .. ".." .. sel[1].branch)
|
||||
else
|
||||
vim.notify("Select maximum two commits", vim.log.levels.ERROR)
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
keys = {
|
||||
{
|
||||
"<leader>gD",
|
||||
function()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
Snacks.picker.git_diff_any()
|
||||
end,
|
||||
desc = "Snacks: Git Diff",
|
||||
},
|
||||
{
|
||||
"<leader>gE",
|
||||
function()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
Snacks.picker.git_diff_branches()
|
||||
end,
|
||||
desc = "Snacks: Git Branch Diff",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
opts = {},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user