Skip to content

Commit

Permalink
Add docformatter builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Jul 14, 2023
1 parent ea1a453 commit 835ea4d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
17 changes: 17 additions & 0 deletions doc/BUILTINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,23 @@ local sources = { null_ls.builtins.formatting.djlint }
- Command: `djlint`
- Args: `{ "--reformat", "-" }`

### [docformatter](https://github.com/PyCQA/docformatter)

Python formatter complaint with the PEP 257 standard

#### Usage

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

#### Defaults

- Filetypes: `{ "python" }`
- Method: `formatting`
- Command: `docformatter`
- Args: `{ "-" }`

### [dprint](https://dprint.dev/)

A pluggable and configurable code formatting platform written in Rust.
Expand Down
2 changes: 1 addition & 1 deletion lua/null-ls/builtins/_meta/filetype_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ return {
python = {
code_actions = { "refactoring" },
diagnostics = { "flake8", "mypy", "pycodestyle", "pydocstyle", "pylama", "pylint", "pyproject_flake8", "ruff", "semgrep", "vulture" },
formatting = { "autoflake", "autopep8", "black", "blackd", "blue", "isort", "isortd", "pyflyby", "pyink", "reorder_python_imports", "ruff", "usort", "yapf" }
formatting = { "autoflake", "autopep8", "black", "blackd", "blue", "docformatter", "isort", "isortd", "pyflyby", "pyink", "reorder_python_imports", "ruff", "usort", "yapf" }
},
qml = {
diagnostics = { "qmllint" },
Expand Down
3 changes: 3 additions & 0 deletions lua/null-ls/builtins/_meta/formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ return {
djlint = {
filetypes = { "django", "jinja.html", "htmldjango" }
},
docformatter = {
filetypes = { "python" }
},
dprint = {
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "markdown", "toml", "rust", "roslyn" }
},
Expand Down
20 changes: 20 additions & 0 deletions lua/null-ls/builtins/formatting/docformatter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")

local FORMATTING = methods.internal.FORMATTING

return h.make_builtin({
name = "docformatter",
meta = {
url = "https://github.com/PyCQA/docformatter",
description = "Python formatter complaint with the PEP 257 standard",
},
method = { FORMATTING },
filetypes = { "python" },
generator_opts = {
command = "docformatter",
args = { "-" },
to_stdin = true,
},
factory = h.formatter_factory,
})

0 comments on commit 835ea4d

Please sign in to comment.