update nvim

This commit is contained in:
zack 2024-11-14 23:40:28 -05:00
parent 9aa6f3fdbe
commit 5eec7f512f
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
6 changed files with 170 additions and 4 deletions

View file

@ -39,6 +39,7 @@ in {
enable = true;
defaultEditor = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
extraLuaPackages = ps: [ps.magick];
extraPackages = with pkgs; [
# Formatters
alejandra # Nix
@ -49,6 +50,8 @@ in {
stylua
rustywind
imagemagick
# LSP
lua-language-server
nixd
@ -136,6 +139,89 @@ in {
vim.opt.rtp:prepend(lazypath)
require('config.lazy')
local dashboardImage = vim.api.nvim_create_augroup("DashboardImage", { clear = true })
local img = require("image").from_file("${./NeoVim.png}")
local is_visible = false
-- Known image dimensions
local IMG_WIDTH = 50 -- characters
local IMG_HEIGHT = 14 -- lines
-- Debug notification function
local function debug_notify(message)
-- vim.notify(message, vim.log.levels.INFO)
end
-- Function to calculate centered position
local function center_image()
local win_width = vim.o.columns
local win_height = vim.o.lines
local x = math.floor((win_width - IMG_WIDTH) / 2)
local y = math.floor((win_height - IMG_HEIGHT) / 6)
return math.max(0, x), math.max(0, y)
end
-- Function to update image position
local function update_image()
debug_notify("Attempting to update image. is_visible = " .. tostring(is_visible))
if is_visible then
local x, y = center_image()
debug_notify("Positioning image at x=" .. x .. ", y=" .. y)
img:clear()
img:render()
img:move(x, y)
end
end
-- Show image on both VimEnter and when dashboard buffer is created
vim.api.nvim_create_autocmd({ "VimEnter", "BufWinEnter", "BufEnter" }, {
group = dashboardImage,
callback = function(ev)
local filetype = vim.api.nvim_buf_get_option(ev.buf, "filetype")
debug_notify("Event triggered: " .. ev.event .. ", filetype: " .. filetype)
if filetype == "dashboard" then
debug_notify("Dashboard detected, setting visible")
is_visible = true
vim.schedule(update_image)
end
end,
})
-- Handle window resize
vim.api.nvim_create_autocmd("VimResized", {
group = dashboardImage,
callback = function()
debug_notify("Window resized")
update_image()
end,
})
-- Clear image when leaving dashboard
vim.api.nvim_create_autocmd("BufLeave", {
group = dashboardImage,
callback = function()
debug_notify("Leaving buffer")
is_visible = false
img:clear()
end,
})
-- Catch when returning to dashboard
vim.api.nvim_create_autocmd("FileType", {
group = dashboardImage,
pattern = "dashboard",
callback = function()
debug_notify("FileType dashboard detected")
is_visible = true
vim.schedule(update_image)
end,
})
-- Initial debug message
debug_notify("Dashboard image setup loaded")
'';
};