Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What is my LSP client doing wrong when interacting with Harper? #314

Open
Duncan-Britt opened this issue Dec 12, 2024 · 2 comments

Comments

@Duncan-Britt
Copy link

I have a python script which allows me to log messages between my lsp client (emacs) and harper. Despite some grammatical mistakes in my test file, "How about this wrong grammars? I are full. We is good.", I'm unable to get diagnostics from Harper. Perhaps there is something simple that someone more familiar with the language server protocol could spot that I'm missing?

I noticed Harper is requesting a workspace/configuration and receiving null, perhaps that has something to do with it?

~ $ python3 lsp_proxy.py 9000 harper-ls --stdio
2024-12-11 20:10:11,432 - Using selector: KqueueSelector
2024-12-11 20:10:11,435 - LSP Proxy listening on port 9000, forwarding to command: ['harper-ls', '--stdio']
2024-12-11 20:10:15,538 - Client → Server: {
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "processId": 20129,
    "rootPath": "/Users/duncan/",
    "rootUri": "file:///Users/duncan",
    "initializationOptions": {
      "settings": {
        "userDictPath": "/Users/duncan/dict.txt",
        "fileDictPath": "/Users/duncan/.harper/"
      }
    },
    "capabilities": {
      "workspace": {
        "applyEdit": true,
        "executeCommand": {
          "dynamicRegistration": false
        },
        "workspaceEdit": {
          "documentChanges": true
        },
        "didChangeWatchedFiles": {
          "dynamicRegistration": true
        },
        "symbol": {
          "dynamicRegistration": false
        },
        "configuration": true,
        "workspaceFolders": true
      },
      "textDocument": {
        "synchronization": {
          "dynamicRegistration": false,
          "willSave": true,
          "willSaveWaitUntil": true,
          "didSave": true
        },
        "completion": {
          "dynamicRegistration": false,
          "completionItem": {
            "snippetSupport": true,
            "deprecatedSupport": true,
            "resolveSupport": {
              "properties": [
                "documentation",
                "details",
                "additionalTextEdits"
              ]
            },
            "tagSupport": {
              "valueSet": [
                1
              ]
            }
          },
          "contextSupport": true
        },
        "hover": {
          "dynamicRegistration": false,
          "contentFormat": [
            "markdown",
            "plaintext"
          ]
        },
        "signatureHelp": {
          "dynamicRegistration": false,
          "signatureInformation": {
            "parameterInformation": {
              "labelOffsetSupport": true
            },
            "activeParameterSupport": true
          }
        },
        "references": {
          "dynamicRegistration": false
        },
        "definition": {
          "dynamicRegistration": false,
          "linkSupport": true
        },
        "declaration": {
          "dynamicRegistration": false,
          "linkSupport": true
        },
        "implementation": {
          "dynamicRegistration": false,
          "linkSupport": true
        },
        "typeDefinition": {
          "dynamicRegistration": false,
          "linkSupport": true
        },
        "documentSymbol": {
          "dynamicRegistration": false,
          "hierarchicalDocumentSymbolSupport": true,
          "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
            ]
          }
        },
        "documentHighlight": {
          "dynamicRegistration": false
        },
        "codeAction": {
          "dynamicRegistration": false,
          "codeActionLiteralSupport": {
            "codeActionKind": {
              "valueSet": [
                "quickfix",
                "refactor",
                "refactor.extract",
                "refactor.inline",
                "refactor.rewrite",
                "source",
                "source.organizeImports"
              ]
            }
          },
          "isPreferredSupport": true
        },
        "formatting": {
          "dynamicRegistration": false
        },
        "rangeFormatting": {
          "dynamicRegistration": false
        },
        "rename": {
          "dynamicRegistration": false
        },
        "inlayHint": {
          "dynamicRegistration": false
        },
        "publishDiagnostics": {
          "relatedInformation": false,
          "codeDescriptionSupport": false,
          "tagSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        }
      },
      "window": {
        "workDoneProgress": true
      },
      "general": {
        "positionEncodings": [
          "utf-32",
          "utf-8",
          "utf-16"
        ]
      },
      "experimental": {}
    },
    "workspaceFolders": [
      {
        "uri": "file:///Users/duncan",
        "name": "~/"
      }
    ]
  }
}
2024-12-11 20:10:15,680 - Server → Client: {
  "jsonrpc": "2.0",
  "result": {
    "capabilities": {
      "codeActionProvider": true,
      "executeCommandProvider": {
        "commands": [
          "HarperAddToUserDict",
          "HarperAddToFileDict",
          "HarperOpen"
        ]
      },
      "textDocumentSync": {
        "change": 1,
        "openClose": true,
        "save": true
      }
    }
  },
  "id": 1
}
2024-12-11 20:10:15,683 - Client → Server: {
  "jsonrpc": "2.0",
  "method": "initialized",
  "params": {}
}
2024-12-11 20:10:15,683 - Server → Client: {
  "jsonrpc": "2.0",
  "method": "window/logMessage",
  "params": {
    "message": "Server initialized!",
    "type": 3
  }
}
2024-12-11 20:10:15,699 - Server → Client: {
  "jsonrpc": "2.0",
  "method": "workspace/configuration",
  "params": {
    "items": [
      {}
    ]
  },
  "id": 0
}
2024-12-11 20:10:15,700 - Client → Server: {
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "uri": "file:///Users/duncan/eglot-harper-test.org",
      "version": 0,
      "languageId": "org",
      "text": "THIS IS MY HARPER TEST FILE.\nHow about this wrong grammars? I are full. We is good.\nEND TEST FILE.\n"
    }
  }
}
2024-12-11 20:10:15,700 - Client → Server: {
  "jsonrpc": "2.0",
  "method": "workspace/didChangeConfiguration",
  "params": {
    "settings": {
      "harper-ls": {
        "userDictPath": "~/dict.txt",
        "fileDictPath": "~/.harper/"
      }
    }
  }
}
2024-12-11 20:10:15,700 - Server → Client: {
  "jsonrpc": "2.0",
  "method": "workspace/configuration",
  "params": {
    "items": [
      {}
    ]
  },
  "id": 1
}
2024-12-11 20:10:15,707 - Client → Server: {
  "jsonrpc": "2.0",
  "id": 0,
  "result": [
    null
  ]
}
2024-12-11 20:10:15,708 - Client → Server: {
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    null
  ]
}
2024-12-11 20:10:15,760 - Server → Client: {
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "diagnostics": [],
    "uri": "file:///Users/duncan/eglot-harper-test.org"
  }
}
@mcecode
Copy link
Contributor

mcecode commented Dec 12, 2024

I think the grammar mistakes in your test file are not supported yet, at least by the default lints enabled. Can you try using "This sentence has grammar errorz, like this this one." as your sample text? You should get back two errors in your diagnostics array, one for a wrong spelling and the other for repeated words, since those are part of the lints enabled by default.

If that doesn't work, you should probably reply to the workspace/configuration request with the lints you want enabled. You can find a list of those here.

@Duncan-Britt
Copy link
Author

Thanks for the reply. I tried including your sentence "This sentence has grammar errorz, like this this one", however, it did not produce any diagnostics. Still working on getting emacs to respond to the workspace/configuration request with the lints I want, and it might take me a while to figure that out, but I can report back when I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants