#!/usr/bin/env bash 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 # https://github.com/mikavilpas/yazi.nvim#%EF%B8%8F%EF%B8%8F-advanced-configuration conf_print_yazi() { cat <-", mode = { "n", "v" }, "Yazi", desc = "Open yazi at the current file", }, { -- Open in the current working directory "cw", "Yazi cwd", desc = "Open the file manager in nvim's working directory", }, { "", "Yazi toggle", desc = "Resume the last yazi session", }, }, ---@type YaziConfig | {} opts = { -- if you want to open yazi instead of netrw, see below for more info open_for_directories = false, keymaps = { show_help = "", }, }, -- 👇 if you use \$(open_for_directories=true), this is recommended init = function() -- mark netrw as loaded so it's not loaded at all. -- -- More details: https://github.com/mikavilpas/yazi.nvim/issues/802 vim.g.loaded_netrwPlugin = 1 end, } } EOF } conf_print_yazi | tee "${LAZY_DEST}/yazi.lua" conf_print_time-machine() { cat <t", "", desc = "Time Machine", }, { "tt", "TimeMachineToggle", desc = "[Time Machine] Toggle Tree", }, { "tx", "TimeMachinePurgeCurrent", desc = "[Time Machine] Purge current", }, { "tX", "TimeMachinePurgeAll", desc = "[Time Machine] Purge all", }, { "tl", "TimeMachineLogShow", desc = "[Time Machine] Show log", }, }, } EOF } conf_print_time-machine | tee "${LAZY_DEST}/time-machine.lua" # Use triple backtick for code blocks rather than tab # set code-block-style: or MD046: om ~/.markdownlint-cli2.yaml conf_print_markdownlint_yaml() { cat <= 0.12, you can use the multi node pattern instead of ; combining injections: ; ; ((comment)+ @injection.content ; (#lua-match? @injection.content "^#USAGE ") ; (#offset! @injection.content 0 7 0 1) ; (#set! injection.language "kdl")) ; ; this is the preferred way as combined injections have multiple ; limitations: ; https://github.com/neovim/neovim/issues/32635 EOF } conf_print_bash_injections | tee "${LAZY_SYNTAX}/bash/injections.scm" conf_print_bash_injections | tee "${LAZY_SYNTAX}/python/injections.scm" conf_print_go_injections() { cat < -- ──────────────────────────────────────────────── -- Default (what you get with just kitty_scrollback_nvim) default = {}, -- Opens scrollback and immediately starts backward search (?) search = { callbacks = { after_ready = function() vim.api.nvim_feedkeys('?', 'n', false) end, }, }, -- Only shows the last command output (very clean for quick checks) last_cmd = { kitty_get_text = { extent = 'last_non_empty_output', -- or 'output' / 'screen' }, status_window = { enabled = false, -- cleaner without status if only last cmd }, }, }) end, } EOF } conf_print_kitty_scrollback | tee "${LAZY_DEST}/kitty-scrollback.lua" conf_print_diagram() { cat <<'EOF' return { "3rd/diagram.nvim", dependencies = { { "3rd/image.nvim", opts = {} }, -- you'd probably want to configure image.nvim manually instead of doing this }, opts = { -- you can just pass {}, defaults below events = { render_buffer = { "InsertLeave", "BufWinEnter", "TextChanged" }, clear_buffer = {"BufLeave"}, }, renderer_options = { mermaid = { background = nil, -- nil | "transparent" | "white" | "#hex" theme = nil, -- nil | "default" | "dark" | "forest" | "neutral" scale = 1, -- nil | 1 (default) | 2 | 3 | ... width = nil, -- nil | 800 | 400 | ... height = nil, -- nil | 600 | 300 | ... cli_args = nil, -- nil | { "--no-sandbox" } | { "-p", "/path/to/puppeteer" } | ... }, plantuml = { charset = nil, cli_args = nil, -- nil | { "-Djava.awt.headless=true" } | ... }, d2 = { theme_id = nil, dark_theme_id = nil, scale = nil, layout = nil, sketch = nil, cli_args = nil, -- nil | { "--pad", "0" } | ... }, gnuplot = { size = nil, -- nil | "800,600" | ... font = nil, -- nil | "Arial,12" | ... theme = nil, -- nil | "light" | "dark" | custom theme string cli_args = nil, -- nil | { "-p" } | { "-c", "config.plt" } | ... }, }, } } EOF } conf_print_diagram | tee "${LAZY_DEST}/diagram.lua" # frizbee fuzzy finder replaces telescope (native lua) with rust library # relying on SIMD which older hardware doesn't have, very clever if you do. conf_print_fzf_lua_no_frizbee() { cat <<'EOF' return { { "ibhagwan/fzf-lua", opts = function(_, opts) -- Force the standard fzf algorithm (much lighter on CPU) opts.fzf_opts = opts.fzf_opts or {} opts.fzf_opts["--algo"] = "v1" -- 'v1' is the original, fast algorithm -- Optional: Disable the scrollbar if you're on a very old fzf version -- as it has been known to cause crashes on older binaries. -- opts.fzf_opts["--no-scrollbar"] = true end, }, } EOF } conf_print_fzf_lua_no_frizbee | tee "${LAZY_DEST}/fzf_lua_no_frizbee.lua" conf_print_blink_no_frizbee() { cat <<'EOF' return { { "saghen/blink.cmp", opts = { fuzzy = { -- 'frizbee' is the new default; 'fuzzy' is the old reliable implementation = "lua", }, }, }, } EOF } conf_print_blink_no_frizbee | tee "${LAZY_DEST}/blink_no_frizbee.lua" # ############################ # Hacking Below this Point # ############################ # # Conform.nvim formatters, append new formatters here. # Use the official bash formatter on sh files using conform.nvim # Understands heredocs <<-EOF tab indent/removal # gofumpt strict formatter for go # # conf_print_conform_formatters() { # cat << 'EOF' # return { # "stevearc/conform.nvim", # opts = { # formatters_by_ft = { # sh = { "shfmt" }, bash = { "shfmt" }, zsh = { "shfmt" }, # go = { "goimports", "gofumpt" }, # }, # formatters = { # shfmt = { # prepend_args = { "-ln", "bash", "-i", "0", "-ci", "-sr", "-bn", "-kp" }, # }, # }, # -- these are top-level opts # format = { # async = false, -- synchronous for visual selection # timeout_ms = 500, # lsp_format = "fallback", # }, # log_level = vim.log.levels.debug, # 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, # }, # } # EOF # } # conf_print_conform_formatters | tee "${LAZY_DEST}/conform-formatters.lua" # # conf_print_conform_conform() { # cat <<- 'EOF' # vim.keymap.set("n", "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"