Git Product home page Git Product logo

python-syntax's Introduction

Python syntax highlighting for Vim

This is an enhanced version of the original Vim 6.1 Python syntax highlighting python.vim by Neil Schemenauer.

Features

  • Enhanced highlighting for:
    • Strings
    • Special symbols inside strings
    • Numeric constants
  • Added support for:
    • Python 3
    • Numbers with underscores
    • String %-formatting and f-strings
    • Magic comments: source code encoding and shebangs
    • New exceptions and builtins
    • Doctests
    • @decorator syntax
    • Class variables such as self and cls
    • Operators
  • Highlighting of the following errors:
    • Invalid symbols in source file
    • Invalid numeric constants
    • Invalid %-formatting inside strings
    • Invalid variable names
    • Invalid operators
    • Mixing spaces and tabs
    • Trailing spaces (Enabled with g:python_highlight_space_errors)
  • Commands for easy switching between versions

Folding is done by the plugin SimpylFold.

How to install

Use one of the following plugin managers:

Configuration

Option variables

Set variable to 1 to enable or 0 to disable.

For example to enable all syntax highlighting features you can add the following command to your ~/.config/nvim/init.vim or ~/.vimrc:

let g:python_highlight_all = 1
Variable Description Default
g:python_version_2 Python 2 mode 0
b:python_version_2 Python 2 mode (buffer local) 0
g:python_highlight_builtins Highlight builtin functions and objects 0
g:python_highlight_builtin_objs Highlight builtin objects only 0
g:python_highlight_builtin_funcs Highlight builtin functions only 0
g:python_highlight_builtin_funcs_kwarg Highlight builtin functions when used as kwarg 1
g:python_highlight_exceptions Highlight standard exceptions 0
g:python_highlight_string_formatting Highlight % string formatting 0
g:python_highlight_string_format Highlight syntax of str.format syntax 0
g:python_highlight_string_templates Highlight syntax of string.Template 0
g:python_highlight_indent_errors Highlight indentation errors 0
g:python_highlight_space_errors Highlight trailing spaces 0
g:python_highlight_doctests Highlight doc-tests 0
g:python_highlight_class_vars Highlight class variables self and cls 0
g:python_highlight_operators Highlight all operators 0
g:python_highlight_all Enable all highlight options above, except for previously set. 0
g:python_highlight_file_headers_as_comments Highlight shebang and coding headers as comments 0
g:python_slow_sync Disable for slow machines 1

Commands

Command Description
Python2Syntax Switch to Python 2
Python3Syntax Switch to Python 3

python-syntax's People

Contributors

hdima avatar nfnty avatar lilydjwg avatar anntzer avatar monkoose avatar iho avatar achimnol avatar mcsalgado avatar graywh avatar yuriihabrusiev avatar

Stargazers

Sergey Ukolov avatar

Watchers

James Cloos avatar Rom Grk avatar  avatar

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.