-
Couldn't load subscription status.
- Fork 2.4k
Add Gitlab Duo LSP configuration #4157
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
base: master
Are you sure you want to change the base?
Conversation
This file contains the GitLab Duo Language Server configuration for Neovim, including setup instructions, token management, and OAuth device flow.
lsp/gitlab_duo.lua
Outdated
| --- }) | ||
| --- ``` | ||
|
|
||
| local curl = require('plenary.curl') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvim 0.12 has vim.net.request but currently does not support POST :(
We have gone to a lot of trouble to keep all the configs in this repo totally "isolated" (self-contained), so would like to avoid a dependency on plenary.
Writing a curl wrapper for the purposes of this config using vim.system should not be much code.
Alternatively, we are interested in gaining POST support for vim.net.request if you want to work on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed plenary dependency, thanks to Claude. I'm new to lua, So I may not be able to make substantial contributions for now
lsp/gitlab_duo.lua
Outdated
| --- local bufnr = args.buf | ||
| --- local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) | ||
| --- | ||
| --- if client.name == 'gitlab_duo' and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we drop this condition? similar to https://github.com/neovim/nvim-lspconfig/blob/master/lsp/copilot.lua , there is nothing service-specific about inline_completion. The desc field should be generic like in the copilot config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmk It is now removed, I was bit worried if it can have unexpected behaviours if we haven't added allow list of client names.
|
|
||
| -- Configuration | ||
| local config = { | ||
| gitlab_url = vim.env.GITLAB_URL or 'https://gitlab.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just mentioning: users can provide arbitrary fields using vim.lsp.config():
vim.lsp.config('gitlab_duo', {
gitlab_duo = {
gitlab_url = '...',
},
})Then in callbacks such as cmd() in this config, which are passed a config object, you can access those fields:
cmd = function(..., config)
local foo = config.gitlab_duo
...
end)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmk I couldn't get this working, cmd expects a table, not a function, right ?
Add GitLab Duo Language Server Configuration
Summary
This PR adds native support for the GitLab Duo Language Server to the Neovim LSP configuration collection, enabling AI-powered code suggestions from GitLab Duo directly in Neovim.
Motivation
GitLab Duo provides AI-assisted code completion similar to GitHub Copilot, but requires a specific LSP setup with OAuth device flow authentication. This configuration makes it easy for Neovim users to integrate GitLab Duo into their workflow without manual LSP setup.
Features
🔐 OAuth Device Flow Authentication
🔄 Automatic Token Management
🎮 User Commands
:LspGitLabDuoSignIn- Start OAuth authentication flow:LspGitLabDuoSignOut- Sign out and remove stored token:LspGitLabDuoStatus- View authentication and token status⌨️ Standard Keybindings
Implementation Details
Authentication Flow
:LspGitLabDuoSignInToken Lifecycle
LSP Handlers
$/gitlab/token/check- Handles token validation errors$/gitlab/featureStateChange- Notifies about feature availabilityDependencies
Required:
curlmoduleRuntime:
Installation & Usage
Basic Setup
First-Time Authentication
Follow the browser prompts to authorize the application.
Testing
Manual Testing Steps
Install dependencies:
Load the configuration:
Authenticate:
Test suggestions:
.lua,.py,.js, etc.)Test token management:
Expected Behavior
Configuration Options
Users can customize the GitLab instance URL via environment variable:
Default is
https://gitlab.com.Supported Languages
Ruby, Go, JavaScript, TypeScript, React, Rust, Lua, Python, Java, C, C++, PHP, C#, Kotlin, Swift, Scala, Vue, Svelte, HTML, CSS, SCSS, JSON, YAML
Documentation
Checklist
Screenshots
Note: This configuration requires Neovim 0.12+ for native inline completion support.