The Wayback Machine - https://web.archive.org/web/20220811075802/https://github.com/mattn/vim-lsp-settings/pull/606
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Dagger CUE LSP #606

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dolanor
Copy link

@dolanor dolanor commented Aug 11, 2022

Hi,
we recently released a CUE LSP, and I followed vim-lsp documentation to configure it, and it works pretty well. But I wanted to make it even simpler to use it and started creating this PR.
But somehow, I can't make it work.
The configuration that works with bare vim-lsp is:

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> ,rn <plug>(lsp-rename)
    nmap <buffer> [g <plug>(lsp-previous-diagnostic)
    nmap <buffer> ]g <plug>(lsp-next-diagnostic)
    nmap <buffer> K <plug>(lsp-hover)

    let g:lsp_format_sync_timeout = 1000
    autocmd! BufWritePre *.cue call execute('LspDocumentFormatSync')

    " refer to doc to add more commands
endfunction

let g:lsp_log_file = expand('/tmp/vim-lsp.log')
let g:lsp_log_verbose = 1

let g:lsp_experimental_workspace_folders = get(g:, 'lsp_experimental_workspace_folders', 1)

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

On a second improvement, I'd like to be able to use either the cuelsp server embedded in the dagger binary, but I want user who just want to use CUE not to have to download dagger. We have a standalone cuelsp binary as well. I think somehow haskell has 2 binaries as well, but I couldn't get the configuration right, so I reduced to just 1 case.

@dolanor dolanor marked this pull request as draft Aug 11, 2022
settings.json Outdated Show resolved Hide resolved
@mattn
Copy link
Owner

@mattn mattn commented Aug 11, 2022

Thank you. LGTM. Could you please follow the indentation to other's code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants