diff --git a/020_neovim-lazyvim_plugins.sh b/020_neovim-lazyvim_plugins.sh index fc9d445..57951fa 100644 --- a/020_neovim-lazyvim_plugins.sh +++ b/020_neovim-lazyvim_plugins.sh @@ -2,8 +2,11 @@ DEST=${1:-/etc/skel} LAZY_DEST=${DEST}/.config/nvim/lua/plugins +LAZY_UTILS_DEST=${DEST}/.config/nvim/lua/utils LAZY_SYNTAX=${DEST}/.config/nvim/after/queries +mkdir -p "$LAZY_DEST" "$LAZY_UTILS_DEST" + # Yazi tui filemanager # For extra configuration options see: # https://github.com/mikavilpas/yazi.nvim @@ -172,54 +175,66 @@ mkdir -p "${LAZY_SYNTAX}/html" mkdir -p "${LAZY_SYNTAX}/yaml" conf_print_toml_injections() { - cat <uf", function() +# local is_disabled = vim.g.disable_autoformat or vim.b.disable_autoformat +# if is_disabled then +# -- Re-enable logic (global + buffer) +# vim.b.disable_autoformat = false +# vim.g.disable_autoformat = false +# vim.notify("Autoformat enabled", vim.log.levels.INFO) +# else +# vim.b.disable_autoformat = true +# vim.notify("Autoformat disabled for buffer", vim.log.levels.WARN) +# end +# end, { desc = "Toggle autoformat" }) +# +# return { +# "stevearc/conform.nvim", +# opts = function(_, opts) +# -- Merge formatters (preserves LazyVim defaults) +# opts.formatters_by_ft = vim.tbl_extend("force", opts.formatters_by_ft or {}, { +# sh = { "shfmt" }, +# go = { "goimports", "gofumpt" }, +# }) +# +# -- shfmt with your exact flags (heredoc-friendly) +# opts.formatters = vim.tbl_extend("force", opts.formatters or {}, { +# shfmt = { +# prepend_args = { "-ln", "bash", "-i", "0", "-ci", "-sr", "-bn", "-kp" }, +# }, +# }) +# +# -- Format-on-save with guard clause (global/buffer priority) +# opts.format_on_save = function(bufnr) +# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then +# return +# end +# return { +# timeout_ms = 500, +# lsp_format = "fallback", +# } +# end +# end, +# } +# EOF +# } +# conf_print_conform_conform | tee "${PLUGINS_HOME}/conform.lua" + +# conf_print_conform_keymaps() { +# cat << 'EOF' +# conf_print_conform_keymaps() { +# cat << 'EOF' +# return { +# "stevearc/conform.nvim", +# keys = { +# { +# "fs", +# function() +# require("conform").format({ async = false, lsp_fallback = true, timeout_ms = 500 }) +# end, +# mode = { "n", "v" }, +# desc = "Format selection or buffer", +# }, +# { +# "tf", +# function() +# if vim.g.disable_autoformat or vim.b.disable_autoformat then +# vim.b.disable_autoformat = false +# vim.g.disable_autoformat = false +# print("Autoformat enabled") +# else +# vim.g.disable_autoformat = true +# print("Autoformat disabled") +# end +# end, +# mode = "n", +# desc = "Toggle Autoformat on Save", +# }, +# }, +# } +# EOF +# } +# conf_print_conform_keymaps | tee "${LAZY_DEST}/conform-keymaps.lua" + +conf_print_conform_lualine() { + cat <<-'EOF' + return { + "nvim-lualine/lualine.nvim", + opts = function(_, opts) + table.insert(opts.sections.lualine_x, { + function() + if vim.g.disable_autoformat or vim.b.disable_autoformat then + return "󰉐 OFF" + end + return nil + end, + color = { fg = "#ff9e64", gui = "bold" }, + }) + end, + } +EOF +} + +conf_print_conform_lualine | tee "${LAZY_DEST}/lualine.lua" + +# # A quick audit of the key systems tied to your formatting workflow and status UI. +# # Call with: +# # :lua require("utils.checklist").run() +# +# conf_print_conform_checklist() { +# cat << EOF +# -- ~/.config/nvim/lua/utils/checklist.lua +# -- Neovim Configuration Health Check (Formatting & UI Systems) +# +# local M = {} +# +# local status = { +# header = "🧭 Neovim Config Checklist", +# items = {}, +# } +# +# -- Utility function +# local function add_result(name, ok, detail) +# table.insert(status.items, { +# name = name, +# ok = ok, +# detail = detail or "", +# }) +# end +# +# local function check_plugin(name) +# local ok, plugin = pcall(require, name) +# add_result(name, ok, ok and "Loaded ✅" or "Missing ❌") +# return ok, plugin +# end +# +# function M.run() +# status.items = {} +# +# -- Basic checks +# add_result("Neovim version", vim.fn.has("nvim-0.9") == 1, vim.version().string) +# +# -- Plugin checks +# local c_ok = check_plugin("conform") +# local l_ok = check_plugin("lualine") +# local w_ok = check_plugin("which-key") +# +# -- Conform.nvim sanity +# if c_ok then +# local conform = require("conform") +# add_result( +# "Conform config", +# type(conform.formatters_by_ft) == "table", +# "Formatter map loaded: " .. tostring(conform.formatters_by_ft and "yes" or "no") +# ) +# end +# +# -- Autoformat toggles +# local global_toggle = vim.g.disable_autoformat +# local buf_toggle = vim.b.disable_autoformat +# add_result("Global autoformat state", global_toggle ~= true, tostring(global_toggle or false)) +# add_result("Buffer autoformat state", buf_toggle ~= true, tostring(buf_toggle or false)) +# +# -- Keymap validation +# local keymaps = vim.api.nvim_get_keymap("n") +# local uf_found = false +# for _, km in ipairs(keymaps) do +# if km.lhs == "uf" then +# uf_found = true +# add_result("uf Keymap", true, km.rhs) +# break +# end +# end +# if not uf_found then +# add_result("uf Keymap", false, "Not found ❌") +# end +# +# -- Lualine check +# if l_ok then +# local lualine_ok = pcall(require("lualine").setup) +# add_result("Lualine setup callable", lualine_ok, lualine_ok and "OK" or "Fail to load") +# end +# +# -- Which-key registry +# if w_ok then +# local wk = require("which-key") +# local has_wk = wk.register ~= nil +# +# -- Print results +# vim.notify(status.header, vim.log.levels.INFO, { title = "Checklist" }) +# for _, item in ipairs(status.items) do +# local level = item.ok and vim.log.levels.INFO or vim.log.levels.WARN +# local icon = item.ok and "✅" or "❌" +# vim.notify(string.format("%s %s — %s", icon, item.name, item.detail), level, { title = "Checklist" }) +# end +# end +# +# return M +# EOF +# } +# conf_print_conform_checklist | tee "${LAZY_UTILS_DEST}/checklist.lua"