pascal-language-server icon indicating copy to clipboard operation
pascal-language-server copied to clipboard

Language Server Reports too few Capabilities

Open mskamp opened this issue 1 year ago • 4 comments

With a build of the latest trunk, the language server claims to support a very limited set of capabilities:

"capabilities":{"referencesProvider":false,"executeCommandProvider":{"commands":["pasls.formatCode","pasls.completeCode","pasls.invertAssignment","pasls.removeEmptyMethods"]},"documentHighlightProvider":false,"hoverProvider":false,"workspaceSymbolProvider":false,"declarationProvider":false,"signatureHelpProvider":{"triggerCharacters":[]},"documentSymbolProvider":true,"definitionProvider":false,"workspace":{"workspaceFolders":{"changeNotifications":false,"supported":false}},"textDocumentSync":{"save":{"includeText":false},"willSaveWaitUntil":false,"willSave":false,"change":1,"openClose":true},"codeActionProvider":false,"completionProvider":{"allCommitCharacters":[],"resolveProvider":false,"triggerCharacters":[]},"implementationProvider":false}

For example, since "referencesProvider":false, the language server claims to not support the “references” method, contrary to what is claimed in README.md.

It appears that this behavior has changed with commit d70ca94dcff452406ca154d8871300a099d3c24b. Notably, the call to ApplySettings has been removed but not inserted again. The logic for setting capabilities like "referencesProvider", however, has been moved to ApplySettings. Yet, this method is never called.

When adding a call to ApplySettings in PasLS.General.pas:443, the reported capabilities change as follows:

"capabilities":{"referencesProvider":true,"executeCommandProvider":{"commands":["pasls.formatCode","pasls.completeCode","pasls.invertAssignment","pasls.removeEmptyMethods"]},"documentHighlightProvider":true,"hoverProvider":true,"workspaceSymbolProvider":false,"declarationProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",")",","]},"documentSymbolProvider":true,"definitionProvider":true,"workspace":{"workspaceFolders":{"changeNotifications":true,"supported":true}},"textDocumentSync":{"save":{"includeText":false},"willSaveWaitUntil":false,"willSave":false,"change":1,"openClose":true},"codeActionProvider":false,"completionProvider":{"allCommitCharacters":[],"resolveProvider":false,"triggerCharacters":[".","^"]},"implementationProvider":true}

This list is more in line with the claims in README.md. Still, I'm not sure where ApplySettings is supposed to be called and if the position noted above is the intended one.

mskamp avatar Mar 31 '24 10:03 mskamp

I think this was a regression from an overhaul by @mvancanneyt. Not sure anything can work with ApplySettings being called! What do you think Michael?

genericptr avatar Mar 31 '24 12:03 genericptr

I think it was an oversight while reworking the code. ApplySettings() should be called, I will look into it.

mvancanneyt avatar Apr 01 '24 15:04 mvancanneyt

I'm also having an issue with the server capabilities being claimed to be limited.

@mskamp how exactly did you call the ApplySettings function so I can do the same?

LinusDenning2001 avatar Sep 19 '24 12:09 LinusDenning2001

@LinusDenning2001 Here is the diff of my changes, which I've applied to the current trunk:

diff --git a/src/serverprotocol/PasLS.General.pas b/src/serverprotocol/PasLS.General.pas
index 2669aff..8436bda 100644
--- a/src/serverprotocol/PasLS.General.pas
+++ b/src/serverprotocol/PasLS.General.pas
@@ -441,6 +441,8 @@ begin
         IdentifierList.SortMethodForCompletion:=icsScopedAlphabetic;
       end;
 
+    Result.Capabilities.ApplySettings(ServerSettings);
+
     // Set search path for codetools.
     RootPath:=TDefineTemplate.Create('RootPath','RootPath','',CodetoolsOptions.ProjectDir,da_Directory);
     if ServerSettings.includeWorkspaceFoldersAsUnitPaths then

mskamp avatar Sep 19 '24 16:09 mskamp