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

@ -26,7 +26,7 @@ return {
{ "~/library/writings" }, { "~/library/writings" },
}, },
}, },
fzf = { }, fzf = {},
}, },
}) })
@ -51,13 +51,38 @@ return {
}) })
end, { noremap = true, desc = "Find files in current directory" }) 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(
vim.keymap.set("n", "<leader>fG", get_builtin("live_grep"), { noremap = true, desc = "Grep for string in project" }) "n",
vim.keymap.set("n", "<leader>fb", get_builtin("buffers"), { noremap = true, desc = "Search currently opened buffers" }) "<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>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>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" }) vim.keymap.set("n", "<leader>fA", get_builtin("resume"), { noremap = true, desc = "Return last search" })
@ -69,7 +94,12 @@ return {
{ {
"ThePrimeagen/harpoon", "ThePrimeagen/harpoon",
config = function() 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") local has_telescope, telescope = pcall("telescope")
if has_telescope then if has_telescope then

View File

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

View File

@ -20,7 +20,7 @@ return {
}, },
input = { enabled = true }, input = { enabled = true },
notifier = { enabled = true }, notifier = { enabled = true },
git = { enabled = true, }, git = { enabled = true },
lazygit = { lazygit = {
enabled = vim.fn.executable("lazygit") == 1, enabled = vim.fn.executable("lazygit") == 1,
}, },
@ -35,9 +35,27 @@ return {
words = { enabled = true }, words = { enabled = true },
}, },
keys = { 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>gb",
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Open current file history in lazygit" }, 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() init = function()
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
@ -58,7 +76,9 @@ return {
Snacks.toggle.option("relativenumber", { name = "Relative number" }):map("<leader>uL") Snacks.toggle.option("relativenumber", { name = "Relative number" }):map("<leader>uL")
Snacks.toggle.diagnostics():map("<leader>ud") Snacks.toggle.diagnostics():map("<leader>ud")
Snacks.toggle.line_number():map("<leader>ul") 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.treesitter():map("<leader>uT")
Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark style" }):map("<leader>ub") Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark style" }):map("<leader>ub")
Snacks.toggle.inlay_hints():map("<leader>uh") Snacks.toggle.inlay_hints():map("<leader>uh")
@ -86,7 +106,13 @@ return {
keys = { keys = {
{ "-", "<cmd>Oil<CR>", { desc = "Open parent directory in file explorer" } }, { "-", "<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

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

View File

@ -14,7 +14,7 @@ function module.apply_to_config(config)
config.check_for_updates = false config.check_for_updates = false
-- Enable some things for Wayland. -- 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.enable_wayland = true
config.front_end = "WebGpu" config.front_end = "WebGpu"
config.force_reverse_video_cursor = true config.force_reverse_video_cursor = true
@ -22,6 +22,7 @@ function module.apply_to_config(config)
-- Use some IME. -- Use some IME.
config.use_ime = true config.use_ime = true
config.xim_im_name = "ibus"
-- Set up the visual bell. -- Set up the visual bell.
config.audible_bell = "SystemBeep" config.audible_bell = "SystemBeep"

View File

@ -44,7 +44,7 @@ function module.apply_to_config(config)
end) end)
-- Maximize the terminal on startup. -- 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 {}) local tab, pane, window = wezterm.mux.spawn_window(cmd or {})
window:gui_window():maximize() window:gui_window():maximize()
end) end)

View File

@ -9,14 +9,11 @@ local module = {}
local copy_mode = nil local copy_mode = nil
if wezterm.gui then if wezterm.gui then
copy_mode = wezterm.gui.default_key_tables().copy_mode copy_mode = wezterm.gui.default_key_tables().copy_mode
table.insert( table.insert(copy_mode, {
copy_mode, key = "z",
{
key = 'z',
mods = keymod, mods = keymod,
action = act.CopyMode { MoveBackwardZoneOfType = 'Output' }, action = act.CopyMode({ MoveBackwardZoneOfType = "Output" }),
} })
)
end end
function module.apply_to_config(config) function module.apply_to_config(config)

View File

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