techee / geany-lsp

LSP plugin for the Geany editor
GNU General Public License v2.0
11 stars 1 forks source link

Correctly interpret server initialize responses #15

Closed techee closed 2 months ago

techee commented 9 months ago

I got a bit lazy and didn't take these into account and only use what's enabled/disabled in the config file. So for instance, when autocompletion is enabled in the config file but the server doesn't support it, autocompletion will not work - instead, it should fall back to the TM implementation.

Since the defaults will be enabled for most options, users would have to manually disable the features the given server doesn't support to get the TM fallback which isn't very user-friendly.

Example of such a initialize response from the server is for instance something like below. Currently only some of them are parsed and used, such as commit characters or text document sync kind.

{
  "capabilities" : {
    "astProvider" : true,
    "callHierarchyProvider" : true,
    "clangdInlayHintsProvider" : true,
    "codeActionProvider" : true,
    "compilationDatabase" : {
      "automaticReload" : true
    },
    "completionProvider" : {
      "allCommitCharacters" : [
        " ",
        "\t",
        "(",
        ")",
        "[",
        "]",
        "{",
        "}",
        "<",
        ">",
        ":",
        ";",
        ",",
        "+",
        "-",
        "/",
        "*",
        "%",
        "^",
        "&",
        "#",
        "?",
        ".",
        "=",
        "\"",
        "'",
        "|"
      ],
      "resolveProvider" : false,
      "triggerCharacters" : [
        ".",
        "<",
        ">",
        ":",
        "\"",
        "/",
        "*"
      ]
    },
    "declarationProvider" : true,
    "definitionProvider" : true,
    "documentFormattingProvider" : true,
    "documentHighlightProvider" : true,
    "documentLinkProvider" : {
      "resolveProvider" : false
    },
    "documentOnTypeFormattingProvider" : {
      "firstTriggerCharacter" : "\n",
      "moreTriggerCharacter" : []
    },
    "documentRangeFormattingProvider" : true,
    "documentSymbolProvider" : true,
    "executeCommandProvider" : {
      "commands" : [
        "clangd.applyFix",
        "clangd.applyTweak"
      ]
    },
    "hoverProvider" : true,
    "implementationProvider" : true,
    "memoryUsageProvider" : true,
    "referencesProvider" : true,
    "renameProvider" : true,
    "selectionRangeProvider" : true,
    "semanticTokensProvider" : {
      "full" : {
        "delta" : true
      },
      "legend" : {
        "tokenModifiers" : [
          "declaration",
          "deprecated",
          "deduced",
          "readonly",
          "static",
          "abstract",
          "virtual",
          "dependentName",
          "defaultLibrary",
          "usedAsMutableReference",
          "functionScope",
          "classScope",
          "fileScope",
          "globalScope"
        ],
        "tokenTypes" : [
          "variable",
          "variable",
          "parameter",
          "function",
          "method",
          "function",
          "property",
          "variable",
          "class",
          "interface",
          "enum",
          "enumMember",
          "type",
          "type",
          "unknown",
          "namespace",
          "typeParameter",
          "concept",
          "type",
          "macro",
          "comment"
        ]
      },
      "range" : false
    },
    "signatureHelpProvider" : {
      "triggerCharacters" : [
        "(",
        ")",
        "{",
        "}",
        "<",
        ">",
        ","
      ]
    },
    "textDocumentSync" : {
      "change" : 2,
      "openClose" : true,
      "save" : true
    },
    "typeDefinitionProvider" : true,
    "typeHierarchyProvider" : true,
    "workspaceSymbolProvider" : true
  },
  "serverInfo" : {
    "name" : "clangd",
    "version" : "Debian clangd version 14.0.6 linux+grpc aarch64-unknown-linux-gnu"
  }
}
techee commented 9 months ago

Done for those affecting Geany behavior.

The remaining should be added too to enable/disable menu entries with corresponding functionality but these are not so critical.

techee commented 2 months ago

Done.