Skip to content

lsp: enable snippet support

Waqar Ahmed requested to merge work/lsp-snippet-enable into master

This change announces to the servers that we support snippets, even though in reality we don't. However, we can still work with snippet-y text by removing the snippet markers and using that with our own snippet handler which is not quite ready to accept lsp style snippets.

The benefit of this change is that we don't have to put in hacks to add "()" parens to stuff. We also don't have to move our cursor manually which can be incorrect in many cases e.g., string.isEmpty(), with cursor in between the parens doesn't make sense.

For cpp/clangd the existing logic was okay-ish. However some servers like dart-analyzer do something different. If you dont have snippets, the server will just remove the snippet markers from the text and send it to you. This results in sometimes very annoying editing experience. For e.g.,

- maxLines: ,| // cursor position at the end is annoying
- initState() {
  // some comment
  }() // () what are parens doing here??

Thus its better to just remove those markers ourselves and then we can just set the cursor position as we want and don't have to manually decide anything.

Edited by Waqar Ahmed

Merge request reports