vim support for SWI-Prolog

1,028 views
Skip to first unread message

Boris Vassilev

unread,
Sep 15, 2015, 7:16:00 AM9/15/15
to swi-p...@googlegroups.com
Hello,

I was finally provoked to ask that question:

Does anyone use vim as a primary editor with SWI-Prolog? I realize it is not optimal. There seems to be a built-in syntax file for Prolog, but it is very (very) limited. There is also this one repository on github (https://github.com/adimit/prolog.vim), but as it is at the moment it does have some issues.

If anyone has setup their vim and are happy with it, can you please share it? It will be highly appreciated. Even syntax highlighting that just works (tm) with SWI V7 would already be great.

If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.

Thank you,
Boris

Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
Save our in-boxes! http://emailcharter.org

Samer Abdallah

unread,
Sep 15, 2015, 9:43:21 AM9/15/15
to Boris Vassilev, swi-p...@googlegroups.com

On 15 Sep 2015, at 12:15, Boris Vassilev <boris.v...@gmail.com> wrote:

> Hello,
>
> I was finally provoked to ask that question:
>
> Does anyone use vim as a primary editor with SWI-Prolog?

Yes - me!
I like vim.
Though I do curse it sometimes.
Once I heard of a magical foot pedal that would allow you switch between
insert and command mode without using your fingers, but this may be
an apocryphal story.

> I realize it is not optimal. There seems to be a built-in syntax file for Prolog, but it is very (very) limited. There is also this one repository on github (https://github.com/adimit/prolog.vim), but as it is at the moment it does have some issues.
>
> If anyone has setup their vim and are happy with it, can you please share it? It will be highly appreciated. Even syntax highlighting that just works (tm) with SWI V7 would already be great.

Well, I had my own modifications to the syntax highlighting definition, but it doesn’t handle some things,
like 0’x code literals, very well (or at all in fact), but more recently I’ve noticed the standard vim Prolog
on other machines doing quite well with escapes in string literals and even code literals. I could look into
this and try to merge them into a best-of-both sort of thing.

cheers,
Samer

>
> If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.
>
> Thank you,
> Boris
>
> Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
> Save our in-boxes! http://emailcharter.org
>
> --
> You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

signature.asc

Paulo Moura

unread,
Sep 15, 2015, 11:25:29 AM9/15/15
to swi-p...@googlegroups.com
Hi Boris,

> On 15/09/2015, at 12:15, Boris Vassilev <boris.v...@gmail.com> wrote:
>
> Hello,
>
> I was finally provoked to ask that question:
>
> Does anyone use vim as a primary editor with SWI-Prolog? I realize it is not optimal. There seems to be a built-in syntax file for Prolog, but it is very (very) limited.

You can use Logtalk's vim support for Prolog files as well:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding/vim

Besides syntax highlighting, it also provides code completion.

> There is also this one repository on github (https://github.com/adimit/prolog.vim), but as it is at the moment it does have some issues.
>
> If anyone has setup their vim and are happy with it, can you please share it? It will be highly appreciated. Even syntax highlighting that just works (tm) with SWI V7 would already be great.

The bundle above supports ISO Prolog features and some de facto standard ones (besides, of course, Logtalk features). But feel free to use it as a basis for a SWI-Prolog specific one. Just be sure that you named after SWI. Don't use just "prolog" as different Prolog systems provide different set of built-ins and syntax extensions (as you know).

Cheers,

Paulo

P.S. For support for other text editors and syntax highlighters see:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding


> If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.
>
> Thank you,
> Boris
>
> Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
> Save our in-boxes! http://emailcharter.org
>
> --
> You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:pmo...@logtalk.org>
Web: <http://logtalk.org/>
-----------------------------------------------------------------




-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:pmo...@logtalk.org>
Web: <http://logtalk.org/>
-----------------------------------------------------------------




Anne Ogborn

unread,
Sep 15, 2015, 3:43:08 PM9/15/15
to Samer Abdallah, Boris Vassilev, swi-p...@googlegroups.com
Sameer -

Over the years I've built a number of foot operated keyboards for stroke victims. There are now several
that are commercially available. The ones I built were mostly for Second Life users - SL depends heavily on chording with ctrl-alt-shift, so I made some that chorded well.

http://www.amazon.com/Control-Keyboard-Action-Switch-Pedal/dp/B00B3PV47O/ref=sr_1_1?ie=UTF8&qid=1442342856&sr=8-1&keywords=foot+keyboard+usb

If you find it slides around out from under your feet, gluing it to a piece of rough plywood (OSB works well) helps.

Another alternative is a set of foot pedals for a flight simulator. Like real aircraft, they have right-left by pushing on pedals, and heel-toe motion for 'brakes' (which presumably is where you'd wire them).

I've used the Java Robot library and java joystick to do the software. It was relatively pain free.

I've struggled with RSI on and off, and went through a period of experimenting with alternative input methods to deal with it. At one point I had a tablet for a mouse. That worked well for pointing, but the button on the pen really aggravated the RSI. I found a racing game steering wheel with a shift control, so I sat the wheel off to the side and used the shifter as mouse buttons. Since I had everything wired up, I wondered what to do with the wheel angle data. I wired it to scroll. This turned out to be great - I could grab the wheel and scroll to where I wanted.

Later on I tried the foot pedals, but they were never that useful.

Besides flight sim gear, musicians MIDI gear and adaptive aids for the disabled have promise.

Most of these flight simulator type controls come with lots of extra knobs, levers, and switches, and I fiddled around with wiring them up. Ultimately, I discovered why real aircraft designers moved to using 'glass cockpits' (monitor type LCD displays) - the information density each way is just plain higher. It becomes really confusing to remember where you wired the switch between regex and straight text up to.

But, I admit, my workstation looked a lot cooler at the height of the experimenting.



::Annie is here, hanging upside down in a full motion flight simulator that's thrashing around dangerously. She's fixing a bug::

ps - I sometimes do some work with NUI's (gesture interfaces using Kinect and similar 3D cameras) - Unfortunately the two periods didn't overlap.

Boris Vassilev

unread,
Sep 16, 2015, 3:51:10 AM9/16/15
to Paulo Moura, swi-p...@googlegroups.com
Hello Paulo (and everyone),

this is indeed a proper "drop-in" replacement, and it seems to handle "vanilla" Prolog much better than what I have been using until now. Thanks a bunch!

The configuration files look a bit easier to understand and modify than the ones I was using previously, too.

Cheers,
Boris

Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
Save our in-boxes! http://emailcharter.org

On Tue, Sep 15, 2015 at 6:20 PM, Paulo Moura <pmo...@logtalk.org> wrote:
Hi Boris,

> On 15/09/2015, at 12:15, Boris Vassilev <boris.v...@gmail.com> wrote:
>
> Hello,
>
> I was finally provoked to ask that question:
>
> Does anyone use vim as a primary editor with SWI-Prolog? I realize it is not optimal. There seems to be a built-in syntax file for Prolog, but it is very (very) limited.

You can use Logtalk's vim support for Prolog files as well:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding/vim

Besides syntax highlighting, it also provides code completion.
> There is also this one repository on github (https://github.com/adimit/prolog.vim), but as it is at the moment it does have some issues.
>
> If anyone has setup their vim and are happy with it, can you please share it? It will be highly appreciated. Even syntax highlighting that just works (tm) with SWI V7 would already be great.

The bundle above supports ISO Prolog features and some de facto standard ones (besides, of course, Logtalk features). But feel free to use it as a basis for a SWI-Prolog specific one. Just be sure that you named after SWI. Don't use just "prolog" as different Prolog systems provide different set of built-ins and syntax extensions (as you know).

Cheers,

Paulo

P.S. For support for other text editors and syntax highlighters see:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding
> If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.
>
> Thank you,
> Boris
>
> Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
> Save our in-boxes! http://emailcharter.org
>

Jan Wielemaker

unread,
Sep 16, 2015, 4:01:33 AM9/16/15
to Boris Vassilev, Paulo Moura, swi-p...@googlegroups.com
On 09/16/2015 09:50 AM, Boris Vassilev wrote:
> Hello Paulo (and everyone),
>
> this is indeed a proper "drop-in" replacement, and it seems to handle
> "vanilla" Prolog much better than what I have been using until now.
> Thanks a bunch!
>
> The configuration files look a bit easier to understand and modify than
> the ones I was using previously, too.

You probably won't get the realtime semantic colouring, documentation
info, jumping to called code, etc. You might using the techniques I'm
using for the SWISH editor if you can establish a socket connection from
vim to Prolog. The alternative is probably what I did when I was using
Visual Studio for the Windows port: use your daily editor to write the
bunch of the code and next use the dedicated editor for fixing compiler
errors and debugging.

Cheers --- Jan

>
> Cheers,
> Boris
>
> Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
> Save our in-boxes! http://emailcharter.org
>
> On Tue, Sep 15, 2015 at 6:20 PM, Paulo Moura <pmo...@logtalk.org
> <mailto:pmo...@logtalk.org>> wrote:
>
> Hi Boris,
>
> > On 15/09/2015, at 12:15, Boris Vassilev <boris.v...@gmail.com <mailto:boris.v...@gmail.com>> wrote:
> >
> > Hello,
> >
> > I was finally provoked to ask that question:
> >
> > Does anyone use vim as a primary editor with SWI-Prolog? I realize it is not optimal. There seems to be a built-in syntax file for Prolog, but it is very (very) limited.
>
> You can use Logtalk's vim support for Prolog files as well:
>
> https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding/vim
>
> Besides syntax highlighting, it also provides code completion.
>
> > There is also this one repository on github (https://github.com/adimit/prolog.vim), but as it is at the moment it
> does have some issues.
> >
> > If anyone has setup their vim and are happy with it, can you please share it? It will be highly appreciated. Even syntax highlighting that just works (tm) with SWI V7 would already be great.
>
> The bundle above supports ISO Prolog features and some de facto
> standard ones (besides, of course, Logtalk features). But feel free
> to use it as a basis for a SWI-Prolog specific one. Just be sure
> that you named after SWI. Don't use just "prolog" as different
> Prolog systems provide different set of built-ins and syntax
> extensions (as you know).
>
> Cheers,
>
> Paulo
>
> P.S. For support for other text editors and syntax highlighters see:
>
> https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding
>
>
> > If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.
> >
> > Thank you,
> > Boris
> >
> > Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
> > Save our in-boxes!http://emailcharter.org
> >
> > --
> > You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email toswi-prolog...@googlegroups.com
> <mailto:swi-prolog%2Bunsu...@googlegroups.com>.
> > Visit this group athttp://groups.google.com/group/swi-prolog.
> > For more options, visithttps://groups.google.com/d/optout.
>
> -----------------------------------------------------------------
> Paulo Moura
> Logtalk developer
>
> Email: <mailto:pmo...@logtalk.org <mailto:pmo...@logtalk.org>>
> Web: <http://logtalk.org/>
> -----------------------------------------------------------------
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.

Stephen Coda

unread,
Sep 16, 2015, 4:59:54 AM9/16/15
to SWI-Prolog, boris.v...@gmail.com, pmo...@logtalk.org
the alternative is probably what I did when I was using 

Visual Studio for the Windows port: use your daily editor to write the 
bunch of the code and next use the dedicated editor for fixing compiler 
errors and debugging. 

That's pretty much what I'm doing, swapping between my default emacs setup and PCEmacs.

Boris Vassilev

unread,
Sep 16, 2015, 5:02:47 AM9/16/15
to Jan Wielemaker, swi-p...@googlegroups.com
Hello Jan,

I realize how much I am missing out by not using PceEmacs.

There are ways to get vim to work with external syntax checkers (the "syntastic" vim plugin, for example), so what you suggest must be doable, too. I just don't know enough to be even able to estimate how much effort it would be for me :(

Editing in vim (with proper syntax highlighting, automatic indenting etc) + compiling / testing from the top level has worked out decently for me, although I have not yet done any bigger project in Prolog....

Thank you again,
Boris

Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
Save our in-boxes! http://emailcharter.org

Jan Wielemaker

unread,
Sep 16, 2015, 5:15:29 AM9/16/15
to Boris Vassilev, swi-p...@googlegroups.com
On 09/16/2015 11:02 AM, Boris Vassilev wrote:
> Hello Jan,
>
> I realize how much I am missing out by not using PceEmacs.
>
> There are ways to get vim to work with external syntax checkers (the
> "syntastic" vim plugin, for example), so what you suggest must be
> doable, too. I just don't know enough to be even able to estimate how
> much effort it would be for me :(

All I can say is that there is quite some support that is reusable
in quite different contexts. All the smart colouring is in
library(prolog_colour), which is used by PceEmacs as well as the
HTML generation for PlDoc and SWISH. In PceEmacs it is a very close
in-process interaction. In PlDoc it is a one-shot process and in
SWISH the server and client work asynchronously to deal with network
latency and bandwidth.

The Eclipse PDT environment defines some extensions that enhance the
embedded console interaction (completion, single-keystroke interaction).

Thanks to the PDT work, most of the stuff an IDE needs is now
made available using (somewhat) documented and stable interfaces.

Cheers --- Jan

Markus Triska

unread,
Sep 16, 2015, 4:01:47 PM9/16/15
to SWI-Prolog
Hi Boris,


On Tuesday, September 15, 2015 at 1:16:00 PM UTC+2, boris.vassilev wrote:
 
If someone has a good argument towards "Don't use vim for Prolog", I will accept this as an answer too.

There are some strong arguments for using GNU Emacs when working with Prolog. One is the excellent Prolog mode by Stefan Bruda and others, which now is bundled with GNU Emacs (M-x prolog-mode). It has many nice features for electric indentation, good syntax highlighting etc.

Also, there are Emacs definitions that let you query Prolog within the same Emacs buffer you are currently working on, and get the results directly in the buffer with a single key binding:


This gets more useful the more you use Emacs: You can do this in Prolog files, mail messages, git commit logs etc., if you do this from within Emacs. I also find such embedded queries very useful in comments, documentation and test cases. I first saw this idea in Ulrich Neumerkel's great GUPU environment. Editing queries is a lot easier in Emacs than on the command line, and embedding both queries and their results naturally in Emacs buffers using a single key binding is often very valuable.

One ergonomic tip for Emacs usage: Make CapsLock act as an additional Ctrl key.
 
All the best!
Markus
Reply all
Reply to author
Forward
0 new messages