Table of Contents

GitHub Copilot layer

Table of ContentsClose

1. Description

This layer enables usage of GitHub Copilot in Spacemacs.

It provides code completion, chat-based AI interaction, and a powerful framework for integrating external AI tools and models.

1.1. Features:

  • AI powered code completions using copilot.el.
  • AI chat interactions using copilot-chat.el.
  • AI tool integration via mcp.el, allowing the chat AI to run commands, interact with the filesystem, and more. [EXPERIMENTAL]
  • Automatic generation of git commit messages.

2. Install

To use this configuration layer, add it to your `~/.spacemacs`. You will need to add `github-copilot` to the existing `dotspacemacs-configuration-layers` list in this file.

2.1. Prerequisites

This layer requires external components to be fully functional.

  1. Copilot Language Server: The core `copilot.el` package requires the language server. It can be installed manually with:

    $ npm install -g @github/copilot-language-server
    

    Or, you can install it from within Emacs:

    SPC SPC copilot-install-server
    
  2. Runtime Environments (Python & Node.js): This layer acts as a client. The actual tools (MCP Servers) run externally.

    • Node.js: Required for the official filesystem server and many web-based tools (install via `npm`).
    • Python 3: Required for many system administration and local scripting tools.

    Please ensure both `node` (and `npm`) and `python3` are available in your system's `PATH`.

  3. MCP Server Installation (Manual): This layer does not install MCP servers for you. You must install them manually. For example, the common filesystem server is a Node.js package.

    $ npm install -g @modelcontextprotocol/server-filesystem
    

3. Configuration

The Copilot service must be logged into.

  • For code completion: run `SPC SPC copilot-login`.
  • For chat: the chat interface will prompt for a separate login the first time it is started.

3.1. Git Commit Messages

This layer can automatically generate commit messages for you when opening a commit buffer (e.g., via Magit). You can choose between two styles by setting the `github-copilot-enable-commit-messages` variable.

3.1.1. The G.O.L.E.M. Standard (Preferred)

For Spacemacs development, we strongly recommend the G.O.L.E.M. style. This invokes the "Guardian Of Legacy Elisp Manifestations" persona, which enforces the strict Tim Pope standard:

  • Imperative mood ("Fix bug" not "Fixed bug").
  • 50-character subject line limit.
  • 72-character body wrap.

Set the variable to 'golem to enable this mode:

(github-copilot :variables
                github-copilot-enable-commit-messages 'golem)

3.1.2. Standard Copilot Style

If you prefer the default, conversational style of GitHub Copilot, set the variable to t.

(github-copilot :variables
                github-copilot-enable-commit-messages t)

Alternatively, you can invoke `SPC SPC copilot-chat-insert-commit-message` manually within a Git commit buffer.

3.2. MCP / Tool Integration (Manual Setup Required)

This layer provides powerful tool-using capabilities to the AI chat by integrating `mcp.el` (Model Context Protocol).

This framework requires manual configuration. The layer provides the `github-copilot-mcp-servers` variable (which is `nil` by default) for you to define your servers.

You must add your server list to the `dotspacemacs/user-config` function in your `~/.spacemacs` file after the `mcp-hub` package is loaded.

3.2.1. Example: Enabling the Filesystem Server *

  1. First, install the server (this requires Node.js / `npx`):

    $ npm install -g @modelcontextprotocol/server-filesystem
    
  2. Then, add the following code to your `dotspacemacs/user-config`:

    (defun dotspacemacs/user-config ()
      ;; ...
      (with-eval-after-load 'mcp-hub
        ;; This list is the "Single Source of Truth"
        (setq github-copilot-mcp-servers
              '(;; Add the filesystem server
                ;; It must be installed (e.g., via "npm install -g @modelcontextprotocol/server-filesystem")
                ("fs" . (:command "npx"
                         :args ("-y" "@modelcontextprotocol/server-filesystem"
                                ;; This path MUST be absolute and point to your projects
                                "/home/your-user/projects")))))
    
        ;; We must also tell the mcp-hub to use this new list
        (setq mcp-hub-servers github-copilot-mcp-servers))
      )
    

3.2.2. Finding More Servers *

You can add any MCP-compliant server to this list (like a local Ollama instance). You can find more servers to install and use here:

4. Key bindings

4.1. General

Key binding Description
`C-M-<return>` accept the current completion suggestion
`C-M-S-<return>` accept the current completion suggestion word by word
`C-M-<tab>` show the next github copilot completion (and refresh)
`C-M-<iso-lefttab>` show the previous github copilot completion (and refresh)
`SPC $ c` Start a transient state for the Copilot chat interface
`SPC $ m` Open the `*Mcp-Hub*` buffer to manage/view tool servers

4.2. In Chat

Key binding Description
`,,` Send the current text to Copilot (in Normal mode)
`,a` Kill the chat process (in Normal mode)
`,k` Kill the chat process (in Normal mode)
`C-c C-c` Send the current text to Copilot (in Prompt buffer)
`C-c C-a` Kill the chat process (in Prompt buffer)
`C-c C-k` Kill the chat process (in Prompt buffer)

Author: root

Created: 2026-01-15 Thu 21:25

Validate