Skip to content

Improved nginx vim plugin (incl. syntax highlighting)

Notifications You must be signed in to change notification settings

rameshgkwd05/nginx.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nginx.vim

Description

Vim plugin for Nginx

Features

The plugin is based on the recent vim-plugin distributed with nginx-1.12.0 and additionally features the following syntax improvements:

  • Highlight IPv4 and IPv6 addresses
  • Mark insecure ssl_protocols as errors
  • Inline template syntax highlight for ERB and Jinja
  • Inline syntax highlight for LUA
  • Improve integer matching
  • Syntax highlighting for proxy_next_upstream options
  • Syntax highlighting for sticky options
  • Syntax highlighting for upstream server options
  • More to come!

Furthermore:

  • Remove annoying delimiters, resulting in strange word-boundaries

Screenshots

A server block with highlighting of insecure ssl_protocol options: nginx server block with SSL configuration

An upstream block with highlighted options: nginx upstream configuration

Embedded highlighting for ERB and Jinja templates: Embedded highlighting for ERB and Jinja templates

Embedded LUA syntax highlighting: Embedded LUA syntax highlighting

Snippets

The plugin comes with useful snippets which can be accessed using e.g. vim-snipmate.

Select a decent cipher for your requirements (all of them can provide SSLLabs A+ ratings)

  • ciphers-high<tab>: High-security ciphers (elliptic curves), not compatible with IE < 11, OpenSSL-0.9.8, Safari < 7, Android < 4.4
  • ciphers-medium<tab>: Medium-security ciphers with good compatibility (No IE6, IE8) but TLSv1 and SHA required
  • ciphers-low<tab>: Low-security ciphers (using weak 3DES cipher and TLSv1), but compatible with everything but IE6 and Java6
  • ssl-options<tab>: Bootstrap secure SSL options

Example:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS';

Or add a robots.txt file with robots.txt<tab>:

# Tell bots to not index this site
location /robots.txt {
    default_type text/plain;
    return 200 'User-agent: *\nDisallow: /\n';
}

It also has auto-completion for location and server blocks with location<tab> resp. server<tab>, and many more!

References

  • Based on the original nginx-1.12.0/contrib/vim
  • IPv4 and IPv6 address highlighting, based on expressions found in this forum post
  • Blog post introducing this plugin including some more examples

Installation

NeoBundle:

NeoBundle 'chr4/nginx.vim'

" Optionally, if you like Jinja template syntax highlighting
NeoBundle 'lepture/vim-jinja'

Vundle:

Plugin 'chr4/nginx.vim'

" Optionally, if you like Jinja template syntax highlighting
Plugin 'lepture/vim-jinja'

Pathogen:

git clone https://github.com/chr4/nginx.vim.git bundle/nginx.vim

# Optionally, if you like Jinja template syntax highlighting
git clone https://github.com/lepture/vim-jinja.git bundle/vim-jinja

License

Copyright (c) Chris Aumann. Distributed under the same terms as Vim itself. See :help license.

About

Improved nginx vim plugin (incl. syntax highlighting)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 96.7%
  • Nginx 3.3%