New plugins to the Kate, utils to: Python, JavaScript, Django and XML

The project plugin in kate.git master now has four new more plugins, with many features in each one: Python (autocomplete, smart snippets, parse checker, pep8 checker and pyflakes checker), Javascript (autocompletes, jquery snippet, pretty JSON, and jslint checker), Django (smart snippets and utils to Django template) and XML (pretty xml). There are also many generic functions and generic classes in these that will be useful to the new plugins developers.

I began to develop these plugins in 2009, this was my first version :-). I wanted to set a shortcut to a snippet, as it was not possible (now it is posible) I started to develop these plugins to Kate.

In November 2011, I created a repository on github to develop new features and share them. I have to thank Alejandro Blanco, Jeroen van Veen, Javier Romero, Martin Borho, Justin Chudgar and Yaco Sistemas for helping me in this project.

In October 2012 Christoph Cullmann (Kate maintainer) sent me an e-mail, in which he asked me if I was interested to contribute with KDE project. I answered: “Of course!”…. finally I have a little time, and I have been able to integrate these plugins in the kate.git

Features to Python Plugin:

  • Python dynamic autocomplete using pyplete, this is in beta… It requires development, but now it is very useful.
  • Smart snippets:
    1. Insert an __init__ method into a class.
    2. Insert a super call into a method.
    3. Insert a call recursive into a method or into a function
  • Simple snippet: Insert the debug instrunctions “import ipdb; ipdb.set_trace()”
  • Checkers: When you save the file it is syntax checked, pep8 checked and pyflakes checked. You can invocate them any other time.

[

][3]

Python auto complete

Features to Javascript Plugin:

  • JavaScript static autocomplete, using a JSON file.
  • JQuery static autocomplete using a JSON file.
  • Pretty JSON: Pretty format of a JSON code selected
  • JSLint checker: When you save the file it is JSLint checked. You can invocate it any other time.
  • JQuery snippet, insert the ready code of the jQuery

JSLint checker

Features to Django Plugin:

  • Smart snippets:
    1. Create a model class
    2. Create a form class
    3. Template to the urls.py file
  • Simple snippet: Insert the typical imports of a views.py file
  • Template Django utils
    1. Insert the tag block/endblock. The name of the block will be the text selected
    2. Close the last templatetag open

Create a form class

Pretty XML:

Pretty format of an XML code selected

Pretty XML

Generic features:

Also I have added many generic functions and generic classes, likely the more outstanding are the autocompletations. Now you can create a code completion model with very few lines:

import kate
from libkatepate.autocomplete import AbstractJSONFileCodeCompletionModel, reset

class MyCodeCompletionModel(AbstractJSONFileCodeCompletionModel):

    MIMETYPES = [] # List of mimetypes E.G.: ['application/javascript', 'text/html']
    TITLE_AUTOCOMPLETION = "My Auto Completion Model"
    FILE_PATH = 'my_autocompletion.json'
    # Operators to separate the instrunctions
    OPERATORS = ["=", " ", "[", "]", "(", ")", "{", "}", ":", ">", "<",
                 "+", "-", "*", "/", "%", " && ", " || ", ","]

@kate.init
@kate.viewCreated
def createSignalAutocompleteJS(view=None, *args, **kwargs):
    view = view or kate.activeView()
    cci = view.codeCompletionInterface()
    cci.registerCompletionModel(my_code_completion_model)

my_code_completion_model = MyCodeCompletionModel(kate.application)
my_code_completion_model.modelReset.connect(reset)

The my_autocompletion.json file should have this format:

{
    "xxx": {
      "category": "module",
      "children": {
        "www": {
          "category": "class",
          "children": {}
        },
        "yyy": {
          "category": "constant",
          "children": {}
        },
        "zzz": {
          "category": "function",
          "args": "(x1, x2, x3)",
          "children": {}
        }
      }
    }
  }

I encourage you to participate in the KDE project, for me this participation has been very simple because this community is very, very open.

Thanks all,

See also