Skip to content

tachyons/gitlab.nvim

Repository files navigation

GitLab Plugin for Neovim

[[TOC]]

A Lua based plugin for Neovim that offers GitLab Duo Code Suggestions.

All feedback can be submitted in the [Feedback] GitLab for Neovim issue.

If you're interested in contributing check out the development process.

Requirements

Software Version
GitLab SaaS 16.1+
GitLab self-managed 16.1+
Neovim 0.9+

Setup

  1. Follow the installation steps for your chosen plugin manager.

    1. Optional: Configure GitLab Duo Code Suggestions as an Omni completion provider.
  2. Setup helptags using :helptags ALL for access to :help gitlab.txt.

Installation

To install the GitLab Vim plugin:

  1. Clone Neovim's packpath which is included by packadd on startup.

    git clone git@gitlab.com:gitlab-org/editor-extensions/gitlab.vim.git ~/.local/share/nvim/site/pack/gitlab/start/gitlab.vim
  2. Add the following plugin to your lazy.nvim configuration:

    {
      url = "git@gitlab.com:gitlab-org/editor-extensions/gitlab.vim.git",
      lazy = false,
    }
  3. Declare the plugin in your packer.nvim configuration:

    use {
      "git@gitlab.com:gitlab-org/editor-extensions/gitlab.vim.git",
    }

Uninstalling

  1. Manual installation:
    1. Clone this repository into your pack directory:

      rm -r ~/.local/share/nvim/site/pack/gitlab/start/gitlab.vim
      rm ~/.local/share/nvim/gitlab-code-suggestions-language-server-*

Omni completion

To enable omni completion using GitLab Duo Code Suggestions:

  1. Follow the steps to enable GitLab Duo Code Suggestions for your GitLab instance (SaaS or self-managed).
  2. Enable Code Suggestions for your GitLab group/user.
  3. Create a Personal Access Token with the api scope.
  4. Install the GitLab Duo Code Suggestions language server.

You may find it helpful to configure omni completion's popup menu even for a single suggestion:

vim.o.completeopt = 'menu,menuone'
  1. Use ctrl-x ctrl-o to open the Omni completion popup menu inside of supported filetypes.

Keymaps

Module Key Bindings Mode Description
code_suggestions ctrl-x ctrl-o NORMAL Requests completions from GitLab Duo Code Suggestions through the language server.

Statusline

Enabling gitlab.statusline will indicate the status of the GitLab Duo Code Suggestions integration.

Troubleshooting

For help troubleshooting please refer to the troubleshooting guide.

Features

GitLab Duo Code Suggestions (Beta)

Write code more efficiently by using generative AI to suggest code while you’re developing. To learn more about this feature, see the GitLab Duo Code Suggestions documentation

This feature is in Beta GitLab Duo Code Suggestions is a generative artificial intelligence (AI) model. GitLab currently leverages Google Cloud’s Vertex AI Codey API models

No new additional data is collected to enable this feature. Private non-public GitLab customer data is not used as training data. Learn more about Google Vertex AI Codey APIs Data Governance

Beta users should read about the known limitations

Supported Languages

Languages supported by GitLab Duo Code Suggestions can be found in the documentation.

For your convenience this plugin provides Vim auto-commands to start the LSP integration for some supported filetypes. That is Ruby is a supported language so the plugin will add a FileType ruby auto-command.

You can configure this behavior for additional filetypes through the code_suggestions.auto_filetypes setup option.

Release Process

  1. Review whether each merge request since the last release has/requires a changelog entry.

  2. Create a new merge request to increment the plugin version.

    1. Update PLUGIN_VERSION in lua/gitlab/globals.lua.

    2. Add a new ## vX.Y.Z header above the previous CHANGELOG.md entry.

  3. Merge the merge request once it has been approved.

  4. Create a new signed git tag off of the main branch.

Issues

Report issues in the feedback issue.

Contributing

This extension is open source and hosted on GitLab. Contributions are more than welcome. Feel free to fork and add new features or submit bug reports. See CONTRIBUTING for more information.

A list of the great people who contributed this project, and made it even more awesome, is available. Thank you all! 🎉

License

See LICENSE.