File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed
Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ let s:default_registry = {
2222\ ' suggested_filetypes' : [' apkbuild' ],
2323\ ' description' : ' Fix policy violations found by apkbuild-lint in APKBUILDs' ,
2424\ },
25+ \ ' ast-grep' : {
26+ \ ' function' : ' ale#fixers#astgrep#Fix' ,
27+ \ ' suggested_filetypes' : [],
28+ \ ' description' : ' Apply ast-grep rules.' ,
29+ \ },
2530\ ' autoimport' : {
2631\ ' function' : ' ale#fixers#autoimport#Fix' ,
2732\ ' suggested_filetypes' : [' python' ],
Original file line number Diff line number Diff line change 1+ " Author: Ben Boeckel <[email protected] >2+ " Description: Fix files with `ast-grep`.
3+
4+ call ale#Set (' astgrep_executable' , ' ast-grep' )
5+ call ale#Set (' astgrep_scan_options' , ' --update-all' )
6+
7+ function ! ale#fixers#astgrep#Fix (buffer ) abort
8+ let l: executable = ale#Var (a: buffer , ' astgrep_executable' )
9+ let l: options = ale#Var (a: buffer , ' astgrep_scan_options' )
10+
11+ return {
12+ \ ' command' : ale#Escape (l: executable )
13+ \ . ' scan'
14+ \ . (empty (l: options ) ? ' ' : ' ' . l: options )
15+ \}
16+ endfunction
Original file line number Diff line number Diff line change @@ -38,5 +38,17 @@ g:ale_astgrep_linter_languages
3838 `ast- grep ` linter.
3939
4040
41+ *ale-options.astgrep_scan_options*
42+ *g:ale_astgrep_scan_options*
43+ *b:ale_astgrep_scan_options*
44+ astgrep_scan_options
45+ g:ale_astgrep_scan_options
46+ Type: | String |
47+ Default: `' --update-all' `
48+
49+ This variable can be modified to change the options when applying rules with
50+ the `ast-grep scan` command.
51+
52+
4153===============================================================================
4254 vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
Original file line number Diff line number Diff line change 1+ Before:
2+ Save g:ale_astgrep_executable
3+ Save g:ale_astgrep_scan_options
4+
5+ After:
6+ Restore
7+
8+ Execute(The ast-grep callback should return the correct default values):
9+ AssertEqual
10+ \ {
11+ \ 'command': ale#Escape('ast-grep') . ' scan --update-all'
12+ \ },
13+ \ ale#fixers#astgrep#Fix(bufnr(''))
14+
15+ Execute(The astgrep executable and options should be configurable):
16+ let g:ale_astgrep_executable = '/path/to/ast-grep'
17+ let g:ale_astgrep_scan_options = '--interactive'
18+
19+ AssertEqual
20+ \ {
21+ \ 'command': ale#Escape('/path/to/ast-grep')
22+ \ . ' scan'
23+ \ . ' --interactive',
24+ \ },
25+ \ ale#fixers#astgrep#Fix(bufnr(''))
You can’t perform that action at this time.
0 commit comments