Skip to content

Commit 9bca811

Browse files
committed
Initial commit
0 parents  commit 9bca811

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

CODE_OF_CONDUCT.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributor Code of Conduct
2+
3+
[Don't be a jerk.](https://meta.wikimedia.org/wiki/Don%27t_be_a_jerk)

LICENCE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
3+
Copyright (C) 2024 Gilles Roustan <[email protected]>
4+
5+
Everyone is permitted to copy and distribute verbatim or modified
6+
copies of this license document, and changing it is allowed as long
7+
as the name is changed.
8+
9+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11+
12+
0. You just DO WHAT THE FUCK YOU WANT TO.
13+

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# none-ls-ecs.nvim
2+
3+
This plugin for [none-ls.nvim](https://github.com/nvimtools/none-ls.nvim) allows to use PHP
4+
[Easy coding standard](https://github.com/easy-coding-standard/easy-coding-standard) formatter in Neovim
5+
with none-ls.nvim.
6+
7+
**Note:** This plugin is not intended to be used alone, it is a dependency of [none-ls.nvim](https://github.com/nvimtools/none-ls.nvim).
8+
9+
## 📦 Installation
10+
11+
This should be used as a dependency of **none-ls.nvim**.
12+
13+
### [lazy.nvim](https://github.com/folke/lazy.nvim)
14+
15+
```lua
16+
{
17+
{
18+
"nvimtools/none-ls.nvim",
19+
config = function()
20+
require("null-ls").register(require("none-ls-ecs.formatting"))
21+
end,
22+
dependencies = {
23+
"gbprod/none-ls-ecs.nvim",
24+
},
25+
},
26+
}
27+
```
28+
29+
## FAQ
30+
31+
How to trigger the formatter only if the project is using Easy coding standard?
32+
33+
```lua
34+
null_ls.register(require("none-ls-ecs.formatting").with({
35+
condition = function(utils)
36+
return utils.root_has_file("ecs.php")
37+
end,
38+
}))
39+
```
40+
41+
How to use project's ecs bin instead of globally installed one?
42+
43+
```lua
44+
null_ls.register(require("none-ls-ecs.formatting").with({
45+
command = "vendor/bin/ecs",
46+
condition = function(utils)
47+
return utils.root_has_file("vendor/bin/ecs")
48+
end,
49+
}))
50+
```

lua/none-ls-ecs/formatting/init.lua

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
local h = require("null-ls.helpers")
2+
local methods = require("null-ls.methods")
3+
4+
local FORMATTING = methods.internal.FORMATTING
5+
6+
return h.make_builtin({
7+
name = "EasyCodingStandard",
8+
meta = {
9+
url = "https://github.com/easy-coding-standard/easy-coding-standard",
10+
description = "Formatter for php files.",
11+
},
12+
method = FORMATTING,
13+
filetypes = { "php" },
14+
generator_opts = {
15+
command = "ecs",
16+
args = {
17+
"check",
18+
"--no-interaction",
19+
"--no-progress-bar",
20+
"--no-error-table",
21+
"--quiet",
22+
"--fix",
23+
"$FILENAME",
24+
},
25+
to_stdin = false,
26+
to_temp_file = true,
27+
},
28+
factory = h.formatter_factory,
29+
})

0 commit comments

Comments
 (0)