There are many options, such as the native tools, GNU-Emacs, PDT (for Eclipse), a VSC plugin and most likely more. There is also an experimental LSP (Language Server Protocol) that should allow using any editor of choice that supports LSP.
I use the native tools. Just run Prolog in a terminal (terminator), normally starting it as
swipl myfile.pl
To edit the main file, use ?- edit.
. To edit anything else that has a name (predicates, modules, files, …), use ?- edit(Name).
To find stuff anywhere in the project I split the terminal and use git grep
(always have my source under git). Then there is a script edit
in the customize
directory of the release. I install that in my ~/bin
and install a PceEmacs client from https://raw.githubusercontent.com/SWI-Prolog/packages-xpce/master/src/unx/client.c. Just compile that using cc -o xpce-client client.c
should work on most machines. Install also in ~/bin
. Now, if the Prolog editor is open you can run from any terminal
edit file:line[:column]
To edit at that position. That works nicely with git grep
as well as to copy paste locations of error messages for editing. Note that the commandline also allows for editing a file+line. Typically only use the plain file name, i.e. myfile
to avoid the need for quotes.
?- edit(file:line).
edit If you use terminator. consider adding the editor plugin. See Install SWI on Catalina? - #10 by jan
After editing sources I normally type ?- make.
in the Prolog console to update the compiled image and try again. You can also compile from the PceEmacs editor. Note that the editor runs in its own Prolog thread. This allows editing while the program runs. Prolog/View threads
can come handy to see a dynamic chart of the resource usage if your program takes long. That also allows to profile suspect threads for a while to see what it is doing.
Ultimately I hope the LSP protocol will allow for a good user experience on any IDE of the user’s preference … The native IDE works well, but it is a bit unconventional and multiple IDEs for different tasks is a burden. You might still want to use the native editor for browsing around and fixing minor issues as the highlighting and context menus on predicates, calls, files, etc. are quite helpful. That is similar to what I did when using MS Visual Studio and MSVC on Wndows: I used VS for the final steps while I used Emacs for bulk editing.
P.s. The brew
version is rather minimal. The Macports
version is complete. If you need to go source the best option is typically to install the dependencies from Macports or brew and then just compile from the git sources. First might be a bit tricky. Once working you can update easily in less than a minute.