mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-13 20:41:04 +08:00
Report LSP status without autoload false negatives (#20)
This commit is contained in:
parent
1c54077487
commit
097c8abcd7
2 changed files with 97 additions and 5 deletions
|
|
@ -147,12 +147,58 @@ function! s:Off(name, reason) abort
|
|||
return ' off ' . a:name . ' (' . a:reason . ')'
|
||||
endfunction
|
||||
|
||||
function! s:LspCheck(ft, server) abort
|
||||
if !get(g:, 'chopsticks_enable_lsp', 1)
|
||||
return s:Off(a:ft, 'LSP disabled by profile')
|
||||
function! s:PlugDir(name) abort
|
||||
if !exists('g:plugs') || !has_key(g:plugs, a:name)
|
||||
return ''
|
||||
endif
|
||||
if !exists('*lsp#get_server_names')
|
||||
return ' -- ' . a:ft . ' (vim-lsp not loaded)'
|
||||
return fnamemodify(get(g:plugs[a:name], 'dir', ''), ':p')
|
||||
endfunction
|
||||
|
||||
function! s:PlugInstalled(name) abort
|
||||
let l:dir = s:PlugDir(a:name)
|
||||
return !empty(l:dir) && isdirectory(l:dir)
|
||||
endfunction
|
||||
|
||||
function! s:LspStackIssue() abort
|
||||
if !get(g:, 'chopsticks_enable_lsp', 1)
|
||||
return 'LSP disabled by profile'
|
||||
endif
|
||||
if empty(s:PlugDir('vim-lsp'))
|
||||
return 'vim-lsp not declared by this profile'
|
||||
endif
|
||||
if !s:PlugInstalled('vim-lsp')
|
||||
return 'vim-lsp not installed; run :PlugInstall'
|
||||
endif
|
||||
if empty(s:PlugDir('vim-lsp-settings'))
|
||||
return 'vim-lsp-settings not declared by this profile'
|
||||
endif
|
||||
if !s:PlugInstalled('vim-lsp-settings')
|
||||
return 'vim-lsp-settings not installed; run :PlugInstall'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:LspStackCheck() abort
|
||||
let l:issue = s:LspStackIssue()
|
||||
if l:issue ==# 'LSP disabled by profile'
|
||||
return s:Off('vim-lsp stack', l:issue)
|
||||
endif
|
||||
if !empty(l:issue)
|
||||
return ' -- vim-lsp stack (' . l:issue . ')'
|
||||
endif
|
||||
if exists(':LspStatus') == 2 || exists(':LspInstallServer') == 2
|
||||
return ' OK vim-lsp stack (installed)'
|
||||
endif
|
||||
return ' OK vim-lsp stack (installed; not loaded yet)'
|
||||
endfunction
|
||||
|
||||
function! s:LspCheck(ft, server) abort
|
||||
let l:issue = s:LspStackIssue()
|
||||
if l:issue ==# 'LSP disabled by profile'
|
||||
return s:Off(a:ft, l:issue)
|
||||
endif
|
||||
if !empty(l:issue)
|
||||
return ' -- ' . a:ft . ' (' . l:issue . ')'
|
||||
endif
|
||||
let l:dir = expand('~/.local/share/vim-lsp-settings/servers/' . a:server)
|
||||
if isdirectory(l:dir)
|
||||
|
|
@ -178,6 +224,7 @@ function! s:ChopsticksStatus() abort
|
|||
call add(l:lines, '')
|
||||
|
||||
call add(l:lines, '── lsp servers ── (:LspInstallServer to install)')
|
||||
call add(l:lines, s:LspStackCheck())
|
||||
call add(l:lines, s:LspCheck('python', 'pylsp'))
|
||||
call add(l:lines, s:LspCheck('go', 'gopls'))
|
||||
call add(l:lines, s:LspCheck('rust', 'rust-analyzer'))
|
||||
|
|
|
|||
|
|
@ -186,6 +186,51 @@ check_vim() {
|
|||
-c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") | cquit | endif' \
|
||||
-c 'qa!' 2>&1
|
||||
|
||||
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
|
||||
-c 'ChopsticksStatus' \
|
||||
-c "redir! > $TMP_ROOT/status-default.txt" \
|
||||
-c 'silent %print' \
|
||||
-c 'redir END' \
|
||||
-c 'qa!' 2>&1
|
||||
if grep -Fq 'vim-lsp not loaded' "$TMP_ROOT/status-default.txt"; then
|
||||
cat "$TMP_ROOT/status-default.txt"
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq 'OK vim-lsp stack (installed)' "$TMP_ROOT/status-default.txt"
|
||||
grep -Fq 'python (:LspInstallServer in a python file)' "$TMP_ROOT/status-default.txt"
|
||||
|
||||
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
|
||||
-c 'silent! delcommand LspStatus' \
|
||||
-c 'silent! delcommand LspInstallServer' \
|
||||
-c 'ChopsticksStatus' \
|
||||
-c "redir! > $TMP_ROOT/status-lsp-not-loaded.txt" \
|
||||
-c 'silent %print' \
|
||||
-c 'redir END' \
|
||||
-c 'qa!' 2>&1
|
||||
grep -Fq 'OK vim-lsp stack (installed; not loaded yet)' "$TMP_ROOT/status-lsp-not-loaded.txt"
|
||||
|
||||
vim -u NONE -i NONE -es -N \
|
||||
-c 'let g:chopsticks_profile = "minimal"' \
|
||||
-c 'source .vimrc' \
|
||||
-c 'ChopsticksStatus' \
|
||||
-c "redir! > $TMP_ROOT/status-minimal.txt" \
|
||||
-c 'silent %print' \
|
||||
-c 'redir END' \
|
||||
-c 'qa!' 2>&1
|
||||
grep -Fq 'off vim-lsp stack (LSP disabled by profile)' "$TMP_ROOT/status-minimal.txt"
|
||||
grep -Fq 'off python (LSP disabled by profile)' "$TMP_ROOT/status-minimal.txt"
|
||||
|
||||
mkdir -p "$TMP_ROOT/missing-home/.vim/autoload"
|
||||
cp "$HOME/.vim/autoload/plug.vim" "$TMP_ROOT/missing-home/.vim/autoload/plug.vim"
|
||||
HOME="$TMP_ROOT/missing-home" XDG_CONFIG_HOME="$EMPTY_XDG" \
|
||||
vim -u .vimrc -i NONE -es -N \
|
||||
-c 'ChopsticksStatus' \
|
||||
-c "redir! > $TMP_ROOT/status-missing-plugin.txt" \
|
||||
-c 'silent %print' \
|
||||
-c 'redir END' \
|
||||
-c 'qa!' 2>&1
|
||||
grep -Fq 'vim-lsp not installed; run :PlugInstall' "$TMP_ROOT/status-missing-plugin.txt"
|
||||
|
||||
vim -u NONE -i NONE -es -N \
|
||||
-c 'let g:chopsticks_profile = "minimal"' \
|
||||
-c 'source .vimrc' \
|
||||
|
|
|
|||
Loading…
Reference in a new issue