Refactor the entire configuration
With the release of the Nvidia 555 beta drivers and their improvements to the Wayland experience I've finally decided to return to NixOS with Hyprland again after 2 years of running Gentoo and Opensuse Tumbleweed on X11. So this is me committing the work done so far from the last couple of days. Future commits will be more incremental.
This commit is contained in:
parent
97c86fb014
commit
75b13ac379
72 changed files with 2045 additions and 196 deletions
59
users/hu/packages/nvim/config/lua/util/get_distro.lua
Normal file
59
users/hu/packages/nvim/config/lua/util/get_distro.lua
Normal file
|
@ -0,0 +1,59 @@
|
|||
local function distro_traits(name)
|
||||
local icons = {
|
||||
[ "unknown" ] = {
|
||||
icon = "",
|
||||
color = "#f3be25",
|
||||
},
|
||||
[ "debian" ] = {
|
||||
icon = "",
|
||||
color = "#d70a53",
|
||||
},
|
||||
[ "gentoo" ] = {
|
||||
icon = "",
|
||||
color = "#54487A",
|
||||
},
|
||||
[ "nixos" ] = {
|
||||
icon = "",
|
||||
color = "#5277C3",
|
||||
},
|
||||
[ "\"opensuse-tumbleweed\"" ] = {
|
||||
icon = "",
|
||||
color = "#73ba25",
|
||||
},
|
||||
}
|
||||
|
||||
local icon = icons[name]
|
||||
if icon == nil then
|
||||
icon = icons["unknown"]
|
||||
end
|
||||
|
||||
return icon
|
||||
end
|
||||
|
||||
return function()
|
||||
local release_file = io.open("/etc/os-release", "rb")
|
||||
if release_file == nil then
|
||||
return {
|
||||
name = "unknown",
|
||||
traits = distro_traits("unknown"),
|
||||
}
|
||||
end
|
||||
|
||||
local content = vim.split(release_file:read("*a"), "\n")
|
||||
local distro_id = nil
|
||||
for _, line in ipairs(content) do
|
||||
if string.sub(line, 0, 3) == "ID=" then
|
||||
distro_id = string.sub(line, 4, -1)
|
||||
goto distro_id_found
|
||||
end
|
||||
end
|
||||
::distro_id_found::
|
||||
|
||||
release_file:close()
|
||||
|
||||
return {
|
||||
name = distro_id,
|
||||
traits = distro_traits(distro_id)
|
||||
}
|
||||
end
|
||||
|
7
users/hu/packages/nvim/config/lua/util/hl.lua
Normal file
7
users/hu/packages/nvim/config/lua/util/hl.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
return function (name)
|
||||
local hl = vim.api.nvim_get_hl(0, { name = name })
|
||||
while hl.link ~= nil do
|
||||
hl = vim.api.nvim_get_hl(0, { name = hl.link })
|
||||
end
|
||||
return hl
|
||||
end
|
9
users/hu/packages/nvim/config/lua/util/map.lua
Normal file
9
users/hu/packages/nvim/config/lua/util/map.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
return function(mode, key, mapping, comment)
|
||||
local opts = {
|
||||
noremap = true,
|
||||
silent = true,
|
||||
desc = comment
|
||||
}
|
||||
vim.keymap.set(mode, key, mapping, opts)
|
||||
end
|
||||
|
27
users/hu/packages/nvim/config/lua/util/require_dir.lua
Normal file
27
users/hu/packages/nvim/config/lua/util/require_dir.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
return function(dir, skip_init)
|
||||
local returns = {}
|
||||
local lua_files = vim.split(vim.fn.glob(dir.."/*.lua"), "\n")
|
||||
local namespace = string.gsub(dir, vim.fn.stdpath("config").."/lua/", "")
|
||||
namespace = string.gsub(namespace, "%/", ".")
|
||||
|
||||
for _, file in ipairs(lua_files) do
|
||||
file = string.gsub(file, "%.lua", "")
|
||||
file = string.gsub(file, dir.."/", namespace)
|
||||
|
||||
if skip_init and file == namespace.."init" then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local require_ok, require_return = pcall(require, file)
|
||||
if require_ok then
|
||||
table.insert(returns, require_return)
|
||||
else
|
||||
vim.notify("Could not require file: '"..file.."': "..require_return, vim.log.levels.WARNING)
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
return returns
|
||||
end
|
||||
|
11
users/hu/packages/nvim/config/lua/util/rgb_to_hex.lua
Normal file
11
users/hu/packages/nvim/config/lua/util/rgb_to_hex.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
return function(rgb)
|
||||
if rgb == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local r = string.format("%02x", (rgb / 65536) % 256)
|
||||
local g = string.format("%02x", (rgb / 256) % 256)
|
||||
local b = string.format("%02x", rgb % 256)
|
||||
|
||||
return "#"..r..g..b
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue