Giter VIP home page Giter VIP logo

Comments (9)

elliotpatros avatar elliotpatros commented on August 27, 2024 1

This has been working for me:

  autocmd FileType tex
        \ let b:endwise_addition = '\="\\end" . matchstr(submatch(0), "{.\\{-}}")' |
        \ let b:endwise_words = 'begin' |
        \ let b:endwise_pattern = '\\begin{.\{-}}' |
        \ let b:endwise_syngroups = 'texSection,texBeginEnd,texBeginEndName,texStatement'

Edit: you can do \begin{env*} now too.

from vim-endwise.

maxfl avatar maxfl commented on August 27, 2024

So far after some playing I was able to figure out that the following sequence does the job:

let b:endwise_words = '\\begin{\zs[a-zA-Z0-9*]*\ze}' " ignored
let b:endwise_pattern = '\\begin{\zs[a-zA-Z0-9*]*\ze}'
let b:endwise_addition = '\\end{&}'
let b:endwise_syngroups = 'texBeginEndName'

But it doesn't prevent endwise to add the ending even if it already exists. For now I don't know how it works and how it can be fixed.

from vim-endwise.

 avatar commented on August 27, 2024

Nevertheless, this could for better or worse be included in the standard plugin.

from vim-endwise.

tpope avatar tpope commented on August 27, 2024

Where did texBeginEndName come from? I see texSection (though this might be version dependent).

from vim-endwise.

maxfl avatar maxfl commented on August 27, 2024

It's from vim's tex syntax file.
vim 7.3.1287

" Vim syntax file
" Language: TeX
" Maintainer: Charles E. Campbell [email protected]
" Last Change: Mar 11, 2013
" Version: 78
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX

from vim-endwise.

tpope avatar tpope commented on August 27, 2024

That's a curious inconsistency with both 7.3.000 and 7.4.000 but doesn't appear to be relevant. b:endwise_words needs to be a comma delimited list of words. You might have better luck if you start by trying to target a few specific environments. I doubt a general solution is possible without tweaking the rest of the implementation.

from vim-endwise.

michaelmior avatar michaelmior commented on August 27, 2024

The example given by @maxfl doesn't seem to work for me. This would be very cool to have working somehow in any case.

from vim-endwise.

gelguy avatar gelguy commented on August 27, 2024

I can confirm @maxfl example works and the problem with preventing extra endings exists. There's two factors affecting this.

Firstly, b:endwise_addition is not escaped when endpat is generated so the double-slashes in \\end becomes \end when doing searchpair.

Secondly, in Latex's syntax highlighting, \begin{foo} has two different syntax groups, \begin having texBeginEnd and foo with texBeginEndName. My current method is to introduce a new variable b:endwise_endsyngroups which when defined, overrides b:endwise_syngroups in mysearchpair.

Another minor issue is that the \begin has a lot of environments, so a new tag may match an already existing, but different tag. I believe it is possible to generate the exact end pattern from word when doing searchpos.

from vim-endwise.

michaelmior avatar michaelmior commented on August 27, 2024

Thanks @elliotpatros! That works for me :)

from vim-endwise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.