Coder Social home page Coder Social logo

vim-jinja's Introduction

Jinja for Vim

Jinja bundle for vim.

Feature

  1. full syntax support
  2. great indent support

Installation

Install with Vundle

If you are not using vundle, you really should have a try. Edit your vimrc:

Bundle "lepture/vim-jinja"

And install it:

:so ~/.vimrc
:BundleInstall

Install with pathogen

If you prefer tpope's pathogen, that's ok. Just clone it:

cd ~/.vim/bundle
git clone https://github.com/lepture/vim-jinja.git

Configuration

No configuration is needed, if you are using vim 7.2+, it will detect if a html file is a jinja template.

But if you want to ensure it works well, you can edit your vimrc:

au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm set ft=jinja

Bug report

Report a bug on GitHub Issues.

vim-jinja's People

Contributors

homeworkprod avatar lepture avatar niftylettuce avatar thyrum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vim-jinja's Issues

Percents in strings highlighted as errors

Hi. In a template fragment:

{{date.strftime('%H:%M:%S %d.%m.%Y')}}

(formatting a date using built-in datetime.datetime method) the % signs are highlighted in red - as errors.

Please add a license to the repo

Could you please add an explicit LICENSE file to the repo so that it's clear under what terms the content is provided, and under what terms user contributions are licensed?

Per GitHub docs on licensing:

Generally speaking, the absence of a license means that the default copyright laws apply. This means that you retain all rights to your source code and that nobody else may reproduce, distribute, or create derivative works from your work. This might not be what you intend.

Thanks!

jinja {% raw %} not honored

Hi,

I have a complicated file (exim config file) which I want to process with jinja. It uses a lot of { syntax for its logic, so I wrap those in {% raw %} and {% endraw %}. Your colorizer should see these and not try to color or parse code contained within them (as jinja does). However, it does not seem to. Code inside the raw block throws off the syntax highlighter.

For example:

{% raw %}
MAX_PHYSICAL_HEADER_LENGTH = \
   ${reduce\
      {<\n ${map{<\n$message_headers_raw}{${strlen:$item}}}}\
      {0}\
      {${if >{$item}{$value}{$item}{$value}}}\
   }

{% endraw %}

Omnicomplete not working for HTML

When writing HTML, I'd usually press Ctrl + X, Ctrl + O to close an open tag. When editing a njk file, this plugin's syntax highlighting and everything works fine, but omnicompleting HTML stops working. I get this error message in the command area:

E764: Option 'omnifunc' is not set

Since jinja/nunjucks templates have some much HTML in them, it would be really nice if the omnicomplete worked.

Syntax highlight does not work when file use {%-

But it work with -%}
I'm using the newest revision of vim-jinja (master)

Vim version:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 19 2013 18:32:30)
Included patches: 1-918
Compiled by ArchLinux
Huge version without GUI.  Features included (+) or not (-):
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    -netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       -python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    
+farsi           +mouse_netterm   +syntax          
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2 -I/usr/local/include  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lncurses  -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc       

Editing state.jinja2

Not work:
Not work

Worked: (edit then reopen)
worked

FileType Detection is not working

Thanks for making an awesome syntax highlighter.

ftdetect set a jinja2 file -- extension .html but it includes jinja keywords -- to html. Once I manually changed it :set ft=jinja everything worked well (highlighting + indentation).

I'm using Vim v7.3.

I ended up adding the ftdetect function from this repo to my vimrc to get it working.

Thanks.

How to disable indent?

When I press enter, it indents the code in ways I don't particularly want. How do I disable the indent behaviour, while keeping the syntax highlighting?

Color problems when handling text between '<' and '>'

Hi,

Your plugin helps very much with my current task. Yet my Jinja templates' "free text" contains a lot of '<' and '>' characters (C++ templates).
In this case, I have the inferior sign colored in blue, the first word after it in default (black), and the rest including the ending superior sign in blue again. This is proving a bit disruptive, when all the rest of the free text in the template is colored in black.

Thank you for your plugin and your time,

Heredoc syntax breaks highlighting

Highlighting gets strange after the <<.
I presume it's trying to do HTML related stuff?
The file name is sqs_queues.tf.j2 (Final product is Terraform HCL)

{% for queue_type, queue in sqs.queues.items() %}
# ----- {{ queue_type|replace('_', ' ')|title }} Queue ----- #

resource "aws_sqs_queue" "{{ queue_type }}" {
  name                       = "{{ queue.name }}-queue"
  delay_seconds              = "{{ queue.delay }}"
  max_message_size           = "{{ queue.max_msg_size }}"
  message_retention_seconds  = "{{ queue.msg_retention_secs }}"
  receive_wait_time_seconds  = "{{ queue.rcv_wait_secs }}"
  visibility_timeout_seconds = "{{ queue.visibility_timeout_secs }}"

  redrive_policy = <<EOF
{
  "deadLetterTargetArn":"${aws_sqs_queue.{{ queue_type }}_deadletter.arn}",
  "maxReceiveCount":{{ queue.redrive_max_rcv_count|int }}
}
EOF
}

resource "aws_sqs_queue" "{{ queue_type }}_deadletter" {
  name = "{{ queue.name }}-queue-deadletter"
}

{% if queue.incoming_account is defined %}
resource "aws_sqs_queue_policy" "{{ queue_type }}_allow_sqs_write" {
    queue_url = "${aws_sqs_queue.{{ queue_type }}.id}"
    policy    = "${data.aws_iam_policy_document.{{ queue_type }}_allow_sqs_write.json}"
}

data "aws_iam_policy_document" "{{ queue_type }}_allow_sqs_write" {
    statement {
    sid = "AllowSQSWrite"

    actions = [
      "SQS:SendMessage"
    ]

    resources = [
      "${aws_sqs_queue.{{ queue_type }}.arn}",
    ]

    principals {
      type        = "AWS"
      identifiers = ["arn:aws:iam::{{ queue.incoming_account }}:root"]
    }
  }
}
{% endif %}

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.