merrickluo / lsp-tailwindcss

the lsp-mode client for tailwindcss
GNU General Public License v3.0
180 stars 21 forks source link

Can you provide an implementation of lsp-birdge? #41

Closed ghost closed 1 year ago

ghost commented 2 years ago

make sure to read the troubleshooting guide first.

lsp-bridge is an ultra-fast implementation of lsp client. For a slow lsp server such as tailwindcss, emacs can be completed without lag. I'm trying to provide tailwindcss support for it, but I'm getting a lot of errors when starting the server, here are some of my startup parameter configurations:

{
  "name": "tailwindcss",
  "languageId": "html",
  "command": ["tailwindcss-language-server", "--stdio"],
  "settings": {},
  "capabilities": {
    "completionProvider": {
      "resolveProvider": true
    },
    "codeActionProvider": true,
    "colorProvider": true,
    "hoverProvider": true,
    "textDocumentSync": 1
  },
  "initializationOptions": {
    "configuration": {
      "tailwindCSS": {
        "emmetCompletions": false,
        "showPixelEquivalents": true,
        "rootFontSize": 16,
        "validate": true,
        "lint": {
          "invalidScreen": "error",
          "invalidVariant": "error",
          "invalidTailwindDirective": "error",
          "invalidApply": "error",
          "invalidConfigPath": "error",
          "cssConflict": "warning",
          "recommendedVariantOrder": "warning"
        },
        "experimental": {
          "classRegex": ""
        },
        "classAttributes": ["class", "className", "ngClass"]
      }
    }
  }
}
{
   "jsonrpc": "2.0",
   "id": 49518,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'hover')"
   }
}

The result is that the initialization fails. Can you see the problem?

merrickluo commented 2 years ago

I haven't tried lsp-bridge yet, but in your snippet, it seems the capabilities part should not be required, example: https://github.com/manateelazycat/lsp-bridge/blob/master/langserver/clangd.json

And the error is come from the server trying to read params.capabilities.textDocument.hover.dynamicRegistration, so you probably should remove the capabilities part and let lsp-bridge handle it.

Let me know if it works 😄.

ghost commented 2 years ago

thank you for your reply. I tried removing the capabilities field, but got the error as below. This should be caused by lsp-birdge not parsing this field?

{
   "jsonrpc": "2.0",
   "id": 65353,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'hover')"
   }
}
ghost commented 2 years ago

thank you for your reply. I tried removing the capabilities field, but got the error as below. This should be caused by lsp-birdge not parsing this field?

{
   "jsonrpc": "2.0",
   "id": 65353,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'hover')"
   }
}

When I upgraded lsp-bridge to 2.0 and deleted the custom capablities field, lsp-bridge did process it by itself, but I still got an error. The following is the parameter configuration and error message parsed by lsp-bridge:

--- Send (28384): initialize

{
   "id": 28384,
   "method": "initialize",
   "params": {
      "processId": 1352672,
      "rootPath": "/home/evanmeek/Documents/code/project/web/domeland-ui",
      "clientInfo": {
         "name": "emacs",
         "version": "GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)\n of 2022-04-28"
      },
      "rootUri": "file:///home/evanmeek/Documents/code/project/web/domeland-ui",
      "capabilities": {
         "workspace": {
            "configuration": true
         },
         "textDocument": {
            "completion": {
               "completionItem": {
                  "snippetSupport": true,
                  "deprecatedSupport": true,
                  "tagSupport": {
                     "valueSet": [
                        1
                     ]
                  }
               }
            }
         }
      },
      "initializationOptions": {
         "configuration": {
            "tailwindCSS": {
               "emmetCompletions": false,
               "showPixelEquivalents": true,
               "rootFontSize": 16,
               "validate": true,
               "lint": {
                  "invalidScreen": "error",
                  "invalidVariant": "error",
                  "invalidTailwindDirective": "error",
                  "invalidApply": "error",
                  "invalidConfigPath": "error",
                  "cssConflict": "warning",
                  "recommendedVariantOrder": "warning"
               },
               "experimental": {
                  "classRegex": ""
               },
               "classAttributes": [
                  "class",
                  "className",
                  "ngClass"
               ]
            }
         }
      }
   },
   "jsonrpc": "2.0"
}

-- Recv message (error):

{
   "jsonrpc": "2.0",
   "id": 28384,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'dynamicRegistration')"
   }
}

Is this an error caused by the lack of textDocument/completion/dynamicRegistration sent by lsp-bridge?

ghost commented 2 years ago

thank you for your reply. I tried removing the capabilities field, but got the error as below. This should be caused by lsp-birdge not parsing this field?

{
   "jsonrpc": "2.0",
   "id": 65353,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'hover')"
   }
}

When I upgraded lsp-bridge to 2.0 and deleted the custom capablities field, lsp-bridge did process it by itself, but I still got an error. The following is the parameter configuration and error message parsed by lsp-bridge:

--- Send (28384): initialize

{
   "id": 28384,
   "method": "initialize",
   "params": {
      "processId": 1352672,
      "rootPath": "/home/evanmeek/Documents/code/project/web/domeland-ui",
      "clientInfo": {
         "name": "emacs",
         "version": "GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)\n of 2022-04-28"
      },
      "rootUri": "file:///home/evanmeek/Documents/code/project/web/domeland-ui",
      "capabilities": {
         "workspace": {
            "configuration": true
         },
         "textDocument": {
            "completion": {
               "completionItem": {
                  "snippetSupport": true,
                  "deprecatedSupport": true,
                  "tagSupport": {
                     "valueSet": [
                        1
                     ]
                  }
               }
            }
         }
      },
      "initializationOptions": {
         "configuration": {
            "tailwindCSS": {
               "emmetCompletions": false,
               "showPixelEquivalents": true,
               "rootFontSize": 16,
               "validate": true,
               "lint": {
                  "invalidScreen": "error",
                  "invalidVariant": "error",
                  "invalidTailwindDirective": "error",
                  "invalidApply": "error",
                  "invalidConfigPath": "error",
                  "cssConflict": "warning",
                  "recommendedVariantOrder": "warning"
               },
               "experimental": {
                  "classRegex": ""
               },
               "classAttributes": [
                  "class",
                  "className",
                  "ngClass"
               ]
            }
         }
      }
   },
   "jsonrpc": "2.0"
}

-- Recv message (error):

{
   "jsonrpc": "2.0",
   "id": 28384,
   "error": {
      "code": -32603,
      "message": "Request initialize failed with message: Cannot read properties of undefined (reading 'dynamicRegistration')"
   }
}

Is this an error caused by the lack of textDocument/completion/dynamicRegistration sent by lsp-bridge?

I tried to modify the source code and add the dynamicRegistration field to the textDocument/completion of capabilities, but still this error will be prompted. It seems that I have to start with the source code of tailwindcss server.

merrickluo commented 2 years ago

yeah, it seems lsp-bridge haven't implemented those capabilities yet, and I'm not sure if the language server requires it or just forgot to guard that situation, it's made for vscode after all.

to be comparison, this is the capabilities `lsp-mode` send while initialization
 "capabilities":  {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": false,
        "willRename": false,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "linkSupport": true
      },
      "definition": {
        "linkSupport": true
      },
      "implementation": {
        "linkSupport": true
      },
      "typeDefinition": {
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "details",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": null,
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showMessage": null,
      "showDocument": {
        "support": true
      }
    }
  }
merrickluo commented 1 year ago

close due to inactivity.