chore: reformat codebase

This commit is contained in:
Gabriel Arazas 2025-01-29 12:53:43 +08:00
parent f2f7a9e221
commit 5e8f90a6bd
11 changed files with 144 additions and 94 deletions

View File

@ -302,10 +302,10 @@ return lush(function()
sassMixinName({ fg = base0D }),
-- Spelling highlighting
SpellBad({ gui = "undercurl" }), --, base08)
SpellBad({ gui = "undercurl" }), --, base08)
SpellLocal({ gui = "undercurl" }), --, base0C)
SpellCap({ gui = "undercurl" }), --, base0D)
SpellRare({ gui = "undercurl" }), --, base0E)
SpellCap({ gui = "undercurl" }), --, base0D)
SpellRare({ gui = "undercurl" }), --, base0E)
-- Startify highlighting
StartifyBracket({ fg = base03 }),

View File

@ -26,7 +26,7 @@ return {
{ "~/library/writings" },
},
},
fzf = { },
fzf = {},
},
})
@ -51,13 +51,38 @@ return {
})
end, { noremap = true, desc = "Find files in current directory" })
vim.keymap.set("n", "<leader>fg", get_builtin("grep_string"), { noremap = true, desc = "Grep for string in cursor" })
vim.keymap.set("n", "<leader>fG", get_builtin("live_grep"), { noremap = true, desc = "Grep for string in project" })
vim.keymap.set("n", "<leader>fb", get_builtin("buffers"), { noremap = true, desc = "Search currently opened buffers" })
vim.keymap.set(
"n",
"<leader>fg",
get_builtin("grep_string"),
{ noremap = true, desc = "Grep for string in cursor" }
)
vim.keymap.set(
"n",
"<leader>fG",
get_builtin("live_grep"),
{ noremap = true, desc = "Grep for string in project" }
)
vim.keymap.set(
"n",
"<leader>fb",
get_builtin("buffers"),
{ noremap = true, desc = "Search currently opened buffers" }
)
vim.keymap.set("n", "<leader>fh", get_builtin("help_tags"), { noremap = true, desc = "Search help pages" })
vim.keymap.set("n", "<leader>ft", get_builtin("treesitter"), { noremap = true, desc = "Search treesitter objects" })
vim.keymap.set(
"n",
"<leader>ft",
get_builtin("treesitter"),
{ noremap = true, desc = "Search treesitter objects" }
)
vim.keymap.set("n", "<leader>fM", get_builtin("man_pages"), { noremap = true, desc = "Search manpages" })
vim.keymap.set("n", "<leader>fS", get_builtin("spell_suggest"), { noremap = true, desc = "Pick spell suggestions" })
vim.keymap.set(
"n",
"<leader>fS",
get_builtin("spell_suggest"),
{ noremap = true, desc = "Pick spell suggestions" }
)
vim.keymap.set("n", "<leader>fA", get_builtin("resume"), { noremap = true, desc = "Return last search" })
@ -69,7 +94,12 @@ return {
{
"ThePrimeagen/harpoon",
config = function()
vim.keymap.set("n", "<leader>fm", "<cmd>lua require('harpoon.mark').add_file()<cr>", { desc = "Add mark to file" })
vim.keymap.set(
"n",
"<leader>fm",
"<cmd>lua require('harpoon.mark').add_file()<cr>",
{ desc = "Add mark to file" }
)
local has_telescope, telescope = pcall("telescope")
if has_telescope then

View File

@ -35,5 +35,5 @@ return {
},
},
},
}
},
}

View File

@ -20,7 +20,7 @@ return {
},
input = { enabled = true },
notifier = { enabled = true },
git = { enabled = true, },
git = { enabled = true },
lazygit = {
enabled = vim.fn.executable("lazygit") == 1,
},
@ -35,9 +35,27 @@ return {
words = { enabled = true },
},
keys = {
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Open blame lines for current file" },
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Open lazygit" },
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Open current file history in lazygit" },
{
"<leader>gb",
function()
Snacks.git.blame_line()
end,
desc = "Open blame lines for current file",
},
{
"<leader>gg",
function()
Snacks.lazygit()
end,
desc = "Open lazygit",
},
{
"<leader>gf",
function()
Snacks.lazygit.log_file()
end,
desc = "Open current file history in lazygit",
},
},
init = function()
vim.api.nvim_create_autocmd("User", {
@ -58,7 +76,9 @@ return {
Snacks.toggle.option("relativenumber", { name = "Relative number" }):map("<leader>uL")
Snacks.toggle.diagnostics():map("<leader>ud")
Snacks.toggle.line_number():map("<leader>ul")
Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("<leader>uc")
Snacks.toggle
.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 })
:map("<leader>uc")
Snacks.toggle.treesitter():map("<leader>uT")
Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark style" }):map("<leader>ub")
Snacks.toggle.inlay_hints():map("<leader>uh")
@ -86,7 +106,13 @@ return {
keys = {
{ "-", "<cmd>Oil<CR>", { desc = "Open parent directory in file explorer" } },
{ "<C-->", function () require("oil").open(vim.fn.getcwd()) end, { desc = "Open current working directory in file explorer" } },
{
"<C-->",
function()
require("oil").open(vim.fn.getcwd())
end,
{ desc = "Open current working directory in file explorer" },
},
},
},
}

View File

@ -1,2 +1 @@
return {
}
return {}

View File

@ -31,14 +31,14 @@ return {
highlight_current_scope = { enable = false },
highlight_definitions = { clear_on_cursor_move = true, enable = true },
navigation = {
enable = true,
keymaps = {
goto_definition = "gnd",
goto_next_usage = "<a-*>",
goto_previous_usage = "<a-#>",
list_definitions = "gnD",
list_definitions_toc = "gO",
},
enable = true,
keymaps = {
goto_definition = "gnd",
goto_next_usage = "<a-*>",
goto_previous_usage = "<a-#>",
list_definitions = "gnD",
list_definitions_toc = "gO",
},
},
smart_rename = { enable = true, keymaps = { smart_rename = "grr" } },
textobjects = {

View File

@ -7,10 +7,8 @@ local wezterm = require("wezterm")
-- same code fetching the colors all over various config files.
local xdg_data_home = os.getenv("XDG_DATA_HOME") or "~/.local/share"
local theme_dir = xdg_data_home .. "/base16/bark-on-a-tree"
local light_scheme, light_scheme_metadata =
wezterm.color.load_base16_scheme(theme_dir .. "/albino-bark-on-a-tree.yaml")
local dark_theme, dark_theme_metadata =
wezterm.color.load_base16_scheme(theme_dir .. "/bark-on-a-tree.yaml")
local light_scheme, light_scheme_metadata = wezterm.color.load_base16_scheme(theme_dir .. "/albino-bark-on-a-tree.yaml")
local dark_theme, dark_theme_metadata = wezterm.color.load_base16_scheme(theme_dir .. "/bark-on-a-tree.yaml")
local function scheme_for_appearance()
-- We're just following the default XDG appearance spec.
@ -75,7 +73,7 @@ function module.apply_to_config(config)
-- Configuring the windows padding.
config.window_padding = {
left = 0,
right = '1cell',
right = "1cell",
top = 0,
bottom = 0,
}

View File

@ -5,8 +5,8 @@ function module.apply_to_config(config)
-- Quick select-related options. Quite similar to Kitty hints which is
-- nice.
config.quick_select_patterns = {
"[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git.
"[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging.
"[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git.
"[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging.
"sha256-.{44,128}", -- SHA256 hashes in Base64, used often in getting hashes for Nix packaging.
}
@ -14,7 +14,7 @@ function module.apply_to_config(config)
config.check_for_updates = false
-- Enable some things for Wayland.
if os.getenv "XDG_SESSION_TYPE" == "wayland" then
if os.getenv("XDG_SESSION_TYPE") == "wayland" then
config.enable_wayland = true
config.front_end = "WebGpu"
config.force_reverse_video_cursor = true
@ -22,6 +22,7 @@ function module.apply_to_config(config)
-- Use some IME.
config.use_ime = true
config.xim_im_name = "ibus"
-- Set up the visual bell.
config.audible_bell = "SystemBeep"

View File

@ -44,7 +44,7 @@ function module.apply_to_config(config)
end)
-- Maximize the terminal on startup.
wezterm.on('gui-startup', function(cmd)
wezterm.on("gui-startup", function(cmd)
local tab, pane, window = wezterm.mux.spawn_window(cmd or {})
window:gui_window():maximize()
end)

View File

@ -9,14 +9,11 @@ local module = {}
local copy_mode = nil
if wezterm.gui then
copy_mode = wezterm.gui.default_key_tables().copy_mode
table.insert(
copy_mode,
{
key = 'z',
mods = keymod,
action = act.CopyMode { MoveBackwardZoneOfType = 'Output' },
}
)
table.insert(copy_mode, {
key = "z",
mods = keymod,
action = act.CopyMode({ MoveBackwardZoneOfType = "Output" }),
})
end
function module.apply_to_config(config)
@ -44,20 +41,20 @@ function module.apply_to_config(config)
-- It also makes use of key tables which is defined after.
config.keys = {
-- Clipboard
{ key = "c", mods = keymod, action = act.CopyTo("Clipboard") },
{ key = "v", mods = keymod, action = act.PasteFrom("Clipboard") },
{ key = "c", mods = keymod, action = act.CopyTo("Clipboard") },
{ key = "v", mods = keymod, action = act.PasteFrom("Clipboard") },
-- Font resize.
{ key = "+", mods = keymod, action = act.IncreaseFontSize },
{ key = "_", mods = keymod, action = act.DecreaseFontSize },
{ key = ")", mods = keymod, action = act.ResetFontSize },
{ key = "+", mods = keymod, action = act.IncreaseFontSize },
{ key = "_", mods = keymod, action = act.DecreaseFontSize },
{ key = ")", mods = keymod, action = act.ResetFontSize },
-- Scrollback
{ key = "j", mods = keymod, action = act.ScrollByPage(1) },
{ key = "k", mods = keymod, action = act.ScrollByPage(-1) },
{ key = "j", mods = keymod, action = act.ScrollByPage(1) },
{ key = "k", mods = keymod, action = act.ScrollByPage(-1) },
{ key = "j", mods = "CTRL|ALT", action = act.ScrollToPrompt(1) },
{ key = "k", mods = "CTRL|ALT", action = act.ScrollToPrompt(-1) },
{ key = "G", mods = keymod, action = act.ScrollToBottom },
{ key = "G", mods = keymod, action = act.ScrollToBottom },
{ key = "g", mods = "CTRL|ALT", action = act.ScrollToTop },
-- Pane navigation.
@ -82,21 +79,21 @@ function module.apply_to_config(config)
}),
},
{ key = "h", mods = keymod, action = act.ActivatePaneDirection("Left") },
{ key = "l", mods = keymod, action = act.ActivatePaneDirection("Right") },
{ key = "LeftArrow", mods = keymod, action = act.ActivatePaneDirection("Left") },
{ key = "DownArrow", mods = keymod, action = act.ActivatePaneDirection("Down") },
{ key = "UpArrow", mods = keymod, action = act.ActivatePaneDirection("Up") },
{ key = "RightArrow", mods = keymod, action = act.ActivatePaneDirection("Right") },
{ key = "^", mods = keymod, action = act.ActivateLastTab },
{ key = "h", mods = keymod, action = act.ActivatePaneDirection("Left") },
{ key = "l", mods = keymod, action = act.ActivatePaneDirection("Right") },
{ key = "LeftArrow", mods = keymod, action = act.ActivatePaneDirection("Left") },
{ key = "DownArrow", mods = keymod, action = act.ActivatePaneDirection("Down") },
{ key = "UpArrow", mods = keymod, action = act.ActivatePaneDirection("Up") },
{ key = "RightArrow", mods = keymod, action = act.ActivatePaneDirection("Right") },
{ key = "^", mods = keymod, action = act.ActivateLastTab },
-- More pane-related niceties.
{ key = "f", mods = "LEADER", action = act.TogglePaneZoomState },
{ key = "f", mods = keymod, action = act.TogglePaneZoomState },
{ key = "n", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "n", mods = keymod, action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "n", mods = alt_keymod, action = act.SplitVertical({ domain = "CurrentPaneDomain" }) },
{ key = "d", mods = keymod, action = act.CloseCurrentPane({ confirm = false }) },
{ key = "f", mods = "LEADER", action = act.TogglePaneZoomState },
{ key = "f", mods = keymod, action = act.TogglePaneZoomState },
{ key = "n", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "n", mods = keymod, action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "n", mods = alt_keymod, action = act.SplitVertical({ domain = "CurrentPaneDomain" }) },
{ key = "d", mods = keymod, action = act.CloseCurrentPane({ confirm = false }) },
-- Tab navigation
{
@ -109,12 +106,12 @@ function module.apply_to_config(config)
one_shot = true,
}),
},
{ mods = alt_keymod, key = "h", action = act.ActivateTabRelative(-1) },
{ mods = alt_keymod, key = "j", action = act.ActivateTab(-1) },
{ mods = alt_keymod, key = "k", action = act.ActivateTab(0) },
{ mods = alt_keymod, key = "l", action = act.ActivateTabRelative(1) },
{ key = "t", mods = alt_keymod, action = act.ShowTabNavigator },
{ key = "d", mods = alt_keymod, action = act.CloseCurrentTab({ confirm = false }) },
{ mods = alt_keymod, key = "h", action = act.ActivateTabRelative(-1) },
{ mods = alt_keymod, key = "j", action = act.ActivateTab(-1) },
{ mods = alt_keymod, key = "k", action = act.ActivateTab(0) },
{ mods = alt_keymod, key = "l", action = act.ActivateTabRelative(1) },
{ key = "t", mods = alt_keymod, action = act.ShowTabNavigator },
{ key = "d", mods = alt_keymod, action = act.CloseCurrentTab({ confirm = false }) },
-- Hints and quick selections
{
@ -128,32 +125,32 @@ function module.apply_to_config(config)
}),
},
{ key = "h", mods = "ALT", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "j", mods = "ALT", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "k", mods = "ALT", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "l", mods = "ALT", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "h", mods = "ALT", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "j", mods = "ALT", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "k", mods = "ALT", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "l", mods = "ALT", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "r", mods = keymod, action = act.ReloadConfiguration },
{ key = "o", mods = keymod, action = act.ShowDebugOverlay },
{ key = "p", mods = keymod, action = act.ActivateCommandPalette },
{ key = "y", mods = keymod, action = act.ActivateCopyMode },
{ key = "e", mods = keymod, action = act.EmitEvent("view-last-output-in-new-pane") },
{ key = "r", mods = keymod, action = act.ReloadConfiguration },
{ key = "o", mods = keymod, action = act.ShowDebugOverlay },
{ key = "p", mods = keymod, action = act.ActivateCommandPalette },
{ key = "y", mods = keymod, action = act.ActivateCopyMode },
{ key = "e", mods = keymod, action = act.EmitEvent("view-last-output-in-new-pane") },
-- Selection
{ key = "Space", mods = "LEADER", action = act.QuickSelect },
{ key = "a", mods = keymod, action = act.QuickSelect },
{ key = "s", mods = keymod, action = act.Search({ CaseSensitiveString = "" }) },
{ key = "a", mods = keymod, action = act.QuickSelect },
{ key = "s", mods = keymod, action = act.Search({ CaseSensitiveString = "" }) },
}
config.key_tables = {
hints = {
{ key = "g", action = act.Search({ Regex = "[0-9a-f]{6,}" }) },
{ key = "g", action = act.Search({ Regex = "[0-9a-f]{6,}" }) },
{
key = "h",
action = act.QuickSelectArgs({
patterns = {
"[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git.
"[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging.
"[0-9a-f]{7,40}", -- SHA1 hashes, usually used for Git.
"[0-9a-f]{7,64}", -- SHA256 hashes, used often for getting hashes for Guix packaging.
"sha256-[[:alpha:][:digit:]-=+/?]{44}", -- SHA256 hashes in Base64, used often in getting hashes for Nix packaging.
"[[:alpha:][:digit:]-=+/?]{44,64}",
},
@ -181,8 +178,8 @@ function module.apply_to_config(config)
},
{ key = "Space", action = act.QuickSelect },
{ key = "s", action = act.QuickSelect },
{ key = "f", action = act.Search({ CaseSensitiveString = "" }) },
{ key = "s", action = act.QuickSelect },
{ key = "f", action = act.Search({ CaseSensitiveString = "" }) },
},
pane_navigation = {
@ -204,13 +201,13 @@ function module.apply_to_config(config)
},
resize_pane = {
{ key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "q", action = act.PopKeyTable },
{ key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "q", action = act.PopKeyTable },
{ key = "Escape", action = act.PopKeyTable },
{ key = "Enter", action = act.PopKeyTable },
{ key = "Enter", action = act.PopKeyTable },
},
copy_mode = copy_mode,

View File

@ -1,7 +1,6 @@
local config = require("wezterm").config_builder()
config:set_strict_mode(true)
require("config/events").apply_to_config(config)
require("config/base").apply_to_config(config)
require("config/keys").apply_to_config(config)