diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua index 497b2455..e167999e 100755 --- a/.config/nvim/lua/core/options.lua +++ b/.config/nvim/lua/core/options.lua @@ -80,7 +80,7 @@ M.setup = function() opt.completeopt = 'menuone,noselect' -- Set max text width - opt.textwidth = 120 + opt.textwidth = 80 -- Highlight cursor line opt.cursorline = true diff --git a/.config/wezterm/config/fonts.lua b/.config/wezterm/config/fonts.lua index ce19854f..73223afa 100644 --- a/.config/wezterm/config/fonts.lua +++ b/.config/wezterm/config/fonts.lua @@ -1,4 +1,5 @@ local wezterm = require("wezterm") +local lib = require("wlib") return { -- use_cap_height_to_scale_fallback_fonts = true, @@ -23,5 +24,9 @@ return { -- , BuiltIn "Last Resort High-Efficiency", }), + font_dirs = { + lib.determine_home_path() .. "/.config/fonts", + }, + font_locator = "ConfigDirsOnly", font_size = 14, } diff --git a/.config/wezterm/config/keybinds.lua b/.config/wezterm/config/keybinds.lua index f6b5225b..4dbb8874 100644 --- a/.config/wezterm/config/keybinds.lua +++ b/.config/wezterm/config/keybinds.lua @@ -1,7 +1,7 @@ local wezterm = require("wezterm") return { - -- disable_default_key_bindings = true, + disable_default_key_bindings = true, leader = { key = "a", mods = "CTRL", timeout_milliseconds = 100000 }, keys = { { key = "r", mods = "SUPER", action = "ReloadConfiguration" }, diff --git a/.config/wezterm/lib.lua b/.config/wezterm/lib.lua deleted file mode 100644 index 586ff443..00000000 --- a/.config/wezterm/lib.lua +++ /dev/null @@ -1,15 +0,0 @@ -local mergeable_table = {} - -function mergeable_table.merge(...) - local ret = {} - for _, tbl in ipairs({ ... }) do - for k, v in pairs(tbl) do - ret[k] = v - end - end - return ret -end - -return { - mergeable_table = mergeable_table, -} diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index e26e267d..27fadc7b 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -1,4 +1,4 @@ -local mergeable_table = require("lib").mergeable_table +local Table = require("wlib").new_table() -- NOTE: Should be merged local events = require("config.events") @@ -9,5 +9,5 @@ local rendering = require("config.rendering") local keybinds = require("config.keybinds") local misc = require("config.misc") -local config = mergeable_table.merge(events, fonts, theme, tabbar, misc, rendering, keybinds) +local config = Table.merge(events, fonts, theme, tabbar, misc, rendering, keybinds) return config diff --git a/.config/wezterm/wlib.lua b/.config/wezterm/wlib.lua new file mode 100644 index 00000000..c7e44686 --- /dev/null +++ b/.config/wezterm/wlib.lua @@ -0,0 +1,89 @@ +local os = require("os") +local M = {} + +--- Creates a new custom table that allows +--- usage of lua's `table` attributes +--- +--- This is done really oddly such that we create a local table instance for +--- each invocation, but also get methods for each new table in a lua style +--- +---@return table +function M.new_table() + local t = {} + + --- Dump a table into a json-ish string format, + --- shamelessly taken from https://stackoverflow.com/a/27028488 + ---@param o table + local function dump(o) + if type(o) == "table" then + local s = "{\n" + for k, v in pairs(o) do + if type(k) ~= "number" then + k = '"' .. k .. '"' + end + s = s .. " [" .. k .. "] = " .. dump(v) .. ",\n" + end + return s .. "} " + else + return tostring(o) + end + end + + --- Simple wrapper around dump function + ---@return string + function t.dump() + return dump(t) + end + + --- Allows the combining of multiple tables, where the last table given has the highest + --- priority (it overrides the keys of other tables) + ---@vararg table + ---@return table + function t.merge(...) + local ret = {} + for _, tbl in ipairs({ ... }) do + for k, v in pairs(tbl) do + ret[k] = v + end + end + return ret + end + + return t +end + +--- Returns the path to the users home, note this string needs to be regularized as +--- this is used on both windows and unix. +--- @return string +function M.determine_home_path() + -- This helps give a better error message + -- if we are unable to find their home dir + -- from a environment variable + local checked_env_vars = M.new_table() + + -- Attempt to get UNIX home + local unix_home_var = "HOM" + local unix_home = os.getenv(unix_home_var) + table.insert(checked_env_vars, unix_home_var) + -- This style is chosen as a guard so it's easier + -- to extend in the future + if unix_home then + return unix_home + end + + -- Attempt to get Windows home + local win_home_drive = os.getenv("HOMEDRIVE") + local win_home = os.getenv("HOMEPATH") + if win_home then + return win_home_drive .. win_home + end + + -- NOTE: This will error if it cannot determine the home path + error( + "Unable to determine user's home directory, checked environment variables:\n\n" + .. checked_env_vars.dump() + .. "\n\n" + ) +end + +return M