From dbf86525eaadcaa38daa6735b3a18cb43f3a863c Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 4 Jan 2025 21:36:09 -0800 Subject: [PATCH] feat: Add formatters --- nix/neovim-overlay.nix | 7 ++++++ nvim/lua/plugins/formatting/conform-nvim.lua | 26 ++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index ddfcc76..d264b89 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -144,8 +144,15 @@ with final.pkgs.lib; let shellcheck # Formatters + alejandra + blade-formatter + fish + php84Packages.php-cs-fixer nodePackages.prettier + rustywind + taplo shfmt + stylelint stylua ]; in { diff --git a/nvim/lua/plugins/formatting/conform-nvim.lua b/nvim/lua/plugins/formatting/conform-nvim.lua index d86e35d..cfbf7db 100644 --- a/nvim/lua/plugins/formatting/conform-nvim.lua +++ b/nvim/lua/plugins/formatting/conform-nvim.lua @@ -35,7 +35,8 @@ return { -- Prettier is last but only activated if there is a config available, -- thereby giving it priority only when it is wanted. formatters_by_ft = { - css = { 'biome', 'prettier' }, + blade = { 'blade-formatter', 'rustywind' }, + css = { 'stylelint', 'biome', 'prettier' }, fish = { 'fish_indent' }, graphql = { 'biome', 'prettier' }, handlebars = { 'prettier' }, @@ -44,12 +45,17 @@ return { javascriptreact = { 'biome', 'prettier' }, json = { 'biome', 'prettier' }, jsonc = { 'biome', 'prettier' }, + liquid = { 'prettier' }, lua = { 'stylua' }, less = { 'prettier' }, markdown = { 'prettier' }, ['markdown.mdx'] = { 'prettier' }, - scss = { 'prettier' }, + nix = { 'alejandra' }, + php = { 'pint', 'php_cs_fixer', stop_after_first = true }, + ruby = { 'prettier' }, + scss = { 'stylelint', 'prettier' }, sh = { 'shfmt' }, + toml = { 'taplo' }, typescript = { 'biome', 'prettier' }, typescriptreact = { 'biome', 'prettier' }, vue = { 'biome', 'prettier' }, @@ -60,12 +66,28 @@ return { biome = { require_cwd = true, }, + pint = { + meta = { url = 'https://github.com/laravel/pint' }, + command = require('conform.util').find_executable({ + 'vendor/bin/pint', + }, 'pint'), + args = { '$FILENAME' }, + stdin = false, + }, prettier = { condition = function(_, ctx) return MarleyVim.prettier.has_parser(ctx) and MarleyVim.prettier.has_config(ctx) end, }, + shfmt = { + prepend_args = { + '--indent=2', + '--case-indent', + '--binary-next-line', + '--func-next-line', + }, + }, }, })