scriptencoding utf-8
" Author: Ye Jingchen <ye.jingchen@gmail.com>
" Description: Utilities for ccls

function! ale#handlers#ccls#GetProjectRoot(buffer) abort
    " Try to find ccls configuration files first.
    let l:config = ale#path#FindNearestFile(a:buffer, '.ccls-root')

    if empty(l:config)
        let l:config = ale#path#FindNearestFile(a:buffer, '.ccls')
    endif

    if !empty(l:config)
        return fnamemodify(l:config, ':h')
    endif

    " Fall back on default project root detection.
    return ale#c#FindProjectRoot(a:buffer)
endfunction
