BlogKate linter plugin Syndicate content

Thu, 01/15/2009 - 18:58

Just a quicky: I wrote a little plugin for KTextEditor which supplies you with basic error checking when you save documents. Currently only PHP (via php -l) and JavaScript (via JavaScript Lint) are supported.

Screenshots
Requirements
  • usual tools for compiling C++, e.g. gcc.
  • cmake
  • Qt development packages, i.e. under Ubuntu: sudo aptitude install libqt4-dev
  • KDE 4.2 with development packages for kdelibs and kdebase, i.e. under Ubuntu: sudo aptitude install kdebase-dev kdebase-workspace-dev kdelibs5-dev. Note: You’ll need the experimental KDE 4.2 packages activated as of now, see for example the Kubuntu news on KDE 4.2 RC1 for hints.
  • proper setup of environment variables, read this techbase article for more information. the .bashrc linked there should be enough for most people
  • For PHP support: a PHP executable which supports the -l switch for linting
  • For JavaScript support: a JavaScript Lint executable, you could download and compile the sources for example.
Installing

Get the sources for the linter plugin from KDE SVN and compile it, using e.g. the functions supplied via the .bashrc mentioned above:

  1. # go to your development folder
  2. cs
  3. # checkout sources
  4. svn co svn://anonsvn.kde.org/home/kde/trunk/playground/devtools/kte_linter
  5. cd kte_linter
  6. # build base linter plugin
  7. cd linter
  8. cmakekde
  9. # build php linter plugin
  10. cd ../phplinter
  11. cmakekde
  12. # build javascript linter plugin
  13. cd ../jslinter
  14. cmakekde
  15. # update sycoca
  16. kbuildsycoca4
  17. # start editor and select the plugins - happy coding!
  18. kwrite
Todo
  • Support for more languages

    If you know good linters drop me a note. But it would be even better if you could write your own linter plugin. It’s pretty easy, take a look at one of the existing plugins for a skeleton & documentation.

  • Right now each plugin returns a hardcoded list of highlighting-modes which it supports for linting. This should be made configurable so that custom highlighting modes are supported

  • make error messages more pretty

Happy coding!

Comments

Hi, Just what I was looking Mon, 10/22/2012 - 13:26 — David Anderson (not verified)

Hi,

Just what I was looking for, if I could get it to work…

1) If I start up a session with PHP documents open, then it shows an error “exitCode 0, exitStatus 1” for every PHP document (whether it has errors or not)

2) It correctly detects whether a file has an error or not, but the window it opens to show the error is always empty. (i.e. If the file is good, then nothing happens upon saving - but if the file is bad then it throws up a window which has nothing inside it).

This is with KDE 4.8.5 on Fedora 16.

That is very cool! Mon, 09/28/2009 - 15:19 — Medifast (not verified)

That is very cool!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options