[fpc-pascal] Pascal Language Server
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Apr 23 16:11:35 CEST 2020
On Thu, 23 Apr 2020 20:45:58 +0700
Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> > On Apr 23, 2020, at 8:20 PM, Arjan Adriaanse <arjan at adriaan.se>
> > wrote:
> >
> > Perhaps not all the used generics features are available yet in
> > older FPC versions. I use the most recent release candidate from
> > ftp://ftp.freepascal.org/pub/fpc/beta/3.2.0-rc1/ [2], but will
> > investigate if older versions also work.
>
> Lazbuild used FPC 3.0.4. How do I make lazbuild choose the trunk
> instead of 3.0.4?
Help:
lazbuild -h
lazbuild --compiler=/usr/lib/fpc/3.3.1/ppcx64
> The first thing to address is TCompletion.Process and how it
> interacts with code tools. For example:
>
> URI := ParseURI(textDocument.uri);
> Code := CodeToolBoss.FindFile(URI.Path + URI.Document);
> X := position.character;
> Y := position.line;
> Line := Code.GetLine(Y);
> GetIdentStartEndAtPosition(Line, X + 1, PStart, PEnd);
> CodeToolBoss.IdentifierList.Prefix := Copy(Line, PStart, PEnd -
> PStart);
>
> How LSP is intended to work is that a text buffer which contains the
> current state of the file is sent to the server and then this buffer
> is parsed. I think what the code above does is only operate on the
> file on disk. This maybe be fine for certain completions but it will
> be static until the user saves the file in the client. Worse yet is
> that the text offset we receive from the client is going to be out of
> sync.
Codetools checks used files and automatically reloads them.
> Here's an example request:
>
> {
> "method" : "textDocument/didChange",
> "jsonrpc" : "2.0",
> "params" : {
> "textDocument" : {
> "uri" :
> "file:///Users/ryanjoseph/Desktop/FPCLS-Test/parser_test.pas",
> "version" : 1 },
> "contentChanges" : [
> {
> "text" : "..."
> }
> ]
> }
> }
If LSP updates parser_test.pas, then codetools will notice.
If LSP only sends changes, then you have to apply these changes to
codetools codebuffers:
Code.Insert/Delete/Replace/Move
Modified codebuffers are not auto updated from disk, until you Revert or
Save.
> and a hover request which shows the problem. Line 10 is from the
> didChange request, not line 10 from the file on disk.
>
> {
> "method" : "textDocument/hover",
> "jsonrpc" : "2.0",
> "id" : 3,
> "params" : {
> "textDocument" : {
> "uri" :
> "file:///Users/ryanjoseph/Desktop/FPCLS-Test/parser_test.pas" },
> "position" : {
> "line" : 10,
> "character" : 13
> }
> }
> }
Mattias
More information about the fpc-pascal
mailing list