]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/python/jedils.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / python / jedils.vim
1 " Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
2 " Description: https://github.com/pappasam/jedi-language-server
3
4 call ale#Set('python_jedils_executable', 'jedi-language-server')
5 call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('python_jedils_auto_pipenv', 0)
7 call ale#Set('python_jedils_auto_poetry', 0)
8 call ale#Set('python_jedils_auto_uv', 0)
9
10 function! ale_linters#python#jedils#GetExecutable(buffer) abort
11     if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv'))
12     \ && ale#python#PipenvPresent(a:buffer)
13         return 'pipenv'
14     endif
15
16     if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_jedils_auto_poetry'))
17     \ && ale#python#PoetryPresent(a:buffer)
18         return 'poetry'
19     endif
20
21     if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_jedils_auto_uv'))
22     \ && ale#python#UvPresent(a:buffer)
23         return 'uv'
24     endif
25
26     return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server'])
27 endfunction
28
29 function! ale_linters#python#jedils#GetCommand(buffer) abort
30     let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer)
31     let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
32     \   ? ' run jedi-language-server'
33     \   : ''
34     let l:env_string = ''
35
36     if ale#Var(a:buffer, 'python_auto_virtualenv')
37         let l:env_string = ale#python#AutoVirtualenvEnvString(a:buffer)
38     endif
39
40     return l:env_string . ale#Escape(l:executable) . l:exec_args
41 endfunction
42
43 call ale#linter#Define('python', {
44 \   'name': 'jedils',
45 \   'aliases': ['jedi_language_server'],
46 \   'lsp': 'stdio',
47 \   'executable': function('ale_linters#python#jedils#GetExecutable'),
48 \   'command': function('ale_linters#python#jedils#GetCommand'),
49 \   'project_root': function('ale#python#FindProjectRoot'),
50 \   'completion_filter': 'ale#completion#python#CompletionItemFilter',
51 \})