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

Does not work for snippet with folding #192

Open
e-kwsm opened this issue May 9, 2021 · 4 comments
Open

Does not work for snippet with folding #192

e-kwsm opened this issue May 9, 2021 · 4 comments

Comments

@e-kwsm
Copy link

e-kwsm commented May 9, 2021

  • NVIM: v0.5.0-dev+nightly-709-g554468cc0
  • vsnip: 395d200

Consider the following vim snippet that contains foldmarkers:

{
  "function with foldmarker": {
    "prefix": "function",
    "body": [
      "function ${1:Foo}(${2})  \"{{{",
      "\t${3}",
      "endfunction  \"}}}"
    ]
  }
}

If expanded, the body is folded, and selected instead of the first marker:

snippet-w-fmr

vimrc:

set foldmethod=marker

set runtimepath+=/path/to/vim-vsnip
let g:vsnip_snippet_dir='/path/to/vsnip'

" Expand
imap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'
smap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'

" Jump forward or backward
imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
@hrsh7th
Copy link
Owner

hrsh7th commented May 10, 2021

You should escspe {}

@hrsh7th hrsh7th closed this as completed May 10, 2021
@e-kwsm
Copy link
Author

e-kwsm commented May 10, 2021

The issue is irrelevant with braces: this also happens if foldmarker is set to, e.g., <<<,>>> and the following snippet is expanded:

{
  "function with foldmarker": {
    "prefix": "function",
    "body": [
      "function ${1:Foo}(${2})  \"<<<",
      "\t${3}",
      "endfunction  \">>>"
    ]
  }
}

snippet-w-fmr

@rodhash
Copy link

rodhash commented Jul 4, 2021

Any fix for this?

Just migrated to the neovim native LSP and installed vim-vsnip. Works pretty well, except when using fdm set to something like "syntax".

I'm having trouble recording gif so recorded a quick video .. whenever I have a folded text in the code, it gets weird.

https://www.youtube.com/watch?v=Uq3YU7H1c7Y

@e-kwsm e-kwsm changed the title Does not work for snippet with foldmarker Does not work for snippet with folding Jul 6, 2021
@e-kwsm
Copy link
Author

e-kwsm commented Jul 8, 2021

As @rodhash pointed out, this happens with snippets that have folding—fdm=marker, syntax, etc—on the first line of the body.

@hrsh7th hrsh7th reopened this Jul 8, 2021
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

3 participants