CUELSP is available as a subcommand of the Dagger CLI: dagger cuelsp
Ensure that you have dagger
v0.2.27 or newer installed.
This is how you can install dagger
.
To check what version you have installed, run: dagger version
As a last step, check the version of dagger
that vim has access to by running the following command in vim: !dagger version
Refer to vim-lsp documentation.
Add this to your .vimrc
:
if executable('dagger')
au User lsp_setup call lsp#register_server({
\ 'name': 'dagger_cue_lsp',
\ 'cmd': {server_info->['dagger', 'cuelsp']},
\ 'allowlist': ['cue'],
\ })
endif
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
" nmap <buffer> gs <plug>(lsp-document-symbol-search)
" nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
" nmap <buffer> gr <plug>(lsp-references)
" nmap <buffer> gi <plug>(lsp-implementation)
" nmap <buffer> gt <plug>(lsp-type-definition)
" nmap <buffer> <leader>rn <plug>(lsp-rename)
" nmap <buffer> [g <plug>(lsp-previous-diagnostic)
" nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nnoremap <buffer> <expr>d lsp#scroll(+4)
nnoremap <buffer> <expr>u lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
" refer to vim-lsp doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
Given a local copy of https://github.com/dagger/todoapp, open up dagger.cue
in vim.
Place the cursor over a definition and type CTRL ]
to jump to the implementation.
Type CTRL t
to jump back.
You can also type K
to open the definition description in a hover area.
If there is more content than fits the hover area, press d
to go scroll down and u
to scroll up.
This is what that looks like in practice: