Shougo / neosnippet.vim

neo-snippet plugin
Other
1.12k stars 108 forks source link

Unexpected behavior: jumping between markers #423

Closed fastbodin closed 6 years ago

fastbodin commented 6 years ago

Problem Summary When dealing with multiple nested snippets, the order of the markers seems to get indexed wrong.

Steps to reproduce

  1. Use the following minimal vimrc
    
    set nocompatible
    set runtimepath+=~/path/to/neosnippet.vim/
    filetype plugin indent on
    let g:neocomplete#enable_at_startup = 1
    let g:neosnippet#snippets_directory = '~/snippets'

imap neosnippet#expandable_or_jumpable() ? "\(neosnippet_expand_or_jump)" : (pumvisible() ? "\" : "\") smap neosnippet#expandable_or_jumpable() ? "\(neosnippet_expand_or_jump)" : "\"

2. Input the following snippets into a plaintex.snippets file in ~/snippets

snippet equn abbr "Equation" \begin{equation${1}} ${2} &= ${3} \\ ${4} \end{equation$1} ${5}

snippet br abbr "( ) - bracket" \left( ${1} \right) ${2}

snippet frac abbr "Fraction" \frac{${1}}{${2}} ${3}

3. Run nvim test.tex
4. Type the following keystrokes

equn br frac


**Expected behavior**
Everything is fine up to

equn br frac

I would expect the following key strokes would take the cursor to the following markers
* TAB -> '<2>'
* TAB -> '<3>'
* TAB -> '<4>'
* TAB -> '<5>'

**Actual behavior**
The fourth TAB after 'frac' should have gone to marker '<2>' but instead when to marker '<4>'.  The following four keystrokes take the cursor to the following markers out of the expected order
* TAB -> '<4>'
* TAB -> '<2>'
* TAB -> '<3>'
* TAB -> '<5>'

There seems to be a problem with nesting snippets. It may be how I have defined them?

**Environment Information**
* OS: macOS High Sierra version 10.13.3
* neovim/Vim version: NVIM v0.2.2
* Neosnippet version: Version: 5.0

**:CheckHealth Output**

health#nvim#check

Configuration

Performance

Remote Plugins

terminal

health#provider#check

Clipboard (optional)

Python 2 provider (optional)

Python 3 provider (optional)

Ruby provider (optional)

Node provider (optional)

Screen shots

screen shot 2018-03-07 at 5 04 08 pm

screen shot 2018-03-07 at 5 04 34 pm

screen shot 2018-03-07 at 5 09 24 pm

screen shot 2018-03-07 at 5 05 45 pm

screen shot 2018-03-07 at 5 05 57 pm

screen shot 2018-03-07 at 5 06 08 pm

screen shot 2018-03-07 at 5 06 18 pm

screen shot 2018-03-07 at 5 06 51 pm

screen shot 2018-03-07 at 5 11 20 pm

Shougo commented 6 years ago

Sorry. I don't fix the problem.

The nested behavior is hard to fix.

fastbodin commented 6 years ago

Understood. Thanks for the quick response.

Shougo commented 6 years ago

I should implement deoppet.nvim(the next snippet plugin) instead. I have not much time now though.

fastbodin commented 6 years ago

I was going to ask whether this sort of functionality would likely be implemented in deoppet.nvim. I appreciate your work. I have been looking forward to eventually using deoppet.nvim. Just have been unsure when would be best to make the conversion over.

Shougo commented 6 years ago

Of course, deoppet.nvim should support nested snippet expansion without markers. I think it is possible.

Current neosnippet has very many features. It takes more time. And I have other plugins development. Especially, deoplete.

fastbodin commented 6 years ago

I understand. Il also use deoplete so I appreciate your work there!

Il keep my eye on deoppet.nvim