[Lazarus] Copilot, VS Code, and OmniPascal

Michalis Kamburelis michalis.kambi at gmail.com
Mon May 15 23:19:07 CEST 2023

On a somewhat related note, Castle Game Engine includes Pascal LSP
server. It is documented on https://castle-engine.io/vscode , along
with other notes recommending how to use Castle Game Engine with VS

Our LSP server code is
https://github.com/castle-engine/pascal-language-server , it is based
on https://github.com/Isopod/pascal-language-server (from Philip
Zander), and adds some fixes + CGE extensions (e.g. it can
automatically add paths to CGE units and options we recommend, like
ObjFpc mode). In general, most of that page is really useful to
develop any Pascal applications, I use that setup for any Pascal
applications :) To integrate this LSP with VS Code one can use the
plugin from Ryan Joseph on https://github.com/genericptr/pasls-vscode

Basically, all these Pascal LSP servers (from Ryan Joseph, from Philip
Zander, and CGE fork of Philip Zander) are quite compatible and can be
used with the same VS Code extension. And all of them use under the
hood Lazarus CodeTools, so overall their "understanding" of Pascal
code for auto-complete is quite good.

See also CGE news on
. I switched personally to VS Code, after using Emacs for ~20 years :)

And yes, Copilot (on top of the LSP server) is quite good. It can also
nicely complete code when the LSP servers don't -- e.g. it often
suggests proper variable declaration, method declaration, and more.


pon., 15 maj 2023 o 20:16 Michael Van Canneyt via lazarus
<lazarus at lists.lazarus-ide.org> napisał(a):
> 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:
> https://github.com/genericptr/pascal-language-server
> 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
> debugged.
> 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
> diagnostics needs.
> 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.
> Michael.
> --
> _______________________________________________
> lazarus mailing list
> lazarus at lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus

More information about the lazarus mailing list