File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ let s:default_registry = {
22
22
\ ' suggested_filetypes' : [' apkbuild' ],
23
23
\ ' description' : ' Fix policy violations found by apkbuild-lint in APKBUILDs' ,
24
24
\ },
25
+ \ ' ast-grep' : {
26
+ \ ' function' : ' ale#fixers#astgrep#Fix' ,
27
+ \ ' suggested_filetypes' : [],
28
+ \ ' description' : ' Apply ast-grep rules.' ,
29
+ \ },
25
30
\ ' autoimport' : {
26
31
\ ' function' : ' ale#fixers#autoimport#Fix' ,
27
32
\ ' 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
+ \ . ' %t' ,
16
+ \ ' read_temporary_file' : 1 ,
17
+ \}
18
+ endfunction
Original file line number Diff line number Diff line change @@ -38,5 +38,17 @@ g:ale_astgrep_linter_languages
38
38
`ast- grep ` linter.
39
39
40
40
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
+
41
53
===============================================================================
42
54
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 %t',
12
+ \ 'read_temporary_file': 1,
13
+ \ },
14
+ \ ale#fixers#astgrep#Fix(bufnr(''))
15
+
16
+ Execute(The astgrep executable and options should be configurable):
17
+ let g:ale_astgrep_executable = '/path/to/ast-grep'
18
+ let g:ale_astgrep_scan_options = '--interactive'
19
+
20
+ AssertEqual
21
+ \ {
22
+ \ 'command': ale#Escape('/path/to/ast-grep')
23
+ \ . ' scan'
24
+ \ . ' --interactive %t',
25
+ \ 'read_temporary_file': 1,
26
+ \ },
27
+ \ ale#fixers#astgrep#Fix(bufnr(''))
You can’t perform that action at this time.
0 commit comments