akinsho / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to turn off snippets / prevent automatically added commas (using Omnicomplete?)

textzenith opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Thanks — this has been an essential tool for developing Flutter in Neovim!

Just one small thing that's been bothering me regarding the completion provided by the Dart language server.

Whenever I try and complete a property name (which the LSP is great for!), a colon, space, and comma are automatically added.

e.g.

annoying-completion

To get here I started at the indented position on the line, entered 'k', and then pressed . The extra symbols are added automatically.

I think this is a snippet-based feature, but I'm not sure. It isn't clear how to deal with snippets if you're using Neovim's omnicompletion.

Part of the problem is that I'm left in insert mode at the end of the line, where a snippet engine in a mainstream editor would put the cursor before the comma — allowing the snippet to be completed. It's a distraction that slows down development and makes the process frustrating.

I'm putting this out here so that other people who face the same problem can perhaps find a solution on Google / Github issue search, so please don't be dismissive if I've misjudged this as a flutter-tools.nvim problem. Let's put the right answer here so people can find out!

Expected Behavior

Case 1: The snippet works as expected, placing my cursor before the comma where it is needed.

Case 2: There is an option to turn this off somewhere in the Dart LSP (or, by extension, Flutter Tools) settings. Omni-completing the property will complete only the property name, leaving the cursor where I expect it and allowing me to complete the extra characters by hand.

Steps To Reproduce

Install Flutter Tools, use the standard lua omnicomplete function, and attempt to complete a property name in any widget.

commented

@textzenith there's a setting in the README in the LSP block called enableSnippets which will disable all LSP snippets.

Alternatively regarding omni complete it's a known limitation of the builtin completion that it currently doesn't support LSP snippet expansion, but there is a WIP PR to add it. If you use a completion plugin nvim-cmp being the most popular this works as intended as it is able to parse LSP snippets.

EDIT: Closing this as I like to be proactive with issues if not they hang around forever and I believe the above answers your question

I like the proactive approach! Hope you make some progress tonight.

That definitely answers it. I had placed enableSnippets at the wrong level of nesting in my config. Oops.

there is a WIP PR to add it

This makes sense, I was getting frustrated from looking in quite a few places and ended up missing a fair bit, and sometimes what you miss is the blindingly obvious. Done such a lot of fixing today as I'm trying to be proactive myself 😄

Update, for anyone browsing:

This is built into the Dart Analysis Server, so changing enableSnippets doesn't do anything to change it.

Source:

https://dart.googlesource.com/sdk/+/refs/tags/3.1.0-48.0.dev/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart

As I don't fancy forking the analysis server, looks like the best I'm gonna be able to do is change completion provider, or update the included omnifunc!