From 5e8f90a6bd6df4b5aa55674a010d600a37072432 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 29 Jan 2025 12:53:43 +0800 Subject: [PATCH] chore: reformat codebase --- nvim/lua/lush_theme/fds-theme.lua | 6 +- nvim/lua/plugins/fuzzy-finder.lua | 44 ++++++++++-- nvim/lua/plugins/note-taking.lua | 2 +- nvim/lua/plugins/qol.lua | 38 ++++++++-- nvim/lua/plugins/toolings.lua | 3 +- nvim/lua/plugins/tree-sitter.lua | 16 ++--- wezterm/config/appearance.lua | 8 +-- wezterm/config/base.lua | 7 +- wezterm/config/events.lua | 2 +- wezterm/config/keys.lua | 111 +++++++++++++++--------------- wezterm/wezterm.lua | 1 - 11 files changed, 144 insertions(+), 94 deletions(-) diff --git a/nvim/lua/lush_theme/fds-theme.lua b/nvim/lua/lush_theme/fds-theme.lua index 67c21f5..bcbc593 100644 --- a/nvim/lua/lush_theme/fds-theme.lua +++ b/nvim/lua/lush_theme/fds-theme.lua @@ -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 }), diff --git a/nvim/lua/plugins/fuzzy-finder.lua b/nvim/lua/plugins/fuzzy-finder.lua index e0b612a..05728cf 100644 --- a/nvim/lua/plugins/fuzzy-finder.lua +++ b/nvim/lua/plugins/fuzzy-finder.lua @@ -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", "fg", get_builtin("grep_string"), { noremap = true, desc = "Grep for string in cursor" }) - vim.keymap.set("n", "fG", get_builtin("live_grep"), { noremap = true, desc = "Grep for string in project" }) - vim.keymap.set("n", "fb", get_builtin("buffers"), { noremap = true, desc = "Search currently opened buffers" }) + vim.keymap.set( + "n", + "fg", + get_builtin("grep_string"), + { noremap = true, desc = "Grep for string in cursor" } + ) + vim.keymap.set( + "n", + "fG", + get_builtin("live_grep"), + { noremap = true, desc = "Grep for string in project" } + ) + vim.keymap.set( + "n", + "fb", + get_builtin("buffers"), + { noremap = true, desc = "Search currently opened buffers" } + ) vim.keymap.set("n", "fh", get_builtin("help_tags"), { noremap = true, desc = "Search help pages" }) - vim.keymap.set("n", "ft", get_builtin("treesitter"), { noremap = true, desc = "Search treesitter objects" }) + vim.keymap.set( + "n", + "ft", + get_builtin("treesitter"), + { noremap = true, desc = "Search treesitter objects" } + ) vim.keymap.set("n", "fM", get_builtin("man_pages"), { noremap = true, desc = "Search manpages" }) - vim.keymap.set("n", "fS", get_builtin("spell_suggest"), { noremap = true, desc = "Pick spell suggestions" }) + vim.keymap.set( + "n", + "fS", + get_builtin("spell_suggest"), + { noremap = true, desc = "Pick spell suggestions" } + ) vim.keymap.set("n", "fA", get_builtin("resume"), { noremap = true, desc = "Return last search" }) @@ -69,7 +94,12 @@ return { { "ThePrimeagen/harpoon", config = function() - vim.keymap.set("n", "fm", "lua require('harpoon.mark').add_file()", { desc = "Add mark to file" }) + vim.keymap.set( + "n", + "fm", + "lua require('harpoon.mark').add_file()", + { desc = "Add mark to file" } + ) local has_telescope, telescope = pcall("telescope") if has_telescope then diff --git a/nvim/lua/plugins/note-taking.lua b/nvim/lua/plugins/note-taking.lua index 2e89540..4b9d04a 100644 --- a/nvim/lua/plugins/note-taking.lua +++ b/nvim/lua/plugins/note-taking.lua @@ -35,5 +35,5 @@ return { }, }, }, - } + }, } diff --git a/nvim/lua/plugins/qol.lua b/nvim/lua/plugins/qol.lua index bf8fc18..b5f6084 100644 --- a/nvim/lua/plugins/qol.lua +++ b/nvim/lua/plugins/qol.lua @@ -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 = { - { "gb", function() Snacks.git.blame_line() end, desc = "Open blame lines for current file" }, - { "gg", function() Snacks.lazygit() end, desc = "Open lazygit" }, - { "gf", function() Snacks.lazygit.log_file() end, desc = "Open current file history in lazygit" }, + { + "gb", + function() + Snacks.git.blame_line() + end, + desc = "Open blame lines for current file", + }, + { + "gg", + function() + Snacks.lazygit() + end, + desc = "Open lazygit", + }, + { + "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("uL") Snacks.toggle.diagnostics():map("ud") Snacks.toggle.line_number():map("ul") - Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("uc") + Snacks.toggle + .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) + :map("uc") Snacks.toggle.treesitter():map("uT") Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark style" }):map("ub") Snacks.toggle.inlay_hints():map("uh") @@ -86,7 +106,13 @@ return { keys = { { "-", "Oil", { desc = "Open parent directory in file explorer" } }, - { "", function () require("oil").open(vim.fn.getcwd()) end, { desc = "Open current working directory in file explorer" } }, + { + "", + function() + require("oil").open(vim.fn.getcwd()) + end, + { desc = "Open current working directory in file explorer" }, + }, }, }, } diff --git a/nvim/lua/plugins/toolings.lua b/nvim/lua/plugins/toolings.lua index 97aeadd..a564707 100644 --- a/nvim/lua/plugins/toolings.lua +++ b/nvim/lua/plugins/toolings.lua @@ -1,2 +1 @@ -return { -} +return {} diff --git a/nvim/lua/plugins/tree-sitter.lua b/nvim/lua/plugins/tree-sitter.lua index 47da250..dc44880 100644 --- a/nvim/lua/plugins/tree-sitter.lua +++ b/nvim/lua/plugins/tree-sitter.lua @@ -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 = "", - goto_previous_usage = "", - list_definitions = "gnD", - list_definitions_toc = "gO", - }, + enable = true, + keymaps = { + goto_definition = "gnd", + goto_next_usage = "", + goto_previous_usage = "", + list_definitions = "gnD", + list_definitions_toc = "gO", + }, }, smart_rename = { enable = true, keymaps = { smart_rename = "grr" } }, textobjects = { diff --git a/wezterm/config/appearance.lua b/wezterm/config/appearance.lua index 26e8831..a3a30b8 100644 --- a/wezterm/config/appearance.lua +++ b/wezterm/config/appearance.lua @@ -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, } diff --git a/wezterm/config/base.lua b/wezterm/config/base.lua index 917195c..7d88338 100644 --- a/wezterm/config/base.lua +++ b/wezterm/config/base.lua @@ -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" diff --git a/wezterm/config/events.lua b/wezterm/config/events.lua index c28bf74..9b75cdf 100644 --- a/wezterm/config/events.lua +++ b/wezterm/config/events.lua @@ -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) diff --git a/wezterm/config/keys.lua b/wezterm/config/keys.lua index 9c7c067..71e0ec6 100644 --- a/wezterm/config/keys.lua +++ b/wezterm/config/keys.lua @@ -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, diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index 19ac06e..8e3d9a2 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -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)