[Lazarus] Copilot, VS Code, and OmniPascal
Michael Van Canneyt
michael at freepascal.org
Mon May 15 20:16:04 CEST 2023
On Mon, 15 May 2023, Anthony Walter via lazarus wrote:
> Hello all!
> I would very much like to use Github Copilot with Free Pascal, and possibly
> within the Lazarus IDE.
> I have been using Github Copilot a lot recently with my C and C# coding
> projects and have found it to be an immensely useful tool. Recently I used
> it rapidly to create documentation comments for a large C# API I wrote and
> was impressed with the speed and accuracy. I've also found it extremely
> productive when it comes to working with third-party libraries where I
> haven't much used a new-to-me library. Copilot aids me greatly by
> generating code to do tasks with such code while I learn and become
> familiar with how to use the aforementioned libraries.
> This has led me to experiment with using Github Copilot in Visual Studio
> Code with Pascal, and while it simply works by opening files with a ".pas"
> extension, there is obviously a lot more which can be done to make a tool
> like Copilot with better IDE support. Specifically supporting Pascal
> project files that reference packages with their unit source paths,
> building and debugging, and problem solving (fixing errors in source code).
> My question to you in the Lazarus community is has anyone even attempted to
> integrate the Copilot system into Lazarus? If this is not at all possible,
> has anyone here used the OmniPascal extension to VS Code and configured it
> to work with lazbuild and have working tasks and launch JSON configuration
> files they could share along with their insights? I've googled a few
> supposed "guides" on the subject and found them to be horribly wrong or
> missing many critical steps.
I've discarded OmniPascal, because it eats 100% cpu on Linux on every
project I tried, and that is simply unacceptable.
It's also closed source, so we can't improve it.
Instead I'm working with Ryan Joseph on the Pascal LSP based on the lazarus code tools:
This project does not yet give all the possibilities of Omnipascal, but
it is very usable (identifier completion and code completion work) and
we're improving it still.
I've made many improvements and stabilized the code, removed all memleaks.
It's now also ready to listen on a socket instead of stdin and can be
At the same time Mattias Gaertner and I are improving the fcl-passrc codebase
so it contains some error-recovery mechanisms. Currently it stops at the
first error, we're improving this so it tries to continue to analyze the
code. This work is needed to provide better user experience in Pas2js
and will give better diagnostics than the Lazarus codetools give us.
The codetools are very forgiving of errors, so it keeps functioning in the
presence of some errors, which is a different goal than the what the
Once that is done, I plan to continue to work on the LSP process to
integrate the new possibilities, and then provide an additional
VS Code extension that does some project management
for lazarus and lazbuild.
Any help on this project is of course more than welcome.
More information about the lazarus