File tree Expand file tree Collapse file tree 6 files changed +78
-0
lines changed
test-files/generic/astgrep Expand file tree Collapse file tree 6 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ " Author: Ben Boeckel <[email protected] >2+ " Description: A CLI tool for code structural search, lint and rewriting
3+
4+ call ale#Set (' astgrep_executable' , ' ast-grep' )
5+
6+ function ! ale_linters#generic#astgrep#GetCommand (buffer ) abort
7+ return ' %e lsp'
8+ endfunction
9+
10+ function ! ale_linters#generic#astgrep#GetProjectRoot (buffer ) abort
11+ " Try to find nearest sgconfig.yml
12+ let l: sgconfig_file = ale#path#FindNearestFile (a: buffer , ' sgconfig.yml' )
13+
14+ if ! empty (l: sgconfig_file )
15+ return fnamemodify (l: sgconfig_file , ' :h' )
16+ endif
17+
18+ return ' '
19+ endfunction
20+
21+ call ale#linter#Define (' generic' , {
22+ \ ' name' : ' astgrep' ,
23+ \ ' lsp' : ' stdio' ,
24+ \ ' executable' : {b - > ale#Var (b , ' astgrep_executable' )},
25+ \ ' command' : function (' ale_linters#generic#astgrep#GetCommand' ),
26+ \ ' project_root' : function (' ale_linters#generic#astgrep#GetProjectRoot' ),
27+ \} )
Original file line number Diff line number Diff line change 1+ ===============================================================================
2+ ALE Generic Integration *ale-generic-options*
3+ *ale-integration-generic*
4+
5+ ===============================================================================
6+ Integration Information
7+
8+ Some tools are not language specific. This document collects information on
9+ ale's support for these tools.
10+
11+
12+ ===============================================================================
13+ astgrep *ale-generic-astgrep*
14+
15+ `' ast-grep' ` is a tool which can detect code patterns and offer fixes based
16+ on various languages' abstract syntax trees (ASTs) using tree-sitter.
17+
18+ *ale-options.astgrep_executable*
19+ *g:ale_astgrep_executable*
20+ *b:ale_astgrep_executable*
21+ astgrep_executable
22+ g:ale_astgrep_executable
23+ Type: | String |
24+ Default: `' ast-grep' `
25+
26+ This variable can be modified to change the executable path for
27+ `ast- grep ` .
28+
29+
30+ ===============================================================================
31+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
Original file line number Diff line number Diff line change @@ -3485,6 +3485,8 @@ documented in additional help files.
34853485 fountain................................| ale-fountain-options |
34863486 fusionscript............................| ale-fuse-options |
34873487 fusion-lint...........................| ale-fuse-fusionlint |
3488+ generic.................................| ale-generic-options |
3489+ astgrep...............................| ale-generic-astgrep |
34883490 git commit..............................| ale-gitcommit-options |
34893491 gitlint...............................| ale-gitcommit-gitlint |
34903492 gleam...................................| ale-gleam-options |
Original file line number Diff line number Diff line change 1+ Before:
2+ call ale#assert#SetUpLinterTest('generic', 'astgrep')
3+
4+ After:
5+ call ale#assert#TearDownLinterTest()
6+
7+ Execute(The default executable path should be correct):
8+ AssertLinter 'ast-grep', ale#Escape('ast-grep')
9+
10+ Execute(The project root should be detected correctly in cargo projects):
11+ call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.ext')
12+
13+ AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
14+
15+ Execute(The project root should be empty when no project files can be detected):
16+ call ale#test#SetFilename('../test-files/dummy')
17+
18+ AssertLSPProject ''
You can’t perform that action at this time.
0 commit comments