diff --git a/nvim/lua/lib/init.lua b/nvim/lua/lib/init.lua index ec89d3b..a69fc53 100644 --- a/nvim/lua/lib/init.lua +++ b/nvim/lua/lib/init.lua @@ -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 diff --git a/nvim/lua/lib/lazy/util.lua b/nvim/lua/lib/lazy/util.lua deleted file mode 100644 index 4c95522..0000000 --- a/nvim/lua/lib/lazy/util.lua +++ /dev/null @@ -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 diff --git a/nvim/lua/lib/lazyvim/format.lua b/nvim/lua/lib/lazyvim/format.lua deleted file mode 100644 index cc447db..0000000 --- a/nvim/lua/lib/lazyvim/format.lua +++ /dev/null @@ -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 diff --git a/nvim/lua/lib/lazyvim/ui.lua b/nvim/lua/lib/lazyvim/ui.lua deleted file mode 100644 index cd79af6..0000000 --- a/nvim/lua/lib/lazyvim/ui.lua +++ /dev/null @@ -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 diff --git a/nvim/lua/plugins/ui/lualine-nvim.lua b/nvim/lua/plugins/ui/lualine-nvim.lua index 45bb338..243d4eb 100644 --- a/nvim/lua/plugins/ui/lualine-nvim.lua +++ b/nvim/lua/plugins/ui/lualine-nvim.lua @@ -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, }, diff --git a/nvim/lua/snacks-nvim.lua b/nvim/lua/snacks-nvim.lua index c738c90..ccd51e0 100644 --- a/nvim/lua/snacks-nvim.lua +++ b/nvim/lua/snacks-nvim.lua @@ -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('uf') -lazyvim_format.snacks_toggle(true):map('uF') -- current buffer only - toggle.option('spell', { name = 'spelling' }):map('us') toggle.option('wrap', { name = 'wrap' }):map('uw')