mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-05 09:27:44 +08:00
Compare commits
12 Commits
baaca9a5d7
...
codex/upda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b0f8d91bc | ||
|
|
9e49019a26 | ||
|
|
a0572359ae | ||
|
|
80ff84db84 | ||
|
|
c8c33e7217 | ||
|
|
5098dfd27e | ||
|
|
7cdaaa645d | ||
|
|
2f4a866591 | ||
|
|
f9de268816 | ||
|
|
1aaeb2cdae | ||
|
|
05e22db9a2 | ||
|
|
d0cdde7516 |
1
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
1
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
@@ -1,6 +1,7 @@
|
||||
---
|
||||
name: Report a bug
|
||||
labels: bug
|
||||
type: Bug
|
||||
about: Report a bug with ALE.
|
||||
|
||||
---
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
name: Suggest a new linter or fixer
|
||||
labels: new tool
|
||||
type: Task
|
||||
about: Suggest a new tool ALE can officially integrate with.
|
||||
|
||||
---
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
name: Suggest an improvement
|
||||
labels: enhancement
|
||||
type: Feature
|
||||
about: Suggest some way to improve ALE, or add a new feature.
|
||||
|
||||
---
|
||||
|
||||
43
ale_linters/bindzone/checkzone.vim
Normal file
43
ale_linters/bindzone/checkzone.vim
Normal file
@@ -0,0 +1,43 @@
|
||||
" Description: named-checkzone for bindzone
|
||||
|
||||
call ale#Set('bindzone_checkzone_executable', 'named-checkzone')
|
||||
call ale#Set('bindzone_checkzone_options', '-c IN')
|
||||
|
||||
function! ale_linters#bindzone#checkzone#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'bindzone_checkzone_options'))
|
||||
\ . ' example.com %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#bindzone#checkzone#Handle(buffer, lines) abort
|
||||
let l:warning_pattern = '\vzone example.com/IN: (.+)$'
|
||||
let l:error_pattern = '\v:(\d+): (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:error_pattern)
|
||||
let l:lnum = l:match[1]
|
||||
let l:text = l:match[2]
|
||||
|
||||
call add(l:output, {'text': l:text, 'lnum': l:lnum + 0, 'type': 'E'})
|
||||
endfor
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:warning_pattern)
|
||||
let l:text = l:match[1]
|
||||
|
||||
" Ignore information messages
|
||||
let l:scrub_match = matchlist(l:text, '\v(loaded serial|not loaded due to) ')
|
||||
|
||||
if empty(l:scrub_match)
|
||||
call add(l:output, {'text': l:text, 'lnum': 0, 'type': 'W'})
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('bindzone', {
|
||||
\ 'name': 'checkzone',
|
||||
\ 'executable': {b -> ale#Var(b, 'bindzone_checkzone_executable')},
|
||||
\ 'command': function('ale_linters#bindzone#checkzone#GetCommand'),
|
||||
\ 'callback': 'ale_linters#bindzone#checkzone#Handle',
|
||||
\ 'read_buffer': 0,
|
||||
\})
|
||||
28
ale_linters/lean/lake.vim
Normal file
28
ale_linters/lean/lake.vim
Normal file
@@ -0,0 +1,28 @@
|
||||
" Author: Benjamin Block <https://github.com/benjamindblock>
|
||||
" Description: A language server for Lean 4.
|
||||
|
||||
function! ale_linters#lean#lake#GetProjectRoot(buffer) abort
|
||||
let l:lakefile_toml = ale#path#FindNearestFile(a:buffer, 'lakefile.toml')
|
||||
let l:lakefile_lean = ale#path#FindNearestFile(a:buffer, 'lakefile.lean')
|
||||
|
||||
if !empty(l:lakefile_toml)
|
||||
return fnamemodify(l:lakefile_toml, ':p:h')
|
||||
elseif !empty(l:lakefile_lean)
|
||||
return fnamemodify(l:lakefile_lean, ':p:h')
|
||||
else
|
||||
return fnamemodify('', ':h')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call ale#Set('lean_lake_executable', 'lake')
|
||||
call ale#Set('lean_lake_config', {})
|
||||
|
||||
call ale#linter#Define('lean', {
|
||||
\ 'name': 'lake',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'language': 'lean',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'lean_lake_config')},
|
||||
\ 'executable': {b -> ale#Var(b, 'lean_lake_executable')},
|
||||
\ 'command': '%e serve',
|
||||
\ 'project_root': function('ale_linters#lean#lake#GetProjectRoot'),
|
||||
\})
|
||||
@@ -36,7 +36,7 @@ function! ale_linters#python#pylsp#GetCwd(buffer) abort
|
||||
\ 'name': 'pylsp',
|
||||
\ 'project_root': function('ale#python#FindProjectRoot'),
|
||||
\}
|
||||
let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, l:fake_linter)
|
||||
let l:root = ale#linter#GetRoot(a:buffer, l:fake_linter)
|
||||
|
||||
return !empty(l:root) ? l:root : v:null
|
||||
endfunction
|
||||
|
||||
57
ale_linters/python/pyrefly.vim
Normal file
57
ale_linters/python/pyrefly.vim
Normal file
@@ -0,0 +1,57 @@
|
||||
" Author: oliverralbertini <oliver.albertini@gmail.com>
|
||||
" Description: A performant type-checker supporting LSP for Python 3 created by Facebook
|
||||
|
||||
call ale#Set('python_pyrefly_executable', 'pyrefly')
|
||||
call ale#Set('python_pyrefly_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_pyrefly_auto_pipenv', 0)
|
||||
call ale#Set('python_pyrefly_auto_poetry', 0)
|
||||
call ale#Set('python_pyrefly_auto_uv', 0)
|
||||
|
||||
function! ale_linters#python#pyrefly#GetExecutable(buffer) abort
|
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyrefly_auto_pipenv'))
|
||||
\ && ale#python#PipenvPresent(a:buffer)
|
||||
return 'pipenv'
|
||||
endif
|
||||
|
||||
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyrefly_auto_poetry'))
|
||||
\ && ale#python#PoetryPresent(a:buffer)
|
||||
return 'poetry'
|
||||
endif
|
||||
|
||||
if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyrefly_auto_uv'))
|
||||
\ && ale#python#UvPresent(a:buffer)
|
||||
return 'uv'
|
||||
endif
|
||||
|
||||
return ale#python#FindExecutable(a:buffer, 'python_pyrefly', ['pyrefly'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pyrefly#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#python#pyrefly#GetExecutable(a:buffer)
|
||||
let l:exec_args = [
|
||||
\ ale#Escape(l:executable)
|
||||
\ ]
|
||||
\ + (l:executable =~? '\(pipenv\|poetry\|uv\)$' ? ['run', 'pyrefly'] : [])
|
||||
\ + [
|
||||
\ 'lsp',
|
||||
\ ]
|
||||
|
||||
return join(l:exec_args, ' ')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pyrefly#GetCwd(buffer) abort
|
||||
" Run from project root if found, else from buffer dir.
|
||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||
|
||||
return !empty(l:project_root) ? l:project_root : '%s:h'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('python', {
|
||||
\ 'name': 'pyrefly',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#python#pyrefly#GetExecutable'),
|
||||
\ 'command': function('ale_linters#python#pyrefly#GetCommand'),
|
||||
\ 'project_root': function('ale#python#FindProjectRoot'),
|
||||
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
|
||||
\ 'cwd': function('ale_linters#python#pyrefly#GetCwd'),
|
||||
\})
|
||||
@@ -13,7 +13,7 @@ function! ale_linters#python#pyright#GetCwd(buffer) abort
|
||||
\ 'name': 'pyright',
|
||||
\ 'project_root': function('ale#python#FindProjectRoot'),
|
||||
\}
|
||||
let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, l:fake_linter)
|
||||
let l:root = ale#linter#GetRoot(a:buffer, l:fake_linter)
|
||||
|
||||
return !empty(l:root) ? l:root : v:null
|
||||
endfunction
|
||||
|
||||
@@ -72,20 +72,31 @@ function! ale_linters#python#ruff#Handle(buffer, lines) abort
|
||||
try
|
||||
let l:item = json_decode(l:line)
|
||||
catch
|
||||
let l:item = v:null
|
||||
" If we can't decode a line, skip it.
|
||||
continue
|
||||
endtry
|
||||
|
||||
if !empty(l:item)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:item.location.row,
|
||||
\ 'col': l:item.location.column,
|
||||
\ 'end_lnum': l:item.end_location.row,
|
||||
\ 'end_col': l:item.end_location.column - 1,
|
||||
\ 'code': l:item.code,
|
||||
\ 'text': l:item.message,
|
||||
\ 'type': l:item.code =~? '\vE\d+' ? 'E' : 'W',
|
||||
\})
|
||||
if (l:item.code is# 'W291' || l:item.code is# 'W293')
|
||||
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
" Skip warnings for trailing whitespace if the option is off.
|
||||
continue
|
||||
endif
|
||||
|
||||
if l:item.code is# 'W391'
|
||||
\&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines')
|
||||
" Skip warnings for trailing blank lines if the option is off
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:item.location.row,
|
||||
\ 'col': l:item.location.column,
|
||||
\ 'end_lnum': l:item.end_location.row,
|
||||
\ 'end_col': l:item.end_location.column - 1,
|
||||
\ 'code': l:item.code,
|
||||
\ 'text': l:item.message,
|
||||
\ 'type': l:item.code =~? '\vE\d+' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
25
ale_linters/roc/roc_language_server.vim
Normal file
25
ale_linters/roc/roc_language_server.vim
Normal file
@@ -0,0 +1,25 @@
|
||||
" Author: Benjamin Block <https://github.com/benjamindblock>
|
||||
" Description: A language server for Roc.
|
||||
|
||||
function! ale_linters#roc#roc_language_server#GetProjectRoot(buffer) abort
|
||||
let l:roc_main_file = ale#path#FindNearestFile(a:buffer, 'main.roc')
|
||||
|
||||
if !empty(l:roc_main_file)
|
||||
return fnamemodify(l:roc_main_file, ':p:h')
|
||||
else
|
||||
return fnamemodify('', ':h')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call ale#Set('roc_roc_language_server_executable', 'roc_language_server')
|
||||
call ale#Set('roc_roc_language_server_config', {})
|
||||
|
||||
call ale#linter#Define('roc', {
|
||||
\ 'name': 'roc_language_server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'language': 'roc',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'roc_roc_language_server_config')},
|
||||
\ 'executable': {b -> ale#Var(b, 'roc_roc_language_server_executable')},
|
||||
\ 'command': '%e',
|
||||
\ 'project_root': function('ale_linters#roc#roc_language_server#GetProjectRoot'),
|
||||
\})
|
||||
@@ -25,6 +25,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('sh', {
|
||||
\ 'name': 'language_server',
|
||||
\ 'aliases': ['bash-language-server'],
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#sh#language_server#GetExecutable'),
|
||||
\ 'command': function('ale_linters#sh#language_server#GetCommand'),
|
||||
|
||||
@@ -216,7 +216,7 @@ endfunction
|
||||
function! ale#assert#LSPProject(expected_root) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
let l:root = ale#lsp_linter#FindProjectRoot(l:buffer, l:linter)
|
||||
let l:root = ale#linter#GetRoot(l:buffer, l:linter)
|
||||
|
||||
AssertEqual a:expected_root, l:root
|
||||
endfunction
|
||||
|
||||
@@ -722,6 +722,16 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['typst'],
|
||||
\ 'description': 'A formatter for Typst files',
|
||||
\ },
|
||||
\ 'roc_format': {
|
||||
\ 'function': 'ale#fixers#roc_format#Fix',
|
||||
\ 'suggested_filetypes': ['roc'],
|
||||
\ 'description': 'Formats Roc files.',
|
||||
\ },
|
||||
\ 'roc_annotate': {
|
||||
\ 'function': 'ale#fixers#roc_annotate#Fix',
|
||||
\ 'suggested_filetypes': ['roc'],
|
||||
\ 'description': 'Annotates all top-level definitions in Roc files.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
||||
@@ -1,32 +1,48 @@
|
||||
" Author: Ian Stapleton Cordasco <graffatcolmingov@gmail.com>
|
||||
" Description: Run golangci-lint with the --fix flag to autofix some issues
|
||||
|
||||
call ale#Set('go_golangci_lint_options', '')
|
||||
call ale#Set('go_golangci_lint_executable', 'golangci-lint')
|
||||
call ale#Set('go_golangci_lint_package', 1)
|
||||
call ale#Set('go_golangci_formatter_options', '')
|
||||
call ale#Set('go_golangci_formatter_executable', 'golangci-lint')
|
||||
|
||||
function! ale#fixers#golangci_lint#GetCommand(buffer) abort
|
||||
function! ale#fixers#golangci_lint#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_golangci_formatter_executable')
|
||||
|
||||
return l:executable
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#golangci_lint#GetCommand(buffer, version) abort
|
||||
let l:filename = expand('#' . a:buffer . ':t')
|
||||
let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') . ' --fix'
|
||||
let l:package_mode = ale#Var(a:buffer, 'go_golangci_lint_package')
|
||||
let l:executable = ale#fixers#golangci_lint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'go_golangci_formatter_options')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
|
||||
if l:package_mode
|
||||
if ale#semver#GTE(a:version, [2, 0, 0])
|
||||
return l:env . ale#Escape(l:executable)
|
||||
\ . ' run '
|
||||
\ . l:options
|
||||
\ . ' fmt --stdin '
|
||||
\ . l:options
|
||||
else
|
||||
return l:env . ale#Escape(l:executable)
|
||||
\ . ' run --fix '
|
||||
\ . l:options
|
||||
\ . ' '
|
||||
\ . ale#Escape(l:filename)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
return l:env . ale#Escape(l:executable)
|
||||
\ . ' run '
|
||||
\ . l:options
|
||||
\ . ' ' . ale#Escape(l:filename)
|
||||
function! ale#fixers#golangci_lint#GetCommandForVersion(buffer, version) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#golangci_lint#GetCommand(a:buffer, a:version)
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#golangci_lint#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#golangci_lint#GetCommand(a:buffer),
|
||||
\}
|
||||
let l:executable = ale#fixers#golangci_lint#GetExecutable(a:buffer)
|
||||
let l:command = ale#fixers#golangci_lint#GetExecutable(a:buffer) . ale#Pad('--version')
|
||||
|
||||
return ale#semver#RunWithVersionCheck(
|
||||
\ a:buffer,
|
||||
\ l:executable,
|
||||
\ l:command,
|
||||
\ function('ale#fixers#golangci_lint#GetCommandForVersion'),
|
||||
\)
|
||||
endfunction
|
||||
|
||||
21
autoload/ale/fixers/roc_annotate.vim
Normal file
21
autoload/ale/fixers/roc_annotate.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
" Author: Benjamin Block <https://github.com/benjamindblock>
|
||||
" Description: Official type annotation tool for Roc.
|
||||
|
||||
call ale#Set('roc_roc_annotate_executable', 'roc')
|
||||
call ale#Set('roc_roc_annotate_options', '')
|
||||
|
||||
function! ale#fixers#roc_annotate#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'roc_roc_annotate_executable')
|
||||
let l:command = l:executable . ' format annotate'
|
||||
let l:options = ale#Var(a:buffer, 'roc_roc_annotate_options')
|
||||
|
||||
if l:options isnot# ''
|
||||
let l:command .= ' ' . l:options
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:command . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
20
autoload/ale/fixers/roc_format.vim
Normal file
20
autoload/ale/fixers/roc_format.vim
Normal file
@@ -0,0 +1,20 @@
|
||||
" Author: Benjamin Block <https://github.com/benjamindblock>
|
||||
" Description: Official formatter for Roc.
|
||||
|
||||
call ale#Set('roc_roc_format_executable', 'roc')
|
||||
call ale#Set('roc_roc_format_options', '')
|
||||
|
||||
function! ale#fixers#roc_format#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'roc_roc_format_executable')
|
||||
let l:command = l:executable . ' format'
|
||||
let l:options = ale#Var(a:buffer, 'roc_roc_format_options')
|
||||
|
||||
if l:options isnot# ''
|
||||
let l:command .= ' ' . l:options
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:command . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
@@ -447,3 +447,32 @@ function! ale#linter#GetAddress(buffer, linter) abort
|
||||
|
||||
return type(l:Address) is v:t_func ? l:Address(a:buffer) : l:Address
|
||||
endfunction
|
||||
|
||||
" Get the project root for a linter.
|
||||
" If |b:ale_root| or |g:ale_root| is set to either a String or a Dict mapping
|
||||
" linter names to roots or callbacks, return that value immediately. When no
|
||||
" value is available, fall back to the linter-specific configuration.
|
||||
function! ale#linter#GetRoot(buffer, linter) abort
|
||||
let l:buffer_ale_root = getbufvar(a:buffer, 'ale_root', {})
|
||||
|
||||
if type(l:buffer_ale_root) is v:t_string
|
||||
return l:buffer_ale_root
|
||||
endif
|
||||
|
||||
if has_key(l:buffer_ale_root, a:linter.name)
|
||||
let l:Root = l:buffer_ale_root[a:linter.name]
|
||||
return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root
|
||||
endif
|
||||
|
||||
if has_key(g:ale_root, a:linter.name)
|
||||
let l:Root = g:ale_root[a:linter.name]
|
||||
return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'project_root')
|
||||
let l:Root = a:linter.project_root
|
||||
return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
@@ -296,44 +296,6 @@ function! ale#lsp_linter#GetConfig(buffer, linter) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort
|
||||
let l:buffer_ale_root = getbufvar(a:buffer, 'ale_root', {})
|
||||
|
||||
if type(l:buffer_ale_root) is v:t_string
|
||||
return l:buffer_ale_root
|
||||
endif
|
||||
|
||||
" Try to get a buffer-local setting for the root
|
||||
if has_key(l:buffer_ale_root, a:linter.name)
|
||||
let l:Root = l:buffer_ale_root[a:linter.name]
|
||||
|
||||
if type(l:Root) is v:t_func
|
||||
return l:Root(a:buffer)
|
||||
else
|
||||
return l:Root
|
||||
endif
|
||||
endif
|
||||
|
||||
" Try to get a global setting for the root
|
||||
if has_key(g:ale_root, a:linter.name)
|
||||
let l:Root = g:ale_root[a:linter.name]
|
||||
|
||||
if type(l:Root) is v:t_func
|
||||
return l:Root(a:buffer)
|
||||
else
|
||||
return l:Root
|
||||
endif
|
||||
endif
|
||||
|
||||
" Fall back to the linter-specific configuration
|
||||
if has_key(a:linter, 'project_root')
|
||||
let l:Root = a:linter.project_root
|
||||
|
||||
return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root
|
||||
endif
|
||||
|
||||
return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer)
|
||||
endfunction
|
||||
|
||||
" This function is accessible so tests can call it.
|
||||
function! ale#lsp_linter#OnInit(linter, details, Callback) abort
|
||||
@@ -504,7 +466,7 @@ endfunction
|
||||
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
||||
let l:command = ''
|
||||
let l:address = ''
|
||||
let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, a:linter)
|
||||
let l:root = ale#linter#GetRoot(a:buffer, a:linter)
|
||||
|
||||
if empty(l:root) && a:linter.lsp isnot# 'tsserver'
|
||||
" If there's no project root, then we can't check files with LSP,
|
||||
|
||||
@@ -115,12 +115,11 @@ endfunction
|
||||
|
||||
" Return 1 if a path is an absolute path.
|
||||
function! ale#path#IsAbsolute(filename) abort
|
||||
if has('win32') && a:filename[:0] is# '\'
|
||||
return 1
|
||||
if has('win32')
|
||||
return a:filename[:0] =~# '[\\/]' || a:filename[0:2] =~? '[A-Z]:[/\\]'
|
||||
else
|
||||
return a:filename[:0] is# '/'
|
||||
endif
|
||||
|
||||
" Check for /foo and C:\foo, etc.
|
||||
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
|
||||
endfunction
|
||||
|
||||
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h'))
|
||||
|
||||
@@ -26,7 +26,6 @@ function! ale#python#FindProjectRootIni(buffer) abort
|
||||
" If you change this, update ale-python-root documentation.
|
||||
if filereadable(l:path . '/MANIFEST.in')
|
||||
\|| filereadable(l:path . '/setup.cfg')
|
||||
\|| filereadable(l:path . '/pytest.ini')
|
||||
\|| filereadable(l:path . '/tox.ini')
|
||||
\|| filereadable(l:path . '/.pyre_configuration.local')
|
||||
\|| filereadable(l:path . '/mypy.ini')
|
||||
@@ -55,12 +54,19 @@ endfunction
|
||||
" Given a buffer number, find the project root directory for Python.
|
||||
" The root directory is defined as the first directory found while searching
|
||||
" upwards through paths, including the current directory, until a path
|
||||
" containing an init file (one from MANIFEST.in, setup.cfg, pytest.ini,
|
||||
" tox.ini) is found. If it is not possible to find the project root directory
|
||||
" via init file, then it will be defined as the first directory found
|
||||
" searching upwards through paths, including the current directory, until no
|
||||
" __init__.py files is found.
|
||||
" containing an configuration file is found. (See list above)
|
||||
"
|
||||
" If it is not possible to find the project root directory via configuration
|
||||
" file, then it will be defined as the first directory found searching upwards
|
||||
" through paths, including the current directory, until no __init__.py files
|
||||
" is found.
|
||||
function! ale#python#FindProjectRoot(buffer) abort
|
||||
let l:root = ale#linter#GetRoot(a:buffer, {'name': 'python'})
|
||||
|
||||
if !empty(l:root)
|
||||
return l:root
|
||||
endif
|
||||
|
||||
let l:ini_root = ale#python#FindProjectRootIni(a:buffer)
|
||||
|
||||
if !empty(l:ini_root)
|
||||
|
||||
32
doc/ale-bindzone.txt
Normal file
32
doc/ale-bindzone.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
===============================================================================
|
||||
ALE BINDZone Integration *ale-bindzone-options*
|
||||
|
||||
===============================================================================
|
||||
checkzone *ale-bindzone-checkzone*
|
||||
|
||||
*ale-options.bindzone_checkzone_executable*
|
||||
*g:ale_bindzone_checkzone_executable*
|
||||
*b:ale_bindzone_checkzone_executable*
|
||||
bindzone_checkzone_executable
|
||||
g:ale_bindzone_checkzone_executable
|
||||
Type: |String|
|
||||
Default: `named-checkzone`
|
||||
|
||||
This variable can be changed to set the path to named-checkzone executable.
|
||||
|
||||
*ale-options.bindzone_checkzone_options*
|
||||
*g:ale_bindzone_checkzone_options*
|
||||
*b:ale_bindzone_checkzone_options*
|
||||
bindzone_checkzone_options
|
||||
g:ale_bindzone_checkzone_options
|
||||
Type: |String|
|
||||
Default: `-c IN`
|
||||
|
||||
This variable can be changed to add additional command-line arguments.
|
||||
All available options can be found at:
|
||||
|
||||
https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
@@ -144,7 +144,7 @@ g:ale_go_golangci_lint_options
|
||||
Default: `''`
|
||||
|
||||
This variable can be changed to alter the command-line arguments to the
|
||||
golangci-lint invocation.
|
||||
golangci-lint run invocation.
|
||||
|
||||
*ale-options.go_golangci_lint_package*
|
||||
*g:ale_go_golangci_lint_package*
|
||||
@@ -157,6 +157,30 @@ g:ale_go_golangci_lint_package
|
||||
When set to `1`, the whole Go package will be checked instead of only the
|
||||
current file.
|
||||
|
||||
golangci_lint can also be user as a fixer to format go source files. In this
|
||||
case the following configuration variables can be used to configure the
|
||||
formatters:
|
||||
|
||||
*ale-options.go_golangci_formatter_executable*
|
||||
*g:ale_go_golangci_formatter_executable*
|
||||
*b:ale_go_golangci_formatter_executable*
|
||||
go_golangci_formatter_executable
|
||||
g:ale_go_golangci_formatter_executable
|
||||
Type: |String|
|
||||
Default: `'golangci-lint'`
|
||||
|
||||
The executable that will be run for golangci-lint.
|
||||
|
||||
*ale-options.go_golangci_formatter_options*
|
||||
*g:ale_go_golangci_formatter_options*
|
||||
*b:ale_go_golangci_formatter_options*
|
||||
go_golangci_formatter_options
|
||||
g:ale_go_golangci_formatter_options
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be changed to alter the command-line arguments to the
|
||||
golangci-lint fmt invocation.
|
||||
|
||||
===============================================================================
|
||||
golangserver *ale-go-golangserver*
|
||||
|
||||
29
doc/ale-lean.txt
Normal file
29
doc/ale-lean.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
===============================================================================
|
||||
ALE Lean Integration *ale-lean-options*
|
||||
*ale-integration-lean*
|
||||
|
||||
===============================================================================
|
||||
Integration Information
|
||||
|
||||
Currently, the only supported LSP for Lean 4 is lake.
|
||||
|
||||
===============================================================================
|
||||
lake *ale-lean-lake*
|
||||
|
||||
g:ale_lean_lake_executable *g:ale_lean_lake_executable*
|
||||
*b:ale_lean_lake_executable*
|
||||
Type: |String|
|
||||
Default: `'lake'`
|
||||
|
||||
This variable can be modified to change the executable path for `lake`.
|
||||
|
||||
|
||||
g:ale_lean_lake_config *g:ale_lean_lake_config*
|
||||
*b:ale_lean_lake_config*
|
||||
Type: |Dictionary|
|
||||
Default: `{}`
|
||||
|
||||
Dictionary with configuration settings for lake.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
@@ -55,6 +55,9 @@ For some linters, ALE will search for a Python project root by looking at the
|
||||
files in directories on or above where a file being checked is. ALE applies
|
||||
the following methods, in order:
|
||||
|
||||
If |g:ale_root| or |b:ale_root| provides a value, that value is used as the
|
||||
project root instead and the searching described below is skipped.
|
||||
|
||||
1. Find the first directory containing a common Python configuration file.
|
||||
2. If no configuration file can be found, use the first directory which does
|
||||
not contain a readable file named `__init__.py`.
|
||||
@@ -63,7 +66,6 @@ ALE will look for configuration files with the following filenames. >
|
||||
|
||||
MANIFEST.in
|
||||
setup.cfg
|
||||
pytest.ini
|
||||
tox.ini
|
||||
.pyre_configuration.local
|
||||
mypy.ini
|
||||
@@ -81,6 +83,7 @@ ALE will look for configuration files with the following filenames. >
|
||||
poetry.lock
|
||||
pyproject.toml
|
||||
.tool-versions
|
||||
uv.lock
|
||||
<
|
||||
|
||||
The first directory containing any of the files named above will be used.
|
||||
@@ -1616,6 +1619,69 @@ g:ale_python_pyre_auto_uv
|
||||
executable.
|
||||
|
||||
|
||||
===============================================================================
|
||||
pyrefly *ale-python-pyrefly*
|
||||
|
||||
`pyrefly` will be run from a detected project root, per |ale-python-root|.
|
||||
|
||||
*ale-options.python_pyrefly_executable*
|
||||
*g:ale_python_pyrefly_executable*
|
||||
*b:ale_python_pyrefly_executable*
|
||||
python_pyrefly_executable
|
||||
g:ale_python_pyrefly_executable
|
||||
Type: |String|
|
||||
Default: `'pyrefly'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
Set this to `'pipenv'` to invoke `'pipenv` `run` `pyrefly'`.
|
||||
Set this to `'poetry'` to invoke `'poetry` `run` `pyrefly'`.
|
||||
Set this to `'uv'` to invoke `'uv` `run` `pyrefly'`.
|
||||
|
||||
*ale-options.python_pyrefly_use_global*
|
||||
*g:ale_python_pyrefly_use_global*
|
||||
*b:ale_python_pyrefly_use_global*
|
||||
python_pyrefly_use_global
|
||||
g:ale_python_pyrefly_use_global
|
||||
Type: |Number|
|
||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
*ale-options.python_pyrefly_auto_pipenv*
|
||||
*g:ale_python_pyrefly_auto_pipenv*
|
||||
*b:ale_python_pyrefly_auto_pipenv*
|
||||
python_pyrefly_auto_pipenv
|
||||
g:ale_python_pyrefly_auto_pipenv
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
|
||||
if true. This is overridden by a manually-set executable.
|
||||
|
||||
*ale-options.python_pyrefly_auto_poetry*
|
||||
*g:ale_python_pyrefly_auto_poetry*
|
||||
*b:ale_python_pyrefly_auto_poetry*
|
||||
python_pyrefly_auto_poetry
|
||||
g:ale_python_pyrefly_auto_poetry
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
Detect whether the file is inside a poetry, and set the executable to `poetry`
|
||||
if true. This is overridden by a manually-set executable.
|
||||
|
||||
*ale-options.python_pyrefly_auto_uv*
|
||||
*g:ale_python_pyrefly_auto_uv*
|
||||
*b:ale_python_pyrefly_auto_uv*
|
||||
python_pyrefly_auto_uv
|
||||
g:ale_python_pyrefly_auto_uv
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
Set the executable to `uv` if true. This is overridden by a manually-set
|
||||
executable.
|
||||
|
||||
|
||||
===============================================================================
|
||||
pyright *ale-python-pyright*
|
||||
|
||||
|
||||
79
doc/ale-roc.txt
Normal file
79
doc/ale-roc.txt
Normal file
@@ -0,0 +1,79 @@
|
||||
===============================================================================
|
||||
ALE Roc Integration *ale-roc-options*
|
||||
*ale-integration-roc*
|
||||
|
||||
===============================================================================
|
||||
roc_language_server *ale-roc-roc-language-server*
|
||||
|
||||
*ale-options.roc_roc_language_server_executable*
|
||||
*g:ale_roc_roc_language_server_executable*
|
||||
*b:ale_roc_roc_language_server_executable*
|
||||
roc_roc_language_server_executable
|
||||
g:ale_roc_roc_language_server_executable
|
||||
Type: |String|
|
||||
Default: `'roc_language_server'`
|
||||
|
||||
This variable can be modified to change the executable path for
|
||||
`roc_language_server`.
|
||||
|
||||
*ale-options.roc_roc_language_server_config*
|
||||
*g:ale_roc_roc_language_server_config*
|
||||
*b:ale_roc_roc_language_server_config*
|
||||
roc_roc_language_server_config
|
||||
g:ale_roc_roc_language_server_config
|
||||
Type: |Dictionary|
|
||||
Default: `{}`
|
||||
|
||||
Dictionary with configuration settings for roc_language_server.
|
||||
|
||||
|
||||
===============================================================================
|
||||
roc_format *ale-roc-roc-format*
|
||||
|
||||
*ale-options.roc_roc_format_executable*
|
||||
*g:ale_roc_roc_format_executable*
|
||||
*b:ale_roc_roc_format_executable*
|
||||
roc_roc_format_executable
|
||||
g:ale_roc_roc_format_executable
|
||||
Type: |String|
|
||||
Default: `'roc'`
|
||||
|
||||
This variable can be modified to change the executable path for `roc`.
|
||||
|
||||
*ale-options.roc_roc_format_options*
|
||||
*g:ale_roc_roc_format_options*
|
||||
*b:ale_roc_roc_format_options*
|
||||
roc_roc_format_options
|
||||
g:ale_roc_roc_format_options
|
||||
Type: String
|
||||
Default: `''`
|
||||
|
||||
Additional flags for `roc format`.
|
||||
|
||||
|
||||
===============================================================================
|
||||
roc_annotate *ale-roc-roc-annotate*
|
||||
|
||||
*ale-options.roc_roc_annotate_executable*
|
||||
*g:ale_roc_roc_annotate_executable*
|
||||
*b:ale_roc_roc_annotate_executable*
|
||||
roc_roc_annotate_executable
|
||||
g:ale_roc_roc_annotate_executable
|
||||
Type: |String|
|
||||
Default: `'roc'`
|
||||
|
||||
This variable can be modified to change the executable path for `roc`.
|
||||
|
||||
*ale-options.roc_roc_annotate_options*
|
||||
*g:ale_roc_roc_annotate_options*
|
||||
*b:ale_roc_roc_annotate_options*
|
||||
roc_roc_annotate_options
|
||||
g:ale_roc_roc_annotate_options
|
||||
Type: String
|
||||
Default: `''`
|
||||
|
||||
Additional flags for `roc format annotate`.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
@@ -60,6 +60,8 @@ Notes:
|
||||
* `bibclean`
|
||||
* Bicep
|
||||
* `bicep`
|
||||
* Bindzone
|
||||
* `checkzone` (named-checkzone)
|
||||
* BitBake
|
||||
* `oelint-adv`
|
||||
* Bourne Shell
|
||||
@@ -370,6 +372,8 @@ Notes:
|
||||
* `textlint`
|
||||
* `vale`
|
||||
* `write-good`
|
||||
* Lean 4
|
||||
* `lake`
|
||||
* Less
|
||||
* `lessc`
|
||||
* `prettier`
|
||||
@@ -541,6 +545,7 @@ Notes:
|
||||
* `pylint`!!
|
||||
* `pylsp`
|
||||
* `pyre`
|
||||
* `pyrefly`
|
||||
* `pyright`
|
||||
* `refurb`
|
||||
* `reorder-python-imports`
|
||||
@@ -584,6 +589,10 @@ Notes:
|
||||
* `write-good`
|
||||
* Robot
|
||||
* `rflint`
|
||||
* Roc
|
||||
* roc_annotate
|
||||
* roc_format
|
||||
* roc_language_server
|
||||
* RPM spec
|
||||
* `rpmlint`
|
||||
* Ruby
|
||||
|
||||
26
doc/ale.txt
26
doc/ale.txt
@@ -2297,17 +2297,18 @@ g:ale_root
|
||||
Type: |Dictionary| or |String|
|
||||
Default: `{}`
|
||||
|
||||
This option is used to determine the project root for a linter. If the value
|
||||
is a |Dictionary|, it maps a linter to either a |String| containing the
|
||||
project root or a |Funcref| to call to look up the root. The |Funcref| is
|
||||
provided the buffer number as its argument.
|
||||
This option is used to determine the project root for a linter. When set to a
|
||||
|String| it will be used for all linters. When set to a |Dictionary|, the
|
||||
keys are linter names and the values are either |Strings| containing project
|
||||
roots or |Funcref|s which are passed the buffer number.
|
||||
|
||||
The buffer-specific variable may additionally be a string containing the
|
||||
The buffer-specific variable may additionally be a |String| containing the
|
||||
project root itself.
|
||||
|
||||
If neither variable yields a result, a linter-specific function is invoked to
|
||||
detect a project root. If this, too, yields no result, and the linter is an
|
||||
LSP linter, it will not run.
|
||||
If a value can be found from either variable, ALE uses it directly and skips
|
||||
searching for a project root. If no value is found, a linter-specific
|
||||
function is invoked to detect a project root. If this, too, yields no result
|
||||
and the linter is an LSP linter, it will not run.
|
||||
|
||||
*ale-options.save_hidden*
|
||||
*g:ale_save_hidden*
|
||||
@@ -3361,6 +3362,8 @@ documented in additional help files.
|
||||
bicep...................................|ale-bicep-options|
|
||||
bicep.................................|ale-bicep-bicep|
|
||||
az_bicep..............................|ale-bicep-az_bicep|
|
||||
bindzone................................|ale-bindzone-options|
|
||||
checkzone.............................|ale-bindzone-checkzone|
|
||||
bitbake.................................|ale-bitbake-options|
|
||||
oelint-adv............................|ale-bitbake-oelint_adv|
|
||||
c.......................................|ale-c-options|
|
||||
@@ -3632,6 +3635,8 @@ documented in additional help files.
|
||||
cspell................................|ale-latex-cspell|
|
||||
write-good............................|ale-latex-write-good|
|
||||
textlint..............................|ale-latex-textlint|
|
||||
lean....................................|ale-lean-options|
|
||||
lake..................................|ale-lean-lake|
|
||||
less....................................|ale-less-options|
|
||||
lessc.................................|ale-less-lessc|
|
||||
prettier..............................|ale-less-prettier|
|
||||
@@ -3784,6 +3789,7 @@ documented in additional help files.
|
||||
pylint................................|ale-python-pylint|
|
||||
pylsp.................................|ale-python-pylsp|
|
||||
pyre..................................|ale-python-pyre|
|
||||
pyrefly...............................|ale-python-pyrefly|
|
||||
pyright...............................|ale-python-pyright|
|
||||
refurb................................|ale-python-refurb|
|
||||
reorder-python-imports................|ale-python-reorder_python_imports|
|
||||
@@ -3818,6 +3824,10 @@ documented in additional help files.
|
||||
write-good............................|ale-restructuredtext-write-good|
|
||||
robot...................................|ale-robot-options|
|
||||
rflint................................|ale-robot-rflint|
|
||||
roc.....................................|ale-roc-options|
|
||||
roc_language_server...................|ale-roc-roc-language-server|
|
||||
roc_format............................|ale-roc-roc-format|
|
||||
roc_annotate..........................|ale-roc-roc-annotate|
|
||||
ruby....................................|ale-ruby-options|
|
||||
brakeman..............................|ale-ruby-brakeman|
|
||||
cspell................................|ale-ruby-cspell|
|
||||
|
||||
@@ -69,6 +69,8 @@ formatting.
|
||||
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
|
||||
* Bicep
|
||||
* [bicep](https://github.com/Azure/bicep) :floppy_disk:
|
||||
* Bindzone
|
||||
* [checkzone](https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool)
|
||||
* BitBake
|
||||
* [oelint-adv](https://github.com/priv-kweihmann/oelint-adv)
|
||||
* Bourne Shell
|
||||
@@ -379,6 +381,8 @@ formatting.
|
||||
* [textlint](https://textlint.github.io/)
|
||||
* [vale](https://github.com/ValeLint/vale)
|
||||
* [write-good](https://github.com/btford/write-good)
|
||||
* Lean 4
|
||||
* [lake](https://github.com/leanprover/lean4)
|
||||
* Less
|
||||
* [lessc](https://www.npmjs.com/package/less)
|
||||
* [prettier](https://github.com/prettier/prettier)
|
||||
@@ -550,6 +554,7 @@ formatting.
|
||||
* [pylint](https://www.pylint.org/) :floppy_disk:
|
||||
* [pylsp](https://github.com/python-lsp/python-lsp-server) :warning:
|
||||
* [pyre](https://github.com/facebook/pyre-check) :warning:
|
||||
* [pyrefly](https://github.com/facebook/pyrefly) :warning:
|
||||
* [pyright](https://github.com/microsoft/pyright)
|
||||
* [refurb](https://github.com/dosisod/refurb) :floppy_disk:
|
||||
* [reorder-python-imports](https://github.com/asottile/reorder_python_imports)
|
||||
@@ -593,6 +598,10 @@ formatting.
|
||||
* [write-good](https://github.com/btford/write-good)
|
||||
* Robot
|
||||
* [rflint](https://github.com/boakley/robotframework-lint)
|
||||
* Roc
|
||||
* [roc_annotate](https://github.com/roc-lang/roc)
|
||||
* [roc_format](https://github.com/roc-lang/roc)
|
||||
* [roc_language_server](https://github.com/roc-lang/roc)
|
||||
* RPM spec
|
||||
* [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`)
|
||||
* Ruby
|
||||
|
||||
@@ -14,7 +14,7 @@ Before:
|
||||
let g:ale_completion_enabled = 0
|
||||
let g:ale_completion_autoimport = 0
|
||||
let g:ale_completion_max_suggestions = 50
|
||||
let g:ale_linters = {'typescript': ['tsserver'], 'python': ['pyre']}
|
||||
let g:ale_linters = {'typescript': ['tsserver'], 'python': ['pyrefly']}
|
||||
unlet! b:ale_linters
|
||||
|
||||
let g:server_started_value = 1
|
||||
|
||||
@@ -1,48 +1,80 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('go', 'golangci_lint')
|
||||
Save g:ale_go_go111module
|
||||
Save g:ale_go_golangci_lint_executable
|
||||
Save g:ale_go_golangci_lint_options
|
||||
Save g:ale_go_golangci_lint_package
|
||||
Save g:ale_go_golangci_formatter_executable
|
||||
Save g:ale_go_golangci_formatter_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_go_golangci_lint_executable = 'xxxinvalid'
|
||||
let g:ale_go_golangci_lint_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
call ale#test#SetFilename('../test-files/go/testfile.go')
|
||||
|
||||
After:
|
||||
Restore
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
unlet! b:ale_go_go111module
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
Execute(The golangci-lint callback should return the correct default values with v1):
|
||||
|
||||
Execute(The golangci-lint callback should return the correct default values):
|
||||
GivenCommandOutput ['golangci-lint has version 1.64.8 built with go1.23.0']
|
||||
|
||||
AssertEqual
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid') . ' run --fix',
|
||||
\ 'command': ale#Escape('golangci-lint') . ' run --fix ' . ale#Escape('testfile.go'),
|
||||
\ }
|
||||
|
||||
Execute(The golangci-lint callback should include custom golangci-lint options with v1):
|
||||
let g:ale_go_golangci_formatter_options = "--new --config /dev/null"
|
||||
|
||||
GivenCommandOutput ['golangci-lint has version 1.64.8 built with go1.23.0']
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('golangci-lint')
|
||||
\ . ' run --fix ' . g:ale_go_golangci_formatter_options . ' ' . ale#Escape('testfile.go'),
|
||||
\ },
|
||||
\ ale#fixers#golangci_lint#Fix(bufnr(''))
|
||||
|
||||
Execute(The golangci-lint callback should include custom golangci-lint options):
|
||||
let g:ale_go_golangci_lint_options = "--new --config /dev/null"
|
||||
Execute(The golangci-lint callback should override executable with v1):
|
||||
let g:ale_go_golangci_formatter_executable = 'xxxinvalid'
|
||||
|
||||
AssertEqual
|
||||
GivenCommandOutput ['golangci-lint has version 1.64.8 built with go1.23.0']
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' run ' . g:ale_go_golangci_lint_options . ' --fix',
|
||||
\ . ' run --fix '
|
||||
\ . g:ale_go_golangci_formatter_options
|
||||
\ . ' ' . ale#Escape('testfile.go'),
|
||||
\ },
|
||||
\ ale#fixers#golangci_lint#Fix(bufnr(''))
|
||||
|
||||
Execute(The golangci-lint callback should support per-file mode):
|
||||
let g:ale_go_golangci_lint_package = 0
|
||||
Execute(The golangci-lint callback should return the correct default values with v2):
|
||||
|
||||
AssertEqual
|
||||
GivenCommandOutput ['golangci-lint has version 2.1.5 built with go1.23.0']
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('golangci-lint') . ' fmt --stdin ',
|
||||
\ }
|
||||
|
||||
Execute(The golangci-lint callback should include custom golangci-lint options with v2):
|
||||
let g:ale_go_golangci_formatter_options = "--new --config /dev/null"
|
||||
|
||||
GivenCommandOutput ['golangci-lint has version 2.1.5 built with go1.23.0']
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('golangci-lint')
|
||||
\ . ' fmt --stdin ' . g:ale_go_golangci_formatter_options,
|
||||
\ },
|
||||
|
||||
Execute(The golangci-lint callback should override executable with v2):
|
||||
let g:ale_go_golangci_formatter_executable = 'xxxinvalid'
|
||||
|
||||
GivenCommandOutput ['golangci-lint has version 2.1.5 built with go1.23.0']
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' run '
|
||||
\ . g:ale_go_golangci_lint_options
|
||||
\ . ' --fix ' . ale#Escape('testfile.go'),
|
||||
\ . ' fmt --stdin '
|
||||
\ . g:ale_go_golangci_formatter_options
|
||||
\ },
|
||||
\ ale#fixers#golangci_lint#Fix(bufnr(''))
|
||||
|
||||
20
test/fixers/test_roc_annotate_fixer_callback.vader
Normal file
20
test/fixers/test_roc_annotate_fixer_callback.vader
Normal file
@@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('roc', 'roc_annotate')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The roc annotate callback should return the correct default values):
|
||||
AssertFixer {
|
||||
\ 'command': 'roc format annotate %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
Execute(The roc annotate callback should allow a custom executable):
|
||||
let g:ale_roc_roc_annotate_executable = 'foo/bar'
|
||||
|
||||
AssertFixer {
|
||||
\ 'command': 'foo/bar format annotate %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
20
test/fixers/test_roc_format_fixer_callback.vader
Normal file
20
test/fixers/test_roc_format_fixer_callback.vader
Normal file
@@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('roc', 'roc_format')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The roc format callback should return the correct default values):
|
||||
AssertFixer {
|
||||
\ 'command': 'roc format %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
Execute(The roc format callback should allow a custom executable):
|
||||
let g:ale_roc_roc_format_executable = 'foo/bar'
|
||||
|
||||
AssertFixer {
|
||||
\ 'command': 'foo/bar format %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
26
test/handler/test_bindzone_checkzone.vader
Normal file
26
test/handler/test_bindzone_checkzone.vader
Normal file
@@ -0,0 +1,26 @@
|
||||
Before:
|
||||
runtime ale_linters/bindzone/checkzone.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The checkzone handler should handle basic warnings):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'unknown RR type ''fasd''',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'text': '_some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#bindzone#checkzone#Handle(1, [
|
||||
\ 'zone example.com/IN: _some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
|
||||
\ 'zone example.com/IN: loaded serial 2025050400',
|
||||
\ 'zone example.com/IN: not loaded due to errors',
|
||||
\ '/tmp/vb3wXsu/2/example.com:2: unknown RR type ''fasd''',
|
||||
\ ])
|
||||
@@ -107,7 +107,7 @@ Execute(The mypy handler should handle Windows names with spaces):
|
||||
\ {
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 0,
|
||||
\ 'filename': ale#path#Simplify('C:\something\with spaces.py'),
|
||||
\ 'filename': ale#path#GetAbsPath(getcwd(), 'C:\something\with spaces.py'),
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'No library stub file for module ''django.db''',
|
||||
\ },
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
Before:
|
||||
Save g:ale_warn_about_trailing_blank_lines
|
||||
Save g:ale_warn_about_trailing_whitespace
|
||||
|
||||
let g:ale_warn_about_trailing_blank_lines = 1
|
||||
let g:ale_warn_about_trailing_whitespace = 1
|
||||
|
||||
runtime ale_linters/python/ruff.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_warn_about_trailing_blank_lines
|
||||
unlet! b:ale_warn_about_trailing_whitespace
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(We should handle basic output of ruff correctly):
|
||||
@@ -41,3 +52,66 @@ Execute(We should handle mixed error lines and JSON output from ruff):
|
||||
\ 'ERROR: oh noes!',
|
||||
\ '{"cell":null,"code":"F821","end_location":{"column":8,"row":2},"filename":"/home/eduardo/Code/Python/test.py","fix":null,"location":{"column":1,"row":2},"message":"Undefined name example","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"}',
|
||||
\ ])
|
||||
|
||||
Execute(Warnings about trailing whitespace should be reported by default):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 6,
|
||||
\ 'col': 1,
|
||||
\ 'end_lnum': 6,
|
||||
\ 'end_col': 1,
|
||||
\ 'code': 'W291',
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'who cares',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 6,
|
||||
\ 'col': 1,
|
||||
\ 'end_lnum': 6,
|
||||
\ 'end_col': 1,
|
||||
\ 'code': 'W293',
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'who cares',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ '{"cell":null,"code":"W291","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"who cares","noqa_row":2,"url":""}',
|
||||
\ '{"cell":null,"code":"W293","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"who cares","noqa_row":2,"url":""}',
|
||||
\ ])
|
||||
|
||||
Execute(Disabling trailing whitespace warnings should work):
|
||||
let b:ale_warn_about_trailing_whitespace = 0
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ '{"cell":null,"code":"W291","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"who cares","noqa_row":2,"url":""}',
|
||||
\ '{"cell":null,"code":"W293","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"who cares","noqa_row":2,"url":""}',
|
||||
\ ])
|
||||
|
||||
Execute(Warnings about trailing blank lines should be reported by default):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 6,
|
||||
\ 'col': 1,
|
||||
\ 'end_lnum': 6,
|
||||
\ 'end_col': 1,
|
||||
\ 'code': 'W391',
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'blank line at end of file',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ '{"cell":null,"code":"W391","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"blank line at end of file","noqa_row":2,"url":""}',
|
||||
\ ])
|
||||
|
||||
Execute(Disabling trailing blank line warnings should work):
|
||||
let b:ale_warn_about_trailing_blank_lines = 0
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ '{"cell":null,"code":"W391","end_location":{"column":2,"row":6},"filename":"/test.py","fix":null,"location":{"column":1,"row":6},"message":"blank line at end of file","noqa_row":2,"url":""}',
|
||||
\ ])
|
||||
|
||||
19
test/linter/test_bindzone_checkzone.vader
Normal file
19
test/linter/test_bindzone_checkzone.vader
Normal file
@@ -0,0 +1,19 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('bindzone', 'checkzone')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'named-checkzone',
|
||||
\ ale#Escape('named-checkzone') . ' -c IN example.com %t'
|
||||
|
||||
Execute(The default command should be overridden):
|
||||
let b:ale_bindzone_checkzone_executable = '/bin/bind9-checkzone'
|
||||
AssertLinter '/bin/bind9-checkzone',
|
||||
\ ale#Escape('/bin/bind9-checkzone') . ' -c IN example.com %t'
|
||||
|
||||
Execute(The default options should be overridden):
|
||||
let b:ale_bindzone_checkzone_options = '-c IN -d'
|
||||
AssertLinter 'named-checkzone',
|
||||
\ ale#Escape('named-checkzone') . ' -c IN -d example.com %t'
|
||||
@@ -125,35 +125,35 @@ Execute(The flake8 callbacks should detect virtualenv directories):
|
||||
\ . ' --stdin-display-name %s -',
|
||||
\]
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
|
||||
Execute(FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
|
||||
Execute(FindProjectRoot should detect the project root directory for namespace package via setup.cf):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
|
||||
Execute(FindProjectRoot should ignore the location of pytest.ini):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest/namespace'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
|
||||
Execute(FindProjectRoot should detect the project root directory for namespace package via tox.ini):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
|
||||
Execute(FindProjectRoot should detect the project root directory for non-namespace package):
|
||||
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
|
||||
@@ -111,41 +111,6 @@ Execute(The flakehell callbacks should detect virtualenv directories):
|
||||
\ . ' --stdin-display-name %s -',
|
||||
\]
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
|
||||
call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
|
||||
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
" Some users currently run flakehell this way, so we should support it.
|
||||
Execute(Using `python -m flakehell` should be supported for running flakehell):
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
27
test/linter/test_lean_lake.vader
Normal file
27
test/linter/test_lean_lake.vader
Normal file
@@ -0,0 +1,27 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('lean', 'lake')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'lake', ale#Escape('lake') . ' serve'
|
||||
|
||||
Execute(The project root should be detected correctly without a lakefile):
|
||||
AssertLSPProject '.'
|
||||
|
||||
Execute(The project root should be detected correctly from .toml):
|
||||
call ale#test#SetFilename('../test-files/lean/lakefile_toml/lakefile.toml')
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/lean/lakefile_toml')
|
||||
|
||||
Execute(The project root should be detected correctly from .lean):
|
||||
call ale#test#SetFilename('../test-files/lean/lakefile_lean/lakefile.lean')
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/lean/lakefile_lean')
|
||||
|
||||
Execute(The LSP values should be set correctly):
|
||||
call ale#test#SetFilename('../test-files/lean/lakefile_lean/Main.lean')
|
||||
|
||||
AssertLSPLanguage 'lean'
|
||||
AssertLSPOptions {}
|
||||
AssertLSPConfig {}
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/lean/lakefile_lean')
|
||||
69
test/linter/test_pyrefly.vader
Normal file
69
test/linter/test_pyrefly.vader
Normal file
@@ -0,0 +1,69 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('python', 'pyrefly')
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
unlet! b:bin_dir
|
||||
unlet! b:executable
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The pyrefly command callback should return default string):
|
||||
call ale#test#SetFilename('./foo.py')
|
||||
|
||||
AssertLinter 'pyrefly', ale#Escape('pyrefly') . ' lsp'
|
||||
|
||||
Execute(The pyrefly executable should be configurable):
|
||||
let g:ale_python_pyrefly_executable = '~/.local/bin/pyrefly'
|
||||
|
||||
AssertLinter '~/.local/bin/pyrefly',
|
||||
\ ale#Escape('~/.local/bin/pyrefly') . ' lsp'
|
||||
|
||||
Execute(The pyrefly executable should be run from the virtualenv path):
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
let b:executable = ale#path#Simplify(
|
||||
\ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pyrefly'
|
||||
\)
|
||||
|
||||
AssertLinter b:executable, ale#Escape(b:executable) . ' lsp'
|
||||
|
||||
Execute(You should be able to override the pyrefly virtualenv lookup):
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
let g:ale_python_pyrefly_use_global = 1
|
||||
|
||||
AssertLinter 'pyrefly', ale#Escape('pyrefly') . ' lsp'
|
||||
|
||||
Execute(Setting executable to 'pipenv' appends 'run pyrefly'):
|
||||
let g:ale_python_pyrefly_executable = 'path/to/pipenv'
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLinter 'path/to/pipenv',
|
||||
\ ale#Escape('path/to/pipenv') . ' run pyrefly lsp'
|
||||
|
||||
Execute(Pipenv is detected when python_pyrefly_auto_pipenv is set):
|
||||
let g:ale_python_pyrefly_auto_pipenv = 1
|
||||
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
|
||||
|
||||
AssertLinter 'pipenv',
|
||||
\ ale#Escape('pipenv') . ' run pyrefly lsp'
|
||||
|
||||
Execute(Setting executable to 'poetry' appends 'run pyrefly lsp'):
|
||||
let g:ale_python_pyrefly_executable = 'path/to/poetry'
|
||||
|
||||
AssertLinter 'path/to/poetry',
|
||||
\ ale#Escape('path/to/poetry') . ' run pyrefly lsp'
|
||||
|
||||
Execute(Poetry is detected when python_pyrefly_auto_poetry is set):
|
||||
let g:ale_python_pyrefly_auto_poetry = 1
|
||||
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
|
||||
|
||||
AssertLinter 'poetry',
|
||||
\ ale#Escape('poetry') . ' run pyrefly lsp'
|
||||
|
||||
Execute(uv is detected when python_pyrefly_auto_uv is set):
|
||||
let g:ale_python_pyrefly_auto_uv = 1
|
||||
call ale#test#SetFilename('../test-files/python/uv/whatever.py')
|
||||
|
||||
AssertLinter 'uv',
|
||||
\ ale#Escape('uv') . ' run pyrefly lsp'
|
||||
23
test/linter/test_roc_roc_language_server.vader
Normal file
23
test/linter/test_roc_roc_language_server.vader
Normal file
@@ -0,0 +1,23 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('roc', 'roc_language_server')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'roc_language_server', ale#Escape('roc_language_server')
|
||||
|
||||
Execute(The project root should be detected correctly in empty directory):
|
||||
AssertLSPProject '.'
|
||||
|
||||
Execute(The project root should be detected correctly with main.roc):
|
||||
call ale#test#SetFilename('../test-files/roc/main.roc')
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/roc')
|
||||
|
||||
Execute(The LSP values should be set correctly):
|
||||
call ale#test#SetFilename('../test-files/roc/main.roc')
|
||||
|
||||
AssertLSPLanguage 'roc'
|
||||
AssertLSPOptions {}
|
||||
AssertLSPConfig {}
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/roc')
|
||||
0
test/test-files/lean/lakefile_lean/Main.lean
Normal file
0
test/test-files/lean/lakefile_lean/Main.lean
Normal file
0
test/test-files/lean/lakefile_lean/lakefile.lean
Normal file
0
test/test-files/lean/lakefile_lean/lakefile.lean
Normal file
0
test/test-files/lean/lakefile_toml/Main.lean
Normal file
0
test/test-files/lean/lakefile_toml/Main.lean
Normal file
0
test/test-files/lean/lakefile_toml/lakefile.toml
Normal file
0
test/test-files/lean/lakefile_toml/lakefile.toml
Normal file
0
test/test-files/python/with_virtualenv/env/Scripts/pyrefly.exe
vendored
Executable file
0
test/test-files/python/with_virtualenv/env/Scripts/pyrefly.exe
vendored
Executable file
0
test/test-files/python/with_virtualenv/env/bin/pyrefly
vendored
Executable file
0
test/test-files/python/with_virtualenv/env/bin/pyrefly
vendored
Executable file
0
test/test-files/roc/main.roc
Normal file
0
test/test-files/roc/main.roc
Normal file
@@ -13,6 +13,15 @@ Execute(Relative paths should be resolved correctly):
|
||||
AssertEqual
|
||||
\ 'C:\foo\bar\baz\whatever.txt',
|
||||
\ ale#path#GetAbsPath('C:\foo\bar\baz\xyz', '../whatever.txt')
|
||||
AssertEqual
|
||||
\ 'C:\foo\bar\baz\whatever.txt',
|
||||
\ ale#path#GetAbsPath('C:\foo\bar\baz\xyz', '..\whatever.txt')
|
||||
AssertEqual
|
||||
\ 'C:\foo\bar\baz\whatever.txt',
|
||||
\ ale#path#GetAbsPath('C:/foo/bar/baz/xyz', '../whatever.txt')
|
||||
AssertEqual
|
||||
\ 'C:\foo\bar\baz\whatever.txt',
|
||||
\ ale#path#GetAbsPath('C:/foo/bar/baz/xyz', '..\whatever.txt')
|
||||
endif
|
||||
|
||||
Execute(Absolute paths should be resolved correctly):
|
||||
@@ -26,4 +35,12 @@ Execute(Absolute paths should be resolved correctly):
|
||||
|
||||
if has('win32')
|
||||
AssertEqual '\ding', ale#path#GetAbsPath('/foo/bar/xyz', '\\ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('/foo/bar/xyz', 'c:/ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('/foo/bar/xyz', 'c:\ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('\foo\bar\xyz', 'c:/ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('\foo\bar\xyz', 'c:\ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:/foo/bar/xyz', 'c:/ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:/foo/bar/xyz', 'c:\ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:\foo\bar\xyz', 'c:/ding')
|
||||
AssertEqual 'c:\ding', ale#path#GetAbsPath('c:\foo\bar\xyz', 'c:\ding')
|
||||
endif
|
||||
|
||||
@@ -407,7 +407,7 @@ Execute(PreProcess should allow the `project_root` to be set as a String):
|
||||
\ 'project_root': '/foo/bar',
|
||||
\})
|
||||
|
||||
AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter)
|
||||
AssertEqual '/foo/bar', ale#linter#GetRoot(0, g:linter)
|
||||
|
||||
Execute(PreProcess should `project_root` be set as a Function):
|
||||
let g:linter = ale#linter#PreProcess('testft', {
|
||||
@@ -418,7 +418,7 @@ Execute(PreProcess should `project_root` be set as a Function):
|
||||
\ 'project_root': {-> '/foo/bar'},
|
||||
\})
|
||||
|
||||
AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter)
|
||||
AssertEqual '/foo/bar', ale#linter#GetRoot(0, g:linter)
|
||||
|
||||
Execute(PreProcess should complain when `project_root` is invalid):
|
||||
AssertThrows call ale#linter#PreProcess('testft', {
|
||||
|
||||
27
test/test_python_root_option.vader
Normal file
27
test/test_python_root_option.vader
Normal file
@@ -0,0 +1,27 @@
|
||||
Before:
|
||||
Save g:ale_root
|
||||
Save b:ale_root
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
After:
|
||||
Restore
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The global setting is used as the project root):
|
||||
let g:ale_root = '/foo/python'
|
||||
call ale#test#SetFilename('test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual '/foo/python', ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(The buffer setting overrides the global setting):
|
||||
let g:ale_root = '/foo/python'
|
||||
let b:ale_root = '/bar/python'
|
||||
call ale#test#SetFilename('test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual '/bar/python', ale#python#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(Fallback to searching when no setting is used):
|
||||
unlet! g:ale_root
|
||||
unlet! b:ale_root
|
||||
call ale#test#SetFilename('test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual \
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
||||
Reference in New Issue
Block a user