Skip to content

Commit

Permalink
builtins/formatting: add duster (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcavanunez authored Nov 28, 2024
1 parent 1f2bf17 commit 99b2e42
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/BUILTINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,23 @@ local sources = { null_ls.builtins.formatting.pint }
- Command: `pint`
- Args: `{ "--no-interaction", "--quiet", "$FILENAME" }`

### [duster](https://github.com/tighten/duster)

Automatic configuration for Laravel apps to apply Tighten's standard linting & code standards.

#### Usage

```lua
local sources = { null_ls.builtins.formatting.duster }
```

#### Defaults

- Filetypes: `{ "php" }`
- Method: `formatting`
- Command: `duster`
- Args: `{ "fix", "$FILENAME", "--no-interaction", "--quiet" }`

### [prettier](https://github.com/prettier/prettier)

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
Expand Down
30 changes: 30 additions & 0 deletions lua/null-ls/builtins/formatting/duster.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local h = require("null-ls.helpers")
local u = require("null-ls.utils")
local methods = require("null-ls.methods")

local FORMATTING = methods.internal.FORMATTING

return h.make_builtin({
name = "duster",
meta = {
url = "https://github.com/tighten/duster",
description = "Automatic configuration for Laravel apps to apply Tighten's standard linting & code standards.",
},
method = FORMATTING,
filetypes = { "php" },
generator_opts = {
command = vim.fn.executable("./vendor/bin/duster") == 1 and "./vendor/bin/duster" or "duster",
args = {
"fix",
"$FILENAME",
"--no-interaction",
"--quiet",
},
cwd = h.cache.by_bufnr(function(params)
return u.root_pattern("duster.json", "composer.json", "composer.lock")(params.bufname)
end),
to_stdin = true,
to_temp_file = true,
},
factory = h.formatter_factory,
})

0 comments on commit 99b2e42

Please sign in to comment.