Closed ibarrere closed 4 years ago
Brief update: sometimes it seems to increase the indent as well. I haven't identified particular situations for either, but I've definitely seen it remove indent and also add indent. If I do a double curly brace as well it seems to add/remove two indents.
Update: It also happens with some other characters, like : for example.
Hi, I'm migrating these days to Vim, and trying to troubleshoot a problem with indentation, that a bit different, but I suspect it have a similar reason.
But first: @ibarrere did you manage to solve this issue? If so, then how?
If not, then is your indentexpr
empty as mine? if so, does setting it to HtmlIndent()
fixes your issue?
Now my issue (with solution):
jinja.vim
into my ~/.vim/syntax/
directoryfiletype=htmldjango
and indentations work without isuues, but all {{...}}
are colored as variable names.jinja
the coloring is much better, but the command gg=G
aligns all lines on the first column.From comparing the set options on both cases -- setting indentexpr=HtmlIndent()
fixes the gg=G
command to apply the indents consistently with html syntax:
" Pull in the HTML syntax.
if g:jinja_syntax_html
if v:version < 600
so <sfile>:p:h/html.vim
else
runtime! syntax/html.vim
unlet b:current_syntax
endif
setlocal indentexpr=HtmlIndent() " <--- added this line
endif
And what I really don't understand yet, is how indentexpr
is set in htmldjango.vim
: putting let base_syntax='html'
in jinja.vim
before sourcing the html
syntax seems to do no difference regarding the indentexpr
option...
And one more final question: is my solution good enough for PR (did I miss something in how Vim works)? Or should've I posted this in entirely new issue?
@ivanpu
I'm not actually using the Glench/Vim-Jinja2-Syntax anymore. This issue was so bothersome that I just removed it. I don't even remember what benefit I got from the plugin to begin with, but my current environment allows for jinja specific highlighting and custom tab space, which I think is all I wanted anyway.
Honestly I've been thinking of removing this and sending an issue to the Jinja Vim repo that they'll need to maintain this themselves. @Glench
I don't use Vim and know absolutely nothing about its syntax highlighting, so every time an issue comes up I have to trust that whatever PR is submitted (if any) works and doesn't do anything else unintended. Maintaining Vim stuff is completely orthogonal to the rest of the repository. We already removed the Emacs version long ago.
Closing this, I'm not going to maintain the Vim syntax file anymore. If someone wants to address this issue, they should submit a PR to https://github.com/Glench/Vim-Jinja2-Syntax or whatever other plugin they're using.
Expected Behavior
When I add a curly brace to an indented line I would expect to simply add the curly brace.
Actual Behavior
What seems to happen is that whenever I add a curly brace (either direction) to an indented line, it removes the indent from the start of the line as well. It doesn't seem to matter where in the line I put the curly brace, if I edit an indented line it will happen. The strange thing is, it doesn't do this if I just write an indented line with a curly brace in it, it only affects lines that are already written that I'm then editing.
In the case of the "code" block below, if I were to add a { to the end of "child line" it would delete the indent at the beginning.
Is this expected behavior? It's quite annoying to have to go and fix the indents every time I add a variable to a line.
This is regarding the Glench/Vim-Jinja2-Syntax plugin, btw. I have tried removing the plugin from my .vimrc and behavior goes back to normal, but then of course I don't have the nice coloring that comes along with the plugin.
Template Code
Your Environment