diff options
author | w0rp <devw0rp@gmail.com> | 2023-09-14 00:38:12 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2023-09-14 00:40:56 +0100 |
commit | be69af270547b0d1dd5fe947efb3f61455f709ed (patch) | |
tree | 3d72ab429ed3d6025fb88accbd2be753fb78f26a /ale_linters/ansible/language_server.vim | |
parent | 9092af9ad6a5c93a759be571323ea1d0cafa8d6e (diff) | |
download | ale-be69af270547b0d1dd5fe947efb3f61455f709ed.zip |
#4607 No conflicts with nvim-lspconfig by default
Default `g:ale_disable_lsp` to a new mode `'auto'` by default. With this
setting applied, ALE will now check for the presence of nvim-lspconfig
and automatically turn off particular LSP linters if already configured
via nvim-lspconfig.
For users that do not use `nvim-lspconfig`, everything should work as
before.
Diffstat (limited to 'ale_linters/ansible/language_server.vim')
-rw-r--r-- | ale_linters/ansible/language_server.vim | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ale_linters/ansible/language_server.vim b/ale_linters/ansible/language_server.vim new file mode 100644 index 00000000..0c064353 --- /dev/null +++ b/ale_linters/ansible/language_server.vim @@ -0,0 +1,47 @@ +" Author: Horacio Sanson <https://github.com/hsanson> +" Description: Support ansible language server https://github.com/ansible/ansible-language-server/ + +call ale#Set('ansible_language_server_executable', 'ansible-language-server') +call ale#Set('ansible_language_server_config', {}) + +function! ale_linters#ansible#language_server#Executable(buffer) abort + return ale#Var(a:buffer, 'ansible_language_server_executable') +endfunction + +function! ale_linters#ansible#language_server#GetCommand(buffer) abort + let l:executable = ale_linters#ansible#language_server#Executable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#ansible#language_server#FindProjectRoot(buffer) abort + let l:dir = fnamemodify( + \ ale#path#FindNearestFile(a:buffer, 'ansible.cfg'), + \ ':h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + + let l:dir = fnamemodify( + \ ale#path#FindNearestDirectory(a:buffer, '.git'), + \ ':h:h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + + return '' +endfunction + +call ale#linter#Define('ansible', { +\ 'name': 'language_server', +\ 'aliases': ['ansible_language_server', 'ansible-language-server'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#ansible#language_server#Executable'), +\ 'command': function('ale_linters#ansible#language_server#GetCommand'), +\ 'project_root': function('ale_linters#ansible#language_server#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'ansible_language_server_config')} +\}) |