mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
tombi: support its LSP (#5022)
* tombi: support its LSP * tombi: support linting and formatting
This commit is contained in:
45
ale_linters/toml/tombi.vim
Normal file
45
ale_linters/toml/tombi.vim
Normal file
@@ -0,0 +1,45 @@
|
||||
" Author: Ben Boeckel <github@me.benboeckel.net>
|
||||
" Description: TOML Formatter / Linter / Language Server
|
||||
|
||||
call ale#Set('toml_tombi_executable', 'tombi')
|
||||
call ale#Set('toml_tombi_lsp_options', '')
|
||||
|
||||
function! ale_linters#toml#tombi#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'toml_tombi_lsp_options')
|
||||
|
||||
return '%e lsp'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#toml#tombi#GetProjectRoot(buffer) abort
|
||||
" Try to find nearest tombi.toml
|
||||
let l:tombiconfig_file = ale#path#FindNearestFile(a:buffer, 'tombi.toml')
|
||||
|
||||
if !empty(l:tombiconfig_file)
|
||||
return fnamemodify(l:tombiconfig_file . '/', ':p:h:h')
|
||||
endif
|
||||
|
||||
" Try to find nearest pyproject.toml
|
||||
let l:pyproject_file = ale#path#FindNearestFile(a:buffer, 'pyproject.toml')
|
||||
|
||||
if !empty(l:pyproject_file)
|
||||
return fnamemodify(l:pyproject_file . '/', ':p:h:h')
|
||||
endif
|
||||
|
||||
" Try to find nearest `git` directory
|
||||
let l:gitdir = ale#path#FindNearestFile(a:buffer, '.git')
|
||||
|
||||
if !empty(l:gitdir)
|
||||
return fnamemodify(l:gitdir . '/', ':p:h:h')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('toml', {
|
||||
\ 'name': 'tombi',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'toml_tombi_executable')},
|
||||
\ 'command': function('ale_linters#toml#tombi#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#toml#tombi#GetProjectRoot'),
|
||||
\})
|
||||
Reference in New Issue
Block a user