chore: improve Markdown and codeblock formatting

- Update `prettier.lua` to handle injected code blocks with correct `lang_to_ft` and `lang_to_ext` mappings
- Remove deprecated `markdown_inline` filetype; rely on injected formatting instead
- Update `linting.lua` to match new configuration
- Remove unused formatting and linting tools
This commit is contained in:
2025-10-04 19:22:31 -04:00
parent 3cd44640da
commit 1c52cb4ac0
2 changed files with 128 additions and 37 deletions
+31 -14
View File
@@ -6,20 +6,37 @@ return {
local lint = require('lint') local lint = require('lint')
lint.linters_by_ft = { lint.linters_by_ft = {
-- markdown = { 'markdownlint' }, -- Lua
-- html = { 'htmlhint' }, lua = {},
-- json = { 'jsonlint' },
-- sh = { 'shellharden', 'shellcheck' }, -- Shell / Bash / Zsh
-- bash = { 'shellharden', 'shellcheck' }, sh = { 'shellcheck' },
-- javascript = { 'eslint_d', 'trivy' }, bash = { 'shellcheck' },
-- typescript = { 'eslint_d' },
-- python = { 'pylint', 'trivy' }, -- Markdown
-- ansible = { 'ansiblelint' }, markdown = { 'markdownlint' },
-- gitcommit = { 'gitlint' }, -- markdown_inline = { 'markdownlint' },
-- docker = { 'trivy' },
-- yaml = { 'trivy', 'yamllint' }, -- Web / Frontend
-- editorconfig = { 'editorconfig-checker' }, html = { 'htmlhint' },
-- systemd = { 'systemdlint' }, css = { 'stylelint' },
javascript = { 'eslint_d' },
php = { 'trivy' },
-- YAML
yaml = { 'yamllint' },
-- JSON
json = { 'jsonlint', 'jq' },
-- Python
python = { 'pylint' },
-- Git commit messages
gitcommit = { 'gitlint' },
-- SQL
sql = { 'sqlfluff' },
} }
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
+95 -21
View File
@@ -1,35 +1,109 @@
--[[ vim.api.nvim_create_autocmd({ 'FocusLost', 'BufLeave' }, {
pattern = '*',
callback = function(args)
local buf = args.buf or vim.api.nvim_get_current_buf()
if vim.fn.mode() == 'n' then
vim.defer_fn(function()
if vim.api.nvim_buf_is_valid(buf) then require('conform').format({ bufnr = buf }) end
end, 100)
end
end,
}) ]]
return { return {
'stevearc/conform.nvim', 'stevearc/conform.nvim',
event = { 'BufReadPre', 'BufNewFile' }, event = { 'BufWritePre' },
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
sh = { 'beautysh', 'shellharden' }, -- Lua
bash = { 'beautysh', 'shellharden' }, lua = { 'lsp_format', 'stylua' },
zsh = { 'beautysh' },
javascript = { 'prettier' }, -- Shell / Bash / Zsh
typescript = { 'prettier' }, sh = { 'beautysh' },
css = { 'prettier' }, bash = { 'beautysh' },
-- zsh = { 'beautysh' }, -- beautysh pisses me off with zsh files
-- Markdown
markdown = { 'prettier', 'injected' },
-- markdown_inline = { 'prettier', 'injected' },
-- Web / Frontend
html = { 'prettier' }, html = { 'prettier' },
json = { 'prettier' }, css = { 'prettier', 'stylelint' },
yaml = { 'prettier' }, javascript = { 'prettier', 'eslint_d' },
markdown = { 'prettier', 'markdownlint' }, php = { 'phpcbf' },
graphql = { 'prettier' },
liquid = { 'prettier' }, -- YAML
lua = { 'stylua' }, yaml = { 'prettier', 'yamlfmt' },
python = { 'black', 'sort' },
}, -- JSON / Config
formatters = { json = { 'prettier', 'fixjson' },
--[[ shfmt = {
prepend_args = { '-i', '6' }, -- Python
}, ]] python = { 'black', 'isort' },
-- SQL
sql = { 'sqlfluff' },
}, },
format_injected = true,
default_format_opts = { default_format_opts = {
lsp_format = 'fallback', lsp_format = 'fallback',
}, },
format_on_save = { format_after_save = {
lsp_format = 'fallback', lsp_format = 'fallback',
async = false,
timeout_ms = 1000, timeout_ms = 1000,
}, },
}, },
config = function(_, opts)
local conform = require('conform')
conform.setup(opts)
-- Configure injected formatter
conform.formatters.injected = {
options = {
ignore_errors = false,
lang_to_ft = {
sh = 'sh',
bash = 'sh',
zsh = 'sh',
lua = 'lua',
javascript = 'javascript',
json = 'json',
yaml = 'yaml',
markdown = 'markdown',
python = 'python',
html = 'html',
css = 'css',
toml = 'toml',
sql = 'sql',
php = 'php',
},
-- Map injected languages to the right formatter(s)
lang_to_ext = {
sh = 'sh',
bash = 'sh',
zsh = 'sh',
javascript = 'js',
markdown = 'md',
json = 'json',
yaml = 'yml',
python = 'py',
lua = 'lua',
html = 'html',
css = 'css',
toml = 'toml',
sql = 'sql',
php = 'php',
},
--[[ lang_to_formatters = {
sh = { 'beautysh' },
bash = { 'beautysh'},
javascript = {'prettier'},
json = {'prettier'},
}, ]]
},
}
end,
} }