dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.51k stars 1.43k forks source link

Add support for clojure-lsp #4677

Open hoclun-rigsep opened 9 months ago

hoclun-rigsep commented 9 months ago

Name: clojure-lsp URL: https://clojure-lsp.io

Clojure-lsp seems to be the consensus LSP implementation for Clojure and I'd like it for the refactoring etc commands that ALE provides but that, to my understanding, require an LSP not just a linter like clj-kondo. Thanks for reading!

hoclun-rigsep commented 5 months ago

If I could just figure out how to set project_root I would pr this myself.

hoclun-rigsep commented 5 months ago
function! GetCljProjectRoot(buffer) abort                                
    let l:project_root = ale#path#FindNearestFile(a:buffer, 'deps.edn')  

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

    return ''                                                            
endfunction                                                              

call ale#linter#Define('clojure', {                                      
\   'name': 'clojure-lsp',                                               
\   'lsp': 'stdio',                                                      
\   'executable': '/usr/local/bin/clojure-lsp',                          
\   'command': '/usr/local/bin/clojure-lsp',                             
\   'project_root': function('GetCljProjectRoot'),                       
\})