feat: Remove lazyvim/lazy libs

This commit is contained in:
punkfairie 2024-12-08 16:47:13 -08:00
parent f1ba3cfeb6
commit 8593d10d4f
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
6 changed files with 11 additions and 96 deletions

View file

@ -19,6 +19,15 @@ function M.local_require(prefix)
end
end
---Get and format the foreground of a highlight group.
---@param name string The highlight group name to fetch from.
---@return {fg:string}?
function M.fg(name)
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
return hl and { fg = string.format('#%06x', hl.fg) } or nil
end
---Generates a function that can be used to create which-key mappings.
---@param color string The color to use for the icon.
---@return function

View file

@ -1,23 +0,0 @@
-- https://github.com/folke/lazy.nvim/blob/main/lua/lazy/core/util.lua
---@class lib.lazy.util
local M = {}
---@return string
function M.norm(path)
if path:sub(1, 1) == '~' then
local home = vim.uv.os_homedir() or ''
if home:sub(-1) == '\\' or home:sub(-1) == '/' then
home = home:sub(1, -2)
end
path = home .. path:sub(2)
end
path = path:gsub('\\', '/'):gsub('/+', '/')
return path:sub(-1) == '/' and path:sub(1, -2) or path
end
return M

View file

@ -1,53 +0,0 @@
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/format.lua
---@class lib.lazyvim.format
local M = {}
---@param buf? number The buffer to enable for
function M.enabled(buf)
buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf
local gaf = vim.g.autoformat
local baf = vim.b[buf].autoformat
-- If the buffer has a local value, use that.
if baf ~= nil then
return baf
end
-- Otherwise use the global value if set, or true by default.
return gaf == nil or gaf
end
---@param enable? boolean Whether to enable or disable
---@param buf? boolean Whether to enable for current buffer only
function M.enable(enable, buf)
if enable == nil then
enable = true
end
if buf then
vim.b.autoformat = enable
else
vim.g.autoformat = enable
vim.b.autoformat = nil
end
end
---@param buf? boolean Whether to toggle for current buffer only
function M.snacks_toggle(buf)
return Snacks.toggle({
name = 'auto format (' .. (buf and 'buffer' or 'global') .. ')',
get = function()
if not buf then
return vim.g.autoformat == nil or vim.g.autoformat
end
return M.enabled()
end,
set = function(state)
M.enable(state, buf)
end,
})
end
return M

View file

@ -1,13 +0,0 @@
--https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/ui.lua
---@class lib.lazyvim.ui
local M = {}
---@return {fg?:string}?
function M.fg(name)
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
local fg = hl and hl.fg or nil
return fg and { fg = string.format('#%06x', fg) } or nil
end
return M

View file

@ -20,7 +20,6 @@ return {
end
end,
after = function()
local lazyvim_ui = require('lib.lazyvim.ui')
local icons = require('icons')
vim.o.laststatus = vim.g.lualine_laststatus
@ -84,7 +83,7 @@ return {
.has()
end,
color = function()
return lazyvim_ui.fg('Statement')
return MarleyVim.fg('Statement')
end,
},
@ -96,7 +95,7 @@ return {
return package.loaded['dap'] and require('dap').status ~= ''
end,
color = function()
return lazyvim_ui.fg('debug')
return MarleyVim.fg('debug')
end,
},

View file

@ -1,6 +1,5 @@
-- Snacks needs to be loaded very early, so it gets its own special file.
local set = vim.keymap.set
local lazyvim_format = require('lib.lazyvim.format')
require('snacks').setup({
bigfile = { enabled = true },
@ -41,9 +40,6 @@ end, { desc = 'delete other buffers' })
local toggle = Snacks.toggle
lazyvim_format.snacks_toggle():map('<LEADER>uf')
lazyvim_format.snacks_toggle(true):map('<LEADER>uF') -- current buffer only
toggle.option('spell', { name = 'spelling' }):map('<LEADER>us')
toggle.option('wrap', { name = 'wrap' }):map('<LEADER>uw')