dense-analysis / dense-analysis/ale

toml fixer

Open
#3,938 0 comments 4 reactions 0 assignees View on GitHub
new tool
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

**Name:** toml
**URL:** https://github.com/segeljakt/toml-fmt

toml is widely used these days(rust, poetry, ansible,etc)

I could not find a linter for it however I do find the above toml-fmt works on the command line, but I could not add it to ALE somehow. below is what I tried(after install `cargo install toml-fmt`):

```
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 0447bd3e..a8abf44d 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -156,6 +156,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['python'],
\ 'description': 'Fix Python files with yapf.',
\ },
+\ 'tomlfmt': {
+\ 'function:': 'ale#fixers#tomlfmt#Fix',
+\ 'suggested_filetypes': ['toml'],
+\ 'description':'Fix toml with toml-fmt',
+\ },
\ 'rubocop': {
\ 'function': 'ale#fixers#rubocop#Fix',
\ 'suggested_filetypes': ['ruby'],
diff --git a/autoload/ale/fixers/tomlfmt.vim b/autoload/ale/fixers/tomlfmt.vim
new file mode 100644
index 00000000..a7e70ab0
--- /dev/null
+++ b/autoload/ale/fixers/tomlfmt.vim
@@ -0,0 +1,11 @@
+call ale#Set('toml_tomlfmt_executable', 'toml-fmt')
+call ale#Set('toml_tomlfmt_options', '')
+
+function! ale#fixers#tomlfmt#Fix(buffer) abort
+ let l:executable=ale#Var(a:buffer, 'toml_tomlfmt_executable')
+ let l:options=ale#Var(a:buffer, 'toml_tomlfmt_options')
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . ale#Pad(l:options) . ' ',
+ \}
+endfunction

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.