Code Monkey home page Code Monkey logo

vim-htmldjango_omnicomplete's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=4027

Vim htmldjango autocomplete

An omnicomplete tailored to django templates "tags/variables/filters/templates" I mainly find it useful for completing template and static directory paths. It will also fall back to regular html omnicomplete

Repo: http://github.com/mjbrownie/vim-htmldjango_omnicomplete (star it for updates, feedback appreciated)


Screenshots:

    block: https://github.com/mjbrownie/vim-htmldjango_omnicomplete/raw/master/examples/block_eample.png
    url: https://github.com/mjbrownie/vim-htmldjango_omnicomplete/raw/master/examples/url_example.png
    extends: https://github.com/mjbrownie/vim-htmldjango_omnicomplete/blob/master/examples/extends_example.png

Eg.

    1. Filters

        {{ somevar|a<c-x><c-o>}} should complete 'add' , 'addslashes'

    2. Tags

        {% cy<c-x><x-o> %} should complete 'cycle'

    3. Load statements

        It also should grab any libs you have {% load tag_lib %} in the file.
        Although it needs them in INSTALLED_APPS.

        {% load <c-x><c-o> %} will complete libraries (eg. 'cache', 'humanize')

    4. template filenames

        {% extends '<c-x><c-o>' %} will list base.html ... etc

    5. url complete

        {% url <c-x><c-o> %} should complete views and named urls

    6. super block complete

        eg {% block c<c-x><c-o> %} to complete 'content' or something defined
        in an extended template.


    7. static files complete

        eg {% static "r<c-x><c-o>" %}

        <script src="{% static "<c-x><c-o>" %}" /> - completes js files in static
        <style src="{% static "<c-x><c-o>" %}" /> - completes css files in static
        <img src="{% static "<c-x><c-o>" %}" /> - completes img files in static
        {{ s<c-x><x-o> }}

    8. optional variable name completion (placeholder)

        will complete any maps defined in the python htmldjango_opts['variable']
        dict list. See below for info.


    Where possible info panels show the functions __doc__. Most of the
    internal ones are decent.

Requires:

    +python

    I have this working on command line vim for linux and mac (I had to compile my own for osx with ./configure --enable-pythoninterp --with-features=huge). 

    also I have DJANGO_SETTINGS_MODULE set in my vimrc. please look at my dotfiles if you are having trouble

    https://github.com/mjbrownie/dotfiles/blob/master/_vimrc#L312-L340

SETUP

    1. I like pathogen/Vundle clone into ~/.vim/bundle directory.

        Alternately just stick the vim file in your ~/.vim/autoload/ dir.

    2. in .vimrc set the omnifunc Eg.

        au FileType htmldjango set omnifunc=htmldjangocomplete#CompleteDjango

    3. Optional: At the moment you need to force a html flavour for htmlcompletion

        in .vimrc

        let g:htmldjangocomplete_html_flavour = 'html401s'

        :verbose function htmlcomplete#CheckDoctype for DocType details

        Choices:
            'html401t' 'xhtml10s' 'html32' 'html40t' 'html40f' 'html40s'
            'html401t' 'html401f' 'html401s' 'xhtml10t' 'xhtml10f' 'xhtml10s'
            'xhtml11'

            'html5' if you have html5.vim

TESTING

    django needs to be in sys.path along with DJANGO_SETTINGS_MODULE in your
    environment.

    To test...

    :python import django

    should not result in an error

    :python from django.conf import settings; print settings.INSTALLED_APPS
    :python from django.conf import settings; print settings.TEMPLATE_DIRS

    should show the apps template dirs you need

    I've only tested this on a mac with vim 7.3 and django 1.4

vim-htmldjango_omnicomplete's People

Contributors

mjbrownie avatar

Stargazers

 avatar

Watchers

 avatar  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.