nvim: init.vim: Add support for automatic hover

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-09-09 22:13:27 +05:30
parent 687804162c
commit ba8f4776be

View file

@ -194,18 +194,50 @@ let g:LanguageClient_serverCommands = {
\ 'go' : ['$HOME/go/bin/gopls'],
\ }
nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR>
nnoremap <Leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <Leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <Leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <Leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <Leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <Leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <Leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <Leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <Leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <Leader>lm :call LanguageClient_contextMenu()<CR>
nnoremap <Leader>la :call LanguageClient#textDocument_codeAction()<CR>
" https://github.com/autozimu/LanguageClient-neovim/issues/618
function! LspMaybeHover(is_running) abort
if a:is_running.result && g:LanguageClient_autoHoverAndHighlightStatus
call LanguageClient_textDocument_hover()
endif
endfunction
function! LspMaybeHighlight(is_running) abort
if a:is_running.result && g:LanguageClient_autoHoverAndHighlightStatus
call LanguageClient#textDocument_documentHighlight()
endif
endfunction
augroup lsp_aucommands
au!
au CursorHold * call LanguageClient#isAlive(function('LspMaybeHover'))
au CursorMoved * call LanguageClient#isAlive(function('LspMaybeHighlight'))
augroup END
let g:LanguageClient_autoHoverAndHighlightStatus = 0
function! ToggleLspAutoHoverAndHilight() abort
if g:LanguageClient_autoHoverAndHighlightStatus
let g:LanguageClient_autoHoverAndHighlightStatus = 0
call LanguageClient#clearDocumentHighlight()
echo ""
else
let g:LanguageClient_autoHoverAndHighlightStatus = 1
end
endfunction
nnoremap <Leader>lg :call ToggleLspAutoHoverAndHilight()<CR>
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`