-- The third-party plugins, set up. Each is a package the installer placed at a pinned commit -- (ide/plugins.lock); a missing one is named as a problem and the rest still work. local M = {} local function mini(name, opts) local ide = require("llembas_ide") ide.try("mini." .. name, function() require("mini." .. name).setup(opts or {}) end) end function M.setup() -- Icons as plain letters: a terminal's font is not ours to assume. With a Nerd Font, put -- require("mini.icons").setup({ style = "glyph" }) in lua/user/init.lua. mini("icons", { style = "ascii" }) mini("files", { content = { prefix = function() end }, -- no icon column windows = { preview = true, width_preview = 60 }, options = { use_as_default_explorer = true }, }) mini("pick", { window = { prompt_prefix = "› " } }) require("llembas_ide").try("mini.pick as vim.ui.select", function() vim.ui.select = require("mini.pick").ui_select end) mini("extra") mini("surround") mini("pairs") mini("bufremove") mini("git") mini("diff", { view = { style = "sign", signs = { add = "▎", change = "▎", delete = "▁" } }, -- ]h and [h, ga and gr are the LLeMbas plugin's (its proposed changes): git hunks move on g. mappings = { apply = "", reset = "", textobject = "ih", goto_first = "[G", goto_prev = "[g", goto_next = "]g", goto_last = "]G", }, }) local keys = require("llembas_ide.keys") local ok, clue = pcall(require, "mini.clue") if ok then local clues = { clue.gen_clues.g(), clue.gen_clues.z(), clue.gen_clues.windows(), clue.gen_clues.registers(), clue.gen_clues.marks(), clue.gen_clues.builtin_completion(), } for _, g in ipairs(keys.groups) do table.insert(clues, { mode = "n", keys = g[1], desc = "+" .. g[2] }) table.insert(clues, { mode = "x", keys = g[1], desc = "+" .. g[2] }) end mini("clue", { triggers = { { mode = "n", keys = "" }, { mode = "x", keys = "" }, { mode = "n", keys = "g" }, { mode = "x", keys = "g" }, { mode = "n", keys = "z" }, { mode = "x", keys = "z" }, { mode = "n", keys = "" }, { mode = "n", keys = '"' }, { mode = "x", keys = '"' }, { mode = "n", keys = "'" }, { mode = "n", keys = "`" }, { mode = "n", keys = "[" }, { mode = "n", keys = "]" }, { mode = "i", keys = "" }, }, clues = clues, window = { delay = 300, config = { width = "auto", border = "rounded" } }, }) else table.insert(require("llembas_ide").problems, "mini.clue: not installed") end require("llembas_ide").try("conform", function() -- Formatting happens when asked for (cf, :LLeMbasIdeFormat), never on save. -- A formatter listed here is used when it is installed; otherwise the language server formats. require("conform").setup({ formatters_by_ft = { lua = { "stylua" }, python = { "ruff_format", "black", stop_after_first = true }, javascript = { "prettierd", "prettier", stop_after_first = true }, typescript = { "prettierd", "prettier", stop_after_first = true }, javascriptreact = { "prettierd", "prettier", stop_after_first = true }, typescriptreact = { "prettierd", "prettier", stop_after_first = true }, json = { "prettierd", "prettier", stop_after_first = true }, yaml = { "prettierd", "prettier", stop_after_first = true }, markdown = { "prettierd", "prettier", stop_after_first = true }, html = { "prettierd", "prettier", stop_after_first = true }, css = { "prettierd", "prettier", stop_after_first = true }, sh = { "shfmt" }, bash = { "shfmt" }, go = { "gofmt" }, rust = { "rustfmt" }, c = { "clang-format" }, cpp = { "clang-format" }, }, default_format_opts = { lsp_format = "fallback" }, notify_no_formatters = true, }) end) end --- Format the buffer, or the selected lines. function M.format() local ok, conform = pcall(require, "conform") if ok then conform.format({ async = true, lsp_format = "fallback" }, function(err, did) if err then vim.notify("Format: " .. tostring(err), vim.log.levels.WARN) elseif did == false then vim.notify("Format: nothing to change") end end) else vim.lsp.buf.format({ async = true }) end end return M