From c588857b64808afc660b721e12d78389ec57e205 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 31 Jan 2020 18:28:14 +0900 Subject: Add test --- autoload/lsp_settings.vim | 4 ++++ test/lsp_settings.vimspec | 34 +++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index 9762f6b..55d9452 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -398,6 +398,10 @@ function! s:vim_lsp_load_or_suggest(ft) abort endif endfunction +function! lsp_settings#clear() abort + let s:ftmap = {} +endfunction + function! lsp_settings#init() abort for l:ft in keys(s:settings) if has_key(g:, 'lsp_settings_whitelist') && index(g:lsp_settings_whitelist, l:ft) == -1 || empty(s:settings[l:ft]) diff --git a/test/lsp_settings.vimspec b/test/lsp_settings.vimspec index a03d4bd..2485ca1 100644 --- a/test/lsp_settings.vimspec +++ b/test/lsp_settings.vimspec @@ -20,12 +20,12 @@ Describe lsp_settings Assert Equals(lsp_settings#executable('cmd'), 1) else Assert Equals(lsp_settings#executable('sh'), 1) - endif + 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() + let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') @@ -37,7 +37,7 @@ Describe lsp_settings End It should return 1 when command is executable in server/foo-bar/foo-bar - let l:servers_dir = lsp_settings#servers_dir() + let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') @@ -61,11 +61,11 @@ Describe lsp_settings Assert Equals(empty(lsp_settings#exec_path('cmd')), 0) else Assert Equals(empty(lsp_settings#exec_path('sh')), 0) - endif + endif End It should return 1 when command is executable in server/foo-bar/foo-bar - let l:servers_dir = lsp_settings#servers_dir() + let l:servers_dir = lsp_settings#servers_dir() try call delete(l:servers_dir . '/foo-bar', 'rf') @@ -86,12 +86,32 @@ Describe lsp_settings Describe lsp_settings#init It should setup commands and autocmds. + call lsp_settings#clear() call lsp_settings#init() autocmd vim_lsp_suggest_python Assert exists(':LspInstallServer') delcommand LspInstallServer - for v in map(filter(split(execute('autocmd'), '\n'), 'v:val=~"^vim_lsp_"'), 'split(v:val, " ")[0]') - exe 'autocmd!' v + Assert !exists('#vim_lsp_suggest_efm_langserver') + for v in filter(split(execute('augroup'), '\s\+'), 'v:val=~"^vim_lsp_"') + exe 'augroup ' . v + autocmd! + augroup END + exe 'augroup! ' . v + endfor + bw! + End + + It should setup commands and autocmds with python. + call lsp_settings#clear() + call lsp_settings#init() + new + Throw /E117/ :setfiletype python + bw! + for v in filter(split(execute('augroup'), '\s\+'), 'v:val=~"^vim_lsp_suggest"') + exe 'augroup ' . v + autocmd! + augroup END + exe 'augroup! ' . v endfor End End -- cgit v1.2.3-54-g00ecf