- Remove locally-developed or rarely-used plugin packages (codetyper, curls, edgy, flash) to reduce maintenance surface, external deps, and startup cost; these were local/optional and caused complexity. - Clean up stale/keymap docs and small duplicate or experimental files (keymaps/README.md, sudoku keymaps). - Apply targeted refactors to core modules for readability, robustness, and to align Java/DAP/Copilot integrations with local environment. - Removed plugin modules: - lua/cargdev/plugins/codetyper.lua (deleted) - lua/cargdev/plugins/curls.lua (deleted) - lua/cargdev/plugins/edgy.lua (deleted) - lua/cargdev/plugins/flash.lua (deleted) - Added .codetyper to .gitignore - Java / JDTLS: - ftplugin/java.lua: pin jdtls java executable to JDK 25, switch to mac_arm config, enable LSP formatter and declare multiple runtimes (JavaSE-17, JavaSE-25). - Notifications & startup UX: - lua/cargdev/core/function/notification_manager.lua: large refactor — use local aliases (api, cmd, loop, opt), improved docs, dashboard-aware handling, nvim-notify fallback, safer tracking and cleanup of notifications. - Utilities & monitors: - lua/cargdev/core/function/performance_monitor.lua: use local references, better notify usage and docs. - lua/cargdev/core/function/project_commands.lua: add docs, use local api/fn/notify, clearer RunProject/DebugProject commands. - Terminal helper: - lua/cargdev/core/function/openTerminal.lua: add module docs and small refactor to use local cmd/api aliases and expose keymap. - Keymaps & docs: - Removed stale keymaps README (lua/cargdev/core/keymaps/README.md). - Reworked many keymap files: docstrings, renamed/moved mappings to avoid conflicts, moved DAP mappings into dap plugin config, removed/disabled experimental mappings (see files under lua/cargdev/core/keymaps/*). - Adjusted quick keybindings and prefixes to reduce overlaps. - Plugins & integrations: - lua/cargdev/plugins/formatting.lua: disabled google-java-format fallback for java (prefer JDTLS). - lua/cargdev/plugins/dap.lua: added additional DAP configs (Bun launch, attach helper), moved/registered dap keymaps here. - lua/cargdev/plugins/copilot.lua: reorganized Copilot/Copilot-cmp/CopilotChat config and added copilot source to nvim-cmp. - lua/cargdev/plugins/nvim-cmp.lua: added copilot source and small formatting tweak.
88 lines
3.0 KiB
Lua
88 lines
3.0 KiB
Lua
-- ============================================================================
|
|
-- CONFORM.NVIM: Code formatting on save and on demand
|
|
-- ============================================================================
|
|
-- Lightweight formatter plugin that supports multiple formatters per filetype.
|
|
-- Configured with format-on-save and custom formatters for SQL, XML, and more.
|
|
-- Provides <leader>mp keymap for manual formatting of selection or buffer.
|
|
-- ============================================================================
|
|
|
|
return {
|
|
"stevearc/conform.nvim",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
config = function()
|
|
local conform = require("conform")
|
|
|
|
conform.setup({
|
|
formatters = {
|
|
sqlfluff = {
|
|
command = "sqlfluff",
|
|
args = { "format", "--dialect", "postgres", "-" },
|
|
stdin = true,
|
|
cwd = require("conform.util").root_file({ ".git" }),
|
|
},
|
|
xmllint = {
|
|
command = "xmllint",
|
|
args = { "--format", "-" },
|
|
stdin = true,
|
|
},
|
|
},
|
|
formatters_by_ft = {
|
|
javascript = { "prettier" },
|
|
typescript = { "prettier" },
|
|
javascriptreact = { "prettier" },
|
|
typescriptreact = { "prettier" },
|
|
svelte = { "prettier" },
|
|
css = { "prettier" },
|
|
scss = { "prettier" },
|
|
html = { "prettier" },
|
|
json = { "prettier" },
|
|
yaml = { "prettier" },
|
|
markdown = { "prettier" },
|
|
graphql = { "prettier" },
|
|
liquid = { "prettier" },
|
|
xml = { "xmllint" },
|
|
tex = { "latexindent" },
|
|
lua = { "stylua" },
|
|
python = { "isort", "black" },
|
|
sql = { "sqlfluff" }, -- SQL formatting
|
|
-- java: no conform formatter (google-java-format needs JDK 21+)
|
|
-- falls through to JDTLS LSP via lsp_fallback = true
|
|
},
|
|
format_on_save = function(bufnr)
|
|
-- Disable autoformat for certain filetypes
|
|
local ignore_filetypes = { "sql", "markdown" }
|
|
if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then
|
|
return
|
|
end
|
|
-- Disable for files in certain paths
|
|
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
|
if bufname:match("/node_modules/") then
|
|
return
|
|
end
|
|
return {
|
|
timeout_ms = 2000,
|
|
lsp_fallback = true,
|
|
}
|
|
end,
|
|
})
|
|
|
|
vim.keymap.set({ "n", "v" }, "<leader>mm", function()
|
|
conform.format({
|
|
lsp_fallback = true,
|
|
async = false,
|
|
timeout_ms = 2000,
|
|
})
|
|
end, { desc = "Format: File or range (in visual mode)" })
|
|
|
|
-- Toggle auto-format on save
|
|
vim.api.nvim_create_user_command("FormatToggle", function()
|
|
vim.g.disable_autoformat = not vim.g.disable_autoformat
|
|
if vim.g.disable_autoformat then
|
|
vim.notify("Auto-format on save disabled", vim.log.levels.INFO)
|
|
else
|
|
vim.notify("Auto-format on save enabled", vim.log.levels.INFO)
|
|
end
|
|
end, { desc = "Toggle auto-format on save" })
|
|
end,
|
|
}
|