Jorenar / miniSnip

Lightweight snippet plugin for Vim
MIT License
53 stars 8 forks source link

Problems with expanding #24

Closed akemrir closed 2 years ago

akemrir commented 2 years ago

Hi I have prepared pull request #23

My vim details: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jun 28 2022 16:22:51) / ArchLinux

But at the moment I have problems with expanding in ruby code. It consumes dot. For example:

With following snippet:

? select inline
select { |<{element}>| <{+}> }

Sample code

array.sel<expand>

Result


select { |<{element}>| <{+}> }

And sometimes it does not expand at first time. I am using ddc to support complete menu.

Other settings

let g:miniSnip_dirs = [expand('~/.vim/miniSnip')]
let g:miniSnip_trigger = '<c-s>'
let g:miniSnip_extends = {
      \ "arduino"  : [ "cpp", "c" ],
      \ "cpp"      : [ "c" ],
      \ "markdown" : [ "html" ],
      \ "tex"      : [ "plaintex" ],
      \ "bash"      : [ "sh" ],
      \ "typescript"      : [ "javascript" ],
      \ "typescriptreact"      : [ "javascript" ],
      \ }
let g:miniSnip_expandpattern = '\v[a-zA-Z0-9_-]+%'
Jorenar commented 2 years ago

Huh, that's interesting. Under what name is the snippet saved at?
Because array.sel<expand> should result in message miniSnip: no snippet with that name and not expand at all.

akemrir commented 2 years ago

Yes, it should. But with my change in PR it resolves after dot. When I update accordingly to your comments, I'll get back here.

akemrir commented 2 years ago

Ok, so I've updated the PR and here is minimal vimrc https://gist.github.com/akemrir/17e27ee30adbf45ae364fb2c39be6a06

It works somewhat, but I need to test more. The purpose is to expand words even with - or _ with a-zA-Z0-9 It should grab snippet key after dot and other symbols.

For example } =

I've checked this, but it grabs too much for me. :help \f

I need to build up docs also.

Jorenar commented 2 years ago

OK, going back to the example, if I understand correctly, you have a snippet file sel.snip, yes?
And you want array.sel<expand> to become array.select { |<{element}>| <{+}> }, do I get it right?

akemrir commented 2 years ago

Yes.

Something like that. But I need to check why sometimes it goes back to completion. https://user-images.githubusercontent.com/240986/182774017-5a097e03-e026-42b0-b512-0b54ec731629.mp4

akemrir commented 2 years ago

Ok, found it. Addon works fine. My configuration was the cause. I was using this:

obraz

Which was set to:

set whichwrap+=h,l,<,>,[,],b,s,~

[ and ] was the problem, when I removed them snippet expansion went back to normal. I reverted it to vims default.

akemrir commented 2 years ago

But I've found different problem. I will investigate it. Sometimes I need to hit expand two times to get it really expanded. And sometimes it omit expansion and jumps to next position.

https://user-images.githubusercontent.com/240986/183298884-4882e314-d976-4a51-93f7-86cca7d4f1ea.mp4

Jorenar commented 2 years ago

The mentioned PR is a nice feature, which I definitely want to merge into the plugin, but it's not a solution to this issue.
The default pattern is indeed not correct and needs to be changed.

akemrir commented 2 years ago

I agree. This issue and PR are different topics.