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

Multi-line completion inserts have "^@" instead of newlines #586

Open
Terr opened this issue Jan 18, 2025 · 2 comments
Open

Multi-line completion inserts have "^@" instead of newlines #586

Terr opened this issue Jan 18, 2025 · 2 comments

Comments

@Terr
Copy link

Terr commented Jan 18, 2025

Multi-line inserts, like overriding a parent method in Python or complex Rust functions defined by traits, are inserted with a "^@" (null character? \n?) instead.

I've managed to produce this with two language servers, pyright and rust-analyzer.

Pyright:
pyright

Rust-analyzer:
rust-analyzer

Vim version: 9.1.1033
LSP revision: 68a3696 (latest as of writing this)

I used this mostly clean vimrc to reproduce it:

set nocompatible

" Plugins
call plug#begin('~/.vim/plugged')
"" Language server client
Plug 'yegappan/lsp'
call plug#end()

"" lsp

""" Configuration
autocmd User LspSetup call LspOptionsSet(#{
    \ autoHighlight: v:true,
    \ autoHighlightDiags: v:true,
    \ showInlayHints: v:true,
    \ showDiagsWithVirtualText: v:true,
\ })

""" Language server definitions
let lspServers = [#{
    \  name: 'pyright',
    \  filetype: 'python',
    \  path: 'pyright-langserver',
    \  args: ['--stdio'],
    \  workspaceConfig: #{
    \    python: #{
    \      pythonPath: 'python3'
    \  }}
    \},
    \#{
    \  name: 'rust-analyzer',
    \  filetype: ['rust'],
    \  path: 'rust-analyzer',
    \  args: [],
    \  syncInit: v:true,
    \  initializationOptions: #{
    \    inlayHints: #{
    \      typeHints: #{
    \        enable: v:true
    \      },
    \      parameterHints: #{
    \        enable: v:true
    \      }
    \    },
    \  }
    \}
\]

autocmd User LspSetup call LspAddServer(lspServers)
@berggeist
Copy link
Contributor

This seems to be a known limitation of vim that multiline inserts are not (yet) supported:
Proposal: multiline completion support #2505

There is a draft pull-request for solving this in vim:
feat(completion): support insert special characters when completion #15373

@Terr
Copy link
Author

Terr commented Jan 19, 2025

Interesting, I wasn't expecting it to be a limitation of vim because coc.nvim is able to insert multiple lines. I wonder how it does it.

edit: as far as I can tell coc.nvim overrides some things, takes completion items coming from it's Node.js backend and inserts them like they are snippets.

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

No branches or pull requests

2 participants