Add support for the Lean 4 LSP, served by lake. (#4952)

This commit is contained in:
Benjamin Block
2025-04-25 21:48:39 -04:00
committed by GitHub
parent baaca9a5d7
commit d0cdde7516
10 changed files with 90 additions and 0 deletions

28
ale_linters/lean/lake.vim Normal file
View 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'),
\})