Hi! Does anyone of you have some working code completion setup for Nim with Vim 8 (...on Windows, ideally...)?
I tried searching around, but was surprised to find out the situation seems quite unclear, AFAICS. There appear to be a variety of competing approaches (nimsuggest vs. nim idetools vs. nimc check (??); implemented as either old pre-LSP plugins vs. new LSP ones at unclear stage of development; then NeoVim vs. Vim pre-8 vs. Vim8 (??); then various stated supported features...), and not being in the community for long enough, I'm completely at loss as to what's the "usual choice", if any at all...
I managed to find some semi-recent thread (~Aug 2018), which seems to paint a rather bleak picture for my case, suggesting that most Nim users are on VSCode & other non-vim, whereas the few vim users who replied appear to have failed to get auto-completion to work.
Is there someone that could share a snippet from their .vimrc, where they managed to get auto-completion working in Vim (not NeoVim), ideally Vim8? I'd be super grateful if you could either paste relevant fragments here verbatim, or share a permalink on github/gist/whatever pastebin site. Concrete snippet would be especially awesome, given that I found any changes in .vimrc brittle and notoriously tricky to setup correctly; but even handwaved hints like "this combination of tools/plugins/... works for me" would be highly appreciated, as they could at least point me in some verified direction. I'd be especially grateful for confirmed working setups; but even theoretical speculations like "Vim has some LSP plugins and Nim has some LSP server" might still be useful if you could point me to a LSP server that is known by you, or at least by the community, to be working well. My main problem is that: (1) there are too many combinations of tools, and I don't see clear leaders, and I feel paralyzed by the very thought of having to laboriously try them one by one; (2) I'm stuck with Vim8 on Windows for now, as switching to NeoVim there is highly non-trivial for me; (3) my love-hate relationship with Vim is too deep now to be able to switch to different editor without a huge psychological & effectiveness cost...
I'd be super grateful for any help!
I've wanted to update my vim plugin for a while, but can't quite get to it.
PMunch's language server implementation works well with the generic Vim LSP plugins AFAIK: https://github.com/PMunch/nimlsp
With the following additions in my .vimrc, it seems to more or less work (though the service seems to hang or crash not so rarely):
" (...)
Plugin 'prabirshrestha/async.vim'
Plugin 'prabirshrestha/vim-lsp'
" (...)
" Nim language support via Language Server Protocol:
" prabirshrestha/vim-lsp + nimlsp
let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('$TEMP/vim-lsp.log')
" let g:lsp_log_file = expand('~/vim-lsp.log')
" Closes the preview window on the second call to preview (e.g. (lsp-hover))
let g:lsp_preview_doubletap = [function('lsp#ui#vim#output#closepreview')]
let g:lsp_async_completion = 1
if executable('nimlsp')
augroup akavelnimlsp
au!
" nimble install nimlsp
au User lsp_setup call lsp#register_server({
\ 'name': 'nimlsp',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'nimlsp c:\\dnload\\nim-etc\\nim']},
\ 'whitelist': ['nim'],
\ })
" See: :help vim-lsp-mappings
au FileType nim nmap gd <plug>(lsp-definition)
au FileType nim nmap K <plug>(lsp-hover)
" See: vim-lsp-omnifunc
au FileType nim setlocal omnifunc=lsp#complete
augroup END
endif
where C:\dnload\nim-etc\nim is the path to where I have Nim downloaded.
(2) I'm stuck with Vim8 on Windows for now, as switching to NeoVim there is highly non-trivial for me;
From what I've heard, neovim(-qt) now runs rather well on windows, so you can give that a try as well :)