genericptr / pascal-language-server

LSP server implementation for Pascal
GNU General Public License v3.0
53 stars 15 forks source link

Language Server Reports too few Capabilities #85

Open mskamp opened 7 months ago

mskamp commented 7 months ago

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.

genericptr commented 7 months ago

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?

mvancanneyt commented 7 months ago

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

LinusDenning2001 commented 1 month ago

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?

mskamp commented 1 month ago

@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