]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp/autoload/lsp/utils/args.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 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / autoload / lsp / utils / args.vim
1 function! lsp#utils#args#_parse(args, opt, remainder_key) abort
2     let l:result = {}
3     let l:is_opts = v:true
4     let l:remainder = []
5     for l:item in split(a:args, ' ')
6         if l:item[:1] !=# '--'
7             let l:is_opts = v:false
8         endif
9
10         if l:is_opts == v:false
11             call add(l:remainder, l:item)
12             continue
13         endif
14
15         let l:parts = split(l:item, '=')
16         let l:key = l:parts[0]
17         let l:value = get(l:parts, 1, '')
18         let l:key = l:key[2:]
19
20         if has_key(a:opt, l:key)
21             if has_key(a:opt[l:key], 'type')
22                 let l:type = a:opt[l:key]['type']
23                 if l:type == type(v:true)
24                     if l:value ==# 'false' || l:value ==# '0' || l:value ==# ''
25                         let l:value = 0
26                     else
27                         let l:value = 1
28                     endif
29                 elseif l:type ==# type(0)
30                     let l:value = str2nr(l:value)
31                 endif
32             endif
33         endif
34         let l:result[l:key] = l:value
35     endfor
36
37     if a:remainder_key != v:null
38         let l:result[a:remainder_key] = join(l:remainder)
39     endif
40
41     return l:result
42 endfunction