Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ clients/pasls-vscode/out/*
# 3rd-party editor projects
*.code-workspace
*.sublime-project
*.sublime-workspace
*.sublime-workspace

/src/tests/testlsp
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ configuration options.

### Configuration

#### pasls
The standard language server reads configuration in this order:

1. built-in defaults
2. `/etc/pasls.cfg`
3. `~/.pasls.cfg`
4. `.pasls.cfg` in the workspace root
5. process environment variables
6. LSP initialization options

Project selections are saved only to the workspace `.pasls.cfg`. If multiple
main programs are discovered, clients can call `pasls.selectMainProgram` with
the selected `.lpr` or `.dpr` path to persist it.

```ini
[Project]
MainProgram=src/app.lpr

[PasLS]
CodeToolsConfig=codetools.config
LazarusConfig=.lazarus

[CodeTools]
Compiler=/usr/bin/fpc
FPCDir=/usr/share/fpcsrc
LazarusDir=/usr/share/lazarus
TargetOS=linux
TargetCPU=x86_64
FPCOptions=-Fuunits -Fiinclude -dDEBUG
```

#### paslssock
The paslssock server can read an initialization file with 2 sections,
`Server` and `CodeTools`. These can be used to set another port on which to
Expand Down
4 changes: 2 additions & 2 deletions src/serverprotocol/PasLS.AllCommands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ interface
PasLS.Command.CompleteCode,
PasLS.Command.InvertAssignment,
PasLS.Command.RemoveEmptyMethods,
PasLS.Command.RemoveUnusedUnits;
PasLS.Command.RemoveUnusedUnits,
PasLS.Command.SelectMainProgram;

procedure RegisterAllCommands;

Expand Down Expand Up @@ -90,4 +91,3 @@ procedure RegisterAllCommands;
end;

end.

60 changes: 60 additions & 0 deletions src/serverprotocol/PasLS.Command.SelectMainProgram.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Pascal Language Server
// Copyright 2026

unit PasLS.Command.SelectMainProgram;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, fpJSON,
LSP.BaseTypes, PasLS.Commands;

type

{ TSelectMainProgramCommand }

TSelectMainProgramCommand = class(TCustomCommand)
protected
function DoExecute(aArguments: TJSONArray): TLSPStreamable; override;
public
class function CommandName: string; override;
end;

implementation

uses
PasLS.Settings;

function TSelectMainProgramCommand.DoExecute(aArguments: TJSONArray): TLSPStreamable;
var
MainProgram: String;
begin
Result := nil;
if (aArguments = nil) or (aArguments.Count = 0) then
Exit;

MainProgram := ExpandFileName(aArguments.Strings[0]);
if not FileExists(MainProgram) then
begin
Transport.SendDiagnostic('Main program file "'+MainProgram+'" can''t be found.');
Exit;
end;

ServerSettings.&program := MainProgram;
if SaveProjectMainProgram(MainProgram) then
Transport.SendDiagnostic('Saved main program to '+ProjectConfigFile)
else
Transport.SendDiagnostic('Main program selected for this session, but project config context is unavailable.');
end;

class function TSelectMainProgramCommand.CommandName: string;
begin
Result := 'pasls.selectMainProgram';
end;

initialization
TSelectMainProgramCommand.Register;

end.
Loading