{"id":29881124,"url":"https://github.com/knsh14/clsp","last_synced_at":"2025-07-31T10:33:18.159Z","repository":{"id":300673128,"uuid":"1006786101","full_name":"knsh14/clsp","owner":"knsh14","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-24T08:11:13.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-27T21:18:11.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knsh14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-23T01:45:48.000Z","updated_at":"2025-06-24T08:11:18.000Z","dependencies_parsed_at":"2025-06-23T02:41:22.352Z","dependency_job_id":"8e408a61-05bb-4d29-95a0-7b972efdb8d3","html_url":"https://github.com/knsh14/clsp","commit_stats":null,"previous_names":["knsh14/clsp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/knsh14/clsp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fclsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fclsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fclsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fclsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knsh14","download_url":"https://codeload.github.com/knsh14/clsp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fclsp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268024673,"owners_count":24183149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-31T10:33:11.476Z","updated_at":"2025-07-31T10:33:18.130Z","avatar_url":"https://github.com/knsh14.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLSP - Command Line LSP Client\n\nA command line tool for sending requests to Language Server Protocol (LSP) servers and displaying the results.\n\n## Installation\n\n```bash\ngo build -o clsp\n```\n\n## Usage\n\n```bash\nclsp -server \u003ccommand\u003e -method \u003cmethod\u003e [options]\n```\n\n### Flags\n\n**Required:**\n- `-server \u003ccmd\u003e`: LSP server command to run (e.g., gopls, clangd, pylsp)\n- `-method \u003cmethod\u003e`: LSP method to call\n\n**Options:**\n- `-args \u003cargs\u003e`: Comma-separated arguments for the LSP server\n- `-params \u003cjson\u003e`: JSON parameters for the method (default: \"{}\")\n- `-params-file \u003cfile\u003e`: Read parameters from JSON file instead of command line\n- `-root \u003curi\u003e`: Root URI for workspace initialization (default: current directory)\n- `-skip-init`: Skip the initialize/initialized sequence for raw requests\n- `-timeout \u003cduration\u003e`: Request timeout (default: 30s)\n- `-format \u003cfmt\u003e`: Output format: pretty, json, raw (default: pretty)\n- `-quiet`: Only output result data, no headers or labels\n- `-verbose`: Enable verbose logging to stderr\n- `-list-methods`: List common LSP methods and exit\n\n### LSP Methods Examples with gopls\n\nAll examples use `gopls` as the LSP server. Replace file paths with your actual Go files.\n\n#### Text Document Information\n\n**Get hover information:**\n```bash\n./clsp -server gopls -method textDocument/hover \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":10,\"character\":5}}'\n```\n\n**Get signature help:**\n```bash\n./clsp -server gopls -method textDocument/signatureHelp \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":20,\"character\":15}}'\n```\n\n#### Code Completion\n\n**Get code completions:**\n```bash\n./clsp -server gopls -method textDocument/completion \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":5,\"character\":10},\"context\":{\"triggerKind\":1}}'\n```\n\n#### Navigation\n\n**Go to definition:**\n```bash\n./clsp -server gopls -method textDocument/definition \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8}}'\n```\n\n**Go to type definition:**\n```bash\n./clsp -server gopls -method textDocument/typeDefinition \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8}}'\n```\n\n**Find implementations:**\n```bash\n./clsp -server gopls -method textDocument/implementation \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8}}'\n```\n\n**Find all references:**\n```bash\n./clsp -server gopls -method textDocument/references \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8},\"context\":{\"includeDeclaration\":true}}'\n```\n\n#### Document Structure\n\n**Get document symbols:**\n```bash\n./clsp -server gopls -method textDocument/documentSymbol \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"}}'\n```\n\n**Highlight symbol occurrences:**\n```bash\n./clsp -server gopls -method textDocument/documentHighlight \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8}}'\n```\n\n#### Code Formatting\n\n**Format entire document:**\n```bash\n./clsp -server gopls -method textDocument/formatting \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"options\":{\"tabSize\":4,\"insertSpaces\":false}}'\n```\n\n**Format specific range:**\n```bash\n./clsp -server gopls -method textDocument/rangeFormatting \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"range\":{\"start\":{\"line\":10,\"character\":0},\"end\":{\"line\":20,\"character\":0}},\"options\":{\"tabSize\":4,\"insertSpaces\":false}}'\n```\n\n#### Code Actions and Refactoring\n\n**Get available code actions:**\n```bash\n./clsp -server gopls -method textDocument/codeAction \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"range\":{\"start\":{\"line\":10,\"character\":0},\"end\":{\"line\":10,\"character\":50}},\"context\":{\"diagnostics\":[]}}'\n```\n\n**Rename symbol:**\n```bash\n./clsp -server gopls -method textDocument/rename \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8},\"newName\":\"NewFunctionName\"}'\n```\n\n**Check if symbol can be renamed:**\n```bash\n./clsp -server gopls -method textDocument/prepareRename \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":15,\"character\":8}}'\n```\n\n#### Enhanced Features\n\n**Get code lenses:**\n```bash\n./clsp -server gopls -method textDocument/codeLens \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"}}'\n```\n\n**Get inlay hints:**\n```bash\n./clsp -server gopls -method textDocument/inlayHint \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"range\":{\"start\":{\"line\":10,\"character\":0},\"end\":{\"line\":30,\"character\":0}}}'\n```\n\n#### Workspace Operations\n\n**Search workspace symbols:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}'\n```\n\n**Execute workspace command:**\n```bash\n./clsp -server gopls -method workspace/executeCommand \\\n  -params '{\"command\":\"gopls.tidy\",\"arguments\":[]}'\n```\n\n#### gopls-Specific Methods\n\n**Get gopls debug info:**\n```bash\n./clsp -server gopls -method gopls/debug/info -params '{}'\n```\n\n**Get GC details:**\n```bash\n./clsp -server gopls -method gopls/gc_details \\\n  -params '{\"uri\":\"file:///path/to/file.go\"}'\n```\n\n**Run go generate:**\n```bash\n./clsp -server gopls -method gopls/generate \\\n  -params '{\"uri\":\"file:///path/to/directory\",\"recursive\":false}'\n```\n\n**List available imports:**\n```bash\n./clsp -server gopls -method gopls/list_imports \\\n  -params '{\"uri\":\"file:///path/to/file.go\"}'\n```\n\n**Add import:**\n```bash\n./clsp -server gopls -method gopls/add_import \\\n  -params '{\"uri\":\"file:///path/to/file.go\",\"importPath\":\"fmt\"}'\n```\n\n#### Output Format Examples\n\n**JSON output:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}' -format json\n```\n\n**Raw output (result only):**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}' -format raw\n```\n\n**Quiet mode:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}' -quiet\n```\n\n#### Using Parameter Files\n\n**Create and use parameter file:**\n```bash\n# Create parameter file\necho '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":10,\"character\":5}}' \u003e hover.json\n\n# Use parameter file\n./clsp -server gopls -method textDocument/hover -params-file hover.json\n```\n\n#### Advanced Options\n\n**Custom timeout:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\".*\"}' -timeout 60s\n```\n\n**Verbose logging:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}' -verbose\n```\n\n**Skip initialization:**\n```bash\n./clsp -server gopls -method textDocument/hover \\\n  -params '{\"textDocument\":{\"uri\":\"file:///path/to/file.go\"},\"position\":{\"line\":10,\"character\":5}}' \\\n  -skip-init\n```\n\n**Custom workspace root:**\n```bash\n./clsp -server gopls -method workspace/symbol \\\n  -params '{\"query\":\"main\"}' -root \"file:///path/to/project\"\n```\n\n## Complete LSP Methods Reference\n\n**Text Document Methods:**\n- `textDocument/hover` - Get hover information at a position\n- `textDocument/completion` - Get code completions at a position\n- `textDocument/signatureHelp` - Get signature help for function calls\n- `textDocument/definition` - Go to definition\n- `textDocument/typeDefinition` - Go to type definition\n- `textDocument/implementation` - Find implementations\n- `textDocument/references` - Find all references\n- `textDocument/documentSymbol` - Get document symbols\n- `textDocument/documentHighlight` - Highlight symbol occurrences\n- `textDocument/formatting` - Format entire document\n- `textDocument/rangeFormatting` - Format specific range\n- `textDocument/codeAction` - Get available code actions\n- `textDocument/codeLens` - Get code lenses\n- `textDocument/rename` - Rename symbol\n- `textDocument/prepareRename` - Check if symbol can be renamed\n- `textDocument/inlayHint` - Get inlay hints\n\n**Workspace Methods:**\n- `workspace/symbol` - Search workspace symbols\n- `workspace/executeCommand` - Execute workspace commands\n- `workspace/didChangeConfiguration` - Notify configuration changes\n- `workspace/didChangeWatchedFiles` - Notify file system changes\n\n**gopls-Specific Methods:**\n- `gopls/debug/info` - Get gopls debug information\n- `gopls/gc_details` - Get garbage collection details\n- `gopls/generate` - Run go generate\n- `gopls/list_imports` - List available imports\n- `gopls/add_import` - Add import to file\n- `gopls/remove_dependency` - Remove unused dependency\n\nUse `./clsp -list-methods` to see the built-in method list with descriptions.\n\n## Implementation Details\n\n### JSON-RPC Protocol\n\nThe tool implements the JSON-RPC 2.0 protocol over stdin/stdout as required by the LSP specification. It handles:\n\n- **Content-Length Headers**: Proper LSP message framing with `Content-Length: N\\r\\n\\r\\n` headers\n- **JSON-RPC Format**: Compliant request/response format with ID tracking\n- **LSP Initialization**: Automatic `initialize` → `initialized` sequence (unless `-skip-init` is used)\n- **Graceful Cleanup**: Sends `shutdown` → `exit` sequence before terminating the LSP server\n\n### Output Formats\n\n- **pretty** (default): Human-readable JSON with formatting and response metadata\n- **json**: Raw JSON-RPC response including headers and error information\n- **raw**: Only the `result` or `error` field content\n\n### Error Handling\n\n- Network and protocol errors are logged to stderr\n- LSP server errors are included in the response output\n- Proper timeout handling with configurable duration\n- Clean process termination with signal handling\n\n### Testing\n\nThe project includes comprehensive tests covering:\n- JSON-RPC message serialization/deserialization\n- Content-Length header parsing\n- ID increment tracking\n- LSP initialization parameter structure\n\nRun tests with:\n```bash\ngo test ./...\ngo test -v ./...  # verbose output\ngo test -cover ./...  # with coverage\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknsh14%2Fclsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknsh14%2Fclsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknsh14%2Fclsp/lists"}