mirror of
https://github.com/dense-analysis/ale
synced 2025-01-13 02:25:55 +00:00
b504eeb094
It's necessary to provide a `-l` option to pyre with the closest parent directory containing a `.pyre_configuration.local` file, or simply change directory (cwd) to the root of the pyre project. Thanks to Ken Verbosky for the code that fixes this. Error seen when not using such a solution: ``` 1031.473923 on 6: Dropping message 'ƛ Background task unexpectedly quited: Invalid configuration: Cannot find any source files to analyze. Either `source_directories` or `targets` must be specified. ``` Issue with this approach is that if you are editing files under different projects, the `pyre persistent` process is not re-created for each file. We have to do `:ALEStopAlllsps` in order for the process to start with the new working directory. Co-authored-by: Oliver Ruben Albertini <ora@fb.com>
45 lines
1.7 KiB
VimL
45 lines
1.7 KiB
VimL
" Author: dsifford <dereksifford@gmail.com>
|
|
" Description: A performant type-checker supporting LSP for Python 3 created by Facebook
|
|
|
|
call ale#Set('python_pyre_executable', 'pyre')
|
|
call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0))
|
|
call ale#Set('python_pyre_auto_pipenv', 0)
|
|
call ale#Set('python_pyre_auto_poetry', 0)
|
|
|
|
function! ale_linters#python#pyre#GetExecutable(buffer) abort
|
|
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv'))
|
|
\ && ale#python#PipenvPresent(a:buffer)
|
|
return 'pipenv'
|
|
endif
|
|
|
|
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyre_auto_poetry'))
|
|
\ && ale#python#PoetryPresent(a:buffer)
|
|
return 'poetry'
|
|
endif
|
|
|
|
return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre'])
|
|
endfunction
|
|
|
|
function! ale_linters#python#pyre#GetCommand(buffer) abort
|
|
let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer)
|
|
let l:exec_args = (l:executable =~? 'pipenv\|poetry$' ? ' run pyre' : '') . ' persistent'
|
|
|
|
return ale#Escape(l:executable) . l:exec_args
|
|
endfunction
|
|
|
|
function! ale_linters#python#pyre#GetCwd(buffer) abort
|
|
let l:local_config = ale#path#FindNearestFile(a:buffer, '.pyre_configuration.local')
|
|
|
|
return fnamemodify(l:local_config, ':h')
|
|
endfunction
|
|
|
|
call ale#linter#Define('python', {
|
|
\ 'name': 'pyre',
|
|
\ 'lsp': 'stdio',
|
|
\ 'executable': function('ale_linters#python#pyre#GetExecutable'),
|
|
\ 'command': function('ale_linters#python#pyre#GetCommand'),
|
|
\ 'project_root': function('ale#python#FindProjectRoot'),
|
|
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
|
|
\ 'cwd': function('ale_linters#python#pyre#GetCwd'),
|
|
\})
|