aboutsummaryrefslogtreecommitdiff
path: root/test/lsp_settings.vimspec
blob: 3b349418d9ebf4e1ae98a3d306b4e01a8d5384bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Describe lsp_settings
    Describe lsp_settings#get
        It should return configuration value from key and name
            Assert Equals(lsp_settings#get('pyls', 'cmd', 'bad'), 'bad')
            let g:lsp_settings = {'pyls': {'cmd': 'good'}}
            Assert Equals(lsp_settings#get('pyls', 'cmd', 'bad'), 'good')
            unlet g:lsp_settings
        End

        It should return default value with lambda
            Assert Equals(lsp_settings#get('pyls', 'cmd', {key, name-> 'good'}), 'good')
        End
    End

    Describe lsp_settings#executable
        It should return command is executable in $PATH
            if has('win32')
                Assert Equals(lsp_settings#executable('cmd'), 1)
            else
                Assert Equals(lsp_settings#executable('sh'), 1)
			endif
            Assert Equals(lsp_settings#executable('unknown-command'), 0)
        End

        It should return command is executable in server/foo-bar/foo-bar
			let l:servers_dir = fnamemodify(expand('<sfile>:h:h').'/servers', ':p')

            try
                call delete(l:servers_dir . '/foo-bar', 'rf')
                call mkdir(l:servers_dir . '/foo-bar')
                call writefile(['echo foo-bar'], l:servers_dir . '/foo-bar/foo-bar.cmd')
                Assert Equals(lsp_settings#executable('foo-bar'), 1)
            finally
                call delete(l:servers_dir . '/foo-bar', 'rf')
            endtry
        End
    End
End