Comments (9)
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.
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.
Nevertheless, this could for better or worse be included in the standard plugin.
from vim-endwise.
Where did texBeginEndName
come from? I see texSection
(though this might be version dependent).
from vim-endwise.
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.
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.
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.
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.
Thanks @elliotpatros! That works for me :)
from vim-endwise.
Related Issues (20)
- OCaml support
- Using the word 'end' in a comment in Ruby breaks auto completion
- Ruby class adds extra end HOT 1
- [Request] Trigger when (o)pening new line HOT 2
- Does not autodisable in paste mode in neovim HOT 1
- [Nvim] Adding automaticly an extra comma for C and Cpp files HOT 1
- Update installation docs HOT 1
- Conflic with CoC HOT 7
- False match at in-line block ending pattern for Ruby
- vim-endwise paired with nvim-cmp causes neovim to freeze HOT 1
- Combining with other `<CR>` mappings HOT 4
- Delay on enter press HOT 4
- Mapping no longer works if delimiteMate plugin is installed HOT 1
- Doesn't work with `#if 0` HOT 1
- Enter prints 'EndwiseAppend("\r")' instead of a newline. HOT 3
- Not working in Ruby for latest commit HOT 1
- 'set cpoptions=n' causes vim-endwise producing 'r' symbol instead of new line HOT 7
- Does not work with Treesitter installed HOT 3
- add support for opening code block delimiters too
- Meson support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-endwise.