{"id":51472454,"url":"https://github.com/tachyons/duo_lsp","last_synced_at":"2026-07-06T19:01:26.337Z","repository":{"id":364023203,"uuid":"1265945056","full_name":"tachyons/duo_lsp","owner":"tachyons","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-11T09:15:43.000Z","size":4886,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T11:10:45.034Z","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/tachyons.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-11T07:50:19.000Z","updated_at":"2026-06-11T09:15:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tachyons/duo_lsp","commit_stats":null,"previous_names":["tachyons/duo_lsp"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tachyons/duo_lsp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tachyons%2Fduo_lsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tachyons%2Fduo_lsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tachyons%2Fduo_lsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tachyons%2Fduo_lsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tachyons","download_url":"https://codeload.github.com/tachyons/duo_lsp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tachyons%2Fduo_lsp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35202786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"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":"2026-07-06T19:01:25.416Z","updated_at":"2026-07-06T19:01:26.307Z","avatar_url":"https://github.com/tachyons.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# duo-lsp\n\nA minimal, self-contained GitLab Duo LSP server written in Go.\n\nImplements the **LSP 3.18 inline completion protocol** (`textDocument/inlineCompletion`)\nbacked by the [GitLab Code Suggestions API](https://docs.gitlab.com/ee/api/code_suggestions.html).\n\nAuthentication uses the **OAuth 2.0 Device Authorization Grant** flow — no browser\nrequired on the machine running the server.\n\n## Prerequisites\n\n- A GitLab account with Duo Code Suggestions enabled\n\n## Installation\n\n### Homebrew (macOS and Linux)\n\n```sh\nbrew tap tachyons/duo-lsp https://gitlab.com/tachyons/duo_mini_lsp\nbrew install duo-lsp\n```\n\nThe formula lives in this repo under `Formula/duo-lsp.rb` and is updated\nautomatically on every release.\n\n### Build from source\n\nRequires Go 1.22+.\n\n```sh\ngo mod tidy\ngo build -o duo-lsp ./cmd/duo-lsp\n```\n\n## Authenticate\n\n```sh\n# Uses the built-in OAuth application ID — no flags needed for gitlab.com\n./duo-lsp auth\n\n# For a self-managed GitLab instance, or to use your own OAuth application:\n./duo-lsp auth --gitlab-url https://gitlab.example.com\n./duo-lsp auth --client-id \u003cyour-application-id\u003e\n```\n\nThe command prints a URL and a user code. Open the URL in any browser, enter the\ncode, and approve the request. The token is saved automatically.\n\n## Start the LSP Server\n\n```sh\n./duo-lsp serve\n```\n\nThe server reads JSON-RPC 2.0 messages from **stdin** and writes responses to\n**stdout** (Content-Length framed, as per the LSP spec). Logs go to **stderr**.\n\nOptional flags:\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `--log-level` | `info` | `debug`, `info`, `warn`, `error` |\n\n## Editor Integration\n\n### Neovim\n\nRequires Neovim **0.12+**. The built-in `vim.lsp` and `vim.lsp.inline_completion`\nAPIs are used — no plugins required.\n\n#### 1. Register and enable the server\n\nAdd to your `init.lua` (or any file sourced at startup):\n\n```lua\nvim.lsp.config['gitlab_duo_lsp'] = {\n  cmd = { \"/path/to/duo-lsp\", \"serve\" },\n  -- Add or remove filetypes as needed\n  filetypes = { \"ruby\", \"go\", \"lua\", \"python\", \"javascript\", \"typescript\" },\n}\n\nvim.lsp.enable('gitlab_duo_lsp')\n```\n\nReplace `/path/to/duo-lsp` with the absolute path to the binary. If installed\nvia Homebrew, use `vim.fn.exepath('duo-lsp')` instead of a hardcoded path.\n\n#### 2. Enable inline completion\n\n```lua\nvim.lsp.inline_completion.enable()\n```\n\nThis activates ghost-text suggestions that appear automatically while you type\n(debounced at 200 ms by Neovim's built-in handler).\n\n#### 3. Accept a suggestion with Tab\n\n```lua\nvim.keymap.set('i', '\u003cTab\u003e', function()\n  if not vim.lsp.inline_completion.get() then\n    return '\u003cTab\u003e'\n  end\nend, { expr = true, desc = 'Accept the current inline completion' })\n```\n\n`\u003cTab\u003e` accepts the displayed suggestion when one is visible, and falls back to\na literal tab otherwise.\n\n#### Complete minimal config\n\n```lua\n-- ~/.config/nvim/init.lua  (or any sourced file)\n\nvim.lsp.config['gitlab_duo_lsp'] = {\n  cmd = { vim.fn.exepath('duo-lsp') ~= '' and vim.fn.exepath('duo-lsp') or '/path/to/duo-lsp', 'serve' },\n  filetypes = { 'ruby', 'go', 'lua', 'python', 'javascript', 'typescript' },\n}\n\nvim.lsp.enable('gitlab_duo_lsp')\nvim.lsp.inline_completion.enable()\n\n-- Tab: accept suggestion or fall back to literal tab\nvim.keymap.set('i', '\u003cTab\u003e', function()\n  if not vim.lsp.inline_completion.get() then\n    return '\u003cTab\u003e'\n  end\nend, { expr = true, desc = 'Accept the current inline completion' })\n\n-- Optional: cycle through multiple suggestions\nvim.keymap.set('i', '\u003cM-]\u003e', function()\n  vim.lsp.inline_completion.select({ count = 1 })\nend, { desc = 'Next inline completion' })\n\nvim.keymap.set('i', '\u003cM-[\u003e', function()\n  vim.lsp.inline_completion.select({ count = -1 })\nend, { desc = 'Previous inline completion' })\n```\n\n#### Optional: debug logging\n\n```lua\nvim.lsp.config['gitlab_duo_lsp'] = {\n  cmd = { 'duo-lsp', 'serve', '--log-level', 'debug' },\n  filetypes = { 'ruby', 'go', 'lua' },\n}\n```\n\n```sh\ntail -f /tmp/duo-lsp.log\n```\n\n## Architecture\n\n```\ncmd/duo-lsp/main.go          CLI entry point (auth / serve / config-path)\ninternal/\n  auth/auth.go               OAuth device flow (wraps golang.org/x/oauth2)\n  config/config.go           Persistent JSON config (~/.config/duo-lsp/config.json)\n  api/completions.go         GitLab Code Suggestions REST client\n  lsp/\n    types.go                 LSP 3.18 protocol types (inline completion subset)\n    server.go                JSON-RPC 2.0 / LSP server (stdio transport)\n```\n\n## LSP Methods Handled\n\n| Method | Description |\n|--------|-------------|\n| `initialize` | Handshake; advertises `inlineCompletionProvider` |\n| `initialized` | Client confirmation notification |\n| `shutdown` / `exit` | Clean shutdown |\n| `textDocument/didOpen` | Track document content |\n| `textDocument/didChange` | Update document content (full sync) |\n| `textDocument/didClose` | Remove document from cache |\n| `textDocument/inlineCompletion` | **Return inline completions from GitLab API** |\n\n## Config File\n\nLocated at `~/.config/duo-lsp/config.json` (macOS/Linux) or\n`%AppData%\\duo-lsp\\config.json` (Windows).\n\n```json\n{\n  \"gitlab_base_url\": \"https://gitlab.com\",\n  \"oauth_client_id\": \"your-app-id\",\n  \"access_token\": \"\u003cstored after auth\u003e\",\n  \"refresh_token\": \"\u003cstored after auth\u003e\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftachyons%2Fduo_lsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftachyons%2Fduo_lsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftachyons%2Fduo_lsp/lists"}