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 0 when command is not in server/foo-bar/foo-bar let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') call mkdir(l:servers_dir . '/foo-bar', 'p') Assert Equals(lsp_settings#executable('foo-bar'), 0) finally call delete(l:servers_dir . '/foo-bar', 'rf') endtry End It should return 1 when command is executable in server/foo-bar/foo-bar let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') call mkdir(l:servers_dir . '/foo-bar', 'p') if has('win32') call writefile(['@echo off', 'echo foo-bar'], l:servers_dir . '/foo-bar/foo-bar.cmd') else call writefile(['#!/bin/sh', 'echo foo-bar'], l:servers_dir . '/foo-bar/foo-bar') call setfperm(l:servers_dir . '/foo-bar/foo-bar', 'rwxr-xr-x') endif Assert Equals(lsp_settings#executable('foo-bar'), 1) finally call delete(l:servers_dir . '/foo-bar', 'rf') endtry End End Describe lsp_settings#exec_path It should return full-path to the command if has('win32') Assert Equals(empty(lsp_settings#exec_path('cmd')), 0) else Assert Equals(empty(lsp_settings#exec_path('sh')), 0) endif End It should return 1 when command is executable in server/foo-bar/foo-bar let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') call mkdir(l:servers_dir . '/foo-bar', 'p') if has('win32') call writefile(['@echo off', 'echo foo-bar'], l:servers_dir . '/foo-bar/foo-bar.cmd') Assert Equals(lsp_settings#exec_path('foo-bar'), l:servers_dir . '\foo-bar\foo-bar.cmd') else call writefile(['#!/bin/sh', 'echo foo-bar'], l:servers_dir . '/foo-bar/foo-bar') call setfperm(l:servers_dir . '/foo-bar/foo-bar', 'rwxr-xr-x') Assert Equals(lsp_settings#exec_path('foo-bar'), l:servers_dir . '/foo-bar/foo-bar') endif finally call delete(l:servers_dir . '/foo-bar', 'rf') endtry End End End