Documentation
Gram is a source code editor and an IDE. It has a lot of features but is also very much a work in progress. It is a community project, although the community right now consists of one grumpy toad in its spare time and a small but dedicated group of contributors (much love to them). The project hopes to move slowly but steadily in the direction of stability, reliability and respect.
It has a lot of things going for it:
- It mostly works today. I use it every day to write code.
- Decent performance.
- Cross-platform support for Mac, Linux, FreeBSD and Windows.
- Remote development over SSH.
- Integrated debugger support via the
DAPprotocol. - Jupyter Notebook support (REPL mode).
- Built in git support.
- Pretty decent Vim and Helix modal editing modes.
- Partial/limited support for Zed Wasm extensions.
- No AI integration or monetization scheme.
- No telemetry or proprietary server component.
- No video or audio chat.
- No involuntary auto updates.
- Tries not to install anything without explicit permission.
- Integrated documentation.
- Built in support for a lot of languages and language servers.
- Lots of builtin themes.
This project did not start with a vision of the perfect editor, but as a reaction against what was and still is happening to the world of software development, the world at large and to editors like VS Code, Zed and Vim. Its core philosophy is that writing code by hand with care is good and righteous, and aims to be a good tool for doing just that.
Gram started as a hard fork of the Zed editor. For more details on the background and motivation behind this fork, read the Mission Statement.
Migrating
Features
- Debugger: Integrated support for DAP, the debugger adapter protocol.
- Remote Development: Connect to remote servers via SSH and edit as if working on a local project.
- Extensions: Add support for additional languages, themes and icons using the extension system.
- Supported Languages
- Language Servers: Gram relies on language servers for providing advanced semantic functionality for various programming languages.
Development
Configuration
- Configuring Gram
- Configuring Languages
- Key bindings
- Snippets
- Themes
- Icon Themes
- Visual Customization
- Vim Mode
- Helix Mode
- SuperTab
Using Gram
- Multibuffers
- Command Palette
- Command-line Interface
- Outline Panel
- Code Completions
- Git
- Debugger
- Diagnostics
- Tasks
- Tab Switcher
- Remote Development
- Environment Variables
- REPL
Platform Support
Handling Problems
Extensions
NOTE: The Zed extension system relies on a closed-source server component, which is stripped from Gram. Instead, all extensions have to be built from source. Currently, there is no extension registry so the extensions have to be installed either via the suggestion popups or an URL and Wasm extensions need rustup installed in order to compile.
- Overview
- Installing Extensions
- Developing Extensions
- Extension Capabilities
- Language Extensions
- Debugger Extensions
- Theme Extensions
- Icon Theme Extensions
Integrations and related tools
There are some related projects mostly around making Gram available in various package managers and Linux distributions. This list is not complete, if you know of any packaging effort, Gram-specific extensions or anything like that, feel free to submit a PR at https://codeberg.org/GramEditor/gram.
- Homebrew (Mac): https://formulae.brew.sh/cask/gram
- Arch Linux: https://archlinux.org/packages/extra/x86_64/gram
- Arch Linux (AUR): https://aur.archlinux.org/packages/gram-git
- Alpine Linux: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/gram
- Gentoo Linux: https://codeberg.org/GramEditor/gram-gentoo
- Raycast (Mac): https://www.raycast.com/justyt65/gram
- Chimera Linux (WIP): https://github.com/chimera-linux/cports/pull/5506
Legal note on accepting contributions
If you have previously installed Zed and agreed to their license agreement, you may be legally prevented from contributing to Gram despite the open source license of the code. I am not a lawyer and I suspect that the license that they use would not hold up at least in European court, but I don’t know. For that exact reason, I never agreed to their license. This is the main reason this fork even exists.
If you do want to contribute patches, you will have to accept full responsibility for ensuring and warranting that you are legally allowed to do so.
You are the community
Gram is proudly open source, in spirit, not just in words. That said, we have strong opinions about what we want to include in the editor. For example, the main reason for this fork from Zed is to remove certain “features” that we disagree with, morally. However, you are of course free to make it your own in any way you see fit.
There is no official discord or reddit community, but there is an XMPP chat for Gram at gram@rooms.slidge.im. Any XMPP client should be able to connect, and there is a basic web UI available. There are chat logs available in an online archive as well.
Strict No AI/LLM Policy
No more AI. I used to have a milder version of this statement here before, which I wrote early on when I wasn’t really aware of “vibe-coding” as such and was mostly annoyed purely at the chatbox / autocomplete version of AI. That was bad enough, but I really am not a fan of what that has become (in March 2026 when I am writing this). I have copied this policy from the Zig language project Code of Conduct:
No LLMs for issues.
No LLMs for pull requests.
No LLMs for comments on the bug tracker, including translation. English is encouraged, but not required. You are welcome to post in your native language and rely on others to have their own translation tools of choice to interpret your words.
The Zed code base contains a lot of AI-generated code. It doesn’t need a single line more.
SciActive’s Human Contribution Policy
Gram adheres to SciActive’s human contribution policy 2 UP.
SciActive Human Contribution Policy
Version 2-UP (Upstream Patches Excepted), 2 September 2026 https://sciactive.com/human-contribution-policy/
Preamble
The SciActive Human Contribution Policy is a free, general contribution policy meant to safeguard projects from the inherent legal and security risks of AI generated contributions. It is also meant to ensure that the trust projects’ users place in the projects and their maintainers is not inadvertently violated by the inclusion of untrusted material. The inclusion of AI generated material in projects presents significant known and unknown risks to the longevity and security of the projects. This policy is meant to declare that the human authorship of any material introduced in covered projects is both desired and ensured.
The purpose of this document is to define a clear boundary between human authorship and machine generation, and clearly declare that a project will only accept contributions that are human authored. If a project chooses to adopt and adhere to this policy, it is a clear indication that the project will not accept AI generated contributions and that its users can be assured that, once adopted, the contributions to the project are authored by humans, and humans alone, except when this policy allows specific exceptions.
Definitions
“This policy” refers to version 2-UP of the SciActive Human Contribution Policy.
“The project” means the collective body of work covered by this policy, including but not limited to, the source code, object code, documentation, scripts, configuration files, graphical assets, supporting material, policy documents, translations, and processes. This does not include source codes and object codes of dependencies that are merely linked to, not stored, within the project, and any portions of object code resulting from the compilation of the imported source codes of linked dependencies when compiled during the normal build process of the project.
“AI generated” means that the subject material is in whole, or in meaningful part, the output of a generative AI model or models, such as a Large Language Model. This does not include code that is the result of non-generative tools, such as standard compilers, linters, or basic IDE auto-completions. This does, however, include code that is the result of code block generators and automatic refactoring tools that make use of generative AI models.
“Contribution” means any material submitted to the project with the intention of being included in, or distributed with, the project. A contribution may be material that is presented to a review process, such as a pull request, or material that is submitted into any of the project’s material tracking or distribution systems, such as a source control commit or submission to a content management system, even by a project team member or maintainer.
“Contributor” means the natural person or legal entity ultimately responsible for submitting the contribution. The contributor, in this case, cannot be an automated agent. In the case that an automated agent submits or attempts to submit a contribution to the project, the natural person or legal entity responsible for initiating the agent is the contributor.
“User” means the person or entity who ultimately uses or is intended to ultimately use the project or its product.
Policy
- Contributions must be human authored. AI generated contributions are not permitted and will not be accepted. a. The following types of contributions are excepted from this requirement: i. Patches merged from an upstream project, where the upstream project is clearly declared an upstream project on this project’s home page, repository, or documentation.
- If a contributor attempts to submit AI generated material without disclosing that the material is AI generated, the contribution will be considered a deceptive contribution, and action may be taken against the contributor.
Reasoning
Legal Implications of AI Generated Contributions
License Laundering
Generative AI models are trained on publicly available code that may be subject to restrictive licensing conditions. These models may produce verbatim, near verbatim, or derivative snippets of this code, which would therefore be subject to the license terms under which that code was released. If these snippets are introduced into a code base with an incompatible license, that code base’s licensing could become legally unenforceable, or the maintainers of the code base could even be subject to lawsuits.
This policy helps protect the project from having incompatibly licensed code introduced into the project’s code base.
Copyright Ineligibility
As of March 2026, the US Copyright Office and several international bodies maintain that AI generated material, without significant human “creative control”, cannot be copyrighted. This means that AI generated material often resides in the public domain, making it impossible to enforce any license terms on the material.
This policy helps protect the project from having material from the public domain introduced into the project.
Compliance with New Laws
New regulations may impose strict control or new liability for AI generated material. This may include, and may not be limited to, legal liabilities concerning security vulnerabilities or “hallucinated” sections of AI generated code.
This policy helps protect the project from becoming in violation of any new laws, or liable in new ways, with regard to any new legislation that may govern the use or distribution of AI generated material.
Technical and Security Implications of AI Generated Contributions
Prevalence of Security Vulnerabilities
AI generated code may be more likely than human authored code to introduce security vulnerabilities. These vulnerabilities can be very difficult to recognize during the code review process.
This policy helps protect the project from the introduction of new security vulnerabilities.
Dependency Hallucinations and Slopsquatting
AI generated code often includes references to non-existent dependencies. These references are commonly called “hallucinations”. A new type of attack has arisen that involves an attacker registering a package whose name is frequently hallucinated. When AI generated code containing this hallucination is accepted, and this dependency is installed, the attacker can ship malicious code into the project’s build, introducing a major security vulnerability. This type of attack has become known as “slopsquatting”.
This policy helps protect the project from both hallucinated dependencies and slopsquatting attacks.
Architectural Drift
AI generated material frequently mirrors industry-standard practices and lacks the context of the project’s overall architecture and practices, resulting in code that can duplicate efforts, neglect the project’s own practices, and deviate from the project’s overall planned architecture, and documentation that is inconsistent with the project’s existing standards and practices. As more of a project becomes AI generated material, the original architecture can become more obscured, resulting in a code base that is often no longer coherent and difficult to return back to the original “vision”.
This policy helps protect the project from incurring this kind of technical debt.
Ethical and Community Implications of AI Generated Contributions
Erosion of Trust
The users of the project have an implicit trust that the maintainers of the project understand the code contained within the project’s code base. AI generated code, which may not even be fully understood by the contributor, breaks this implicit trust. AI generated code is the result of an automated process, not intentional authorship. Allowing this code into the project’s code base would mean the maintainers of the project may not fully understand the code base.
This policy helps protect the project from eroding the trust the users have placed into the project and its maintainers.
Maintenance Exhaustion
AI generated material can be created much faster than it can be reviewed. This imbalance can lead to a heavy burden on maintainers of reviewing an abundance of AI generated material that often has the appearance of high quality material, but contains many flaws. The difficulty of properly reviewing these contributions, along with the tremendous volume of these contributions, can lead maintainers to feel “burnt out” and leave the project.
This policy helps protect the project from incurring this heavy maintenance load.
Use of This Policy
This policy is distributed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license, available at https://creativecommons.org/licenses/by-sa/4.0/. Anyone can share and reuse this policy, in its original form or modified, under the conditions of the CC BY-SA 4.0 license. The full legal text of the license is available at https://creativecommons.org/licenses/by-sa/4.0/legalcode.en. If you modify this policy, rename the policy in order to avoid the implication that the modified policy is endorsed by SciActive Inc.
SciActive Human Contribution Policy © 2026 by SciActive Inc is licensed under CC BY-SA 4.0
All Actions
All Actions
{#ACTIONS_TABLE#}
Command-line Interface
Gram has a CLI, on Linux this should come with the distribution’s Gram package
(binary name can vary from distribution to distribution, gram will be used
later for brevity). For macOS, the CLI comes in the same package with the editor
binary, and could be installed into the system with the cli: install Gram
command which will create a symlink to the /usr/local/bin/gram. It can also be
built from source out of the cli crate in this repository.
Use gram --help to see the full list of capabilities. General highlights:
-
Opening another empty Gram window:
gram -
Opening a file or directory in Gram:
gram /path/to/entry(use-nto open in the new window) -
Reading from stdin:
ps axf | gram - -
Starting Gram with logs in the terminal:
gram --foreground -
Uninstalling Gram and all its related files:
gram --uninstall
Command Palette
The Command Palette is the main way to access available functionality in the editor. To open it, hit: command_palette::Toggle.
The list of commands can be filtered by typing part of the command name to call. Once the correct command is selected, hit enter to run it.
Any time you see instructions that include commands of the form gram: ...,
editor: ... or similar, you should be able to find and execute the command
from the Command Palette. You can bind the command to a key combination in the
keymap editor.
Completions
“Code Completions” provided by Language Servers (LSPs) automatically installed by Gram or via Gram Language Extensions.
Language Server Code Completions
When there is an appropriate language server available, Gram will provide
completions of variable names, functions, and other symbols in the current file.
You can disable these by adding the following to your Gram settings.jsonc
file:
"show_completions_on_input": false
You can manually trigger completions with ctrl-space or by triggering the
editor::ShowCompletions action from the command palette.
The code completions can optionally show a text icon to show what kind of item
it is. e.g. Function / Property / Constant etc. Defaults to "Off" Enable with:
"completion_menu_item_kind": "symbol"
For more information, see:
Configuration
There are separate pages describing how to configure these aspects of the editor:
Settings Editor
The Settings Editor can be opened with the gram::OpenSettings keybinding,
or through the gram: open settings action in the command palette. Through it,
you can customize your local, user settings as well as project settings.
Note that not all settings that Gram supports are available through the Settings Editor yet. Some more intricate ones, such as language formatters, can only be changed through the JSON settings file > gram::OpenSettingsFile.
User Settings File
Your settings.jsonc file can be opened with gram::OpenSettingsFile. By
default it is located at ~/.config/gram/settings.jsonc, though if you have
XDG_CONFIG_HOME in your environment on Linux it will be at
$XDG_CONFIG_HOME/gram/settings.json instead.
Whatever you have added to your user settings file gets merged with any local configuration inside your projects.
Default Settings
In the Settings Editor, the values you see set are the default ones. You can also verify them in JSON by running gram::OpenDefaultSettings from the command palette.
Extensions that provide language servers may also provide default settings for those language servers.
Project Settings File
Similarly to user files, you can open your project settings file by running
gram::OpenProjectSettings from the command palette. This will create a
.gram directory containing.gram/settings.jsonc.
Although most projects will only need one settings file at the root, you can add
more local settings files for subdirectories as needed. Not all settings can be
set in local files, just those that impact the behavior of the editor and
language tooling. For example you can set tab_size, formatter etc. but not
theme, vim_mode and similar.
The syntax for configuration files is a super-set of JSON that allows //
comments.
Per-release Channel Overrides
You can scope overrides to a specific channel by adding top-level stable or
dev objects.
They are merged into the base configuration with settings from these keys taking precedence upon launching the specified build. For example:
{
"theme": "sunset",
"vim_mode": false,
"stable": {
"theme": "gram-dark",
},
}
With this configuration, Dev keeps all base preferences while Stable switches to
gram-dark.
Changing settings in the Settings Editor will always apply the change across all channels.
Settings
Find below an extensive run-through of many supported settings by Gram.
Active Pane Modifiers
- Description: Styling settings applied to the active pane.
- Setting:
active_pane_modifiers - Default:
{
"active_pane_modifiers": {
"border_size": 0.0,
"inactive_opacity": 1.0,
},
}
Border size
- Description: Size of the border surrounding the active pane. When set to 0, the active pane doesn’t have any border. The border is drawn inset.
- Setting:
border_size - Default:
0.0
Options
Non-negative float values
Inactive Opacity
- Description: Opacity of inactive panels. When set to 1.0, the inactive panes have the same opacity as the active one. If set to 0, the inactive panes content will not be visible at all. Values are clamped to the [0.0, 1.0] range.
- Setting:
inactive_opacity - Default:
1.0
Options
float values
Bottom Dock Layout
- Description: Control the layout of the bottom dock, relative to the left and right docks.
- Setting:
bottom_dock_layout - Default:
"contained"
Options
- Contain the bottom dock, giving the full height of the window to the left and right docks.
{
"bottom_dock_layout": "contained",
}
- Give the bottom dock the full width of the window, truncating the left and right docks.
{
"bottom_dock_layout": "full",
}
- Left align the bottom dock, truncating the left dock and giving the right dock the full height of the window.
{
"bottom_dock_layout": "left_aligned",
}
- Right align the bottom dock, giving the left dock the full height of the window and truncating the right dock.
{
"bottom_dock_layout": "right_aligned",
}
Allow Rewrap
- Description: Controls where the editor::Rewrap action is allowed in the current language scope
- Setting:
allow_rewrap - Default:
"in_comments"
Options
- Allow rewrap in comments only:
{
"allow_rewrap": "in_comments",
}
- Allow rewrap in selections only:
{
"allow_rewrap": "in_selections",
}
- Allow rewrap anywhere:
{
"allow_rewrap": "anywhere",
}
Note: This setting has no effect in Vim mode, as rewrap is already allowed everywhere.
Auto Indent
- Description: Whether indentation should be adjusted based on the context whilst typing. This can be specified on a per-language basis.
- Setting:
auto_indent - Default:
true
Options
boolean values
Auto Indent On Paste
- Description: Whether indentation of pasted content should be adjusted based on the context
- Setting:
auto_indent_on_paste - Default:
true
Options
boolean values
Auto Install extensions
Extensions have to be manually installed in Gram.
You can find the names of your currently installed extensions by listing the subfolders under the extension installation location:
On macOS:
ls ~/Library/Application\ Support/Gram/extensions/installed/
On Linux:
ls ~/.local/share/gram/extensions/installed
Autosave
- Description: When to automatically save edited buffers.
- Setting:
autosave - Default:
off
Options
- To disable autosave, set it to
off:
{
"autosave": "off",
}
- To autosave when focus changes, use
on_focus_change:
{
"autosave": "on_focus_change",
}
- To autosave when the active window changes, use
on_window_change:
{
"autosave": "on_window_change",
}
- To autosave after an inactivity period, use
after_delay:
{
"autosave": {
"after_delay": {
"milliseconds": 1000,
},
},
}
Note that a save will be triggered when an unsaved tab is closed, even if this is earlier than the configured inactivity period.
Autoscroll on Clicks
- Description: Whether to scroll when clicking near the edge of the visible text area.
- Setting:
autoscroll_on_clicks - Default:
false
Options
boolean values
Auto Signature Help
- Description: Show method signatures in the editor, when inside parentheses
- Setting:
auto_signature_help - Default:
false
Options
boolean values
Show Signature Help After Edits
- Description: Whether to show the signature help after completion or a bracket
pair inserted. If
auto_signature_helpis enabled, this setting will be treated as enabled also. - Setting:
show_signature_help_after_edits - Default:
false
Options
boolean values
Base Keymap
- Description: Base key bindings scheme. Base keymaps can be overridden with user keymaps.
- Setting:
base_keymap - Default:
Emacs
Options
- VS Code
{
"base_keymap": "VSCode",
}
- Atom
{
"base_keymap": "Atom",
}
- JetBrains
{
"base_keymap": "JetBrains",
}
- None
{
"base_keymap": "None",
}
- Sublime Text
{
"base_keymap": "SublimeText",
}
- TextMate
{
"base_keymap": "TextMate",
}
- Emacs
{
"base_keymap": "Emacs",
}
- Minimal
{
"base_keymap": "Minimal",
}
Buffer Font Family
- Description: The name of a font to use for rendering text in the editor.
- Setting:
buffer_font_family - Default:
.GramMono.
Options
The name of any font family installed on the user’s system, or ".GramMono".
Buffer Font Features
- Description: The OpenType features to enable for text in the editor.
- Setting:
buffer_font_features - Default:
null - Platform: macOS and Windows.
Options
Gram supports all OpenType features that can be enabled or disabled for a given buffer or terminal font, as well as setting values for font features.
For example, to disable font ligatures, add the following to your settings:
{
"buffer_font_features": {
"calt": false,
},
}
You can also set other OpenType features, like setting cv01 to 7:
{
"buffer_font_features": {
"cv01": 7,
},
}
Buffer Font Fallbacks
- Description: Set the buffer text’s font fallbacks, this will be merged with the platform’s default fallbacks.
- Setting:
buffer_font_fallbacks - Default:
null - Platform: macOS and Windows.
Options
For example, to use Nerd Font as a fallback, add the following to your
settings:
{
"buffer_font_fallbacks": ["Nerd Font"],
}
Buffer Font Size
- Description: The default font size for text in the editor.
- Setting:
buffer_font_size - Default:
15
Options
A font size from 6 to 100 pixels (inclusive)
Buffer Font Weight
- Description: The default font weight for text in the editor.
- Setting:
buffer_font_weight - Default:
400
Options
integer values between 100 and 900
Buffer Line Height
- Description: The default line height for text in the editor.
- Setting:
buffer_line_height - Default:
"comfortable"
Options
"standard", "comfortable" or { "custom": float } (1 is compact, 2 is
loose)
Centered Layout
- Description: Configuration for the centered layout mode.
- Setting:
centered_layout - Default:
"centered_layout": {
"left_padding": 0.2,
"right_padding": 0.2,
}
Options
The left_padding and right_padding options define the relative width of the
left and right padding of the central pane from the workspace when the centered
layout mode is activated. Valid values range is from 0 to 0.4.
Close on File Delete
- Description: Whether to automatically close editor tabs when their corresponding files are deleted from disk.
- Setting:
close_on_file_delete - Default:
false
Options
boolean values
When enabled, this setting will automatically close tabs for files that have been deleted from the file system. This is particularly useful for workflows involving temporary or scratch files that are frequently created and deleted. When disabled (default), deleted files remain open with a strikethrough through their tab title.
Note: Dirty files (files with unsaved changes) will not be automatically closed even when this setting is enabled, ensuring you don’t lose unsaved work.
Confirm Quit
- Description: Whether or not to prompt the user to confirm before closing the application.
- Setting:
confirm_quit - Default:
false
Options
boolean values
Diagnostics Max Severity
- Description: Which level to use to filter out diagnostics displayed in the editor
- Setting:
diagnostics_max_severity - Default:
null
Options
- Allow all diagnostics (default):
{
"diagnostics_max_severity": "all",
}
- Show only errors:
{
"diagnostics_max_severity": "error",
}
- Show errors and warnings:
{
"diagnostics_max_severity": "warning",
}
- Show errors, warnings, and information:
{
"diagnostics_max_severity": "info",
}
- Show all including hints:
{
"diagnostics_max_severity": "hint",
}
Direnv Integration
- Description: Settings for direnv integration. Requires
direnvto be installed.direnvintegration make it possible to use the environment variables set by adirenvconfiguration to detect some language servers in$PATHinstead of installing them. It also allows for those environment variables to be used in tasks. - Setting:
load_direnv - Default:
"direct"
Options
There are three options to choose from:
shell_hook: Use the shell hook to load direnv. This relies on direnv to activate upon entering the directory. Supports POSIX shells and fish.direct: Usedirenv export jsonto load direnv. This will load direnv directly without relying on the shell hook and might cause some inconsistencies. This allows direnv to work with any shell.disabled: No shell environment will be loaded automatically; direnv must be invoked manually (e.g. withdirenv exec) to be used.
Double Click In Multibuffer
- Description: What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers)
- Setting:
double_click_in_multibuffer - Default:
"select"
Options
- Behave as a regular buffer and select the whole word (default):
{
"double_click_in_multibuffer": "select",
}
- Open the excerpt clicked as a new buffer in the new tab:
{
"double_click_in_multibuffer": "open",
}
For the case of “open”, regular selection behavior can be achieved by holding
alt when double clicking.
Drop Target Size
- Description: Relative size of the drop target in the editor that will open dropped file as a split pane (0-0.5). For example, 0.25 means if you drop onto the top/bottom quarter of the pane a new vertical split will be used, if you drop onto the left/right quarter of the pane a new horizontal split will be used.
- Setting:
drop_target_size - Default:
0.2
Options
float values between 0 and 0.5
Current Line Highlight
- Description: How to highlight the current line in the editor.
- Setting:
current_line_highlight - Default:
all
Options
- Don’t highlight the current line:
"current_line_highlight": "none"
- Highlight the gutter area:
"current_line_highlight": "gutter"
- Highlight the editor area:
"current_line_highlight": "line"
- Highlight the full line:
"current_line_highlight": "all"
Selection Highlight
- Description: Whether to highlight all occurrences of the selected text in an editor.
- Setting:
selection_highlight - Default:
true
Rounded Selection
- Description: Whether the text selection should have rounded corners.
- Setting:
rounded_selection - Default:
true
Cursor Blink
- Description: Whether or not the cursor blinks.
- Setting:
cursor_blink - Default:
true
Options
boolean values
Cursor Shape
- Description: Cursor shape for the default editor.
- Setting:
cursor_shape - Default:
bar
Options
- A vertical bar:
"cursor_shape": "bar"
- A block that surrounds the following character:
"cursor_shape": "block"
- An underline / underscore that runs along the following character:
"cursor_shape": "underline"
- An box drawn around the following character:
"cursor_shape": "hollow"
Gutter
- Description: Settings for the editor gutter
- Setting:
gutter - Default:
{
"gutter": {
"line_numbers": true,
"runnables": true,
"breakpoints": true,
"folds": true,
"min_line_number_digits": 4,
},
}
Options
line_numbers: Whether to show line numbers in the gutterrunnables: Whether to show runnable buttons in the gutterbreakpoints: Whether to show breakpoints in the gutterfolds: Whether to show fold buttons in the guttermin_line_number_digits: Minimum number of characters to reserve space for in the gutter
Hide Mouse
- Description: Determines when the mouse cursor should be hidden in an editor or input box.
- Setting:
hide_mouse - Default:
on_typing_and_movement
Options
- Never hide the mouse cursor:
"hide_mouse": "never"
- Hide only when typing:
"hide_mouse": "on_typing"
- Hide on both typing and cursor movement:
"hide_mouse": "on_typing_and_movement"
Snippet Sort Order
- Description: Determines how snippets are sorted relative to other completion items.
- Setting:
snippet_sort_order - Default:
inline
Options
- Place snippets at the top of the completion list:
"snippet_sort_order": "top"
- Place snippets normally without any preference:
"snippet_sort_order": "inline"
- Place snippets at the bottom of the completion list:
"snippet_sort_order": "bottom"
- Do not show snippets in the completion list at all:
"snippet_sort_order": "none"
Editor Scrollbar
- Description: Whether or not to show the editor scrollbar and various elements in it.
- Setting:
scrollbar - Default:
"scrollbar": {
"show": "auto",
"cursors": true,
"git_diff": true,
"search_results": true,
"selected_text": true,
"selected_symbol": true,
"diagnostics": "all",
"axes": {
"horizontal": true,
"vertical": true,
},
},
Show Mode
- Description: When to show the editor scrollbar.
- Setting:
show - Default:
auto
Options
- Show the scrollbar if there’s important information or follow the system’s configured behavior:
"scrollbar": {
"show": "auto"
}
- Match the system’s configured behavior:
"scrollbar": {
"show": "system"
}
- Always show the scrollbar:
"scrollbar": {
"show": "always"
}
- Never show the scrollbar:
"scrollbar": {
"show": "never"
}
Git Diff Indicators
- Description: Whether to show git diff indicators in the scrollbar.
- Setting:
git_diff - Default:
true
Git diff indicators appear as colored marks showing lines that have been added, modified, or deleted compared to the git HEAD.
Options
boolean values
Search Results Indicators
- Description: Whether to show buffer search results in the scrollbar.
- Setting:
search_results - Default:
true
Search result indicators appear as marks showing all locations in the file where your current search query matches.
Options
boolean values
Selected Text Indicators
- Description: Whether to show selected text occurrences in the scrollbar.
- Setting:
selected_text - Default:
true
Selected text indicators appear as marks showing all occurrences of the currently selected text throughout the file.
Options
boolean values
Selected Symbols Indicators
- Description: Whether to show selected symbol occurrences in the scrollbar.
- Setting:
selected_symbol - Default:
true
Selected symbol indicators appear as marks showing all occurrences of the currently selected symbol (like a function or variable name) throughout the file.
Options
boolean values
Diagnostics
- Description: Which diagnostic indicators to show in the scrollbar.
- Setting:
diagnostics - Default:
all
Diagnostic indicators appear as colored marks showing errors, warnings, and other language server diagnostics at their corresponding line positions in the file.
Options
- Show all diagnostics:
{
"show_diagnostics": "all",
}
- Do not show any diagnostics:
{
"show_diagnostics": "off",
}
- Show only errors:
{
"show_diagnostics": "error",
}
- Show only errors and warnings:
{
"show_diagnostics": "warning",
}
- Show only errors, warnings, and information:
{
"show_diagnostics": "info",
}
Axes
- Description: Forcefully enable or disable the scrollbar for each axis
- Setting:
axes - Default:
"scrollbar": {
"axes": {
"horizontal": true,
"vertical": true,
},
}
Horizontal
- Description: When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
- Setting:
horizontal - Default:
true
Options
boolean values
Vertical
- Description: When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
- Setting:
vertical - Default:
true
Options
boolean values
Minimap
- Description: Settings related to the editor’s minimap, which provides an overview of your document.
- Setting:
minimap - Default:
{
"minimap": {
"show": "never",
"thumb": "always",
"thumb_border": "left_open",
"current_line_highlight": null,
},
}
Show Mode
- Description: When to show the minimap in the editor.
- Setting:
show - Default:
never
Options
- Always show the minimap:
{
"show": "always",
}
- Show the minimap if the editor’s scrollbars are visible:
{
"show": "auto",
}
- Never show the minimap:
{
"show": "never",
}
Thumb Display
- Description: When to show the minimap thumb (the visible editor area) in the minimap.
- Setting:
thumb - Default:
always
Options
- Show the minimap thumb when hovering over the minimap:
{
"thumb": "hover",
}
- Always show the minimap thumb:
{
"thumb": "always",
}
Thumb Border
- Description: How the minimap thumb border should look.
- Setting:
thumb_border - Default:
left_open
Options
- Display a border on all sides of the thumb:
{
"thumb_border": "full",
}
- Display a border on all sides except the left side:
{
"thumb_border": "left_open",
}
- Display a border on all sides except the right side:
{
"thumb_border": "right_open",
}
- Display a border only on the left side:
{
"thumb_border": "left_only",
}
- Display the thumb without any border:
{
"thumb_border": "none",
}
Current Line Highlight
- Description: How to highlight the current line in the minimap.
- Setting:
current_line_highlight - Default:
null
Options
- Inherit the editor’s current line highlight setting:
{
"minimap": {
"current_line_highlight": null,
},
}
- Highlight the current line in the minimap:
{
"minimap": {
"current_line_highlight": "line",
},
}
or
{
"minimap": {
"current_line_highlight": "all",
},
}
- Do not highlight the current line in the minimap:
{
"minimap": {
"current_line_highlight": "gutter",
},
}
or
{
"minimap": {
"current_line_highlight": "none",
},
}
Editor Tab Bar
- Description: Settings related to the editor’s tab bar.
- Settings:
tab_bar - Default:
"tab_bar": {
"show": true,
"show_nav_history_buttons": true,
"show_tab_bar_buttons": "on_pane_focus",
"show_pinned_tabs_in_separate_row": false,
"wrap_tabs": false
}
Show
- Description: Whether or not to show the tab bar in the editor.
- Setting:
show - Default:
true
Options
boolean values
Navigation History Buttons
- Description: Whether or not to show the navigation history buttons.
- Setting:
show_nav_history_buttons - Default:
true
Options
boolean values
Tab Bar Buttons
- Description: When to show the tab bar buttons.
- Setting:
show_tab_bar_buttons - Default:
on_pane_focus
Options
boolean values
Pinned Tabs in Separate Row
- Description: Whether or not pinned tabs appear in a top row and unpinned tabs in a bottom row. When disabled, all tabs appear in a single row.
- Setting:
show_pinned_tabs_in_separate_row - Default:
false
Options
boolean values
Wrap Tabs
- Description: Whether to wrap tabs onto additional rows instead of scrolling horizontally when the tab bar overflows.
- Setting:
wrap_tabs - Default:
false
Options
boolean values
Editor Tabs
- Description: Configuration for the editor tabs.
- Setting:
tabs - Default:
"tabs": {
"close_position": "right",
"file_icons": false,
"git_status": false,
"activate_on_close": "history",
"show_close_button": "hover",
"show_diagnostics": "off"
},
Close Position
- Description: Where to display close button within a tab.
- Setting:
close_position - Default:
right
Options
- Display the close button on the right:
{
"close_position": "right",
}
- Display the close button on the left:
{
"close_position": "left",
}
File Icons
- Description: Whether to show the file icon for a tab.
- Setting:
file_icons - Default:
false
Git Status
- Description: Whether or not to show Git file status in tab.
- Setting:
git_status - Default:
false
Activate on close
- Description: What to do after closing the current tab.
- Setting:
activate_on_close - Default:
history
Options
- Activate the tab that was open previously:
{
"activate_on_close": "history",
}
- Activate the right neighbour tab if present:
{
"activate_on_close": "neighbour",
}
- Activate the left neighbour tab if present:
{
"activate_on_close": "left_neighbour",
}
Show close button
- Description: Controls the appearance behavior of the tab’s close button.
- Setting:
show_close_button - Default:
hover
Options
- Show it just upon hovering the tab:
{
"show_close_button": "hover",
}
- Show it persistently:
{
"show_close_button": "always",
}
- Never show it, even if hovering it:
{
"show_close_button": "hidden",
}
Show Diagnostics
- Description: Whether to show diagnostics indicators in tabs. This setting only works when file icons are active and controls which files with diagnostic issues to mark.
- Setting:
show_diagnostics - Default:
off
Options
- Do not mark any files:
{
"show_diagnostics": "off",
}
- Only mark files with errors:
{
"show_diagnostics": "errors",
}
- Mark files with errors and warnings:
{
"show_diagnostics": "all",
}
Show Inline Code Actions
- Description: Whether to show code action button at start of buffer line.
- Setting:
inline_code_actions - Default:
true
Options
boolean values
Drag And Drop Selection
- Description: Whether to allow drag and drop text selection in buffer.
delayis the milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created. - Setting:
drag_and_drop_selection - Default:
"drag_and_drop_selection": {
"enabled": true,
"delay": 300
}
Editor Toolbar
- Description: Whether or not to show various elements in the editor toolbar.
- Setting:
toolbar - Default:
"toolbar": {
"breadcrumbs": true,
"quick_actions": true,
"selections_menu": true,
"code_actions": false
},
Options
Each option controls displaying of a particular toolbar element. If all elements are hidden, the editor toolbar is not displayed.
Use System Tabs
- Description: Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).
- Setting:
use_system_window_tabs - Default:
false
Options
This setting enables integration with macOS’s native window tabbing feature.
When set to true, Gram windows can be grouped together as tabs in a single
macOS window, following the system-wide tabbing preferences set by the user
(such as “Always”, “In Full Screen”, or “Never”). This setting is only available
on macOS.
Enable Language Server
- Description: Whether or not to use language servers to provide code intelligence.
- Setting:
enable_language_server - Default:
true
Options
boolean values
Ensure Final Newline On Save
- Description: Removes any lines containing only whitespace at the end of the file and ensures just one newline at the end.
- Setting:
ensure_final_newline_on_save - Default:
true
Options
boolean values
Expand Excerpt Lines
- Description: The default number of lines to expand excerpts in the multibuffer by
- Setting:
expand_excerpt_lines - Default:
5
Options
Positive integer values
Excerpt Context Lines
- Description: The number of lines of context to provide when showing excerpts in the multibuffer.
- Setting:
excerpt_context_lines - Default:
2
Options
Positive integer value between 1 and 32. Values outside of this range will be
clamped to this range.
Extend Comment On Newline
- Description: Whether to start a new line with a comment when a previous line is a comment as well.
- Setting:
extend_comment_on_newline - Default:
true
Options
boolean values
Status Bar
- Description: Control various elements in the status bar. Note that some items in the status bar have their own settings set elsewhere.
- Setting:
status_bar - Default:
"status_bar": {
"show": true,
"position": "bottom",
"active_language_button": true,
"cursor_position_button": true,
"line_endings_button": false,
"active_encoding_button": "non_utf8"
},
LSP
- Description: Configuration for language servers.
- Setting:
lsp - Default:
null
Options
The following settings can be overridden for specific language servers:
initialization_optionssettings
To override configuration for a language server, add an entry for that language
server’s name to the lsp value.
Some options are passed via initialization_options to the language server.
These are for options which must be specified at language server startup and
when changed will require restarting the language server.
For example to pass the check option to rust-analyzer, use the following
configuration:
"lsp": {
"rust-analyzer": {
"initialization_options": {
"check": {
"command": "clippy" // rust-analyzer.check.command (default: "check")
}
}
}
}
While other options may be changed at a runtime and should be placed under
settings:
"lsp": {
"yaml-language-server": {
"settings": {
"yaml": {
"keyOrdering": true // Enforces alphabetical ordering of keys in maps
}
}
}
}
Global LSP Settings
- Description: Configuration for global LSP settings that apply to all language servers
- Setting:
global_lsp_settings - Default:
{
"global_lsp_settings": {
"button": true,
},
}
Options
button: Whether to show the LSP status button in the status bar
LSP Highlight Debounce
- Description: The debounce delay in milliseconds before querying highlights from the language server based on the current cursor location.
- Setting:
lsp_highlight_debounce - Default:
75
Options
integer values representing milliseconds
Features
- Description: Features that can be globally enabled or disabled
- Setting:
features - Default:
{
"features": {},
}
Format On Save
- Description: Whether or not to perform a buffer format before saving.
- Setting:
format_on_save - Default:
on
Options
on, enables format on save obeyingformattersetting:
{
"format_on_save": "on",
}
off, disables format on save:
{
"format_on_save": "off",
}
Formatter
- Description: How to perform a buffer format.
- Setting:
formatter - Default:
auto
Options
- To use the current language server, use
"language_server":
{
"formatter": "language_server",
}
- Or to use an external command, use
"external". Specify the name of the formatting program to run, and an array of arguments to pass to the program. The buffer’s text will be passed to the program on stdin, and the formatted output should be written to stdout. For example, the following command would strip trailing spaces usingsed(1):
{
"formatter": {
"external": {
"command": "sed",
"arguments": ["-e", "s/ *$//"],
},
},
}
- External formatters may optionally include a
{buffer_path}placeholder which at runtime will include the path of the buffer being formatted. Formatters operate by receiving file content via standard input, reformatting it and then outputting it to standard output and so normally don’t know the filename of what they are formatting. Tools like Prettier support receiving the file path via a command line argument which can then used to impact formatting decisions.
WARNING: {buffer_path} should not be used to direct your formatter to read
from a filename. Your formatter should only read from standard input and should
not read or write files directly.
"formatter": {
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
- Or to use code actions provided by the connected language servers, use
"code_actions":
{
"formatter": [
// Use ESLint's --fix:
{ "code_action": "source.fixAll.eslint" },
// Organize imports on save:
{ "code_action": "source.organizeImports" },
],
}
- Or to use multiple formatters consecutively, use an array of formatters:
{
"formatter": [
{ "language_server": { "name": "rust-analyzer" } },
{
"external": {
"command": "sed",
"arguments": ["-e", "s/ *$//"],
},
},
],
}
Here rust-analyzer will be used first to format the code, followed by a call
of sed. If any of the formatters fails, the subsequent ones will still be
executed.
Auto close
- Description: Whether to automatically add matching closing characters when typing opening parenthesis, bracket, brace, single or double quote characters.
- Setting:
use_autoclose - Default:
true
Options
boolean values
Always Treat Brackets As Autoclosed
- Description: Controls how the editor handles the autoclosed characters.
- Setting:
always_treat_brackets_as_autoclosed - Default:
false
Options
boolean values
Example
If the setting is set to true:
- Enter in the editor:
))) - Move the cursor to the start:
^))) - Enter again:
)))
The result is still ))) and not )))))), which is what it would be by
default.
File Scan Exclusions
- Setting:
file_scan_exclusions - Description: Files or globs of files that will be excluded by Gram entirely.
They will be skipped during file scans, file searches, and not be displayed in
the project file tree. Overrides
file_scan_inclusions. - Default:
"file_scan_exclusions": [
"**/.git",
"**/.svn",
"**/.hg",
"**/.jj",
"**/CVS",
"**/.DS_Store",
"**/Thumbs.db",
"**/.classpath",
"**/.settings"
],
Note, specifying file_scan_exclusions in settings.jsonc will override the
defaults (shown above). If you are looking to exclude additional items you will
need to include all the default values in your settings.
File Scan Inclusions
- Setting:
file_scan_inclusions - Description: Files or globs of files that will be included by Gram, even when
ignored by git. This is useful for files that are not tracked by git, but are
still important to your project. Note that globs that are overly broad can
slow down Gram’s file scanning.
file_scan_exclusionstakes precedence over these inclusions. - Default:
"file_scan_inclusions": [".env*"],
File Types
- Setting:
file_types - Description: Configure how Gram selects a language for a file based on its filename or extension. Supports glob entries.
- Default:
"file_types": {
"Shell Script": [".env.*"]
}
Examples
To interpret all .c files as C++, files called MyLockFile as TOML and files
starting with Dockerfile as Dockerfile:
{
"file_types": {
"C++": ["c"],
"TOML": ["MyLockFile"],
"Dockerfile": ["Dockerfile*"],
},
}
Diagnostics
- Description: Configuration for diagnostics-related features.
- Setting:
diagnostics - Default:
{
"diagnostics": {
"include_warnings": true,
"inline": {
"enabled": false,
},
"update_with_cursor": false,
"primary_only": false,
"use_rendered": false,
},
}
Inline Diagnostics
- Description: Whether or not to show diagnostics information inline.
- Setting:
inline - Default:
{
"diagnostics": {
"inline": {
"enabled": false,
"update_debounce_ms": 150,
"padding": 4,
"min_column": 0,
"max_severity": null,
},
},
}
Options
- Enable inline diagnostics.
{
"diagnostics": {
"inline": {
"enabled": true,
},
},
}
- Delay diagnostic updates until some time after the last diagnostic update.
{
"diagnostics": {
"inline": {
"enabled": true,
"update_debounce_ms": 150,
},
},
}
- Set padding between the end of the source line and the start of the diagnostic.
{
"diagnostics": {
"inline": {
"enabled": true,
"padding": 4,
},
},
}
- Horizontally align inline diagnostics at the given column.
{
"diagnostics": {
"inline": {
"enabled": true,
"min_column": 80,
},
},
}
- Show only warning and error diagnostics.
{
"diagnostics": {
"inline": {
"enabled": true,
"max_severity": "warning",
},
},
}
Git
- Description: Configuration for git-related features.
- Setting:
git - Default:
{
"git": {
"git_gutter": "tracked_files",
"inline_blame": {
"enabled": true,
},
"branch_picker": {
"show_author_name": true,
},
"hunk_style": "staged_hollow",
},
}
Git Gutter
- Description: Whether or not to show the git gutter.
- Setting:
git_gutter - Default:
tracked_files
Options
- Show git gutter in tracked files
{
"git": {
"git_gutter": "tracked_files",
},
}
- Hide git gutter
{
"git": {
"git_gutter": "hide",
},
}
Gutter Debounce
- Description: Sets the debounce threshold (in milliseconds) after which changes are reflected in the git gutter.
- Setting:
gutter_debounce - Default:
null
Options
integer values representing milliseconds
Example:
{
"git": {
"gutter_debounce": 100,
},
}
Inline Git Blame
- Description: Whether or not to show git blame information inline, on the currently focused line.
- Setting:
inline_blame - Default:
{
"git": {
"inline_blame": {
"enabled": true,
},
},
}
Options
- Disable inline git blame:
{
"git": {
"inline_blame": {
"enabled": false,
},
},
}
- Only show inline git blame after a delay (that starts after cursor stops moving):
{
"git": {
"inline_blame": {
"delay_ms": 500,
},
},
}
- Show a commit summary next to the commit date and author:
{
"git": {
"inline_blame": {
"show_commit_summary": true,
},
},
}
- Use this as the minimum column at which to display inline blame information:
{
"git": {
"inline_blame": {
"min_column": 80,
},
},
}
- Set the padding between the end of the line and the inline blame hint, in ems:
{
"git": {
"inline_blame": {
"padding": 10,
},
},
}
Branch Picker
- Description: Configuration related to the branch picker.
- Setting:
branch_picker - Default:
{
"git": {
"branch_picker": {
"show_author_name": false,
},
},
}
Options
- Show the author name in the branch picker:
{
"git": {
"branch_picker": {
"show_author_name": true,
},
},
}
Hunk Style
- Description: What styling we should use for the diff hunks.
- Setting:
hunk_style - Default:
{
"git": {
"hunk_style": "staged_hollow",
},
}
Options
- Show the staged hunks faded out and with a border:
{
"git": {
"hunk_style": "staged_hollow",
},
}
- Show unstaged hunks faded out and with a border:
{
"git": {
"hunk_style": "unstaged_hollow",
},
}
Go to Definition Fallback
- Description: What to do when the editor::GoToDefinition action fails to find a definition
- Setting:
go_to_definition_fallback - Default:
"find_all_references"
Options
- Do nothing:
{
"go_to_definition_fallback": "none",
}
- Find references for the same symbol (default):
{
"go_to_definition_fallback": "find_all_references",
}
Hard Tabs
- Description: Whether to indent lines using tab characters or multiple spaces.
- Setting:
hard_tabs - Default:
false
Options
boolean values
Helix Mode
- Description: Whether or not to enable Helix mode. Enabling
helix_modealso enablesvim_mode. See the Helix documentation for more details. - Setting:
helix_mode - Default:
false
Options
boolean values
Indent Guides
- Description: Configuration related to indent guides. Indent guides can be configured separately for each language.
- Setting:
indent_guides - Default:
{
"indent_guides": {
"enabled": true,
"line_width": 1,
"active_line_width": 1,
"coloring": "fixed",
"background_coloring": "disabled",
},
}
Options
- Disable indent guides
{
"indent_guides": {
"enabled": false,
},
}
- Enable indent guides for a specific language.
{
"languages": {
"Python": {
"indent_guides": {
"enabled": true,
},
},
},
}
- Enable indent aware coloring (“rainbow indentation”). The colors that are
used for different indentation levels are defined in the theme (theme key:
accents). They can be customized by using theme overrides.
{
"indent_guides": {
"enabled": true,
"coloring": "indent_aware",
},
}
- Enable indent aware background coloring (“rainbow indentation”). The colors
that are used for different indentation levels are defined in the theme
(theme key:
accents). They can be customized by using theme overrides.
{
"indent_guides": {
"enabled": true,
"coloring": "indent_aware",
"background_coloring": "indent_aware",
},
}
Hover Popover Enabled
- Description: Whether or not to show the informational hover box when moving the mouse over symbols in the editor.
- Setting:
hover_popover_enabled - Default:
true
Options
boolean values
Hover Popover Delay
- Description: Time to wait in milliseconds before showing the informational hover box.
- Setting:
hover_popover_delay - Default:
300
Options
integer values representing milliseconds
Icon Theme
- Description: The icon theme setting can be specified in two forms - either as
the name of an icon theme or as an object containing the
mode,dark, andlighticon themes for files/folders inside Gram. - Setting:
icon_theme - Default:
Gram (Default)
Icon Theme Object
- Description: Specify the icon theme using an object that includes the
mode,dark, andlight. - Setting:
icon_theme - Default:
"icon_theme": {
"mode": "system",
"dark": "Gram (Default)",
"light": "Gram (Default)"
},
Mode
- Description: Specify the icon theme mode.
- Setting:
mode - Default:
system
Options
- Set the icon theme to dark mode
{
"mode": "dark",
}
- Set the icon theme to light mode
{
"mode": "light",
}
- Set the icon theme to system mode
{
"mode": "system",
}
Dark
- Description: The name of the dark icon theme.
- Setting:
dark - Default:
Gram (Default)
Options
Run the icon_theme_selector::Toggle action in the command palette to see a current list of valid icon themes names.
Light
- Description: The name of the light icon theme.
- Setting:
light - Default:
Gram (Default)
Options
Run the icon_theme_selector::Toggle action in the command palette to see a current list of valid icon themes names.
Image Viewer
- Description: Settings for image viewer functionality
- Setting:
image_viewer - Default:
{
"image_viewer": {
"unit": "binary",
},
}
Options
Unit
- Description: The unit for image file sizes
- Setting:
unit - Default:
"binary"
Options
- Use binary units (KiB, MiB):
{
"image_viewer": {
"unit": "binary",
},
}
- Use decimal units (KB, MB):
{
"image_viewer": {
"unit": "decimal",
},
}
Inlay hints
- Description: Configuration for displaying extra text with hints in the editor.
- Setting:
inlay_hints - Default:
"inlay_hints": {
"enabled": false,
"show_type_hints": true,
"show_parameter_hints": true,
"show_other_hints": true,
"show_background": false,
"edit_debounce_ms": 700,
"scroll_debounce_ms": 50,
"toggle_on_modifiers_press": null
}
Options
Inlay hints querying consists of two parts: editor (client) and LSP server. With the inlay settings above are changed to enable the hints, editor will start to query certain types of hints and react on LSP hint refresh request from the server. At this point, the server may or may not return hints depending on its implementation, further configuration might be needed, refer to the corresponding LSP server documentation.
The following languages have inlay hints preconfigured by Gram:
- Go
- Rust
- Svelte
- TypeScript
Use the lsp section for the server configuration. Examples are provided in the
corresponding language documentation.
Hints are not instantly queried in Gram, two kinds of debounces are used, either may be set to 0 to be disabled. Settings-related hint updates are not debounced.
All possible config values for toggle_on_modifiers_press are:
"inlay_hints": {
"toggle_on_modifiers_press": {
"control": true,
"shift": true,
"alt": true,
"platform": true,
"function": true
}
}
Unspecified values have a false value, hints won’t be toggled if all the
modifiers are false or not all the modifiers are pressed.
Journal
- Description: Configuration for the journal.
- Setting:
journal - Default:
"journal": {
"path": "~",
"hour_format": "hour12"
}
Path
- Description: The path of the directory where journal entries are stored. If an
invalid path is specified, the journal will fall back to using
~(the home directory). - Setting:
path - Default:
~
Options
string values
Hour Format
- Description: The format to use for displaying hours in the journal.
- Setting:
hour_format - Default:
hour12
Options
- 12-hour format:
{
"hour_format": "hour12",
}
- 24-hour format:
{
"hour_format": "hour24",
}
JSX Tag Auto Close
- Description: Whether to automatically close JSX tags
- Setting:
jsx_tag_auto_close - Default:
{
"jsx_tag_auto_close": {
"enabled": true,
},
}
Options
enabled: Whether to enable automatic JSX tag closing
Languages
- Description: Configuration for specific languages.
- Setting:
languages - Default:
null
Options
To override settings for a language, add an entry for that languages name to the
languages value. Example:
"languages": {
"C": {
"format_on_save": "off",
"preferred_line_length": 64,
"soft_wrap": "preferred_line_length"
},
"JSON": {
"tab_size": 4
}
}
The following settings can be overridden for each specific language:
enable_language_serverensure_final_newline_on_saveformat_on_saveformatterhard_tabspreferred_line_lengthremove_trailing_whitespace_on_saveshow_whitespaceswhitespace_mapsoft_wraptab_sizeuse_autoclosealways_treat_brackets_as_autoclosed
These values take in the same options as the root-level settings with the same name.
Line Indicator Format
- Description: Format for line indicator in the status bar
- Setting:
line_indicator_format - Default:
"short"
Options
- Short format:
{
"line_indicator_format": "short",
}
- Long format:
{
"line_indicator_format": "long",
}
Linked Edits
- Description: Whether to perform linked edits of associated ranges, if the
language server supports it. For example, when editing opening
<html>tag, the contents of the closing</html>tag will be edited as well. - Setting:
linked_edits - Default:
true
Options
boolean values
LSP Document Colors
- Description: Whether to show document color information from the language server
- Setting:
lsp_document_colors - Default:
true
Options
boolean values
Max Tabs
- Description: Maximum number of tabs to show in the tab bar
- Setting:
max_tabs - Default:
null
Options
Positive integer values or null for unlimited tabs
Middle Click Paste (Linux only)
- Description: Enable middle-click paste on Linux
- Setting:
middle_click_paste - Default:
true
Options
boolean values
Multi Cursor Modifier
- Description: Determines the modifier to be used to add multiple cursors with the mouse. The open hover link mouse gestures will adapt such that it do not conflict with the multicursor modifier.
- Setting:
multi_cursor_modifier - Default:
alt
Options
- Maps to
Alton Linux and Windows and toOptionon macOS:
{
"multi_cursor_modifier": "alt",
}
- Maps
Controlon Linux and Windows and toCommandon macOS:
{
"multi_cursor_modifier": "cmd_or_ctrl", // alias: "cmd", "ctrl"
}
Node
- Description: Configuration for Node.js integration
- Setting:
node - Default:
{
"node": {
"ignore_system_version": false,
"path": null,
"npm_path": null,
},
}
Options
ignore_system_version: Whether to ignore the system Node.js versionpath: Custom path to Node.js binarynpm_path: Custom path to npm binary
Network Proxy
- Description: Configure a network proxy for Gram.
- Setting:
proxy - Default:
null
Options
The proxy setting must contain a URL to the proxy.
The following URI schemes are supported:
httphttpssocks4- SOCKS4 proxy with local DNSsocks4a- SOCKS4 proxy with remote DNSsocks5- SOCKS5 proxy with local DNSsocks5h- SOCKS5 proxy with remote DNS
http will be used when no scheme is specified.
By default no proxy will be used, or Gram will attempt to retrieve proxy
settings from environment variables, such as http_proxy, HTTP_PROXY,
https_proxy, HTTPS_PROXY, all_proxy, ALL_PROXY, no_proxy and
NO_PROXY.
For example, to set an http proxy, add the following to your settings:
{
"proxy": "http://127.0.0.1:10809",
}
Or to set a socks5 proxy:
{
"proxy": "socks5h://localhost:10808",
}
If you wish to exclude certain hosts from using the proxy, set the NO_PROXY
environment variable. This accepts a comma-separated list of hostnames, host
suffixes, IPv4/IPv6 addresses or blocks that should not use the proxy. For
example if your environment included NO_PROXY="google.com, 192.168.1.0/24" all
hosts in 192.168.1.*, google.com and *.google.com would bypass the proxy.
See
reqwest NoProxy docs
for more.
On Last Window Closed
- Description: What to do when the last window is closed
- Setting:
on_last_window_closed - Default:
"platform_default"
Options
- Use platform default behavior:
{
"on_last_window_closed": "platform_default",
}
- Always quit the application:
{
"on_last_window_closed": "quit_app",
}
Profiles
- Description: Configuration profiles that can be applied on top of existing settings
- Setting:
profiles - Default:
{}
Options
Configuration object for defining settings profiles. Example:
{
"profiles": {
"presentation": {
"buffer_font_size": 20,
"ui_font_size": 18,
"theme": "One Light",
},
},
}
Preview tabs
-
Description: Preview tabs allow you to open files in preview mode, where they close automatically when you switch to another file unless you explicitly pin them. This is useful for quickly viewing files without cluttering your workspace. Preview tabs display their file names in italics.
There are several ways to convert a preview tab into a regular tab:- Double-clicking on the file
- Double-clicking on the tab header
- Using the project_panel::OpenPermanent action
- Editing the file
- Dragging the file to a different pane
-
Setting:
preview_tabs -
Default:
"preview_tabs": {
"enabled": true,
"enable_preview_from_project_panel": true,
"enable_preview_from_file_finder": false,
"enable_preview_from_multibuffer": true,
"enable_preview_multibuffer_from_code_navigation": false,
"enable_preview_file_from_code_navigation": true,
"enable_keep_preview_on_code_navigation": false,
}
Enable preview from project panel
- Description: Determines whether to open files in preview mode when opened from the project panel with a single click.
- Setting:
enable_preview_from_project_panel - Default:
true
Options
boolean values
Enable preview from file finder
- Description: Determines whether to open files in preview mode when selected from the file finder.
- Setting:
enable_preview_from_file_finder - Default:
false
Options
boolean values
Enable preview from multibuffer
- Description: Determines whether to open files in preview mode when opened from a multibuffer.
- Setting:
enable_preview_from_multibuffer - Default:
true
Options
boolean values
Enable preview multibuffer from code navigation
- Description: Determines whether to open tabs in preview mode when code navigation is used to open a multibuffer.
- Setting:
enable_preview_multibuffer_from_code_navigation - Default:
false
Options
boolean values
Enable preview file from code navigation
- Description: Determines whether to open tabs in preview mode when code navigation is used to open a single file.
- Setting:
enable_preview_file_from_code_navigation - Default:
true
Options
boolean values
Enable keep preview on code navigation
- Description: Determines whether to keep tabs in preview mode when code
navigation is used to navigate away from them. If
enable_preview_file_from_code_navigationorenable_preview_multibuffer_from_code_navigationis also true, the new tab may replace the existing one. - Setting:
enable_keep_preview_on_code_navigation - Default:
false
Options
boolean values
File Finder
File Icons
- Description: Whether to show file icons in the file finder.
- Setting:
file_icons - Default:
true
Modal Max Width
- Description: Max-width of the file finder modal. It can take one of these
values:
small,medium,large,xlarge, andfull. - Setting:
modal_max_width - Default:
small
Skip Focus For Active In Search
- Description: Determines whether the file finder should skip focus for the active file in search results.
- Setting:
skip_focus_for_active_in_search - Default:
true
Pane Split Direction Horizontal
- Description: The direction that you want to split panes horizontally
- Setting:
pane_split_direction_horizontal - Default:
"up"
Options
- Split upward:
{
"pane_split_direction_horizontal": "up",
}
- Split downward:
{
"pane_split_direction_horizontal": "down",
}
Pane Split Direction Vertical
- Description: The direction that you want to split panes vertically
- Setting:
pane_split_direction_vertical - Default:
"left"
Options
- Split to the left:
{
"pane_split_direction_vertical": "left",
}
- Split to the right:
{
"pane_split_direction_vertical": "right",
}
Preferred Line Length
- Description: The column at which to soft-wrap lines, for buffers where soft-wrap is enabled.
- Setting:
preferred_line_length - Default:
80
Options
integer values
Private Files
- Description: Globs to match against file paths to determine if a file is private
- Setting:
private_files - Default:
["**/.env*", "**/*.pem", "**/*.key", "**/*.cert", "**/*.crt", "**/secrets.yml"]
Options
List of string glob patterns
Projects Online By Default
- Description: Whether or not to show the online projects view by default.
- Setting:
projects_online_by_default - Default:
true
Options
boolean values
Read SSH Config
- Description: Whether to read SSH configuration files
- Setting:
read_ssh_config - Default:
true
Options
boolean values
Redact Private Values
- Description: Hide the values of variables from visual display in private files
- Setting:
redact_private_values - Default:
false
Options
boolean values
Relative Line Numbers
- Description: Whether to show relative line numbers in the gutter
- Setting:
relative_line_numbers - Default:
"disabled"
Options
- Show relative line numbers in the gutter whilst counting wrapped lines as one line:
{
"relative_line_numbers": "enabled",
}
- Show relative line numbers in the gutter, including wrapped lines in the counting:
{
"relative_line_numbers": "wrapped",
}
- Do not use relative line numbers:
{
"relative_line_numbers": "disabled",
}
Remove Trailing Whitespace On Save
- Description: Whether or not to remove any trailing whitespace from lines of a buffer before saving it.
- Setting:
remove_trailing_whitespace_on_save - Default:
true
Options
boolean values
Resize All Panels In Dock
- Description: Whether to resize all the panels in a dock when resizing the dock. Can be a combination of “left”, “right” and “bottom”.
- Setting:
resize_all_panels_in_dock - Default:
["left"]
Options
List of strings containing any combination of:
"left": Resize left dock panels together"right": Resize right dock panels together"bottom": Resize bottom dock panels together
Restore on File Reopen
- Description: Whether to attempt to restore previous file’s state when opening it again. The state is stored per pane.
- Setting:
restore_on_file_reopen - Default:
true
Options
boolean values
Restore on Startup
- Description: Controls session restoration on startup.
- Setting:
restore_on_startup - Default:
last_session
Options
- Restore all workspaces that were open when quitting Gram:
{
"restore_on_startup": "last_session",
}
- Restore the workspace that was closed last:
{
"restore_on_startup": "last_workspace",
}
- Always start with an empty editor:
{
"restore_on_startup": "empty_tab",
}
- Always start with the welcome launchpad:
{
"restore_on_startup": "launchpad",
}
Scroll Beyond Last Line
- Description: Whether the editor will scroll beyond the last line
- Setting:
scroll_beyond_last_line - Default:
"one_page"
Options
- Scroll one page beyond the last line by one page:
{
"scroll_beyond_last_line": "one_page",
}
- The editor will scroll beyond the last line by the same amount of lines as
vertical_scroll_margin:
{
"scroll_beyond_last_line": "vertical_scroll_margin",
}
- The editor will not scroll beyond the last line:
{
"scroll_beyond_last_line": "off",
}
Options
boolean values
Scroll Sensitivity
- Description: Scroll sensitivity multiplier. This multiplier is applied to both the horizontal and vertical delta values while scrolling.
- Setting:
scroll_sensitivity - Default:
1.0
Options
Positive float values
Fast Scroll Sensitivity
- Description: Scroll sensitivity multiplier for fast scrolling. This multiplier is applied to both the horizontal and vertical delta values while scrolling. Fast scrolling happens when a user holds the alt or option key while scrolling.
- Setting:
fast_scroll_sensitivity - Default:
4.0
Options
Positive float values
Horizontal Scroll Margin
- Description: The number of characters to keep on either side when scrolling with the mouse
- Setting:
horizontal_scroll_margin - Default:
5
Options
Non-negative integer values
Vertical Scroll Margin
- Description: The number of lines to keep above/below the cursor when scrolling with the keyboard
- Setting:
vertical_scroll_margin - Default:
3
Options
Non-negative integer values
Search
- Description: Search options to enable by default when opening new project and buffer searches.
- Setting:
search - Default:
"search": {
"button": true,
"whole_word": false,
"case_sensitive": false,
"include_ignored": false,
"regex": false,
"center_on_match": false
},
Button
- Description: Whether to show the project search button in the status bar.
- Setting:
button - Default:
true
Whole Word
- Description: Whether to only match on whole words.
- Setting:
whole_word - Default:
false
Case Sensitive
- Description: Whether to match case sensitively. This setting affects both searches and editor actions like “Select Next Occurrence”, “Select Previous Occurrence”, and “Select All Occurrences”.
- Setting:
case_sensitive - Default:
false
Include Ignore
- Description: Whether to include gitignored files in search results.
- Setting:
include_ignored - Default:
false
Regex
- Description: Whether to interpret the search query as a regular expression.
- Setting:
regex - Default:
false
Center On Match
- Description: Whether to center the cursor on each search match when navigating.
- Setting:
center_on_match - Default:
false
Search Wrap
- Description: If
search_wrapis disabled, search result do not wrap around the end of the file - Setting:
search_wrap - Default:
true
Center on Match
- Description: If
center_on_matchis enabled, the editor will center the cursor on the current match when searching. - Setting:
center_on_match - Default:
false
Seed Search Query From Cursor
- Description: When to populate a new search’s query based on the text under the cursor.
- Setting:
seed_search_query_from_cursor - Default:
always
Options
alwaysalways populate the search query with the word under the cursorselectiononly populate the search query when there is text selectednevernever populate the search query
Use Smartcase Search
- Description: When enabled, automatically adjusts search case sensitivity based
on your query. If your search query contains any uppercase letters, the search
becomes case-sensitive; if it contains only lowercase letters, the search
becomes case-insensitive.
This applies to both in-file searches and project-wide searches. - Setting:
use_smartcase_search - Default:
false
Options
boolean values
Examples:
- Searching for “function” would match “function”, “Function”, “FUNCTION”, etc.
- Searching for “Function” would only match “Function”, not “function” or “FUNCTION”
Completions
- Description: Controls how completions are processed for this language.
- Setting:
completions - Default:
{
"completions": {
"words": "fallback",
"words_min_length": 3,
"lsp": true,
"lsp_fetch_timeout_ms": 0,
"lsp_insert_mode": "replace_suffix",
},
}
Words
- Description: Controls how words are completed. For large documents, not all words may be fetched for completion.
- Setting:
words - Default:
fallback
Options
enabled- Always fetch document’s words for completions along with LSP completionsfallback- Only if LSP response errors or times out, use document’s words to show completionsdisabled- Never fetch or complete document’s words for completions (word-based completions can still be queried via a separate action)
Min Words Query Length
- Description: Minimum number of characters required to automatically trigger word-based completions. Before that value, it’s still possible to trigger the words-based completion manually with the corresponding editor command.
- Setting:
words_min_length - Default:
3
Options
Positive integer values
LSP
- Description: Whether to fetch LSP completions or not.
- Setting:
lsp - Default:
true
Options
boolean values
LSP Fetch Timeout (ms)
- Description: When fetching LSP completions, determines how long to wait for a response of a particular server. When set to 0, waits indefinitely.
- Setting:
lsp_fetch_timeout_ms - Default:
0
Options
integer values representing milliseconds
LSP Insert Mode
- Description: Controls what range to replace when accepting LSP completions.
- Setting:
lsp_insert_mode - Default:
replace_suffix
Options
insert- Replaces text before the cursor, using theinsertrange described in the LSP specificationreplace- Replaces text before and after the cursor, using thereplacerange described in the LSP specificationreplace_subsequence- Behaves like"replace"if the text that would be replaced is a subsequence of the completion text, and like"insert"otherwisereplace_suffix- Behaves like"replace"if the text after the cursor is a suffix of the completion, and like"insert"otherwise
Show Completions On Input
- Description: Whether or not to show completions as you type.
- Setting:
show_completions_on_input - Default:
true
Options
boolean values
Show Completion Documentation
- Description: Whether to display inline and alongside documentation for items in the completions menu.
- Setting:
show_completion_documentation - Default:
true
Options
boolean values
Show Whitespaces
- Description: Whether or not to render whitespace characters in the editor.
- Setting:
show_whitespaces - Default:
selection
Options
allselectionnoneboundary
Whitespace Map
- Description: Specify the characters used to render whitespace when show_whitespaces is enabled.
- Setting:
whitespace_map - Default:
{
"whitespace_map": {
"space": "•",
"tab": "→",
},
}
Soft Wrap
- Description: Whether or not to automatically wrap lines of text to fit editor / preferred width.
- Setting:
soft_wrap - Default:
none
Options
noneto avoid wrapping completely.prefer_line(deprecated, same asnone)editor_widthto wrap lines that overflow the editor widthpreferred_line_lengthto wrap lines that overflowpreferred_line_lengthconfig valueboundedto wrap lines at the minimum ofeditor_widthandpreferred_line_length
Show Wrap Guides
- Description: Whether to show wrap guides (vertical rulers) in the editor. Setting this to true will show a guide at the ‘preferred_line_length’ value if ‘soft_wrap’ is set to ‘preferred_line_length’, and will show any additional guides as specified by the ‘wrap_guides’ setting.
- Setting:
show_wrap_guides - Default:
true
Options
boolean values
Use On Type Format
- Description: Whether to use additional LSP queries to format (and amend) the code after every “trigger” symbol input, defined by LSP server capabilities
- Setting:
use_on_type_format - Default:
true
Options
boolean values
Use Auto Surround
- Description: Whether to automatically surround selected text when typing opening parenthesis, bracket, brace, single or double quote characters. For example, when you select text and type ‘(’, Gram will surround the text with ().
- Setting:
use_auto_surround - Default:
true
Options
boolean values
Use System Path Prompts
- Description: Whether to use the system provided dialogs for Open and Save As. When set to false, Gram will use the built-in keyboard-first pickers.
- Setting:
use_system_path_prompts - Default:
true
Options
boolean values
Use System Prompts
- Description: Whether to use the system provided dialogs for prompts, such as confirmation prompts. When set to false, Gram will use its built-in prompts. Note that on Linux, this option is ignored and Gram will always use the built-in prompts.
- Setting:
use_system_prompts - Default:
true
Options
boolean values
Wrap Guides (Vertical Rulers)
- Description: Where to display vertical rulers as wrap-guides. Disable by
setting
show_wrap_guidestofalse. - Setting:
wrap_guides - Default: []
Options
List of integer column numbers
Tab Size
- Description: The number of spaces to use for each tab character.
- Setting:
tab_size - Default:
4
Options
integer values
Tasks
- Description: Configuration for tasks that can be run within Gram
- Setting:
tasks - Default:
{
"tasks": {
"variables": {},
"enabled": true,
"prefer_lsp": false,
},
}
Options
variables: Custom variables for task configurationenabled: Whether tasks are enabledprefer_lsp: Whether to prefer LSP-provided tasks over Gram language extension ones
Diagnostics
- Description: Setting for sending debug-related data, such as crash reports.
- Setting:
diagnostics - Default:
true
Options
boolean values
Terminal
- Description: Configuration for the terminal.
- Setting:
terminal - Default:
{
"terminal": {
"alternate_scroll": "off",
"blinking": "terminal_controlled",
"copy_on_select": false,
"keep_selection_on_copy": true,
"dock": "bottom",
"default_width": 640,
"default_height": 320,
"detect_venv": {
"on": {
"directories": [".env", "env", ".venv", "venv"],
"activate_script": "default",
},
},
"env": {},
"font_family": null,
"font_features": null,
"font_size": null,
"line_height": "comfortable",
"minimum_contrast": 45,
"option_as_meta": false,
"button": true,
"shell": "system",
"scroll_multiplier": 3.0,
"toolbar": {
"breadcrumbs": false,
},
"working_directory": "current_project_directory",
"scrollbar": {
"show": null,
},
},
}
Terminal: Dock
- Description: Control the position of the dock
- Setting:
dock - Default:
bottom
Options
"bottom", "left" or "right"
Terminal: Alternate Scroll
- Description: Set whether Alternate Scroll mode (DECSET code:
?1007) is active by default. Alternate Scroll mode converts mouse scroll events into up / down key presses when in the alternate screen (e.g. when running applications like vim or less). The terminal can still set and unset this mode with ANSI escape codes. - Setting:
alternate_scroll - Default:
off
Options
- Default alternate scroll mode to off
{
"terminal": {
"alternate_scroll": "off",
},
}
- Default alternate scroll mode to on
{
"terminal": {
"alternate_scroll": "on",
},
}
Terminal: Blinking
- Description: Set the cursor blinking behavior in the terminal
- Setting:
blinking - Default:
terminal_controlled
Options
- Never blink the cursor, ignore the terminal mode
{
"terminal": {
"blinking": "off",
},
}
- Default the cursor blink to off, but allow the terminal to turn blinking on
{
"terminal": {
"blinking": "terminal_controlled",
},
}
- Always blink the cursor, ignore the terminal mode
{
"terminal": {
"blinking": "on",
},
}
Terminal: Copy On Select
- Description: Whether or not selecting text in the terminal will automatically copy to the system clipboard.
- Setting:
copy_on_select - Default:
false
Options
boolean values
Example
{
"terminal": {
"copy_on_select": true,
},
}
Terminal: Cursor Shape
- Description: Controls the visual shape of the cursor in the terminal. When not explicitly set, it defaults to a block shape.
- Setting:
cursor_shape - Default:
null(defaults to block)
Options
- A block that surrounds the following character
{
"terminal": {
"cursor_shape": "block",
},
}
- A vertical bar
{
"terminal": {
"cursor_shape": "bar",
},
}
- An underline / underscore that runs along the following character
{
"terminal": {
"cursor_shape": "underline",
},
}
- A box drawn around the following character
{
"terminal": {
"cursor_shape": "hollow",
},
}
Terminal: Keep Selection On Copy
- Description: Whether or not to keep the selection in the terminal after copying text.
- Setting:
keep_selection_on_copy - Default:
true
Options
boolean values
Example
{
"terminal": {
"keep_selection_on_copy": false,
},
}
Terminal: Env
- Description: Any key-value pairs added to this object will be added to the
terminal’s environment. Keys must be unique, use
:to separate multiple values in a single variable - Setting:
env - Default:
{}
Example
{
"terminal": {
"env": {
"GRAM": "1",
"KEY": "value1:value2",
},
},
}
Terminal: Font Size
- Description: What font size to use for the terminal. When not set defaults to matching the editor’s font size
- Setting:
font_size - Default:
null
Options
integer values
{
"terminal": {
"font_size": 15,
},
}
Terminal: Font Family
- Description: What font to use for the terminal. When not set, defaults to matching the editor’s font.
- Setting:
font_family - Default:
null
Options
The name of any font family installed on the user’s system
{
"terminal": {
"font_family": "Berkeley Mono",
},
}
Terminal: Font Features
- Description: What font features to use for the terminal. When not set, defaults to matching the editor’s font features.
- Setting:
font_features - Default:
null - Platform: macOS and Windows.
Options
See Buffer Font Features
{
"terminal": {
"font_features": {
"calt": false,
// See Buffer Font Features for more features
},
},
}
Terminal: Line Height
- Description: Set the terminal’s line height.
- Setting:
line_height - Default:
standard
Options
- Use a line height that’s
comfortablefor reading, 1.618.
{
"terminal": {
"line_height": "comfortable",
},
}
- Use a
standardline height, 1.3. This option is useful for TUIs, particularly if they use box characters. (default)
{
"terminal": {
"line_height": "standard",
},
}
- Use a custom line height.
{
"terminal": {
"line_height": {
"custom": 2,
},
},
}
Terminal: Minimum Contrast
- Description: Controls the minimum contrast between foreground and background colors in the terminal. Uses the APCA (Accessible Perceptual Contrast Algorithm) for color adjustments. Set this to 0 to disable this feature.
- Setting:
minimum_contrast - Default:
45
Options
integer values from 0 to 106. Common recommended values:
0: No contrast adjustment45: Minimum for large fluent text (default)60: Minimum for other content text75: Minimum for body text90: Preferred for body text
{
"terminal": {
"minimum_contrast": 45,
},
}
Terminal: Option As Meta
- Description: Re-interprets the option keys to act like a ‘meta’ key, like in Emacs.
- Setting:
option_as_meta - Default:
false
Options
boolean values
{
"terminal": {
"option_as_meta": true,
},
}
Terminal: Shell
- Description: What shell to use when launching the terminal.
- Setting:
shell - Default:
system
Options
- Use the system’s default terminal configuration (usually the
/etc/passwdfile).
{
"terminal": {
"shell": "system",
},
}
- A program to launch:
{
"terminal": {
"shell": {
"program": "sh",
},
},
}
- A program with arguments:
{
"terminal": {
"shell": {
"with_arguments": {
"program": "/bin/bash",
"args": ["--login"],
},
},
},
}
Terminal: Detect Virtual Environments
- Description: Activate the Python Virtual Environment, if one is found, in the terminal’s working directory (as resolved by the working_directory and automatically activating the virtual environment.
- Setting:
detect_venv - Default:
{
"terminal": {
"detect_venv": {
"on": {
// Default directories to search for virtual environments, relative
// to the current working directory. We recommend overriding this
// in your project's settings, rather than globally.
"directories": [".env", "env", ".venv", "venv"],
// Can also be `csh`, `fish`, and `nushell`
"activate_script": "default",
},
},
},
}
Disable with:
{
"terminal": {
"detect_venv": "off",
},
}
Terminal: Scroll Multiplier
- Description: The multiplier for scrolling speed in the terminal when using mouse wheel or trackpad.
- Setting:
scroll_multiplier - Default:
1.0
Options
Positive floating point values. Values less than or equal to 0 will be clamped to a minimum of 0.01.
Example
{
"terminal": {
"scroll_multiplier": 5.0
}
}
Terminal: Toolbar
- Description: Whether or not to show various elements in the terminal toolbar.
- Setting:
toolbar - Default:
{
"terminal": {
"toolbar": {
"breadcrumbs": false,
},
},
}
Options
At the moment, only the breadcrumbs option is available, it controls
displaying of the terminal title that can be changed via PROMPT_COMMAND.
If the terminal title is empty, the breadcrumbs won’t be shown.
The shell running in the terminal needs to be configured to emit the title.
Example command to set the title: echo -e "\e]2;New Title\007";
Terminal: Button
- Description: Control to show or hide the terminal button in the status bar
- Setting:
button - Default:
true
Options
boolean values
{
"terminal": {
"button": false,
},
}
Terminal: Working Directory
- Description: What working directory to use when launching the terminal.
- Setting:
working_directory - Default:
"current_project_directory"
Options
- Use the current file’s project directory. Fallback to the first project directory strategy if unsuccessful.
{
"terminal": {
"working_directory": "current_project_directory",
},
}
- Use the first project in this workspace’s directory. Fallback to using this platform’s home directory.
{
"terminal": {
"working_directory": "first_project_directory",
},
}
- Always use this platform’s home directory if it can be found.
{
"terminal": {
"working_directory": "always_home",
},
}
- Always use a specific directory. This value will be shell expanded. If this path is not a valid directory the terminal will default to this platform’s home directory.
{
"terminal": {
"working_directory": {
"always": {
"directory": "~/gram/projects/",
},
},
},
}
Terminal: Opening Paths and URLs
File paths and URLs printed in the terminal become links while you hold ctrl
(cmd on macOS):
ctrl-click(cmd-clickon macOS) opens a path in the editor, or a URL in the browser.ctrl-alt-click(cmd-alt-clickon macOS) opens a path in the system’s default app. In remote projects it opens in the editor.
When a program running in the terminal has captured the mouse (vim, tmux, htop
and the like), add shift to either one.
Terminal: Path Hyperlink Regexes
- Description: Regexes used to identify path hyperlinks. The regexes can be specified in two forms - a single regex string, or an array of strings (which will be collected into a single multi-line regex string).
- Setting:
path_hyperlink_regexes - Default:
{
"terminal": {
"path_hyperlink_regexes": [
// Python-style diagnostics
"File \"(?<path>[^\"]+)\", line (?<line>[0-9]+)",
// Common path syntax with optional line, column, description, trailing punctuation, or
// surrounding symbols or quotes
[
"(?x)",
"# optionally starts with 0-2 opening prefix symbols",
"[({\\[<]{0,2}",
"# which may be followed by an opening quote",
"(?<quote>[\"'`])?",
"# `path` is the shortest sequence of any non-space character",
"(?<link>(?<path>[^ ]+?",
" # which may end with a line and optionally a column,",
" (?<line_column>:+[0-9]+(:[0-9]+)?|:?\\([0-9]+([,:][0-9]+)?\\))?",
"))",
"# which must be followed by a matching quote",
"(?(<quote>)\\k<quote>)",
"# and optionally a single closing symbol",
"[)}\\]>]?",
"# if line/column matched, may be followed by a description",
"(?(<line_column>):[^ 0-9][^ ]*)?",
"# which may be followed by trailing punctuation",
"[.,:)}\\]>]*",
"# and always includes trailing whitespace or end of line",
"([ ]+|$)",
],
],
},
}
Terminal: Path Hyperlink Timeout (ms)
- Description: Maximum time to search for a path hyperlink. When set to 0, path hyperlinks are disabled.
- Setting:
path_hyperlink_timeout_ms - Default:
1
REPL
- Description: Repl settings.
- Setting:
repl - Default:
"repl": {
// Maximum number of columns to keep in REPL's scrollback buffer.
// Clamped with [20, 512] range.
"max_columns": 128,
// Maximum number of lines to keep in REPL's scrollback buffer.
// Clamped with [4, 256] range.
"max_lines": 32
},
Theme
- Description: The theme setting can be specified in two forms - either as the
name of a theme or as an object containing the
mode,dark, andlightthemes for the Gram UI. - Setting:
theme - Default:
One Dark
Theme Object
- Description: Specify the theme using an object that includes the
mode,dark, andlightthemes. - Setting:
theme - Default:
"theme": {
"mode": "system",
"dark": "One Dark",
"light": "One Light"
},
Mode
- Description: Specify theme mode.
- Setting:
mode - Default:
system
Options
- Set the theme to dark mode
{
"mode": "dark",
}
- Set the theme to light mode
{
"mode": "light",
}
- Set the theme to system mode
{
"mode": "system",
}
Dark
- Description: The name of the dark Gram theme to use for the UI.
- Setting:
dark - Default:
One Dark
Options
Run the theme_selector::Toggle action in the command palette to see a current list of valid themes names.
Light
- Description: The name of the light Gram theme to use for the UI.
- Setting:
light - Default:
One Light
Options
Run the theme_selector::Toggle action in the command palette to see a current list of valid themes names.
Title Bar
- Description: Whether or not to show various elements in the title bar
- Setting:
title_bar - Default:
"title_bar": {
"show": true,
"show_branch_icon": false,
"show_branch_name": true,
"show_project_items": true,
"show_onboarding_banner": true,
"show_user_picture": true,
"show_menus": false
}
Options
show_branch_icon: Whether to show the branch icon beside branch switcher in the titlebarshow_branch_name: Whether to show the branch name button in the titlebarshow_project_items: Whether to show the project host and name in the titlebarshow_onboarding_banner: Whether to show onboarding banners in the titlebarshow_user_picture: Whether to show user picture in the titlebarshow_menus: Whether to show the menus in the titlebar
Vim
- Description: Whether or not to enable vim mode.
- Setting:
vim_mode - Default:
false
When Closing With No Tabs
- Description: Whether the window should be closed when using ‘close active item’ on a window with no tabs
- Setting:
when_closing_with_no_tabs - Default:
"platform_default"
Options
- Use platform default behavior:
{
"when_closing_with_no_tabs": "platform_default",
}
- Always close the window:
{
"when_closing_with_no_tabs": "close_window",
}
- Never close the window:
{
"when_closing_with_no_tabs": "keep_window_open",
}
Project Panel
- Description: Customize project panel
- Setting:
project_panel - Default:
{
"project_panel": {
"button": true,
"default_width": 240,
"dock": "left",
"entry_spacing": "comfortable",
"file_icons": true,
"folder_icons": true,
"git_status": true,
"indent_size": 20,
"auto_reveal_entries": true,
"auto_fold_dirs": true,
"drag_and_drop": true,
"scrollbar": {
"show": null,
},
"sticky_scroll": true,
"show_diagnostics": "all",
"indent_guides": {
"show": "always",
},
"sort_mode": "directories_first",
"hide_root": false,
"hide_hidden": false,
"starts_open": true,
"auto_open": {
"on_create": true,
"on_paste": true,
"on_drop": true,
},
},
}
Dock
- Description: Control the position of the dock
- Setting:
dock - Default:
left
Options
- Default dock position to left
{
"dock": "left",
}
- Default dock position to right
{
"dock": "right",
}
Entry Spacing
- Description: Spacing between worktree entries
- Setting:
entry_spacing - Default:
comfortable
Options
- Comfortable entry spacing
{
"entry_spacing": "comfortable",
}
- Standard entry spacing
{
"entry_spacing": "standard",
}
Git Status
- Description: Indicates newly created and updated files
- Setting:
git_status - Default:
true
Options
- Default enable git status
{
"git_status": true,
}
- Default disable git status
{
"git_status": false,
}
Default Width
- Description: Customize default width taken by project panel
- Setting:
default_width - Default:
240
Options
float values
Auto Reveal Entries
- Description: Whether to reveal it in the project panel automatically, when a corresponding project entry becomes active. Gitignored entries are never auto revealed.
- Setting:
auto_reveal_entries - Default:
true
Options
- Enable auto reveal entries
{
"auto_reveal_entries": true,
}
- Disable auto reveal entries
{
"auto_reveal_entries": false,
}
Auto Fold Dirs
- Description: Whether to fold directories automatically when directory has only one directory inside.
- Setting:
auto_fold_dirs - Default:
true
Options
- Enable auto fold dirs
{
"auto_fold_dirs": true,
}
- Disable auto fold dirs
{
"auto_fold_dirs": false,
}
Indent Size
- Description: Amount of indentation (in pixels) for nested items.
- Setting:
indent_size - Default:
20
Indent Guides: Show
- Description: Whether to show indent guides in the project panel.
- Setting:
indent_guides - Default:
"indent_guides": {
"show": "always"
}
Options
- Show indent guides in the project panel
{
"indent_guides": {
"show": "always",
},
}
- Hide indent guides in the project panel
{
"indent_guides": {
"show": "never",
},
}
Scrollbar: Show
- Description: Whether to show a scrollbar in the project panel. Possible values: null, “auto”, “system”, “always”, “never”. Inherits editor settings when absent, see its description for more details.
- Setting:
scrollbar - Default:
"scrollbar": {
"show": null
}
Options
- Show scrollbar in the project panel
{
"scrollbar": {
"show": "always",
},
}
- Hide scrollbar in the project panel
{
"scrollbar": {
"show": "never",
},
}
Sort Mode
- Description: Sort order for entries in the project panel
- Setting:
sort_mode - Default:
directories_first
Options
- Show directories first, then files
{
"sort_mode": "directories_first",
}
- Show directories, then mod.rs files, then everything else
{
"sort_mode": "smart_sort",
}
3. Mix directories and files together
```json
{
"sort_mode": "mixed",
}
- Show files first, then directories
{
"sort_mode": "files_first",
}
Auto Open
- Description: Control whether files are opened automatically after different creation flows in the project panel.
- Setting:
auto_open - Default:
"auto_open": {
"on_create": true,
"on_paste": true,
"on_drop": true
}
Options
on_create: Whether to automatically open newly created files in the editor.on_paste: Whether to automatically open files after pasting or duplicating them.on_drop: Whether to automatically open files dropped from external sources.should_focus: Whether to focus on files automatically opened.
Debugger
- Description: Configuration for debugger panel and settings
- Setting:
debugger - Default:
{
"debugger": {
"stepping_granularity": "line",
"save_breakpoints": true,
"dock": "bottom",
"button": true,
},
}
See the debugger page for more information about debugging support within Gram.
Git Panel
- Description: Setting to customize the behavior of the git panel.
- Setting:
git_panel - Default:
{
"git_panel": {
"button": true,
"dock": "left",
"default_width": 360,
"status_style": "icon",
"fallback_branch_name": "main",
"sort_by_path": false,
"collapse_untracked_diff": false,
"tree_view": false,
"diff_stats": true,
"scrollbar": {
"show": null,
},
},
}
Options
button: Whether to show the git panel button in the status bardock: Where to dock the git panel. Can beleftorrightdefault_width: Default width of the git panelstatus_style: How to display git status. Can belabel_colororiconfallback_branch_name: What branch name to use ifinit.defaultBranchis not setsort_by_path: Whether to sort entries in the panel by path or by status (the default)collapse_untracked_diff: Whether to collapse untracked files in the diff paneltree_view: Whether to show entries as a tree rather than a flat listdiff_stats: Whether to show the number of added and deleted lines for each entry, and the total for the repositoryscrollbar: When to show the scrollbar in the git panel
Git Hosting Providers
- Description: Register self-hosted GitHub, GitLab, or Bitbucket instances so commit hashes, issue references, and permalinks resolve to the right host.
- Setting:
git_hosting_providers - Default:
[]
Options
Each entry accepts:
provider: One ofgithub,gitlab, orbitbucketname: Display name for the instancebase_url: Base URL, e.g.https://git.example.corp
You can define these in user or project settings; project settings are merged on top of user settings.
{
"git_hosting_providers": [
{
"provider": "github",
"name": "BigCorp GitHub",
"base_url": "https://git.example.corp",
},
],
}
Outline Panel
- Description: Customize outline Panel
- Setting:
outline_panel - Default:
"outline_panel": {
"button": true,
"default_width": 300,
"dock": "left",
"file_icons": true,
"folder_icons": true,
"git_status": true,
"indent_size": 20,
"auto_reveal_entries": true,
"auto_fold_dirs": true,
"indent_guides": {
"show": "always"
},
"scrollbar": {
"show": null
}
}
Calls
- Description: Customize behavior when participating in a call
- Setting:
calls - Default:
"calls": {
// Join calls with the microphone live by default
"mute_on_join": false,
// Share your project when you are the first to join a channel
"share_on_join": false
},
Colorize Brackets
- Description: Whether to use tree-sitter bracket queries to detect and colorize the brackets in the editor (also known as “rainbow brackets”).
- Setting:
colorize_brackets - Default:
false
Options
boolean values
The colors that are used for different indentation levels are defined in the
theme (theme key: accents). They can be customized by using theme overrides.
Unnecessary Code Fade
- Description: How much to fade out unused code.
- Setting:
unnecessary_code_fade - Default:
0.3
Options
Float values between 0.0 and 0.9, where:
0.0means no fading (unused code looks the same as used code)0.9means maximum fading (unused code is very faint but still visible)
Example
{
"unnecessary_code_fade": 0.5,
}
UI Font Family
- Description: The name of the font to use for text in the UI.
- Setting:
ui_font_family - Default:
.GramSans. This currently aliases to IBM Plex.
Options
The name of any font family installed on the system, ".GramSans" to use the
Gram-provided default, or ".SystemUIFont" to use the system’s default UI font
(on macOS and Windows).
UI Font Features
- Description: The OpenType features to enable for text in the UI.
- Setting:
ui_font_features - Default:
"ui_font_features": {
"calt": false
}
- Platform: macOS and Windows.
Options
Gram supports all OpenType features that can be enabled or disabled for a given UI font, as well as setting values for font features.
For example, to disable font ligatures, add the following to your settings:
{
"ui_font_features": {
"calt": false,
},
}
You can also set other OpenType features, like setting cv01 to 7:
{
"ui_font_features": {
"cv01": 7,
},
}
UI Font Fallbacks
- Description: The font fallbacks to use for text in the UI.
- Setting:
ui_font_fallbacks - Default:
null - Platform: macOS and Windows.
Options
For example, to use Nerd Font as a fallback, add the following to your
settings:
{
"ui_font_fallbacks": ["Nerd Font"],
}
UI Font Size
- Description: The default font size for text in the UI.
- Setting:
ui_font_size - Default:
16
Options
integer values from 6 to 100 pixels (inclusive)
UI Font Weight
- Description: The default font weight for text in the UI.
- Setting:
ui_font_weight - Default:
400
Options
integer values between 100 and 900
Client Side Decoration Rounding
- Description: Defines window border radius for platforms that use client side decorations.
- Setting:
client_side_decoration_rounding - Default:
10.0
Client Side Decoration Shadow
- Description: Defines window shadow size for platforms that use client side decorations.
- Setting:
client_side_decoration_shadow - Default:
10.0
Settings Profiles
- Description: Configure any number of settings profiles that are temporarily
applied on top of your existing user settings when selected from
settings profile selector: toggle. - Setting:
profiles - Default:
{}
In your settings.jsonc file, add the profiles object. Each key within this
object is the name of a settings profile, and each value is an object that can
include any of Gram’s settings.
Example:
"profiles": {
"Presenting (Dark)": {
"buffer_font_size": 18.0,
"theme": "One Dark",
"ui_font_size": 18.0
},
"Presenting (Light)": {
"buffer_font_size": 18.0,
"theme": "One Light",
"ui_font_size": 18.0
},
"Writing": {
"buffer_font_size": 15.0,
"theme": "Catppuccin Frappé - No Italics",
"ui_font_size": 15.0,
"tab_bar": { "show": false },
"toolbar": { "breadcrumbs": false }
}
}
To preview and enable a settings profile, open the command palette via command_palette::Toggle and search for settings profile selector: toggle.
An example configuration:
// ~/.config/gram/settings.jsonc
{
"theme": "cave-light",
"tab_size": 2,
"preferred_line_length": 80,
"soft_wrap": "none",
"buffer_font_size": 18,
"buffer_font_family": ".GramMono",
"autosave": "on_focus_change",
"format_on_save": "off",
"vim_mode": false,
"projects_online_by_default": true,
"terminal": {
"font_family": "FiraCode Nerd Font Mono",
"blinking": "off",
},
"languages": {
"C": {
"format_on_save": "on",
"formatter": "language_server",
"preferred_line_length": 64,
"soft_wrap": "preferred_line_length",
},
},
}
Configuring supported languages
The language support is built on two main technologies:
- Tree-sitter: This handles syntax highlighting and structure-based features like the outline panel.
- Language Server Protocol (LSP): This provides semantic features such as code completion and diagnostics.
These components work together to provide language capabilities.
Topics
- Language-specific settings
- File associations
- Working with language servers
- Formatting and linting configuration
- Customizing syntax highlighting and themes
- Advanced language features
See the list of Supported Languages for details on specific configurations. To add support for additional languages, see the guide on how to create new Language Extensions.
Language-specific Settings
It is possible to override global settings for individual languages. These
custom configurations are defined in the settings.jsonc file under the
languages key.
Here’s an example of language-specific settings:
"languages": {
"Python": {
"tab_size": 4,
"formatter": "language_server",
"format_on_save": "on"
},
"JavaScript": {
"tab_size": 2,
"formatter": {
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
}
}
Some of the settings that can be customized include:
tab_size: The number of spaces for each indentation levelformatter: The tool used for code formattingformat_on_save: Whether to automatically format code when savingenable_language_server: Toggle language server supporthard_tabs: Use tabs instead of spaces for indentationpreferred_line_length: The recommended maximum line lengthsoft_wrap: How to wrap long lines of codeshow_completions_on_input: Whether or not to show completions as you typeshow_completion_documentation: Whether to display inline and alongside documentation for items in the completions menucolorize_brackets: Whether to use tree-sitter bracket queries to detect and colorize the brackets in the editor (also known as “rainbow brackets”)
File Associations
Gram automatically detects file types based on their extensions, but you can customize these associations.
To set up custom file associations, use the
file_types setting in your
settings.jsonc:
"file_types": {
"C++": ["c"],
"TOML": ["MyLockFile"],
"Dockerfile": ["Dockerfile*"]
}
This configuration tells Gram to:
- Treat
.cfiles as C++ instead of C - Recognize files named “MyLockFile” as TOML
- Apply Dockerfile syntax to any file starting with “Dockerfile”
You can use glob patterns for more flexible matching, allowing you to handle complex naming conventions in your projects.
Working with Language Servers
Language servers provide capabilities like auto-completion, go-to-definition, and real-time error checking.
What are Language Servers?
Language servers implement the Language Server Protocol (LSP), which standardizes communication between the editor and language-specific tools. This allows editors to support advanced features for multiple programming languages without implementing each feature separately.
Some key features provided by language servers include:
- Code completion
- Error checking and diagnostics
- Code navigation (go to definition, find references)
- Code actions (Rename, extract method)
- Hover information
- Workspace symbol search
Managing Language Servers
Gram simplifies language server management for users:
-
Suggested extensions: When you open a file with a known file type, you may be prompted to install the associated extension. For the installation to work, you will need to have rustup configured correctly.
-
Storage Location:
- macOS:
~/Library/Application Support/Gram/languages - Linux:
$XDG_DATA_HOME/gram/languages,$FLATPAK_XDG_DATA_HOME/gram/languages, or$HOME/.local/share/gram/languages
- macOS:
Choosing Language Servers
Some languages offer multiple language server options. You might have multiple extensions installed that bundle language servers targeting the same language, potentially leading to overlapping capabilities. Gram allows you to prioritize which language servers are used and in what order.
Specify preferences using the language_servers setting:
"languages": {
"PHP": {
"language_servers": ["intelephense", "!phpactor", "!phptools", "..."]
}
}
In this example:
intelephenseis set as the primary language serverphpactoris disabled (note the!prefix)...expands to the rest of the language servers that are registered for PHP
Toolchains
Some language servers need to be configured with a current “toolchain”, which is an installation of a specific version of a programming language compiler or/and interpreter, which can possibly include a full set of dependencies of a project.
An example of what Gram considers a toolchain is a virtual environment in Python.
Not all languages in Gram support toolchain discovery and selection, but for
those that do, you can specify the toolchain from a toolchain picker (via
toolchain::Select). To learn more about toolchains, see
toolchains.
Configuring Language Servers
Custom configuration options for language servers are configured using the lsp
section of settings.jsonc:
"lsp": {
"rust-analyzer": {
"initialization_options": {
"check": {
"command": "clippy"
}
}
}
}
This example configures the Rust Analyzer to use Clippy for additional linting when saving files.
Nested objects
When configuring language server options it’s important to use nested objects rather than dot-delimited strings. This is particularly relevant when working with more complex configurations. Let’s look at a real-world example using the TypeScript language server:
Suppose you want to configure the following settings for TypeScript:
- Enable strict null checks
- Set the target ECMAScript version to ES2020
Here’s how you would structure these settings in settings.jsonc:
"lsp": {
"typescript-language-server": {
"initialization_options": {
// These are not supported (VSCode dotted style):
// "preferences.strictNullChecks": true,
// "preferences.target": "ES2020"
//
// These is correct (nested notation):
"preferences": {
"strictNullChecks": true,
"target": "ES2020"
},
}
}
}
Possible configuration options
Depending on how a particular language server is implemented, they may depend on initialization options specified in the LSP.
These options are sent during language server startup and require the server to be restarted for changes to be applied.
For example, rust-analyzer and clangd are configured this way.
"lsp": {
"rust-analyzer": {
"initialization_options": {
"checkOnSave": false
}
}
}
Most language servers use settings that can be updated without restarting.
"lsp": {
"tailwindcss-language-server": {
"settings": {
"tailwindCSS": {
"emmetCompletions": true,
},
}
}
}
Some language servers allow configuring how the language server binary is launched. Language servers are automatically downloaded or launched if found in your path.
TODO: This should be opt in.
If you wish to specify an explicit alternate binary you can specify that in settings:
"lsp": {
"rust-analyzer": {
"binary": {
// Whether to fetch the binary from the internet, or attempt to find locally.
"ignore_system_version": false,
"path": "/path/to/langserver/bin",
"arguments": ["--option", "value"],
"env": {
"FOO": "BAR"
}
}
}
}
Enabling or Disabling Language Servers
You can toggle language server support globally or per-language:
"languages": {
"Markdown": {
"enable_language_server": false
}
}
This disables the language server for Markdown files, which can be useful for
performance in large documentation projects. You can configure this globally in
your ~/.config/gram/settings.jsonc or inside a .gram/settings.jsonc in your
project directory.
Formatting and Linting
Configuring Formatters
Gram supports both built-in and external formatters. See
formatter docs for more. Configure
formatters globally or per-language in settings.jsonc:
"languages": {
"JavaScript": {
"formatter": {
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
},
"format_on_save": "on"
},
"Rust": {
"formatter": "language_server",
"format_on_save": "on"
}
}
This example uses Prettier for JavaScript and the language server’s formatter for Rust, both set to format on save.
To disable formatting for a specific language:
"languages": {
"Markdown": {
"format_on_save": "off"
}
}
Setting Up Linters
Linting is typically handled by language servers.
Many language servers allow you to configure linting rules:
"lsp": {
"eslint": {
"settings": {
"codeActionOnSave": {
"rules": ["import/order"]
}
}
}
}
This configuration sets up ESLint to organize imports on save for JavaScript files.
To run linter fixes automatically on save:
"languages": {
"JavaScript": {
"formatter": {
"code_action": "source.fixAll.eslint"
}
}
}
Integrating Formatting and Linting
Here’s an example that uses Prettier for formatting and ESLint for linting JavaScript files automatically on save:
"languages": {
"JavaScript": {
"formatter": [
{
"code_action": "source.fixAll.eslint"
},
{
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
],
"format_on_save": "on"
}
}
Troubleshooting
If you encounter issues with formatting or linting:
- Check the editor log file for error messages (Use the command palette:
gram: open log) - Ensure external tools (formatters, linters) are correctly installed and in your PATH.
- Verify configurations in both Gram settings and language-specific config
files (e.g.,
.eslintrc,.prettierrc)
Syntax Highlighting and Themes
Customizing Syntax Highlighting
Gram uses Tree-sitter grammars for syntax highlighting. Override the default
highlighting using the theme_overrides setting.
This example makes comments italic and changes the color of strings:
"theme_overrides": {
"One Dark": {
"syntax": {
"comment": {
"font_style": "italic"
},
"string": {
"color": "#00AA00"
}
}
}
}
Selecting and Customizing Themes
To change the editor theme:
- Use the theme selector (theme_selector::Toggle)
- Or set it in
settings.jsonc:
"theme": {
"mode": "dark",
"dark": "One Dark",
"light": "GitHub Light"
}
Create custom themes by creating a JSON file in ~/.config/gram/themes/. Gram
will automatically detect and make available any themes in this directory.
Using Theme Extensions
Gram supports theme extensions. Find the URL for the theme you want to install and install it from the Extensions panel (gram::Extensions).
To create your own theme extension, refer to the Developing Theme Extensions guide.
Using Language Server Features
Inlay Hints
Inlay hints provide additional information inline in code, such as parameter
names or inferred types. Configure inlay hints in settings.jsonc:
"inlay_hints": {
"enabled": true,
"show_type_hints": true,
"show_parameter_hints": true,
"show_other_hints": true
}
For language-specific inlay hint settings, refer to the documentation for each language.
Code Actions
Code actions provide quick fixes and refactoring options. Access code actions
using the editor: Toggle Code Actions command or by clicking the lightbulb
icon that appears next to the cursor when actions are available.
Go To Definition and References
Use these commands to navigate the codebase:
editor: Go to Definition(f12|f12)editor: Go to Type Definition(cmd-f12|ctrl-f12)editor: Find All References(shift-f12|shift-f12)
Rename Symbol
To rename a symbol across a project:
- Place the cursor on the symbol
- Use the
editor: Rename Symbolcommand (f2|f2) - Enter the new name and press Enter
These features depend on the capabilities of the language server for each language.
When renaming a symbol that spans multiple files, Gram will open a preview in a multibuffer. Here you can review all the changes before applying them. To confirm the rename, simply save the multibuffer. If you decide not to proceed with the rename, you can undo the changes or close the multibuffer without saving.
Hover Information
Use the editor: Hover command to display information about the symbol under
the cursor. This often includes type information, documentation, and links to
relevant resources.
Workspace Symbol Search
The workspace: Open Symbol command allows you to search for symbols
(functions, classes, variables) across your entire project. This is useful for
quickly navigating large codebases.
Code Completion
Gram provides code completion suggestions as you type. You can manually trigger
completion with the editor: Show Completions command. Use tab|tab
or enter|enter to accept suggestions.
Diagnostics
Language servers provide real-time diagnostics (errors, warnings, hints) as you
code. View all diagnostics for your project using the diagnostics: Toggle
command.
Debugger
Gram uses the Debug Adapter Protocol (DAP) to provide debugging functionality across multiple programming languages. DAP is a standardized protocol that defines how debuggers, editors, and IDEs communicate with each other. It allows Gram to support various debuggers without needing to implement language-specific debugging logic. Gram implements the client side of the protocol, and various debug adapters implement the server side.
This protocol enables features like setting breakpoints, stepping through code, inspecting variables, and more, in a consistent manner across different programming languages and runtime environments.
Supported Languages
To debug code written in a specific language, Gram needs to find a debug adapter for that language. Some debug adapters are provided by Gram without additional setup, and some are provided by language extensions. The following languages currently have debug adapters available:
- C (built-in)
- C++ (built-in)
- Go (built-in)
- Java (provided by extension)
- JavaScript (built-in)
- PHP (built-in)
- Python (built-in)
- Ruby (provided by extension)
- Rust (built-in)
- Swift (provided by extension)
- TypeScript (built-in)
If your language isn’t listed, you can contribute by adding a debug adapter for it.
Follow those links for language- and adapter-specific information and examples, or read on for more about Gram’s general debugging features that apply to all adapters.
Getting Started
For most languages, the fastest way to get started is to run debugger::Start (debugger::Start). This opens the new process modal,
which shows you a contextual list of preconfigured debug tasks for the current
project. Debug tasks are created from tests, entry points (like a main
function), and from other sources — consult the documentation for your language
for full information about what’s supported.
You can open the same modal by clicking the “plus” button at the top right of the debug panel.
For languages that don’t provide preconfigured debug tasks (this includes C,
C++, and some extension-supported languages), you can define debug
configurations in the .gram/debug.jsonc file in your project root. This file
should be an array of configuration objects:
[
{
"adapter": "CodeLLDB",
"label": "First configuration"
// ...
},
{
"adapter": "Debugpy",
"label": "Second configuration"
// ...
}
]
Check the documentation for your language for example configurations covering
typical use-cases. Once you’ve added configurations to .gram/debug.jsonc,
they’ll appear in the list in the new process modal.
Gram will also load debug configurations from .vscode/launch.json, and show
them in the new process modal if no configurations are found in
.gram/debug.jsonc.
Global debug configurations
If you run the same launch profiles across multiple projects, you can store them
once in your user configuration. Invoke gram::OpenDebugTasks from the
command palette to open the global debug.jsonc file; Gram creates it next to
your user settings.jsonc and keeps it in sync with the debugger UI. The file
lives at:
- macOS:
~/Library/Application Support/Gram/debug.jsonc - Linux/BSD:
$XDG_CONFIG_HOME/gram/debug.jsonc(falls back to~/.config/gram/debug.jsonc) - Windows:
%APPDATA%\Gram\debug.jsonc
Populate this file with the same array of objects you would place in
.gram/debug.jsonc. Any scenarios defined there are merged into every
workspace, so your favorite launch presets appear automatically in the “New
Debug Session” dialog.
Launching & Attaching
Gram debugger offers two ways to debug your program; you can either launch a new instance of your program or attach to an existing process. Which one you choose depends on what you are trying to achieve.
When launching a new instance, Gram (and the underlying debug adapter) can often do a better job at picking up the debug information compared to attaching to an existing process, since it controls the lifetime of a whole program. Running unit tests or a debug build of your application is a good use case for launching.
Compared to launching, attaching to an existing process might seem inferior, but that’s far from truth; there are cases where you cannot afford to restart your program, because for example, the bug is not reproducible outside of a production environment or some other circumstances.
Configuration
Gram requires the adapter and label fields for all debug tasks. In addition,
Gram will use the build field to run any necessary setup steps before the
debugger starts (see below), and can accept a tcp_connection
field to connect to an existing process.
All other fields are provided by the debug adapter and can contain
task variables. Most adapters support request,
program, and cwd:
[
{
// The label for the debug configuration and used to identify the debug session inside the debug panel & new process modal
"label": "Example Start debugger config",
// The debug adapter that Gram should use to debug the program
"adapter": "Example adapter name",
// Request:
// - launch: Gram will launch the program if specified, or show a debug terminal with the right configuration
// - attach: Gram will attach to a running program to debug it, or when the process_id is not specified, will show a process picker (only supported for node currently)
"request": "launch",
// The program to debug. This field supports path resolution with ~ or . symbols.
"program": "path_to_program",
// cwd: defaults to the current working directory of your project ($GRAM_WORKTREE_ROOT)
"cwd": "$GRAM_WORKTREE_ROOT"
}
]
Check your debug adapter’s documentation for more information on the fields it supports.
Build tasks
Gram allows embedding a Gram task in the build field that is run before the
debugger starts. This is useful for setting up the environment or running any
necessary setup steps before the debugger starts.
[
{
"label": "Build Binary",
"adapter": "CodeLLDB",
"program": "path_to_program",
"request": "launch",
"build": {
"command": "make",
"args": ["build", "-j8"]
}
}
]
Build tasks can also refer to the existing tasks by unsubstituted label:
[
{
"label": "Build Binary",
"adapter": "CodeLLDB",
"program": "path_to_program",
"request": "launch",
"build": "my build task" // Or "my build task for $GRAM_FILE"
}
]
Automatic scenario creation
Given a Gram task, Gram can automatically create a scenario for you. Automatic scenario creation also powers our scenario creation from gutter. Automatic scenario creation is currently supported for Rust, Go, Python, JavaScript, and TypeScript.
Breakpoints
To set a breakpoint, simply click next to the line number in the editor gutter. Breakpoints can be tweaked depending on your needs; to access additional options of a given breakpoint, right-click on the breakpoint icon in the gutter and select the desired option. At present, you can:
- Add a log to a breakpoint, which will output a log message whenever that breakpoint is hit.
- Make the breakpoint conditional, which will only stop at the breakpoint when the condition is met. The syntax for conditions is adapter-specific.
- Add a hit count to a breakpoint, which will only stop at the breakpoint after it’s hit a certain number of times.
- Disable a breakpoint, which will prevent it from being hit while leaving it visible in the gutter.
Some debug adapters (e.g. CodeLLDB and JavaScript) will also verify whether your breakpoints can be hit; breakpoints that cannot be hit are surfaced more prominently in the UI.
All breakpoints enabled for a given project are also listed in “Breakpoints” item in your debugging session UI. From “Breakpoints” item in your UI you can also manage exception breakpoints. The debug adapter will then stop whenever an exception of a given kind occurs. Which exception types are supported depends on the debug adapter.
Settings
The settings for the debugger are grouped under the debugger key in
settings.jsonc:
dock: Determines the position of the debug panel in the UI.stepping_granularity: Determines the stepping granularity.save_breakpoints: Whether the breakpoints should be reused across Gram sessions.button: Whether to show the debug button in the status bar.timeout: Time in milliseconds until timeout error when connecting to a TCP debug adapter.log_dap_communications: Whether to log messages between active debug adapters and Gram.format_dap_log_messages: Whether to format DAP messages when adding them to the debug adapter logger.
Dock
- Description: The position of the debug panel in the UI.
- Default:
bottom - Setting: debugger.dock
Options
left- The debug panel will be docked to the left side of the UI.right- The debug panel will be docked to the right side of the UI.bottom- The debug panel will be docked to the bottom of the UI.
"debugger": {
"dock": "bottom"
},
Stepping granularity
- Description: The Step granularity that the debugger will use
- Default:
line - Setting:
debugger.stepping_granularity
Options
- Statement - The step should allow the program to run until the current statement has finished executing. The meaning of a statement is determined by the adapter and it may be considered equivalent to a line. For example ‘for(int i = 0; i < 10; i++)’ could be considered to have 3 statements ‘int i = 0’, ‘i < 10’, and ‘i++’.
{
"debugger": {
"stepping_granularity": "statement",
},
}
- Line - The step should allow the program to run until the current source line has executed.
{
"debugger": {
"stepping_granularity": "line",
},
}
- Instruction - The step should allow one instruction to execute (e.g. one x86 instruction).
{
"debugger": {
"stepping_granularity": "instruction",
},
}
Save Breakpoints
- Description: Whether the breakpoints should be saved across Gram sessions.
- Default:
true - Setting:
debugger.save_breakpoints
Options
boolean values
{
"debugger": {
"save_breakpoints": true,
},
}
Button
- Description: Whether the button should be displayed in the debugger toolbar.
- Default:
true - Setting:
debugger.show_button
Options
boolean values
{
"debugger": {
"show_button": true,
},
}
Timeout
- Description: Time in milliseconds until timeout error when connecting to a TCP debug adapter.
- Default:
2000 - Setting:
debugger.timeout
Options
integer values
{
"debugger": {
"timeout": 3000,
},
}
Inline Values
- Description: Whether to enable editor inlay hints showing the values of variables in your code during debugging sessions.
- Default:
true - Setting:
inlay_hints.show_value_hints
Options
{
"inlay_hints": {
"show_value_hints": false,
},
}
Inline value hints can also be toggled from the Editor Controls menu in the editor toolbar.
Log Dap Communications
- Description: Whether to log messages between active debug adapters and Gram. (Used for DAP development)
- Default: false
- Setting: debugger.log_dap_communications
Options
boolean values
{
"debugger": {
"log_dap_communications": true,
},
}
Format Dap Log Messages
- Description: Whether to format DAP messages when adding them to the debug adapter logger. (Used for DAP development)
- Default: false
- Setting: debugger.format_dap_log_messages
Options
boolean values
{
"debugger": {
"format_dap_log_messages": true,
},
}
Customizing Debug Adapters
- Description: Custom program path and arguments to override how Gram launches a specific debug adapter.
- Default: Adapter-specific
- Setting:
dap.$ADAPTER.binaryanddap.$ADAPTER.args
You can pass binary, args, or both. binary should be a path to a debug
adapter (like lldb-dap) not a debugger (like lldb itself). The args
setting overrides any arguments that Gram would otherwise pass to the adapter.
{
"dap": {
"CodeLLDB": {
"binary": "/Users/name/bin/lldb-dap",
"args": ["--wait-for-debugger"],
"env": {"KEY": "whatever"},
"ignore_system_version": false,
"allow_binary_download": false,
"enable_auto_updates": false,
},
},
}
Theme
The Debugger supports the following theme options:
debugger.accent: Color used to accent breakpoint & breakpoint-related symbolseditor.debugger_active_line.background: Background color of active debug line
Troubleshooting
If you’re running into problems with the debugger, there are some features you can use to gather more information about the problem:
- When you have a session running in the debug panel, you can run the dev::CopyDebugAdapterArguments action to copy a JSON blob to the clipboard that describes how Gram initialized the session. This is especially useful when the session failed to start, and is great context to add if you open a GitHub issue.
- You can also use the dev::OpenDebugAdapterLogs action to see a trace of all of Gram’s communications with debug adapters during the most recent debug sessions.
Diagnostics
Gram gets its diagnostics from the language servers and supports both push and pull variants of the LSP which should make it compatible with all existing language servers.
Regular diagnostics
By default, all diagnostics are displayed as underlined text in the editor and the scrollbar.
Editor diagnostics can be filtered using the editor setting:
"diagnostics_max_severity": null
Possible values: "off", "error", "warning", "info", "hint", null
(default, all diagnostics)
The scrollbar diagnostics are configured using
"scrollbar": {
"diagnostics": "all",
}
Possible values: "none", "error", "warning", "information", "all"
(default)
The diagnostics can be hovered to display a tooltip with full, rendered
diagnostic message. Or, editor::GoToDiagnostic and
editor::GoToPreviousDiagnostic could be used to navigate between diagnostics
in the editor, showing a popover for the currently active diagnostic.
Inline diagnostics (Error lens)
It’s possible to display diagnostics as a lens to the right of the code. This is disabled by default, but can either be temporarily turned on (or off) using the editor menu, or permanently, using the
"diagnostics": {
"inline": {
"enabled": true,
"max_severity": null, // same values as the `diagnostics_max_severity` from the editor settings
}
}
Other UI places
Project Panel
The project panel can have its entries coloured based on the severity of the diagnostics in the file:
"project_panel": {
"show_diagnostics": "all",
}
Possible values: "off", "errors", "all" (default)
Editor tabs
Editor tabs can be coloured in the same way as project panel entries:
"tabs": {
"show_diagnostics": "off",
}
Possible values: "off" (default), "errors", "all"
Environment Variables
Multiple features in Gram are affected by environment variables:
- Tasks
- Built-in terminal
- Look-up of language servers
- Language servers
In order to make the best use of these features, it’s helpful to understand where Gram gets its environment variables from and how they’re used.
Where does Gram get its environment variables from?
How Gram was started — whether it’s icon was clicked in the macOS Dock or in a
Linux window manager, or whether it was started via the CLI gram that comes
with Gram — influences which environment variables Gram can use.
Launched from the CLI
If Gram is opened via the CLI (gram), it will inherit the environment
variables from the surrounding shell session.
That means if you do
$ export MY_ENV_VAR=hello
$ zed .
the environment variable MY_ENV_VAR is now available inside Gram. For example,
in the built-in terminal.
The CLI gram will always pass along its environment to Gram, regardless of
whether a Gram instance was previously running or not.
Launched via window manager, Dock, or launcher
When Gram has been launched via the macOS Dock, or a GNOME or KDE icon on Linux, or an application launcher like Alfred or Raycast, it has no surrounding shell environment from which to inherit its environment variables.
In order to still have a useful environment, Gram spawns a login shell in the user’s home directory and gets its environment. This environment is then set on the Gram process. That means all Gram windows and projects will inherit that home directory environment.
Since that can lead to problems for users that require different environment
variables for a project (because they use direnv, or asdf, or mise, … in
that project), when opening project, Gram spawns another login shell. This time
in the project’s directory. The environment from that login shell is not set
on the process (because that would mean opening a new project changes the
environment for all Gram windows). Instead, the environment is stored and passed
along when running tasks, opening terminals, or spawning language servers.
Where and how are environment variables used?
There are two sets of environment variables:
- Environment variables of the Gram process
- Environment variables stored per project
The variables from (1) are always used, since they are stored on the process itself and every spawned process (tasks, terminals, language servers, …) will inherit them by default.
The variables from (2) are used explicitly, depending on the feature.
Tasks
Tasks are spawned with a combined environment. In order of precedence (low to high, with the last overwriting the first):
- the Gram process environment
- if the project was opened from the CLI: the CLI environment
- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project’s root folder
- optional, explicitly configured environment in settings
Built-in terminal
Built-in terminals, like tasks, are spawned with an combined environment. In order of precedence (low to high):
- the Gram process environment
- if the project was opened from the CLI: the CLI environment
- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project’s root folder
- optional, explicitly configured environment in settings
Look-up of language servers
For some languages the language server adapters lookup the binary in the user’s
$PATH. Examples:
- Go
- Zig
- Rust (if configured to do so)
- C
- TypeScript
For this look-up, Gram uses the following the environment:
- if the project was opened from the CLI: the CLI environment
- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project’s root folder
Language servers
After looking up a language server, Gram starts them.
These language server processes always inherit Gram’s process environment. But, depending on the language server look-up, additional environment variables might be set or overwrite the process environment.
- If the language server was found in the project environment’s
$PATH, then the project environment’s is passed along to the language server process. Where the project environment comes from depends on how the project was opened, via CLI or not. See previous point on look-up of language servers. - If the language servers was not found in the project environment, Gram tries to install it globally and start it globally. In that case, the process will inherit Gram’s process environment, and — if the project was opened via ClI — from the CLI.
Git
There is integrated support for working with git and git forges in the code editor.
Here’s an overview of all currently supported features:
- Committing
- Staging, pushing, pulling, and fetching
- Project Diff: A multibuffer view of all changes
- Diff indicators in buffers and editor scrollbars
- Inline diff toggle and reverts in the editor for unstaged changes
- Git status in the Project Panel
- Branch creating and switching
- Git blame viewing
- Git stash pop, apply, drop and view
Git Panel
The Git Panel provides a birds-eye view of the state of the working tree and staging area.
Open the Git Panel using git_panel::ToggleFocus, or by clicking the Git icon in the status bar.
The Git Panel shows the state of the project: Which repository and branch are active, what files have changed and the current staging state of each file.
Gram monitors the project repository, so any changes made within or outside the editor are instantly visible in the git panel.
Configuration
Configure how the editor hard wraps commit messages with the
preferred-line-length setting of the “Git Commit” language. The default is
72, but it can be set to any number of characters, 0 or more.
The Git Panel also allows configuring the soft_wrap setting to adjust how
commit messages display while typing them in the Git Panel. The default setting
is editor_width, however, none, preferred_line_length, and bounded are
also options.
To open Git diffs side by side, enable git.split_diff. The setting
defaults to false.
Example
"languages": {
"Git Commit": {
"soft_wrap": "editor_width",
"preferred_line_length": 72
},
}
Project Diff
See all of the current changes by opening the Project Diff (git::Diff), accessible via the git::Diff action in the Command Palette or the Git Panel.
All of the changes displayed in the Project Diff behave the same as any other multibuffer: they are all editable excerpts of files.
Side-by-side diffs
When git.split_diff is enabled, project, commit and file diffs open with
the old version on the left and the current version on the right. Matching rows
are aligned across both panes; inserted and deleted rows are shown with hatched
padding on the side that has no corresponding text. Scrolling and folds stay in
sync between the panes.
The view can be toggled for the active diff with the editor::SplitDiff and
editor::UnsplitDiff actions. The current version remains the editable side,
so staging, reverting and saving continue to work as in the regular diff view.
For example, to enable the view by default, add this to settings.json:
{
"git": {
"split_diff": true
}
}
Stage or unstage each hunk as well as a whole file by hitting the buttons on the tab bar or their corresponding keybindings.
Fetch, push, and pull
Fetch, push, or pull from the Git repository in Gram via the buttons available on the Git Panel or via the Command Palette actions: git::Fetch, git::Push, and git::Pull.
Staging Workflow
Gram has two primary staging workflows, using either the Project Diff or the panel directly.
Using the Project Diff
In the Project Diff view it’s possible to focus on each hunk and stage them individually by clicking on the tab bar buttons or via the keybindings git::StageAndNext (git::StageAndNext).
Similarly, stage all hunks at the same time with the git::StageAll (git::StageAll) keybinding and then immediately commit with git::Commit (git::Commit).
Using the Git Panel
From the panel, simply type a commit message and hit the commit button, or
git::Commit. This will automatically stage all tracked files
(indicated by a [·] in the entry’s checkbox) and commit them.
Entries can be staged using each individual entry’s checkbox. All changes can be staged using the button at the top of the panel, or git::StageAll.
Committing
There are two ways to commit changes from within the editor:
- Using the button at the bottom of the Git Panel. Hitting git::Commit immediately commits all of your staged changes.
- Invoke the action git::ExpandCommitEditor or use the keyboard shortcut git::ExpandCommitEditor while focused on the Git Panel commit text area.
Undo a commit
As soon as you commit in Gram, in the Git Panel, you’ll see a bar right under the commit textarea which will show the most recently submitted commit.
In there, you can use the “Uncommit” button, which will run a command similar to
git reset HEADˆ --soft.
Commit Line Length
By default, the commit line length is set to 72. It can be configured in
settings.json.
See preferred-line-length in the Configuration section.
Stashing
Git stash allows you to temporarily save your uncommitted changes and return to a clean working directory. This is useful to quickly switch branches or pull updates without committing incomplete work.
Creating Stashes
To stash all current changes, use the git::StashAll action. This will save both staged and unstaged changes to a new stash entry and set up a clean working directory.
Managing Stashes
Gram provides a comprehensive stash picker accessible via git::ViewStash. From the stash picker, you can:
- View stash list: Browse all your saved stashes with their descriptions and timestamps
- Open diffs: See exactly what changes are stored in each stash
- Apply stashes: Apply stash changes to your working directory while keeping the stash entry
- Pop stashes: Apply stash changes and remove the stash entry from the list
- Drop stashes: Delete unwanted stash entries without applying them
Quick Stash Operations
For faster workflows, Gram provides direct actions to work with the most recent stash:
- Apply latest stash: Use git::StashApply to apply the most recent stash without removing it
- Pop latest stash: Use git::StashPop to apply and remove the most recent stash
Stash Diff View
When viewing a specific stash in the diff view, you have additional options available through the interface:
- Apply the current stash to your working directory
- Pop the current stash (apply and remove)
- Remove the stash without applying changes
To open the stash diff view, select a stash from the stash picker and use the stash_picker::ShowStashItem (stash_picker::ShowStashItem) keybinding.
Git Integrations
Gram integrates with popular Git hosting services to ensure that Git commit hashes and references to Issues, Pull Requests, and Merge Requests become clickable links.
Gram currently supports links to the hosted versions of GitHub, GitLab, Bitbucket, Sourcehut and Codeberg.
For self-hosted GitHub, GitLab, or Bitbucket instances, add them to the
git_hosting_providers setting so commit hashes and permalinks resolve to your
domain:
{
"git_hosting_providers": [
{
"provider": "gitlab",
"name": "Corp GitLab",
"base_url": "https://git.example.corp",
},
],
}
Copy Permalink
Create a permanent link to a code snippet on your Git hosting service.
These links are useful for sharing a specific line or range of lines in a file
at a specific commit. Trigger this action via the Command Palette (search for
permalink), by creating a
custom key bindings to the
editor::CopyPermalinkToLine or editor::OpenPermalinkToLine actions or by
simply right clicking and selecting Copy Permalink with line(s) selected in
your editor.
Diff Hunk Keyboard Shortcuts
When viewing files with changes, Gram displays diff hunks that can be expanded or collapsed for detailed review:
- Expand all diff hunks: editor::ExpandAllDiffHunks ( editor::ExpandAllDiffHunks)
- Collapse all diff hunks: Press
Escape(bound to editor::Cancel) - Toggle selected diff hunks: editor::ToggleSelectedDiffHunks (editor::ToggleSelectedDiffHunks)
- Navigate between hunks: editor::GoToHunk and editor::GoToPreviousHunk
Tip: The
Escapekey is the quickest way to collapse all expanded diff hunks and return to an overview of your changes.
Action Reference
| Action | Keybinding |
|---|---|
| git::Add | git::Add |
| git::StageAll | git::StageAll |
| git::UnstageAll | git::UnstageAll |
| git::ToggleStaged | git::ToggleStaged |
| git::StageAndNext | git::StageAndNext |
| git::UnstageAndNext | git::UnstageAndNext |
| git::Commit | git::Commit |
| git::ExpandCommitEditor | git::ExpandCommitEditor |
| git::Push | git::Push |
| git::ForcePush | git::ForcePush |
| git::Pull | git::Pull |
| git::PullRebase | git::PullRebase |
| git::Fetch | git::Fetch |
| git::Diff | git::Diff |
| git::Restore | git::Restore |
| git::RestoreFile | git::RestoreFile |
| git::Branch | git::Branch |
| git::Switch | git::Switch |
| git::CheckoutBranch | git::CheckoutBranch |
| git::Blame | git::Blame |
| git::StashAll | git::StashAll |
| git::StashPop | git::StashPop |
| git::StashApply | git::StashApply |
| git::ViewStash | git::ViewStash |
| editor::ToggleGitBlameInline | editor::ToggleGitBlameInline |
| editor::ExpandAllDiffHunks | editor::ExpandAllDiffHunks |
| editor::ToggleSelectedDiffHunks | editor::ToggleSelectedDiffHunks |
Not all actions have default keybindings, but can be bound by customizing your keymap.
Git CLI Configuration
If you would like to also use Gram for your
git commit message editor
when committing from the command line you can use gram --wait:
git config --global core.editor "gram --wait"
Or add the following to your shell environment (in ~/.zshrc, ~/.bashrc,
etc):
export GIT_EDITOR="gram --wait"
Globs
Glob patterns is the formal
name for Unix shell-style path matching wildcards like *.md or docs/**/*.md
supported by sh, bash, zsh, etc. A glob is similar but distinct from a
regex (regular expression).
In Gram these are commonly used when matching filenames.
Glob Flavor
Gram uses two different rust crates for matching glob patterns:
- ignore crate for matching glob
patterns stored in
.gitignorefiles - glob crate for matching file paths in Gram
While simple expressions are portable across environments (e.g. running
ls *.py or *.tmp in a gitignore) there is significant divergence in the
support for and syntax of more advanced features varies (character classes,
exclusions, **, etc) across implementations. The rest of this document will be
describing globs as supported in Gram via the glob crate implementation. See
References below for documentation links for glob pattern syntax
for .gitignore, shells and other programming languages.
The glob crate is implemented entirely in rust and does not rely on the glob
/ fnmatch interfaces provided by libc. This means that globs in Gram should
behave similarly across platforms.
Introduction
A glob “pattern” is used to match a file name or complete file path. For example, when using “Search all files” project_search::ToggleFocus you can click the funnel shaped Toggle Filters“ button or project_search::ToggleFilters and it will show additional search fields for “Include” and “Exclude” which support specifying glob patterns for matching file paths and file names.
When creating a glob pattern you can use one or multiple special characters:
| Special Character | Meaning |
|---|---|
? | Matches any single character |
* | Matches any (possibly empty) sequence of characters |
** | Matches the current directory and arbitrary subdirectories |
[abc] | Matches any one character in the brackets |
[a-z] | Matches any of a range of characters (ordered by Unicode) |
[!...] | The negation of [...] (matches a character not in the brackets) |
Notes:
- Shell-style brace-expansions like
{a,b,c}are not supported. - To match a literal
-character inside brackets it must come first[-abc]or last[abc-]. - To match the literal
[character use[[]or put it as the first character in the group[[abc]. - To match the literal
]character use[]]or put it as the last character in the group[abc]].
Examples
Matching file extensions
If you wanted to only search Markdown files add *.md to the “Include” search
field.
Case insensitive matching
Globs in Gram are case-sensitive, so *.c will not match main.C (even on
case-insensitive filesystems like HFS+/APFS on macOS). Instead use brackets to
match characters. So instead of *.c use *.[cC].
Matching directories
If you wanted to search the
gram repository for examples of
Configuring Language Servers
(under "lsp" in Gram settings.jsonc) you could search for "lsp" and in the
“Include” filter specify docs/**/*.md. This would only match files whose path
was under the docs directory or any nested subdirectories **/ of that folder
with a filename that ends in .md.
If instead you wanted to restrict yourself only to Gram Language-Specific
Documentation pages you could define a narrower pattern of:
docs/languages/*.md this would match docs/languages/rust.md and
docs/languages/cpp.md but not docs/configuring-languages.md.
Implicit Wildcards
When using the “Include” / “Exclude” filters on a Project Search each glob is
wrapped in implicit wildcards. For example to exclude any files with license in
the path or filename from your search just type license in the exclude box.
Behind the scenes Gram transforms license to **license**. This means that
files named license.*, *.license or inside a license subdirectory will all
be filtered out. This enables users to easily filter for *.ts without having
to remember to type **/*.ts every time.
Alternatively, if in your Gram settings you wanted a
file_types override which only applied to
a certain directory you must explicitly include the wildcard globs. For example,
if you had a directory of template files with the html extension that you
wanted to recognize as Jinja2 template you could use the following:
{
"file_types": {
"C++": ["[cC]"],
"Jinja2": ["**/templates/*.html"],
},
}
References
While globs in Gram are implemented as described above, when writing code using globs in other languages, please reference your platform’s glob documentation:
- macOS fnmatch (BSD C Standard Library)
- Linux fnmatch (GNU C Standard Library)
- POSIX fnmatch (POSIX Specification)
- node-glob (Node.js
globpackage) - Python glob (Python Standard Library)
- Golang glob (Go Standard Library)
- gitignore patterns (Gitignore Pattern Format)
- PowerShell: About Wildcards (Wildcards in PowerShell)
Helix Mode
Work in progress! Not all Helix keybindings are implemented yet.
The Helix mode is an emulation layer that brings Helix-style keybindings and
modal editing to Gram. It builds upon Vim mode, so much of the core
functionality is shared. Enabling helix_mode will also enable vim_mode.
For a guide on Vim-related features that are also available in Helix mode, please refer to the Vim mode documentation.
For a detailed list of Helix’s default keybindings, please visit the official Helix documentation.
Core differences
Any text object that works with m i or m a also works with ] and [, so
for example ] ( selects the next pair of parentheses after the cursor.
Help: I can’t open any files
Linux: Clicking links isn’t working
These features are provided by XDG desktop portals, specifically:
org.freedesktop.portal.FileChooserorg.freedesktop.portal.OpenURI
Some window managers, such as Hyprland, don’t provide a file picker by
default. See
this list
as a starting point for alternatives.
Linux: Could not start inotify
Gram relies on inotify to watch your filesystem for changes. If you cannot start inotify then Gram will not work reliably.
If you are seeing “too many open files” then first try sysctl fs.inotify.
- You should see that max_user_instances is 128 or higher (you can change the
limit with
sudo sysctl fs.inotify.max_user_instances=1024). Gram needs only 1 inotify instance. - You should see that
max_user_watchesis 8000 or higher (you can change the limit withsudo sysctl fs.inotify.max_user_watches=64000). Gram needs one watch per directory in all your open projects + one per git repository + a handful more for settings, themes, keymaps, extensions.
It is also possible that you are running out of file descriptors. You can check
the limits with ulimit and update them by editing /etc/security/limits.conf.
Mac: Clicking documentation links isn’t working
If you build and run from source and haven’t already installed Gram as an
application, the gram:// links will not work properly. To get them working,
you will need to either build an application bundle yourself or install one of
the pre-built bundles from the Gram website.
Icon Themes
Gram comes with a built-in icon theme, with more icon themes available as extensions.
Enabling Icon Themes
File and folder icons are disabled by default. You can enable them in
Settings > Panels > File Icons and Settings > Panels > File Icons.
Selecting an Icon Theme
See what icon themes are installed and preview them via the Icon Theme Selector,
which you can open from the command palette with icon theme selector: toggle.
Navigating through the icon theme list by moving up and down will change the icon theme in real time and hitting enter will save it to your settings file.
Installing more Icon Themes
Gram can use icon themes created for the Zed editor. If you find an icon theme you like, you can install it using the repository URL from the Extensions page.
Configuring Icon Themes
Your selected icon theme is stored in your settings file. You can open your settings file from the command palette with gram::OpenSettingsFile (bound to gram::OpenSettingsFile).
Just like with themes, Gram allows for configuring different icon themes for
light and dark mode. You can set the mode to "light" or "dark" to ignore the
current system mode.
{
"icon_theme": {
"mode": "system",
"light": "Light Icon Theme",
"dark": "Dark Icon Theme",
},
}
Icon Theme Development
See: Developing Gram Icon Themes
Key bindings
Predefined Keymaps
If you’re used to a specific editor’s defaults, you can change your
base_keymap through the settings window (gram::OpenSettings) or directly
through your settings.jsonc file (gram::OpenSettingsFile).
The following keymap styles are currently supported:
- Emacs (default)
- VS Code
- Atom
- JetBrains
- Sublime Text
- TextMate
- Minimal (for vim/helix)
- None (disables all key bindings)
This setting can also be changed via the command palette through the
gram: toggle base keymap selector action.
You can also enable vim_mode or helix_mode, which add modal bindings. For
more information, see the documentation for Vim mode and
Helix mode. You may also want to use the Minimal base keymap if
you want a pure vim/helix experience without any key bindings from another
application.
Keymap Editor
You can access the keymap editor through the gram::OpenKeymap action or by
running gram::OpenKeymap action from the command palette. You can
easily add or change a keybind for an action with the Change Keybinding or
Add Keybinding button on the command pallets left bottom corner.
In there, you can see all of the existing actions in Gram as well as the associated keybindings set to them by default.
You can also customize them right from there, either by clicking on the pencil
icon that appears when you hover over a particular action, by double-clicking on
the action row, or by pressing the enter key.
Anything that you end up doing on the keymap editor also gets reflected on the
keymap.jsonc file.
User Keymaps
The keymap file is stored in the following locations for each platform:
- macOS/Linux:
~/.config/gram/keymap.jsonc - Windows:
~\AppData\Roaming\Gram/keymap.jsonc
You can open the keymap with the gram::OpenKeymapFile action from the command palette.
This file contains a JSON array of objects with "bindings". If no "context"
is set, the bindings are always active. If it is set, the binding is only active
when the context matches.
Within each binding section, a key sequence is mapped to an action. If conflicts are detected, they are resolved as described below.
If you are using a non-QWERTY, Latin-character keyboard, you may want to set
use_key_equivalents to true. See
Non-QWERTY keyboards for more information.
For example:
[
{
"bindings": {
"ctrl-right": "editor::SelectLargerSyntaxNode",
"ctrl-left": "editor::SelectSmallerSyntaxNode",
},
},
{
"context": "ProjectPanel && not_editing",
"bindings": {
"o": "project_panel::Open",
},
},
]
If you want to debug problems with custom keymaps, you can use
dev: Open Key Context View from the command palette.
Keybinding Syntax
Gram has the ability to match against not just a single keypress, but a sequence
of keys typed in order. Each key in the "bindings" map is a sequence of
keypresses separated with a space.
Each keypress is a sequence of modifiers followed by a key. The modifiers are:
ctrl-The control keycmd-,win-orsuper-for the platform modifier (Command on macOS, Windows key on Windows, and the Super key on Linux).alt-for alt (option on macOS)shift-The shift keyfn-The function keysecondary-Equivalent tocmdwhen Gram is running on macOS andctrlwhen on Windows and Linux
The keys can be any single Unicode codepoint that your keyboard generates (for
example a, 0, £ or ç), or any named key (tab, f1, shift, or
cmd). If you are using a non-Latin layout (e.g. Cyrillic), you can bind either
to the Cyrillic character or the Latin character that key generates with cmd
pressed.
A few examples:
"bindings": {
"cmd-k cmd-s": "gram::OpenKeymap", // matches ⌘-k then ⌘-s
"space e": "editor::Complete", // type space then e
"ç": "editor::Complete", // matches ⌥-c
"shift shift": "file_finder::Toggle", // matches pressing and releasing shift twice
}
The shift- modifier can only be used in combination with a letter to indicate
the uppercase version. For example, shift-g matches typing G. Although on
many keyboards shift is used to type punctuation characters like (, the
keypress is not considered to be modified, and so shift-( does not match.
The alt- modifier can be used on many layouts to generate a different key. For
example, on a macOS US keyboard, the combination alt-c types ç. You can
match against either in your keymap file, though by convention, Gram spells this
combination as alt-c.
It is possible to match against typing a modifier key on its own. For example,
shift shift can be used to implement JetBrains’ ‘Search Everywhere’ shortcut.
In this case, the binding happens on key release instead of on keypress.
Contexts
If a binding group has a "context" key, it will be matched against the
currently active contexts in Gram.
Gram’s contexts make up a tree, with the root being Workspace. Workspaces
contain Panes and Panels, and Panes contain Editors, etc. The easiest way to see
what contexts are active at a given moment is the key context view, which you
can get to with the dev: open key context view command in the command palette.
For example:
# in an editor, it might look like this:
Workspace os=macos keyboard_layout=com.apple.keylayout.QWERTY
Pane
Editor mode=full extension=md vim_mode=insert
# in the project panel
Workspace os=macos
Dock
ProjectPanel not_editing
Context expressions can contain the following syntax:
X && Y,X || Yto and/or two conditions!Xto check that a condition is false(X)for groupingX > Yto match if an ancestor in the tree matches X and this layer matches Y.
For example:
"context": "Editor"- matches any editor (including inline inputs)"context": "Editor && mode == full"- matches the main editors used for editing code"context": "!Editor && !Terminal"- matches anywhere except where an Editor or Terminal is focused"context": "os == macos > Editor"- matches any editor on macOS.
It’s worth noting that attributes are only available on the node they are
defined on. This means that if you want to (for example) only enable a
keybinding when the debugger is stopped in vim normal mode, you need to do
debugger_stopped > vim_mode == normal.
Note: Before Gram v0.197.x, the
!operator only looked at one node at a time, and>meant “parent” not “ancestor”. This meant that!Editorwould match the contextWorkspace > Pane > Editor, because (confusingly) the Pane matches!Editor, and thatos == macos > Editordid not match the contextWorkspace > Pane > Editorbecause of the intermediatePanenode.
If you’re using Vim mode, we have information on how vim modes influence the context. Helix mode is built on top of Vim mode and uses the same contexts.
Actions
Almost all of Gram’s functionality is exposed as actions.
Most actions do not require any arguments, and so you can bind them as strings:
"ctrl-a": "language_selector::Toggle". Some require a single argument and must
be bound as an array: "cmd-1": ["workspace::ActivatePane", 0]. Some actions
require multiple arguments and are bound as an array of a string and an object:
"ctrl-a": ["pane::DeploySearch", { "replace_enabled": true }].
Precedence
When multiple keybindings have the same keystroke and are active at the same time, precedence is resolved in two ways:
- Bindings that match on lower nodes in the context tree win. This means that if
you have a binding with a context of
Editor, it will take precedence over a binding with a context ofWorkspace. Bindings with no context match at the lowest level in the tree. - If there are multiple bindings that match at the same level in the tree, then the binding defined later takes precedence. As user keybindings are loaded after system keybindings, this allows user bindings to take precedence over built-in keybindings.
The other kind of conflict that arises is when you have two bindings, one of
which is a prefix of the other. For example, if you have
"ctrl-w":"editor::DeleteToNextWordEnd" and
"ctrl-w left":"editor::DeleteToEndOfLine".
When this happens, and both bindings are active in the current context, Gram
will wait for 1 second after you type ctrl-w to see if you’re about to type
left. If you don’t type anything, or if you type a different key, then
DeleteToNextWordEnd will be triggered. If you do, then DeleteToEndOfLine
will be triggered.
Non-QWERTY keyboards
Gram’s support for non-QWERTY keyboards is still a work in progress.
If your keyboard can type the full ASCII range (DVORAK, COLEMAK, etc.), then shortcuts should work as you expect.
Otherwise, read on…
macOS
On Cyrillic, Hebrew, Armenian, and other keyboards that are mostly non-ASCII,
macOS automatically maps keys to the ASCII range when cmd is held. Gram takes
this a step further, and it can always match key-presses against either the
ASCII layout or the real layout, regardless of modifiers and the
use_key_equivalents setting. For example, in Thai, pressing ctrl-ๆ will
match bindings associated with ctrl-q or ctrl-ๆ.
On keyboards that support extended Latin alphabets (French AZERTY, German
QWERTZ, etc.), it is often not possible to type the entire ASCII range without
option. This introduces an ambiguity: option-2 produces @. To ensure that
all the built-in keyboard shortcuts can still be typed on these keyboards, we
move key bindings around. For example, shortcuts bound to @ on QWERTY are
moved to " on a Spanish layout. This mapping is based on the macOS system
defaults and can be seen by running dev: open key context view from the
command palette.
If you are defining shortcuts in your personal keymap, you can opt into the key
equivalent mapping by setting use_key_equivalents to true in your keymap:
[
{
"use_key_equivalents": true,
"bindings": {
"ctrl->": "editor::Indent", // parsed as ctrl-: when a German QWERTZ keyboard is active
},
},
]
Linux
Since v0.196.0, on Linux, if the key that you type doesn’t produce an ASCII character, then we use the QWERTY-layout equivalent key for keyboard shortcuts. This means that many shortcuts can be typed on many layouts.
We do not yet move shortcuts around to ensure that all the built-in shortcuts can be typed on every layout, so if there are some ASCII characters that cannot be typed, and your keyboard layout has different ASCII characters on the same keys as would be needed to type them, you may need to add custom key bindings to make this work. We do intend to fix this at some point, and help is very much appreciated!
Tips and tricks
Disabling a binding
If you’d like a given binding to do nothing in a given context, you can use
null as the action. This is useful if you hit the key binding by accident and
want to disable it, or if you want to type the character that would be typed by
the sequence, or if you want to disable multikey bindings starting with that
key.
[
{
"context": "Workspace",
"bindings": {
"cmd-r": null, // cmd-r will do nothing when the Workspace context is active
},
},
]
A null binding follows the same precedence rules as normal actions, so it
disables all bindings that would match further up in the tree too. If you’d like
a binding that matches further up in the tree to take precedence over a lower
binding, you need to rebind it to the action you want in the context you want.
This is useful for preventing Gram from falling back to a default key binding
when the action you specified is conditional and propagates. For example,
buffer_search::DeployReplace only triggers when the search bar is not in view.
If the search bar is in view, it would propagate and trigger the default action
set for that key binding, such as opening the right dock. To prevent this from
happening:
[
{
"context": "Workspace",
"bindings": {
"cmd-r": null, // cmd-r will do nothing when the search bar is in view
},
},
{
"context": "Workspace",
"bindings": {
"cmd-r": "buffer_search::DeployReplace", // cmd-r will deploy replace when the search bar is not in view
},
},
]
Remapping keys
A common request is to be able to map from a single keystroke to a sequence. You
can do this with the workspace::SendKeystrokes action.
[
{
"bindings": {
// Move down four times
"alt-down": ["workspace::SendKeystrokes", "down down down down"],
// Expand the selection (editor::SelectLargerSyntaxNode);
// copy to the clipboard; and then undo the selection expansion.
"cmd-alt-c": [
"workspace::SendKeystrokes",
"ctrl-shift-right ctrl-shift-right ctrl-shift-right cmd-c ctrl-shift-left ctrl-shift-left ctrl-shift-left",
],
},
},
{
"context": "Editor && vim_mode == insert",
"bindings": {
"j k": ["workspace::SendKeystrokes", "escape"],
},
},
]
There are some limitations to this, notably:
- Any asynchronous operation will not happen until after all your key bindings
have been dispatched. For example, this means that while you can use a binding
to open a file (as in the
cmd-alt-rexample), you cannot send further keystrokes and hope to have them interpreted by the new view. - Other examples of asynchronous things are: opening the command palette, communicating with a language server, changing the language of a buffer, anything that hits the network.
- There is a limit of 100 simulated keys at a time.
The argument to SendKeystrokes is a space-separated list of keystrokes (using
the same syntax as above). Due to the way that keystrokes are parsed, any
segment that is not recognized as a keypress will be sent verbatim to the
currently focused input field.
If the argument to SendKeystrokes contains the binding used to trigger it, it
will use the next-highest-precedence definition of that binding. This allows you
to extend the default behavior of a key binding.
Forward keys to terminal
If you’re on Linux or Windows, you might find yourself wanting to forward key combinations to the built-in terminal instead of them being handled by Gram.
For example, ctrl-n creates a new tab in Gram on Linux. If you want to send
ctrl-n to the built-in terminal when it’s focused, add the following to your
keymap:
{
"context": "Terminal",
"bindings": {
"ctrl-n": ["terminal::SendKeystroke", "ctrl-n"],
},
}
Task Key bindings
You can also bind keys to launch Gram Tasks defined in your tasks.jsonc. See
the tasks documentation for more.
Language Servers
Gram relies on Language Servers to provide semantic information about different programming languages. Each language has its own set of language servers. A language server is a separate program which Gram communicates with using the Language Server Protocol. Many code editors speak the LSP these days and so different editors can provide advanced language features like autocompletion without having to implement them independently.
If Gram knows about a particular language, either natively or via an extension, it can use any language servers it finds already installed on the system.
Gram can also download and install language servers. The Zed editor will do this without asking, but Gram tries not to do anything like downloading binaries from the internet without explicit permission to do so.
Once Gram has failed to launch a language server, an error will be reported and
the bot icon in the lower left of the editor window will have a red indicator.
Click that icon and then choose Configure Servers. Alternatively use the
Command Palette to run the lsp::OpenLanguageServerConfig command.
In this view, you can see all the loaded language servers and choose whether to install any missing language servers yourself or let the editor try to install them for you.
Gram on Linux
See also Repology.
Distro Packages
The preferred installation method is adding the Gram repository for automatic
updates. Alternatively, prebuilt .deb and .rpm packages are available as
release assets at
Gram releases.
Alpine
Alpine Linux provides official packages in the testing repository. Enable the testing repository, then run:
doas apk add gram@testing
Arch
Arch Linux provides official packages in the extra repository.
sudo pacman -S gram
Alternatively, build and install a development snapshot from the AUR:
gram-git. Verify AUR package
integrity yourself.
Debian/Ubuntu
Requires Debian 12 (Bookworm), Ubuntu 24.04 (Noble), or later.
# Add the repository key
sudo curl https://codeberg.org/api/packages/GramEditor/debian/repository.key -o /etc/apt/keyrings/forgejo-GramEditor.asc
# Add the repository
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/forgejo-GramEditor.asc] https://codeberg.org/api/packages/GramEditor/debian gram release" | sudo tee -a /etc/apt/sources.list.d/gram.list
# Update package cache and install
sudo apt update && sudo apt install gram
Fedora/RHEL/Rocky/Alma
Requires Fedora 42, RHEL 10.1, Rocky 10.1, Alma 10.1, or later.
Codeberg Repository
sudo dnf config-manager addrepo --from-repofile="https://codeberg.org/api/packages/GramEditor/rpm.repo"
sudo dnf install gram
Note
RPM package signing is currently non-functional. To install Gram, set
gpgcheck=0in/etc/yum.repos.d/rpm.repo.
Terra Repository
sudo dnf install --nogpgcheck --repofrompath 'terra,https://repos.fyralabs.com/terra$releasever' terra-release && sudo dnf install gram
# For immutable/atomic editions
curl -fsSL https://github.com/terrapkg/subatomic-repos/raw/main/terra.repo | pkexec tee /etc/yum.repos.d/terra.repo
sudo rpm-ostree install terra-release && sudo dnf install gram
Gentoo
Note
Gentoo packages are provided via Gram’s overlay. For more information and installation methods, see Gram’s overlay repository.
sudo eselect repository add gram git https://codeberg.org/GramEditor/gram-gentoo.git
sudo emerge --sync gram
sudo emerge -av app-editors/gram
Nix
Modern Nix (Recommended)
# Temporary environment
nix shell nixpkgs#gram
# User profile installation
nix profile add nixpkgs#gram
NixOS Configuration
environment.systemPackages = [
pkgs.gram
];
Legacy Nix (Channels)
# On NixOS
nix-env -iA nixos.gram
# On non-NixOS Linux
nix-env -iA nixpkgs.gram
OpenSUSE
Requires Leap 16 (or Tumbleweed/Slowroll) or later.
sudo zypper addrepo https://codeberg.org/api/packages/GramEditor/rpm.repo
sudo zypper install gram
Note
RPM package signing is currently non-functional. To install Gram, set
gpgcheck=0in/etc/yum.repos.d/rpm.repo.
Solus
sudo eopkg install gram
Flatpak
Prebuilt Flatpaks are available as release assets at Gram releases. Install via:
flatpak install /path/to/app.liten.Gram-x86_64-${version}.flatpak
From Tarball
If a tarball is available for your architecture at the Gram releases repository:
- Download the install.sh script.
- Run the script.
./install.sh
This downloads and installs the latest Gram release to $HOME/.local. Use
--prefix to install to a different location:
./install.sh --prefix /usr/local ./gram-linux-x86_64-VERSION.tar.gz
Replace VERSION with the release version. A nonstandard prefix must be included
in the desktop’s data search path for its launcher and icons to be discoverable.
From Source
Gram is open source. See developer notes for build instructions.
Troubleshooting
Graphics Issues
Gram fails to open a window
Gram requires a GPU and uses Vulkan for rendering. If Gram fails to load or perform well, Vulkan may be the cause.
A Gram failed to open a window: NoSupportedDeviceFound error indicates Vulkan
cannot find a compatible GPU. Run vkcube
command (usually in the vulkaninfo or vulkan-tools package) to troubleshoot.
Note
Test both X11 and Wayland modes by running
vkcube -m x11orvkcube -m wayland. Some distributions usevkcube-waylandfor Wayland.
This outputs your graphics setup and displays a rotating cube. If it fails, install Vulkan-compatible GPU drivers. Note that some hardware lacks Vulkan support.
Check which GPU Gram uses by searching for Using GPU: ... in
~/.local/share/gram/logs/Gram.log.
Errors like ERROR_INITIALIZATION_FAILED, GPU Crashed, or
ERROR_SURFACE_LOST_KHR may be resolved by installing different GPU drivers or
selecting a different GPU (see
#14225).
- PRIME: On some systems, set
/etc/prime-discretetoon(force discrete) oroff(force integrated). - DRI_PRIME: Set the environment variable
DRI_PRIME=1when running Gram to force the discrete GPU. - AMD Long Lines: If Gram crashes when selecting long lines on an AMD GPU,
set
GRAM_PATH_SAMPLE_COUNT=0(see #26143). - AMD Broken Pipe: If you encounter a ‘Broken Pipe’ error on AMD, try using RADV or Mesa drivers (see #13880).
- AMDVLK: If Gram consistently fails to launch with the default
amdvlkdriver (e.g., on Omarchy, see #28851), removeamdvlkandlib32-amdvlk, and installvulkan-radeoninstead (see #14141).
For more details, refer to the Arch Linux Vulkan guide.
Forcing Gram to use a specific GPU
Option A: Environment Variable Use GRAM_DEVICE_ID={device_id} to specify
the GPU. Find the device ID via lspci -nn | grep VGA:
08:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [GeForce RTX 3070] [10de:2484] (rev a1)
The device ID is 2484 (hexadecimal). Force Gram to use it:
GRAM_DEVICE_ID=0x2484 gram
Export this variable in .bashrc or similar if defining it globally.
Option B: Mesa Device Select If using Mesa, list available GPUs:
MESA_VK_DEVICE_SELECT=list gram --foreground
Then export MESA_VK_DEVICE_SELECT=xxxx:yyyy to choose a specific device. To
fallback to Xwayland, additionally export WAYLAND_DISPLAY="".
Option C: VKDeviceChooser Use vkdevicechooser.
Generating Debug Reports
Pass --system-specs to print system specifications:
gram --system-specs
The editor log is located at ~/.local/share/gram/logs/Gram.log. To generate a
clean log for debugging graphics issues:
truncate -s 0 ~/.local/share/gram/logs/Gram.log # Clear the log file
GRAM_LOG=wgpu=info gram .
cat ~/.local/share/gram/logs/Gram.log
# Copy the output
Or, if the Gram CLI is set up:
GRAM_LOG=wgpu=info /path/to/gram/cli --foreground .
# Copy the output
Forcing X11 Scale Factor
On X11, Gram automatically detects the scale factor for high-DPI displays using this priority:
GPUI_X11_SCALE_FACTORenvironment variable (if set)Xft.dpifrom the X resources database (xrdb)- Automatic detection via RandR (monitor resolution and physical size)
To customize the scale factor:
Check Current Scale Factor
Verify if Xft.dpi is set:
xrdb -query | grep Xft.dpi
If empty, Gram uses RandR for automatic calculation.
Option 1: Set Xft.dpi (X Resources Database)
Xft.dpi ensures consistent scaling across X11 applications. Edit or create
~/.Xresources:
vim ~/.Xresources
Add your desired DPI (e.g., 96 for 1x, 144 for 1.5x, 192 for 2x, 288 for
3x):
Xft.dpi: 96
Load the configuration:
xrdb -merge ~/.Xresources
Restart Gram.
Option 2: Use GPUI_X11_SCALE_FACTOR
This Gram-specific variable bypasses automatic detection.
GPUI_X11_SCALE_FACTOR=1.5 gram
Accepts decimal values (e.g., 1.25, 1.5, 2.0) or randr to force RandR
detection even if Xft.dpi is set. Add to your shell profile or desktop entry
to make it permanent.
Option 3: Adjust System-Wide RandR DPI
This changes the reported DPI for the entire X11 session. Add to .xprofile or
.xinitrc:
xrandr --dpi 192
Replace 192 with your desired DPI.
Font Rendering Parameters
On Linux, Gram reads the following environment variables for font rendering:
GRAM_FONTS_GAMMA: Corresponds to GetGamma values. Allowed range:[1.0, 2.2](others are clipped). Default:1.8.GRAM_FONTS_GRAYSCALE_ENHANCED_CONTRAST: Corresponds to GetGrayscaleEnhancedContrast values. Allowed range:[0.0, ∞)(others are clipped). Default:1.0.
The Mission
“I come with empty hands and the desire to unbuild walls.”
― Ursula K. Le Guin, The Dispossessed
The Gram text editor is a fork of the Zed text editor. This document is an attempt to explain why the fork exists.
Performance, but at what cost?
Programming is more than just productivity. We need tools that are fit for purpose, that aren’t beholden to investors or share holders. There are aspects of the Zed code editor that I think are wrong in the moral and ethical sense, and there are aspects that I think are simply bad choices from a technical perspective.
At first, the promise of Zed seemed alluring. I moved from Emacs to Neovim because I started coding in Rust, and using the Rust LSP in Emacs was a very frustrating experience at the time. Whenever the LSP did any work the editor would freeze, drop keystrokes or otherwise behave badly.
Neovim was better in this aspect, but as soon as I worked on any larger rust project I would have the same kind of experience. Not good. At the same time, more and more languages assume that the editor can use a language server and don’t even try to support editors without it.
When Zed appeared, promising an actually fast and smooth editing experience able to handle large Rust projects without getting bogged down, and also came with good support for Emacs- and Vim-style editing, it seemed like exactly the thing that I ought to try.
However, I never even managed to get the editor installed. When I tried to download and install the binaries from the Zed website or Github page I would get presented with the Zed End User Terms. To install, I would have to accept them.
So, I read the terms!
Editor’s note, 2026-03-03
Credit where credit is due: Within 24 hours of me publishing this fork, Zed updated their Terms of Use and removed the section that seemed to conflict with the terms of the open source licenses.
The quotes below are excerpts from the Zed End User Terms.
PLEASE READ THESE TERMS AND CONDITIONS CAREFULLY BEFORE USING THE SERVICE OR SOFTWARE OFFERED BY ZED INDUSTRIES, INC. (“ZED”, OR “WE”). BY ACCESSING OR USING THE SOLUTION (AS DEFINED BELOW) IN ANY MANNER, YOU (“YOU” OR “CUSTOMER”) AGREE TO BE BOUND BY THESE TERMS (THE “AGREEMENT”) TO THE EXCLUSION OF ALL OTHER TERMS.
My (non-lawyer) interpretation of this section is that if I agree to these terms, I am waiving my right to use any software by Zed Industries under any other license. Does this mean that I could no longer use any of the code from Zed under an open source license, if the rights afforded by that license contradicts these terms? That is my interpretation.
Let’s read on, to section 2 “TERMS APPLICABLE TO THE EDITOR”, paragraph 2.2, “License Limitations”:
You agree that You shall not: (a) exceed the scope of the licenses granted in Section 2.1; (b) make copies of the Editor; (c) distribute, sublicense, assign, delegate, rent, lease, sell, time-share or otherwise transfer the benefits of, use under, or rights to, the license granted in Section 2.1; (d) reverse engineer, decompile, disassemble or otherwise attempt to learn the source code, structure or algorithms underlying the Editor, except to the extent required to be permitted under applicable law; (e) modify, translate or create derivative works of the Editor; or (f) remove any copyright, trademark, patent or other proprietary notice that appears on the Editor or copies thereof.
…
You shall not [..] make copies of the Editor
…
You shall not [..] reverse engineer, decompile, disassemble or otherwise attempt to learn the source code, structure or algorithms underlying the Editor
…
You shall not [..] modify, translate or create derivative works of the Editor
…etc.
I cannot try to learn the source code, structure or algorithms underlying the Editor? I cannot create derivative works?
I couldn’t accept it. I didn’t want to agree to any of it. So I gave up.
Zed kept popping up. People I had respected left their jobs to go work for Zed, and not only that - to work on AI integration in Zed.
I don’t want AI in my editor. I don’t want AI in anything. It’s not just because I think AI is bad for productivity, performance and quality (I do), but because I think the companies behind the technology and the cost of the technology make it not only unsustainable but unethical. Even if AI tools did work to make their users more productive (which I doubt), I still don’t want to use them. At all.
I also object to making myself and my work depend on paying a subscription fee to anyone. I don’t want an outage at Anthropic to affect my ability to do my work. I think it is a grave mistake to build anything on such shaky foundations as the sustainability and profit margins of the AI industry.
I think these are bad features to put in a code editor. Why should a code editor have a license agreement that flies in the face of open source? Why should my code editor integrate with technology that I find distasteful?
Thinking is a feature. Generative LLM technology is not.
Another selling point of Zed is “multiplayer editing” and built-in “collaboration”, meaning integrated audio/video chat with a proprietary server component, subscriptions and end user license agreements.
I don’t want it. In fact, I think these are bad features to put in a code editor. In my team, we use different operating systems, different editors and work from different time zones. We keep meetings to a minimum, and when we do pair programming or mob programming, one person is typing while the others think.
Multiple people editing the same files at once while video chatting at the same time sounds like a nightmare.
I don’t want to sign in, or sign up, or join the community. I want my tools to be hammers, screwdrivers and saws. I don’t need my hammer to come with a subscription fee.
In Zed, the editor will automatically update itself, downloading binaries from the Zed website vetted only by Zed. Its extensions are binary blobs hosted by Zed, automatically updated and downloaded without user control. Those extensions will, in turn, download and install anything they feel like.
As a band aid for this, newer versions of Zed have copied the workspace trust mechanism from VS Code. I think this is, once again, a bad solution to a problem that should not exist.
I don’t want my software to update itself automatically, or to download binaries without me explicitly asking it to.
The editor can offer to download and install something from source, but it should tell you exactly what it wants to download and from where, and it should ask first. In Zed, everything invasive and exploitative is opt out: AI, Telemetry, auto updates - auto-installation isn’t even offered as something to opt out of. Zed does not respect you.
I believe that the tools I use should belong to me. My tools are not there for corporations to bind me with.
Curiosity and spite
At first, I tried to build some other efforts I found online to make Zed work without the AI features just so I could check it out, but didn’t manage to get them to work. At some point, the curiosity turned into spite. I became determined to not only get the editor to run without all of the misfeatures, but to make it a full-blown fork of the project. Independent of corporate control, in the spirit of Vim and the late Bram Moolenaar who could have added subscription fees and abusive license agreements had he so wanted, but instead gave his work as a gift to the world and asked only for donations to a good cause close to his heart in return.
This is the result. Feel free to build it and see if it works for you. There is no license agreement or subscription beyond the open source license of the code (GPLv3). It is yours now, to do with as you please.
Features
- Open: No telemetry, AI or privacy-invading third party integrations.
- Performance: Focuses on helping you with your programming tasks instead of spending CPU and GPU cycles on communicating with AI services, sending your keystrokes to a company server in the US or convincing you to sign up for a subscription.
- Integrated: Gram includes the documentation directly in the editor. Long term, the goal is to include language support for most languages without requiring the use of extensions.
Other options
If you don’t want to use an editor that has gone down the AI route but do want a capable, general-purpose, open source text editor, what other options are there?
Here are some other editors that I have used and would consider reasonable alternatives to Zed. What they all have in common is that they are first and foremost text editors, and do not push or endorse LLM services. Some of them are also strict about the use of LLMs to develop the editors themselves, but not all of them are.
Note: Gram is also not AI free. I have not and do not think it is feasible to remove all generated code from the code base. Not all of it is clearly marked as such. We also merge patches from upstream sometimes, mainly to fix bugs. This stance may change in the future.
As far as I know, these editors are completely free of AI-generated code.
- Vim Classic
- Emacs
- fred - Has committed to be and remain AI-free.
These editors may not be AI free, but I am still OK with recommending them.
- Flow Control - A TUI-based and very promising editor with planned collaboration features.
- Helix
- Kakoune
Note: Also see: ethical-foss/open-slopware.
Multibuffers
Using multibuffers, it’s possible to edit multiple files simultaneously from a single view.
Multibuffers work well together with multiple cursors.
Editing in a multibuffer
Editing a multibuffer is the same as editing a normal file. Changes will be reflected in the open copies of the files in the rest of the editor.
Save all files with editor::Save (bound to cmd-s on macOS, ctrl-s
on Windows/Linux, or :w in Vim mode).
When in a multibuffer, it is often useful to use multiple cursors to edit every
file simultaneously. To edit multiple instances at once, select them with the
mouse (option-click on macOS, alt-click on Window/Linux) or the keyboard.
cmd-d on macOS, ctrl-d on Windows/Linux, or gl in Vim mode will select the
next match of the word under the cursor.
To edit all matches you can select them by running the editor::SelectAllMatches command (cmd-shift-l on macOS, ctrl-shift-l on
Windows/Linux, or g a in Vim mode).
Navigating to the Source File
Click on any of the divider lines between excerpts or place the cursor in an excerpt, and run the editor::OpenExcerpts command. Note: If multiple cursors are being used, the command will open the source file positioned under each cursor within the multibuffer.
Double-clicking excerpts with the mouse to open the source file is disabled by
default, and can be enabled using the setting:
"double_click_in_multibuffer": "open".
Project search
Run pane::ToggleSearch (cmd-shift-f on macOS, ctrl-shift-f on
Windows/Linux, or g/ in Vim mode) to search across the whole project. After
the search has completed, the results will be shown in a new multibuffer. There
will be one excerpt for each matching line across the whole project.
Diagnostics
If an appropriate language server is installed, the diagnostics pane can display
all errors across the project. Open it by clicking on the icon in the status
bar, or run the diagnostics::Deploy command('cmd-shift-m on macOS,
ctrl-shift-m on Windows/Linux, or :clist in Vim mode).
Find References
With a language server installed, find all references to the symbol under the
cursor using the editor::FindReferences command (cmd-click on macOS,
ctrl-click on Windows/Linux, or g A in Vim mode.
Depending on the language server, commands like editor::GoToDefinition and editor::GoToTypeDefinition will also open a multibuffer if there are multiple possible definitions.
Outline Panel
In addition to the modal outline (cmd-shift-o), Gram has the outline panel.
The outline panel can be deployed via cmd-shift-b (outline_panel::ToggleFocus via the command palette), or by clicking the
Outline Panel button in the status bar.
When viewing a “singleton” buffer (i.e., a single file on a tab), the outline panel works similarly to that of the outline modal-it displays the outline of the current buffer’s symbols, as reported by tree-sitter. Clicking on an entry jumps to the associated section in the file. The outline view will also automatically scroll to the section associated with the current cursor position within the file.
Project Search Results
Get an overview of search results across the project.
Project Diagnostics
View a summary of all errors and warnings reported by the language server.
Find All References
Quickly navigate through all references when using the editor::FindAllReferences action.
The outline view provides a way to quickly navigate to specific parts of the code to help maintain context when working with large result sets in multi-buffers.
Remote Development
Gram supports remote editing over SSH, where you run the editor on your main machine but open and edit projects on remote machines.
To make this work, Gram uses a remote process called remote-server, which
needs to be installed on the machine that the editor should connect to. The
editor will SSH to the remote machine and start the remote server which then
takes care of opening, reading and writing files as well as running language
servers.
The remote server communicates with the editor over SSH and GRPC.
Overview
Remote development requires two computers, your local machine that runs the UI and the remote server which runs a small server. The two communicate over SSH, so you will need to be able to SSH from your local machine into the remote server to use this feature.
On your local machine, Gram runs its UI, uses Tree-sitter to parse and syntax-highlight code, and store unsaved changes and recent projects. The source code, language servers, tasks, and the terminal all run on the remote server.
Setup
-
Install the editor on your main machine.
-
Build and copy the remote editor process to your development machine.
Either get a pre-built copy of the remote server from the Codeberg releases page, or build it from source.
If you download the pre-built release, make sure to get a version that matches your remote server. If you are running the editor on a Mac but want to connect to a Linux machine, you will need the Linux version of the remote-server.
Also make sure to get the same version of the remote server as your editor.
Decompress and copy the server to
~/.gram_server/gram-remote-server-{RELEASE_CHANNEL}-{VERSION}.For example:
mkdir -p ~/.gram_server curl -L -o - \ https://codeberg.org/GramEditor/gram/releases/download/1.1.0/gram-remote-server-linux-x86_64-1.1.0.gz \ | gunzip > ~/.gram_server/gram-remote-server-stable-1.1.0 chmod +x ~/.gram_server/gram-remote-server-stable-1.1.0 -
Use projects::OpenRemote to open the “Remote Projects” dialog.
-
Click “Connect New Server” and enter the command you use to SSH into the server. See Supported SSH options for options you can pass.
-
Your local machine will attempt to connect to the remote server using the
sshbinary on your path. Assuming the connection is successful and a compatible server binary is found, the editor will start up and start communicating with the remote server. -
Once the remote server is running, you will be prompted to choose a path to open on the remote server.
Note: The remote server does not currently handle opening very large directories (for example,
/or~that may have >100,000 files) very well.On a Mac, the editor may fail to connect the first time you try, and you will be presented with a permissions dialog to allow Gram to connect to the network. You’ll need to accept this and then try again.
Connect from the command line
To open the editor and connect to a remote project directly from the terminal,
use a command like gram ssh://[<user>@]<host>[:<port>]/<path-to-project>.
It is currently not possible to pass any other arguments to SSH from the
commandline. A workaround here is to set other options you need in your SSH
config file. See the SSH documentation (man ssh_config) for more details.
To hotlink into an SSH project, use a link of the format:
gram://ssh/[<user>@]<host>[:<port>]/<path>.
Supported platforms
The remote machine must be able to run the remote server process, and so you need to compile the remote server process for the target platform (cross compilation).
The following platforms should work:
- macOS Catalina or later (Intel or Apple Silicon)
- Linux (x86_64 or arm64)
- Windows is not yet supported as a remote server, but Windows can be used as a local machine to connect to remote servers. Note that Windows support in is currently not well tested in general.
Configuration
The list of remote servers is stored in your settings file gram::OpenSettings. You can edit this list using the Remote Projects dialog projects::OpenRemote, which provides some robustness - for example it checks that the connection can be established before writing it to the settings file.
{
"ssh_connections": [
{
"host": "192.168.1.10",
"projects": [{ "paths": ["~/code/gram/gram"] }],
},
],
}
Gram shells out to the ssh on your path, and so it will inherit any
configuration you have in ~/.ssh/config for the given host. That said, if you
need to override anything you can configure the following additional options on
each connection:
{
"ssh_connections": [
{
"host": "192.168.1.10",
"projects": [{ "paths": ["~/code/gram/gram"] }],
// any argument to pass to the ssh master process
"args": ["-i", "~/.ssh/work_id_file"],
"port": 22, // defaults to 22
// defaults to your username on your local machine
"username": "me",
},
],
}
You can also set a nickname for the remote server:
{
"ssh_connections": [
{
"host": "192.168.1.10",
"projects": [{ "paths": ["~/code/gram/gram"] }],
// Shown in the UI to help distinguish multiple hosts.
"nickname": "lil-linux",
},
],
}
If you use the command line to open a connection to a host by doing
gram ssh://192.168.1.10/~/.vimrc, then extra options are read from your
settings file by finding the first connection that matches the
host/username/port of the URL on the command line.
Additionally it’s worth noting that while you can pass a password on the command
line gram ssh://user:password@host/~, we do not support writing a password to
your settings file. If you’re connecting repeatedly to the same host, you should
configure key-based authentication.
Remote Development on Windows (SSH)
Gram on Windows supports SSH remoting and will prompt for credentials when needed.
If you encounter authentication issues, confirm that your SSH key agent is running (e.g., ssh-agent or your Git client’s agent) and that ssh.exe is on PATH.
Troubleshooting SSH on Windows
When prompted for credentials, use the graphical askpass dialog. If it doesn’t appear, check for credential manager conflicts and that GUI prompts aren’t blocked by your terminal.
WSL Support
Gram supports opening folders inside of WSL natively on Windows.
Opening a local folder in WSL
To open a local folder inside a WSL container, use the projects: open in wsl
action and select the folder you want to open. You will be presented with a list
of available WSL distributions to open the folder in.
Opening a folder already in WSL
To open a folder that’s already located inside of a WSL container, use the
projects: open wsl action and select the WSL distribution. The distribution
will be added to the Remote Projects window where you will be able to open the
folder.
Port forwarding
If you’d like to be able to connect to ports on your remote server from your local machine, you can configure port forwarding in your settings file. This is particularly useful for developing websites so you can load the site in your browser while working.
{
"ssh_connections": [
{
"host": "192.168.1.10",
"port_forwards": [{ "local_port": 8080, "remote_port": 80 }],
},
],
}
This will cause requests from your local machine to localhost:8080 to be
forwarded to the remote machine’s port 80. Under the hood this uses the -L
argument to ssh.
By default these ports are bound to localhost, so other computers in the same network as your development machine cannot access them. You can set the local_host to bind to a different interface, for example, 0.0.0.0 will bind to all local interfaces.
{
"ssh_connections": [
{
"host": "192.168.1.10",
"port_forwards": [
{
"local_port": 8080,
"remote_port": 80,
"local_host": "0.0.0.0",
},
],
},
],
}
These ports also default to the localhost interface on the remote host. If you
need to change this, you can also set the remote host:
{
"ssh_connections": [
{
"host": "192.168.1.10",
"port_forwards": [
{
"local_port": 8080,
"remote_port": 80,
"remote_host": "docker-host",
},
],
},
],
}
Gram settings
When opening a remote project there are three relevant settings locations:
- The local Gram settings (in
~/.gram/settings.jsonon macOS or~/.config/gram/settings.jsonon Linux) on your local machine. - The server Gram settings (in the same place) on the remote server.
- The project settings (in
.gram/settings.jsonor.editorconfigof your project)
Both the local Gram and the server Gram read the project settings, but they are
not aware of the other’s main settings.json.
Which settings file you should use depends on the kind of setting you want to make:
- Project settings should be used for things that affect the project: indentation settings, which formatter / language server to use, etc.
- Server settings should be used for things that affect the server: paths to language servers, proxy settings, etc.
- Local settings should be used for things that affect the UI: font size, etc.
In addition any extensions you have installed locally will be propagated to the remote server. This means that language servers, etc. will run correctly.
Proxy Configuration
The remote server will not use your local machine’s proxy configuration because they may be under different network policies. If your remote server requires a proxy to access the internet, you must configure it on the remote server itself.
In most cases, your remote server will already have proxy environment variables configured. Gram will automatically use them when downloading language servers, communicating with LLM models, etc.
If needed, you can set these environment variables in the server’s shell
configuration (e.g., ~/.bashrc):
export http_proxy="http://proxy.example.com:8080"
export https_proxy="http://proxy.example.com:8080"
export no_proxy="localhost,127.0.0.1"
Alternatively, you can configure the proxy in the remote machine’s
~/.config/gram/settings.json (Linux) or ~/.gram/settings.json (macOS):
{
"proxy": "http://proxy.example.com:8080"
}
See the proxy documentation for supported proxy types and additional configuration options.
Initializing the remote server
Once you provide the SSH options, Gram shells out to ssh on your local machine
to create a ControlMaster connection with the options you provide.
Any prompts that SSH needs will be shown in the UI, so you can verify host keys, type key passwords, etc.
Once the master connection is established, Gram will check to see if the remote
server binary is present in ~/.gram_server on the remote, and that its version
matches the current version of Gram that you’re using.
To build the remote server binary, run cargo build -p remote_server --release.
Upload it to ~/.gram_server/gram-remote-server-{RELEASE_CHANNEL}-{VERSION} on
the server, for example ~/.gram_server/gram-remote-server-stable-0.181.6. The
version must exactly match the version of Gram itself you are using.
Maintaining the SSH connection
Once the server is initialized. Gram will create new SSH connections (reusing the existing ControlMaster) to run the remote development server.
Each connection tries to run the development server in proxy mode. This mode will start the daemon if it is not running, and reconnect to it if it is. This way when your connection drops and is restarted, you can continue to work without interruption.
In the case that reconnecting fails, the daemon will not be re-used. That said, unsaved changes are by default persisted locally, so that you do not lose work. You can always reconnect to the project at a later date and Gram will restore unsaved changes.
If you are struggling with connection issues, you should be able to see more
information in the Gram log cmd-shift-p Open Log.
Supported SSH Options
Under the hood, Gram shells out to the ssh binary to connect to the remote
server. We create one SSH control master per project, and then use that to
multiplex SSH connections for the Gram protocol itself, any terminals you open
and tasks you run. We read settings from your SSH config file, but if you want
to specify additional options to the SSH control master you can configure Gram
to set them.
When typing in the “Connect New Server” dialog, you can use bash-style quoting
to pass options containing a space. Once you have created a server it will be
added to the "ssh_connections": [] array in your settings file. You can edit
the settings file directly to make changes to SSH connections.
Supported options:
-p/-l- these are equivalent to passing the port and the username in the host string.-L/-Rfor port forwarding-i- to use a specific key file-o- to set custom options-J/-w- to proxy the SSH connection-Ffor specifying anssh_config- And also…
-4,-6,-A,-B,-C,-D,-I,-K,-P,-X,-Y,-a,-b,-c,-i,-k,-l,-m,-o,-p,-w,-x,-y
Note that we deliberately disallow some options (for example -t or -T) that
Gram will set for you.
Known Limitations
- You can’t open files from the remote Terminal by typing the
gramcommand.
REPL
Getting started
Bring the power of Jupyter kernels to your editor! The built-in REPL for Gram allows you to run code interactively in your editor similarly to a notebook with your own text files.
Installation
Gram supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
Currently supported languages:
Once installed, you can start using the REPL in the respective language files,
or other places those languages are supported, such as Markdown. If you recently
added the kernels, run the repl: refresh kernelspecs command to make them
available in the editor.
Using the REPL
To start the REPL, open a file with the language you want to use and use the
repl: run command (defaults to ctrl-shift-enter on macOS) to run a block,
selection, or line. You can also click on the REPL icon in the toolbar.
The repl: run command will be executed on your selection(s), and the result
will be displayed below the selection.
Outputs can be cleared with the repl: clear outputs command, or from the REPL
menu in the toolbar.
Cell mode
Gram supports
notebooks as scripts
using the # %% cell separator in Python and // %% in TypeScript. This allows
you to write code in a single file and run it as if it were a notebook, cell by
cell.
The repl: run command will run each block of code between the # %% markers
as a separate cell.
# %% Cell 1
import time
import numpy as np
# %% Cell 2
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
from matplotlib import style
style.use("ggplot")
Language specific instructions
Python
Global environment
On macOS, your system Python will not work. Either set up pyenv or use a virtual environment.
To setup your current Python to have an available kernel, run:
pip install ipykernel
python -m ipykernel install --user
Conda Environment
source activate myenv
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
Virtualenv with pip
source activate myenv
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
R (Ark Kernel)
Install Ark by downloading the
release for your operating system. For example, for macOS just unpack ark
binary and put it into /usr/local/bin. Then run:
ark --install
R (Xeus Kernel)
- Install Xeus-R
- Install the R Extension for Gram (search for
Rin Gram Extensions)
TypeScript: Deno
- Install Deno and then install the Deno jupyter kernel:
deno jupyter --install
Julia
- Download and install Julia from the official website.
- Install the Julia Extension for Gram (search for
Juliain Gram Extensions)
Scala
- Install Scala with
cs setup(Coursier):brew install coursier/formulas/coursier && cs setup
- REPL (Almond)
setup instructions:
brew install --cask temurin(Eclipse foundation official OpenJDK binaries)brew install coursier/formulas/coursier && cs setupcoursier launch --use-bootstrap almond -- --install
Changing which kernel is used per language
Gram automatically detects the available kernels on your system. If you need to
configure a different default kernel for a language, you can assign a kernel for
any supported language in your settings.json.
{
"jupyter": {
"kernel_selections": {
"python": "conda-env",
"typescript": "deno",
"javascript": "deno",
"r": "ark",
},
},
}
Debugging Kernelspecs
Available kernels are shown via the repl: sessions command. To refresh the
kernels you can run, use the repl: refresh kernelspecs command.
If you have jupyter installed, you can run jupyter kernelspec list to see
the available kernels.
$ jupyter kernelspec list
Available kernels:
ark /Users/z/Library/Jupyter/kernels/ark
conda-base /Users/z/Library/Jupyter/kernels/conda-base
deno /Users/z/Library/Jupyter/kernels/deno
python-chatlab-dev /Users/z/Library/Jupyter/kernels/python-chatlab-dev
python3 /Users/z/Library/Jupyter/kernels/python3
ruby /Users/z/Library/Jupyter/kernels/ruby
rust /Users/z/Library/Jupyter/kernels/rust
Note: Gram makes best effort usage of
sys.prefixandCONDA_PREFIXto find kernels in Python environments. If you want explicitly control runpython -m ipykernel install --user --name myenv --display-name "Python (myenv)"to install the kernel directly while in the environment.
Snippets
Use the snippets::ConfigureSnippets action to create a new snippets file or edit an existing snippets file for a specified scope.
The snippets are located in ~/.config/gram/snippets directory to which you can
navigate to with the snippets::OpenFolder action.
Example configuration
{
// Each snippet must have a name and body, but the prefix and description are optional.
// The prefix is used to trigger the snippet, but when omitted then the name is used.
// Use placeholders like $1, $2 or ${1:defaultValue} to define tab stops.
// The $0 determines the final cursor position.
// Placeholders with the same value are linked.
"Log to console": {
"prefix": "log",
"body": ["console.info(\"Hello, ${1:World}!\")", "$0"],
"description": "Logs to console",
},
}
Scopes
The scope is determined by the language name in lowercase e.g. python.json for
Python, shell script.json for Shell Script, but there are some exceptions to
this rule:
| Scope | Filename |
|---|---|
| Global | snippets.json |
| JSX | javascript.json |
| Plain Text | plaintext.json |
To create JSX snippets you have to use javascript.json snippets file, instead
of jsx.json, but this does not apply to TSX and TypeScript which follow the
above rule.
Known Limitations
- Only the first prefix is used when a list of prefixes is passed in.
- Currently only the
jsonsnippet file format is supported, even though thesimple-completion-language-serversupports bothjsonandtomlfile formats.
See also
The feature_paths option in simple-completion-language-server is disabled by
default.
If you want to enable it you can add the following to your settings.json:
{
"lsp": {
"snippet-completion-server": {
"settings": {
"feature_paths": true,
},
},
},
}
For more configuration information, see the
simple-completion-language-server instructions.
SuperTab
Inspired by the Vim SuperTab plugin, this feature makes the Tab key context-sensitive so that the same key can indent, produce a literal tab character and perform completion, all in one.
The basic concept is that it’s possible to figure out what to do when the user presses tab based on the current context. If the cursor is at the end of some text, activating SuperTab will open the completion menu. If the cursor is at the beginning of the line or only preceded by whitespace, it will indent the line. In any other scenario, it will produce a tab character.
To enable SuperTab, bind the tab key to editor::SuperTab in your
keymap.jsonc:
{
"context": "Editor && mode == full",
"use_key_equivalents": true,
"bindings": {
"tab": "editor::SuperTab"
},
}
Fallback mode
By default, Supertab will fall back to inserting a literal tab character when
not at the beginning of the line or at a completion point. To have it always
indent unless completing, you can configure supertab_fallback in
settings.jsonc or via the Settings interface:
{
"supertab_fallback": "indent", // default is "tab"
}
Tab Switcher
The Tab Switcher provides a quick way to navigate between open tabs in Gram. It displays a list of your open tabs sorted by recent usage, making it easy to jump back to whatever you were just working on.
Quick Switching
When the Tab Switcher is opened using tab_switcher::Toggle, instead of running the tab_switcher::Toggle from the command palette, it’ll stay active as long as the ctrl key is held down.
While holding down ctrl, each subsequent tab press cycles to the next item (shift to cycle backwards) and, when ctrl is released, the selected item is confirmed and the switcher is closed.
Opening the Tab Switcher
The Tab Switcher can also be opened with either tab_switcher::Toggle or tab_switcher::ToggleAll. Using tab_switcher::Toggle will show only the tabs for the current pane, while tab_switcher::ToggleAll shows all tabs for all panes.
While the Tab Switcher is open, you can:
- Press menu::SelectNext to move to the next tab in the list
- Press menu::SelectPrevious to move to the previous tab
- Press enter to confirm the selected tab and close the switcher
- Press escape to close the switcher and return to the original tab from which the switcher was opened
- Press tab_switcher::CloseSelectedItem to close the currently selected tab
As you navigate through the list, Gram will update the pane’s active item to match the selected tab.
Action Reference
| Action | Description |
|---|---|
| tab_switcher::Toggle | Open the Tab Switcher for the current pane |
| tab_switcher::ToggleAll | Open the Tab Switcher showing tabs from all panes |
| tab_switcher::CloseSelectedItem | Close the selected tab in the Tab Switcher |
Tasks
Gram supports ways to spawn (and rerun) commands using its integrated terminal to output the results. These commands can read a limited subset of Gram state (such as a path to the file currently being edited or selected text).
[
{
"label": "Example task",
"command": "for i in {1..5}; do echo \"Hello $i/5\"; sleep 1; done",
// "args": [],
// Env overrides for the command, will be appended to the terminal's environment from the settings.
"env": { "foo": "bar" },
// Current working directory to spawn the command into, defaults to current project root.
// "cwd": "/path/to/working/directory",
// Whether to use a new terminal tab or reuse the existing one to spawn the process, defaults to `false`.
"use_new_terminal": false,
// Whether to allow multiple instances of the same task to be run, or rather wait for the existing ones to finish, defaults to `false`.
"allow_concurrent_runs": false,
// What to do with the terminal pane and tab, after the command was started:
// * `always` — always show the task's pane, and focus the corresponding tab in it (default)
// * `no_focus` — always show the task's pane, add the task's tab in it, but don't focus it
// * `never` — do not alter focus, but still add/reuse the task's tab in its pane
"reveal": "always",
// What to do with the terminal pane and tab, after the command has finished:
// * `never` — Do nothing when the command finishes (default)
// * `always` — always hide the terminal tab, hide the pane also if it was the last tab in it
// * `on_success` — hide the terminal tab on task success only, otherwise behaves similar to `always`
"hide": "never",
// Which shell to use when running a task inside the terminal.
// May take 3 values:
// 1. (default) Use the system's default terminal configuration in /etc/passwd
// "shell": "system"
// 2. A program:
// "shell": {
// "program": "sh"
// }
// 3. A program with arguments:
// "shell": {
// "with_arguments": {
// "program": "/bin/bash",
// "args": ["--login"]
// }
// }
"shell": "system",
// Whether to show the task line in the output of the spawned task, defaults to `true`.
"show_summary": true,
// Whether to show the command line in the output of the spawned task, defaults to `true`.
"show_command": true,
// Which edited buffers to save before running the task:
// * `none` — don't save any buffers (default)
// * `all` — save all edited buffers
// * `current` — save current buffer only
"save": "none",
// Represents the tags for inline runnable indicators, or spawning multiple tasks at once.
// "tags": []
}
]
There are two actions that drive the workflow of using tasks: task: spawn and
task: rerun. task: spawn opens a modal with all available tasks in the
current file. task: rerun reruns the most recently spawned task. You can also
rerun tasks from the task modal.
By default, rerunning tasks reuses the same terminal (due to the
"use_new_terminal": false default) but waits for the previous task to finish
before starting (due to the "allow_concurrent_runs": false default).
Keep "use_new_terminal": false and set "allow_concurrent_runs": true to
allow cancelling previous tasks on rerun.
Task templates
Tasks can be defined:
- in the global
tasks.jsoncfile; such tasks are available in all Gram projects you work on. This file is usually located in~/.config/gram/tasks.json. You can edit them by using thegram: open tasksaction. - in the worktree-specific (local)
.gram/tasks.jsoncfile; such tasks are available only when working on a project with that worktree included. You can edit worktree-specific tasks by using thegram: open project tasksaction. - on the fly with oneshot tasks. These tasks are project-specific and do not persist across sessions.
- by language extension.
Variables
Gram tasks act just like your shell; that also means that you can reference
environmental variables via sh-esque $VAR_NAME syntax. A couple of additional
environmental variables are set for your convenience. These variables allow you
to pull information from the current editor and use it in your tasks. The
following variables are available:
GRAM_COLUMN: current line columnGRAM_ROW: current line rowGRAM_FILE: absolute path of the currently opened file (e.g./Users/my-user/path/to/project/src/main.rs)GRAM_FILENAME: filename of the currently opened file (e.g.main.rs)GRAM_DIRNAME: absolute path of the currently opened file with file name stripped (e.g./Users/my-user/path/to/project/src)GRAM_RELATIVE_FILE: path of the currently opened file, relative toGRAM_WORKTREE_ROOT(e.g.src/main.rs)GRAM_RELATIVE_DIR: path of the currently opened file’s directory, relative toGRAM_WORKTREE_ROOT(e.g.src)GRAM_STEM: stem (filename without extension) of the currently opened file (e.g.main)GRAM_SYMBOL: currently selected symbol; should match the last symbol shown in a symbol breadcrumb (e.g.mod tests > fn test_task_contexts)GRAM_SELECTED_TEXT: currently selected textGRAM_WORKTREE_ROOT: absolute path to the root of the current worktree. (e.g./Users/my-user/path/to/project)GRAM_CUSTOM_RUST_PACKAGE: (Rust-specific) name of the parent package of $GRAM_FILE source file.
To use a variable in a task, prefix it with a dollar sign ($):
{
"label": "echo current file's path",
"command": "echo $GRAM_FILE",
}
You can also use verbose syntax that allows specifying a default if a given
variable is not available: ${GRAM_FILE:default_value}
These environmental variables can also be used in tasks’ cwd, args, and
label fields.
Variable Quoting
When working with paths containing spaces or other special characters, please ensure variables are properly escaped.
For example, instead of this (which will fail if the path has a space):
{
"label": "stat current file",
"command": "stat $GRAM_FILE",
}
Provide the following:
{
"label": "stat current file",
"command": "stat",
"args": ["$GRAM_FILE"],
}
Or explicitly include escaped quotes like so:
{
"label": "stat current file",
"command": "stat \"$GRAM_FILE\"",
}
Task filtering based on variables
Task definitions with variables which are not present at the moment the task list is determined are filtered out. For example, the following task will appear in the spawn modal only if there is a text selection:
{
"label": "selected text",
"command": "echo \"$GRAM_SELECTED_TEXT\"",
}
Set default values to such variables to have such tasks always displayed:
{
"label": "selected text with default",
"command": "echo \"${GRAM_SELECTED_TEXT:no text selected}\"",
}
Oneshot tasks
The same task modal opened via task: spawn supports arbitrary bash-like
command execution: type a command inside the modal text field, and use
opt-enter to spawn it.
The task modal persists these ad-hoc commands for the duration of the session,
task: rerun will also rerun such tasks if they were the last ones spawned.
You can also adjust the currently selected task in a modal (tab is the default
key binding). Doing so will put its command into a prompt that can then be
edited & spawned as a oneshot task.
Ephemeral tasks
You can use the cmd modifier when spawning a task via a modal; tasks spawned
this way will not have their usage count increased (thus, they will not be
respawned with task: rerun and they won’t have a high rank in the task modal).
The intended use of ephemeral tasks is to stay in the flow with continuous
task: rerun usage.
More task rerun control
By default, tasks capture their variables into a context once, and this “resolved task” is being rerun always.
This can be controlled with the "reevaluate_context" argument to the task:
setting it to true will force the task to be reevaluated before each run.
{
"context": "Workspace",
"bindings": {
"alt-t": ["task::Rerun", { "reevaluate_context": true }],
},
}
Custom keybindings for tasks
You can define your own keybindings for your tasks via an additional argument to
task::Spawn. If you wanted to bind the aforementioned
echo current file's path task to alt-g, you would add the following snippet
in your keymap.json file:
{
"context": "Workspace",
"bindings": {
"alt-g": ["task::Spawn", { "task_name": "echo current file's path" }],
},
}
Note that these tasks can also have a ‘target’ specified to control where the spawned task should show up. This could be useful for launching a terminal application that you want to use in the center area:
// In tasks.jsonc
{
"label": "start lazygit",
"command": "lazygit -p $GRAM_WORKTREE_ROOT"
}
// In keymap.jsonc
{
"context": "Workspace",
"bindings": {
"alt-g": [
"task::Spawn",
{ "task_name": "start lazygit", "reveal_target": "center" },
],
},
}
Binding runnable tags to task templates
Gram supports overriding the default action for inline runnable indicators via
workspace-local and global tasks.jsonc file with the following precedence
hierarchy:
- Workspace
tasks.jsonc - Global
tasks.jsonc - Language-provided tag bindings (default).
To tag a task, add the runnable tag name to the tags field on the task
template:
{
"label": "echo current file's path",
"command": "echo $GRAM_FILE",
"tags": ["rust-test"],
}
In doing so, you can change which task is shown in the runnables indicator.
Keybindings to run tasks bound to runnables
When you have a task definition that is bound to the runnable, you can quickly
run it using Code Actions that you
can trigger either via editor: Toggle Code Actions command or by the
cmd-./ctrl-. shortcut. Your task will be the first in the dropdown. The task
will run immediately if there are no additional Code Actions for this line.
Themes
Gram comes with a number of built-in themes, with more themes available as extensions.
Selecting a Theme
See what themes are installed and preview them via the Theme Selector, which you
can open from the command palette with theme selector: toggle (bound to theme_selector::Toggle).
Navigating through the theme list by moving up and down will change the theme in real time and hitting enter will save it to your settings file.
Installing more Themes
Gram can use Zed themes so you can install any theme from zed-themes.com, a gallery with visible previews for many of them.
Configuring a Theme
Your selected theme is stored in your settings file. You can open your settings file from the command palette with gram::OpenSettingsFile (bound to gram::OpenSettingsFile).
By default, Gram maintains two themes: one for light mode and one for dark mode.
You can set the mode to "dark" or "light" to ignore the current system mode.
{
"theme": {
"mode": "system",
"light": "One Light",
"dark": "One Dark",
},
}
Theme Overrides
To override specific attributes of a theme, use the theme_overrides setting.
This setting can be used to configure theme-specific overrides.
For example, add the following to your settings.json if you wish to override
the background color of the editor and display comments and doc comments as
italics:
{
"theme_overrides": {
"One Dark": {
"editor.background": "#333",
"syntax": {
"comment": {
"font_style": "italic",
},
"comment.doc": {
"font_style": "italic",
},
},
"accents": [
"#ff0000",
"#ff7f00",
"#ffff00",
"#00ff00",
"#0000ff",
"#8b00ff",
],
},
},
}
To see a comprehensive list of list of captures (like comment and
comment.doc) see
Language Extensions: Syntax highlighting.
To see a list of available theme attributes look at the JSON file for your theme.
Local Themes
Store new themes locally by placing them in the ~/.config/gram/themes
directory (macOS and Linux) or %USERPROFILE%\AppData\Roaming\Gram\themes\
(Windows).
For example, to create a new theme called my-cool-theme, create a file called
my-cool-theme.json in that directory. It will be available in the theme
selector the next time Gram loads.
Theme Development
Toolchains
The toolchain selection UI is used to pick from a set of tools when working with a given language in a current project.
Imagine that you are working in a Python project, which has virtual environments that encapsulate a set of dependencies of your project along with a suitable interpreter to run it with. The language server has to know which virtual environment you are working with, as it uses the virtual environment to resolve dependencies and parse the code in the project.
The toolchain selector UI is used to pick the correct virtual environment for your project.
It’s also possible to select different toolchains for different sub-projects within a Gram project. The exact definition of a sub-project depends on the language used.
In remote projects, use the toolchain selector to control the active toolchain on the remote host.
Why are toolchains necessary?
Language servers need to use the correct toolchain / virtual environment to function properly. If it cannot resolve dependencies, functionality like “Go to definition” or code completion may be unavailable.
If the toolchain provides an “activation script”, the integrated terminal panel will invoke the script automatically so that the shell environment is set up correctly.
This also applies to tasks. Tasks behave as if they were launched from a new terminal tab, so any activation script will be called before executing a task.
Selecting toolchains
The active toolchain (if any) is displayed in the status bar, on the right hand side of the editor window. Clicking it open the toolchain selector. Alternatively, run the command toolchain::Select from the command palette.
The editor will automatically try to infer a set of toolchains to choose from. A default will also be selected on a best-effort basis when opening a project for the first time.
Toolchain selection applies to the current subproject. This might be the whole project, or in the case of a monorepo with multiple subprojects it may apply to the current subproject only.
Adding toolchains manually
If the automatic detection fails to discover all toolchains you can add additional toolchains manually using the “Add toolchain” button in the toolchain selector UI.
Provide a path to the toolchain and give it a descriptive name.
Troubleshooting
This guide covers common troubleshooting techniques for Gram. Sometimes you’ll be able to identify and resolve issues on your own using this information. Other times, troubleshooting means gathering the right information—logs, profiles, or reproduction steps—to help developers diagnose and fix the problem.
Note: To open the command palette, use
cmd-shift-pon macOS orctrl-shift-pon Windows / Linux.
Retrieve Gram and System Information
When reporting issues or seeking help, it’s useful to know your Gram version and system specifications. You can retrieve this information using the following actions from the command palette:
- gram::About: Find your Gram version number
- gram::CopySystemSpecsIntoClipboard: Populate your clipboard with Gram version number, operating system version, and hardware specs
Gram Log
Often, a good first place to look when troubleshooting any issue in Gram is the Gram log, which might contain clues about what’s going wrong. You can review the most recent 1000 lines of the log by running the gram::OpenLog action from the command palette. If you want to view the full file, you can reveal it in your operating system’s native file manager via gram::RevealLogInFileManager from the command palette.
You’ll find the Gram log in the respective location on each operating system:
- macOS:
~/Library/Logs/Gram/Gram.log - Windows:
C:\Users\YOU\AppData\Local\Gram\logs\Gram.log - Linux:
~/.local/share/gram/logs/Gram.logor$XDG_DATA_HOME
Note: In some cases, it might be useful to monitor the log live, such as when developing a Gram extension. Example:
tail -f ~/Library/Logs/Gram/Gram.log
The log may contain enough context to help you debug the issue yourself, or you may find specific errors that are useful when filing an issue.
Performance Issues (Profiling)
If you’re running into performance issues — such as hitches, hangs, or general unresponsiveness — having a performance profile will help zero in on what is getting stuck.
Minidumps
If Gram is crashing you can set GRAM_GENERATE_MINIDUMPS=1 when running Gram to
get the editor to generate a crash dump file that can be analyzed to debug the
issue. See debugging-crashes.md for more
details.
macOS
Xcode Instruments (which comes bundled with Xcode) is the standard tool for profiling on macOS.
- With Gram running, open Instruments
- Select
Time Profileras the profiling template - In the
Time Profilerconfiguration, set the target to the running Gram process - Start recording
- If the performance issue occurs when performing a specific action in Gram, perform that action now
- Stop recording
- Save the trace file
Startup and Workspace Issues
Gram creates local SQLite databases to persist data relating to its workspace and your projects. These databases store, for instance, the tabs and panes you have open in a project, the scroll position of each open file, the list of all projects you’ve opened (for the recent projects modal picker), etc. You can find and explore these databases in the following locations:
- macOS:
~/Library/Application Support/Gram/db - Linux and FreeBSD:
~/.local/share/gram/db(or withinXDG_DATA_HOMEorFLATPAK_XDG_DATA_HOME) - Windows:
%LOCALAPPDATA%\Gram\db
The naming convention of these databases takes on the form of
0-<release_channel>:
- Stable:
0-stable - Dev:
0-dev
While rare, we’ve seen a few cases where workspace databases became corrupted, which prevented Gram from starting. If you’re experiencing startup issues, you can test whether it’s workspace-related by temporarily moving the database from its location, then trying to start Gram again.
Note: Moving the workspace database will cause Gram to create a fresh one. Your recent projects, open tabs, etc. will be reset to “factory”.
If your issue persists after regenerating the database, please file an issue.
Language Server Issues
If you’re experiencing language-server related issues, such as stale diagnostics or issues jumping to definitions, restarting the language server via editor::RestartLanguageServer from the command palette will often resolve the issue.
Unable to watch for file system changes
By default, Gram uses a method native to the current platform to watch for file system changes (inotify on Linux, FSEvents on Mac). For some file systems, this method does not work, for example for NFS or SSHfs mounts, or when connecting to a Windows remote.
It is possible to use a poll-based file watcher on these file systems instead. The polling watcher is more resource-intensive than the native file watchers, but works in more scenarios.
To use the poll watcher, set the file_watcher option in the Worktree settings.
For example:
{
"file_watcher": {
"mode": "poll", // "native" | "poll"
"poll_interval_ms": 2000 // 500-30000ms
}
}
Uninstall
This guide covers how to uninstall Gram on different operating systems.
macOS
Bundle compilation
If you installed Gram by compiling it using the script/bundle-mac.sh command:
- Quit Gram if it’s running
- Open Finder and go to your Applications folder
- Drag Gram to the Trash (or right-click and select “Move to Trash”)
- Empty the Trash
Removing User Data (Optional)
To completely remove all Gram configuration files and data:
- Open Finder
- Press
Cmd + Shift + Gto open “Go to Folder” - Delete the following directories if they exist:
~/Library/Application Support/Gram~/Library/Saved Application State/app.liten.Gram.savedState~/Library/Logs/Gram~/Library/Caches/app.liten.Gram
Linux
Standard Uninstall
If Gram was installed using the default installation script, run:
gram --uninstall
You’ll be prompted whether to keep or delete your preferences. After making a choice, you should see a message that Gram was successfully uninstalled.
If the gram command is not found in your PATH, try:
$HOME/.local/bin/gram --uninstall
or:
$HOME/.local/gram.app/bin/gram --uninstall
Package Manager
If you installed Gram using a package manager (such as Flatpak or a distribution-specific package manager), consult that package manager’s documentation for uninstallation instructions.
Manual Removal
If the uninstall command fails or Gram was installed to a custom location, you can manually remove:
- Installation directory:
~/.local/gram.app(or your custom installation path) - Binary symlink:
~/.local/bin/gram - Configuration and data:
~/.config/gram
Windows
Standard Installation
- Quit Gram if it’s running
- Open Settings (Windows key + I)
- Go to “Apps” > “Installed apps” (or “Apps & features” on Windows 10)
- Search for “Gram”
- Click the three dots menu next to Gram and select “Uninstall”
- Follow the prompts to complete the uninstallation
Alternatively, you can:
- Open the Start menu
- Right-click on Gram
- Select “Uninstall”
Removing User Data (Optional)
To completely remove all Gram configuration files and data:
- Press
Windows key + Rto open Run - Type
%APPDATA%and press Enter - Delete the
Gramfolder if it exists - Press
Windows key + Ragain, type%LOCALAPPDATA%and press Enter - Delete the
Gramfolder if it exists
Troubleshooting
If you encounter issues during uninstallation:
- macOS/Windows: Ensure Gram is completely quit before attempting to uninstall. Check Activity Manager (macOS) or Task Manager (Windows) for any running Gram processes.
- Linux: If the uninstall script fails, check the error message and consider manual removal of the directories listed above.
- All platforms: If you want to start fresh while keeping Gram installed, you can delete the configuration directories instead of uninstalling the application entirely.
For additional help, see the Linux-specific documentation.
Vim Mode
Gram includes an emulation of Vim mode (modal editing). To learn more about Vim and modal editing, see the Vim documentation.
Full compatibility is impossible, but many of the basic features of Vim are supported as well as some features of various vim plugins.
Gram’s vim mode design
The Gram Vim mode tries to offer a familiar experience to Vim users: it replicates the behavior of motions and commands precisely when it makes sense and uses Gram-specific functionality where appropriate.
This includes support for semantic navigation, multiple cursors, or other features usually provided by plugins like surrounding text.
So, Gram’s vim mode does not replicate Vim one-to-one, but meshes Vim’s modal design with Gram’s extended feature set. It’s also possible to add additional key bindings or override the defaults.
Core differences
There are four types of features in vim mode that use Gram’s core functionality, leading to some differences in behavior:
- Motions: vim mode uses Gram’s semantic parsing to tune the behavior of
motions per language. For example, in Rust, jumping to matching bracket with
%works with the pipe character|. In JavaScript,wconsiders$to be a word character. - Visual block selections: vim mode uses Gram’s multiple cursor to emulate visual block selections, making block selections a lot more flexible. For example, anything you insert after a block selection updates on every line in real-time, and you can add or remove cursors anytime.
- Macros: vim mode uses Gram’s recording system for vim macros. So, you can capture and replay more complex actions, like autocompletion.
- Search and replace: vim mode uses Gram’s search system, so, the syntax for regular expressions is slightly different compared to Vim. See the Regex differences section for details.
The foundations of Gram’s vim mode should already cover many use cases, but patches to add features or additional functionality is always welcome.
Enabling and disabling vim mode
Vim mode can be enabled from the Onboarding screen shown when first installing the editor.
Later, vim mode can be toggled on or off at any time using the command workspace::ToggleVimMode.
Note: This command toggles the following property in
settings.json:{ "vim_mode": true, }
Gram-specific features
Gram uses Tree-sitter and the language server protocol to understand the structure of files and supports multiple cursors out of the box.
Vim mode has several “core Gram” key bindings that will help make the most of Gram’s specific feature set.
Language server (LSP)
The following commands use a language server (if available) to help navigate and refactor code semantically.
| Command | Default Shortcut |
|---|---|
| Go to definition | g d |
| Go to declaration | g D |
| Go to type definition | g y |
| Go to implementation | g I |
| Rename (change definition) | c d |
| Go to All references to the current word | g A |
| Find symbol in current file | g s |
| Find symbol in entire project | g S |
| Go to next diagnostic | g ] or ] d |
| Go to previous diagnostic | g [ or [ d |
| Show inline error (hover) | g h |
| Open the code actions menu | g . |
Git
| Command | Default Shortcut |
|---|---|
| Go to next git change | ] c |
| Go to previous git change | [ c |
| Expand diff hunk | d o |
| Toggle staged | d O |
| Stage and next (in diff view) | d u |
| Unstage and next (in diff view) | d U |
| Restore change | d p |
Tree-sitter
Tree-sitter is an open source project independent from Gram which Gram uses to understand the structure of code, and which supports many programming languages. Gram provides motions that change the current cursor position, and text objects that can be used as the target of actions.
| Command | Default Shortcut |
|---|---|
| Go to next/previous method | ] m / [ m |
| Go to next/previous method end | ] M / [ M |
| Go to next/previous section | ] ] / [ [ |
| Go to next/previous section end | ] [ / [ ] |
| Go to next/previous comment | ] /, ] * / [ /, [ * |
| Select a larger syntax node | [ x |
| Select a smaller syntax node | ] x |
| Text Objects | Default Shortcut |
|---|---|
| Around a class, definition, etc. | a c |
| Inside a class, definition, etc. | i c |
| Around a function, method etc. | a f |
| Inside a function, method, etc. | i f |
| A comment | g c |
| An argument, or list item, etc. | i a |
| An argument, or list item, etc. (including trailing comma) | a a |
| Around an HTML-like tag | a t |
| Inside an HTML-like tag | i t |
| The current indent level, and one line before and after | a I |
| The current indent level, and one line before | a i |
| The current indent level | i i |
Note that the definitions for the targets of the [m family of motions are the
same as the boundaries defined by af. The targets of the [[ are the same as
those defined by ac, though if there are no classes, then functions are also
used. Similarly gc is used to find [ /. g c
The definition of functions, classes and comments is language dependent, and
support can be added to extensions by adding a [textobjects.scm]. The
definition of arguments and tags operates at the Tree-sitter level, but looks
for certain patterns in the parse tree and is not currently configurable per
language.
Multi cursor
Vim does not support multiple cursors out of the box, but these commands can be used in Gram to manipulate them.
| Command | Default Shortcut |
|---|---|
| Add a cursor selecting the next copy of the current word | g l |
| Add a cursor selecting the previous copy of the current word | g L |
| Skip latest word selection, and add next | g > |
| Skip latest word selection, and add previous | g < |
| Add a visual selection for every copy of the current word | g a |
Pane management
These commands open new panes or jump to specific panes.
| Command | Default Shortcut |
|---|---|
| Open a project-wide search | g / |
| Open the current search excerpt | g <space> |
| Open the current search excerpt in a split | <ctrl-w> <space> |
| Go to definition in a split | <ctrl-w> g d |
| Go to type definition in a split | <ctrl-w> g D |
In insert mode
The following commands control Gram’s completion menu.
| Command | Default Shortcut |
|---|---|
| Open the completion menu | ctrl-x ctrl-o |
| Open the code actions menu | ctrl-x ctrl-l |
| Hides all suggestions | ctrl-x ctrl-z |
Supported plugins
Gram’s vim mode includes some features that are usually provided by popular plugins in the Vim ecosystem:
- Surround text objects with
ys(yank surround), change surrounding withcs, and delete surrounding withds. - Comment and uncomment selections with
gcin visual mode andgccin normal mode. - The project panel supports many shortcuts modeled after the Vim plugin
netrw: navigation withhjkl, open file witho, open file in a new tab witht, etc. - It’s possible to add key bindings to your keymap to navigate “camelCase” names. See the optional key bindings section to learn how.
- Use
gRto do ReplaceWithRegister. - Use
cxfor vim-exchange functionality. Note that it does not have a default binding in visual mode, but you can add one to your keymap (refer to the optional key bindings section). - Navigate to indent depths relative to your cursor with the
indent wise plugin
[-,]-,[+,]+,[=,]=. - Select quoted text with AnyQuotes and bracketed text with AnyBrackets text objects. Gram also provides MiniQuotes and MiniBrackets which offer alternative selection behavior based on the mini.ai Neovim plugin. See the Quote and Bracket text objects section below for details.
- It’s possible to configure AnyQuotes, AnyBrackets, MiniQuotes, and MiniBrackets text objects for selecting quoted and bracketed text using different selection strategies. See the Any Bracket Functionality section below for details.
Any Bracket Functionality
Gram offers two different strategies for selecting text surrounded by any quote, or any bracket. These text objects are not enabled by default and must be configured in your keymap to be used.
Included Characters
Each text object type works with specific characters:
| Text Object | Characters |
|---|---|
| AnyQuotes/MiniQuotes | Single quote ('), Double quote ("), Backtick (`) |
| AnyBrackets/MiniBrackets | Parentheses (()), Square brackets ([]), Curly braces ({}), Angle brackets (<>) |
Both “Any” and “Mini” variants work with the same character sets, but differ in their selection strategy.
AnyQuotes and AnyBrackets (Traditional Vim behavior)
These text objects implement traditional Vim behavior:
- Selection priority: Finds the innermost (closest) quotes or brackets first
- Fallback mechanism: If none are found, falls back to the current line
- Character-based matching: Focuses solely on open and close characters without considering syntax
- Vanilla Vim similarity: AnyBrackets matches the behavior of commands like
ci<,ci(, etc., in vanilla Vim, including potential edge cases (like considering>in=>as a closing delimiter)
MiniQuotes and MiniBrackets (mini.ai behavior)
These text objects implement the behavior of the mini.ai Neovim plugin:
- Selection priority: Searches the current line first before expanding outward
- Tree-sitter integration: Uses Tree-sitter queries for more context-aware selections
- Syntax-aware matching: Can distinguish between actual brackets and similar
characters in other contexts (like
>in=>)
Choosing Between Approaches
-
Use AnyQuotes/AnyBrackets if you:
- Prefer traditional Vim behavior
- Want consistent character-based selection prioritizing innermost delimiters
- Need behavior that closely matches vanilla Vim’s text objects
-
Use MiniQuotes/MiniBrackets if you:
- Prefer the mini.ai plugin behavior
- Want more context-aware selections using Tree-sitter
- Prefer current-line priority when searching
Example Configuration
To use these text objects, you need to add bindings to your keymap. Here’s an
example configuration that makes them available when using text object operators
(i and a) or change-surrounds (cs):
{
"context": "vim_operator == a || vim_operator == i || vim_operator == cs",
"bindings": {
// Traditional Vim behavior
"q": "vim::AnyQuotes",
"b": "vim::AnyBrackets",
// mini.ai plugin behavior
"Q": "vim::MiniQuotes",
"B": "vim::MiniBrackets",
},
}
With this configuration, you can use commands like:
cib- Change inside brackets using AnyBrackets behaviorciB- Change inside brackets using MiniBrackets behaviorciq- Change inside quotes using AnyQuotes behaviorciQ- Change inside quotes using MiniQuotes behavior
Command palette
Vim mode allows you to open Gram’s command palette with :. You can then type
to access any usual Gram command. Additionally, vim mode adds aliases for
popular Vim commands to ensure your muscle memory transfers to Gram. For
example, you can write :w or :write to save the file.
Below, you’ll find tables listing the commands you can use in the command palette. We put optional characters in square brackets to indicate that you can omit them.
Note: Gram does not emulate the full power of Vim’s command line yet. Commands currently do not support arguments, and full command history is not available.
File and window management
This table shows commands for managing windows, tabs, and panes. As commands don’t support arguments currently, you cannot specify a filename when saving or creating a new file.
| Command | Description |
|---|---|
:w[rite][!] | Save the current file |
:wq[!] | Save the file and close the buffer |
:q[uit][!] | Close the buffer |
:wa[ll][!] | Save all open files |
:wqa[ll][!] | Save all open files and close all buffers |
:qa[ll][!] | Close all buffers |
:[e]x[it][!] | Close the buffer |
:up[date] | Save the current file |
:cq | Quit completely (close all running instances of Gram) |
:vs[plit] | Split the pane vertically |
:sp[lit] | Split the pane horizontally |
:new | Create a new file in a horizontal split |
:vne[w] | Create a new file in a vertical split |
:tabedit | Create a new file in a new tab |
:tabnew | Create a new file in a new tab |
:tabn[ext] | Go to the next tab |
:tabp[rev] | Go to previous tab |
:tabc[lose] | Close the current tab |
:ls | Show all buffers |
Note: The
!character is used to force the command to execute without saving changes or prompting before overwriting a file.
Ex commands
These ex commands open Gram’s various panels and windows.
| Command | Default Shortcut |
|---|---|
| Open the project panel | :E[xplore] |
| Open the git panel | :G[it] |
| Open the debug panel | :D[ebug] |
| Open the notifications panel | :No[tif] |
| Open the diagnostics window | :cl[ist] |
| Open the terminal | :te[rm] |
| Open the extensions window | :Ext[ensions] |
Navigating diagnostics
These commands navigate diagnostics.
| Command | Description |
|---|---|
:cn[ext] or :ln[ext] | Go to the next diagnostic |
:cp[rev] or :lp[rev] | Go to the previous diagnostics |
:cc or :ll | Open the errors page |
Git
These commands interact with the version control system git.
| Command | Description |
|---|---|
:dif[fupdate] | View the diff under the cursor (d o in normal mode) |
:rev[ert] | Revert the diff under the cursor (d p in normal mode) |
Jump
These commands jump to specific positions in the file.
| Command | Description |
|---|---|
:<number> | Jump to a line number |
:$ | Jump to the end of the file |
:/foo and :?foo | Jump to next/prev line matching foo |
Replacement
This command replaces text. It emulates the substitute command in vim. The
substitute command uses regular expressions, and Gram uses a slightly different
syntax than vim. You can learn more about Gram’s syntax below,
in the regex differences section. Gram will replace only
the first occurrence of the search pattern in the current line. To replace all
matches append the g flag.
| Command | Description |
|---|---|
:[range]s/foo/bar/[g] | Replace instances of foo with bar |
Editing
These commands help you edit text.
| Command | Description |
|---|---|
:j[oin] | Join the current line |
:d[elete][l][p] | Delete the current line |
:s[ort] [i] | Sort the current selection (with i, case-insensitively) |
:y[ank] | Yank (copy) the current selection or line |
Set
These commands modify editor options locally for the current buffer.
| Command | Description |
|---|---|
:se[t] [no]wrap | Lines longer than the width of the window will wrap and displaying continues on the next line |
:se[t] [no]nu[mber] | Print the line number in front of each line |
:se[t] [no]r[elative]nu[mber] | Changes the displayed number to be relative to the cursor |
:se[t] [no]i[gnore]c[ase] | Controls whether the buffer and project search use case-sensitive matching |
Command mnemonics
As any Gram command is available, you may find that it’s helpful to remember mnemonics that run the correct command. For example:
:diffsfor “toggle all hunk diffs”:cppfor “copy path to file”:crpfor “copy relative path”:revealfor “reveal in finder”:zlogfor “open gram log”:clankfor “cancel language server work”
Customizing key bindings
In this section, we’ll learn how to customize the key bindings of Gram’s vim mode. You’ll learn:
- How to select the correct context for your new key bindings.
- Useful contexts for vim mode key bindings.
- Common key bindings to customize for extra productivity.
Selecting the correct context
Gram’s key bindings are evaluated only when the "context" property matches
your location in the editor. For example, if you add key bindings to the
"Editor" context, they will only work when you’re editing a file. If you add
key bindings to the "Workspace" context, they will work everywhere in Gram.
Here’s an example of a key binding that saves when you’re editing a file:
{
"context": "Editor",
"bindings": {
"ctrl-s": "file::Save",
},
}
Contexts are nested, so when you’re editing a file, the context is the
"Editor" context, which is inside the "Pane" context, which is inside the
"Workspace" context. That’s why any key bindings you add to the "Workspace"
context will work when you’re editing a file. Here’s an example:
// This key binding will work when you're editing a file. It comes built into Gram by default as the workspace: save command.
{
"context": "Workspace",
"bindings": {
"ctrl-s": "workspace::Save",
},
}
Contexts are expressions. They support boolean operators like && (and) and
|| (or). For example, you can use the context "Editor && vim_mode == normal"
to create key bindings that only work when you’re editing a file and you’re in
vim’s normal mode.
Vim mode adds several contexts to the "Editor" context:
| Operator | Description |
|---|---|
| VimControl | Indicates that vim keybindings should work. Currently an alias for vim_mode == normal || vim_mode == visual || vim_mode == operator, but the definition may change over time |
| vim_mode == normal | Normal mode |
| vim_mode == visual | Visual mode |
| vim_mode == insert | Insert mode |
| vim_mode == replace | Replace mode |
| vim_mode == waiting | Waiting for an arbitrary key (e.g., after typing f or t) |
| vim_mode == operator | Waiting for another binding to trigger (e.g., after typing c or d) |
| vim_operator | Set to none unless vim_mode == operator, in which case it is set to the current operator’s default keybinding (e.g., after typing d, vim_operator == d) |
Note: Contexts are matched only on one level at a time. So it is possible to use the expression
"Editor && vim_mode == normal", but"Workspace && vim_mode == normal"will never match because we set the vim context at the"Editor"level.
Useful contexts for vim mode key bindings
Here’s a template with useful vim mode contexts to help you customize your vim mode key bindings. You can copy it and integrate it into your user keymap.
[
{
"context": "VimControl && !menu",
"bindings": {
// Put key bindings here if you want them to work in normal & visual mode.
},
},
{
"context": "vim_mode == normal && !menu",
"bindings": {
// "shift-y": ["workspace::SendKeystrokes", "y $"] // Use neovim's yank behavior: yank to end of line.
},
},
{
"context": "vim_mode == insert",
"bindings": {
// "j k": "vim::NormalBefore" // In insert mode, make jk escape to normal mode.
},
},
{
"context": "EmptyPane",
"bindings": {
// Put key bindings here (in addition to the context above) if you want them to
// work when no editor exists.
// "space f": "file_finder::Toggle"
},
},
]
Note: If you would like to emulate Vim’s
mapcommands (nmap, etc.), you can use the actionworkspace::SendKeystrokesin the correct context.
Optional key bindings
By default, you can navigate between the different files open in the editor with
shortcuts like ctrl+w followed by one of hjkl to move to the left, down, up,
or right, respectively.
But you cannot use the same shortcuts to move between all the editor docks (the terminal, project panel, …). If you want to use the same shortcuts to navigate to the docks, you can add the following key bindings to your user keymap.
{
"context": "Dock",
"bindings": {
"ctrl-w h": "workspace::ActivatePaneLeft",
"ctrl-w l": "workspace::ActivatePaneRight",
"ctrl-w k": "workspace::ActivatePaneUp",
"ctrl-w j": "workspace::ActivatePaneDown",
// ... or other keybindings
},
}
Subword motion, which allows you to navigate and select individual words in
camelCase or snake_case, is not enabled by default. To enable it, add these
bindings to your keymap.
{
"context": "VimControl && !menu && vim_mode != operator",
"bindings": {
"w": "vim::NextSubwordStart",
"b": "vim::PreviousSubwordStart",
"e": "vim::NextSubwordEnd",
"g e": "vim::PreviousSubwordEnd",
},
}
Note: Operations like
dwremain unaffected. If you would like operations to also use subword motion, removevim_mode != operatorfrom thecontext.
Vim mode comes with shortcuts to surround the selection in normal mode (ys),
but it doesn’t have a shortcut to add surrounds in visual mode. By default,
shift-s substitutes the selection (erases the text and enters insert mode). To
use shift-s to add surrounds in visual mode, you can add the following object
to your keymap.
{
"context": "vim_mode == visual",
"bindings": {
"shift-s": "vim::PushAddSurrounds",
},
}
In non-modal text editors, cursor navigation typically wraps when moving past line ends. Gram, however, handles this behavior exactly like Vim by default: the cursor stops at line boundaries. If you prefer your cursor to wrap between lines, override these keybindings:
// In VimScript, this would look like this:
// set whichwrap+=<,>,[,],h,l
{
"context": "VimControl && !menu",
"bindings": {
"left": "vim::WrappingLeft",
"right": "vim::WrappingRight",
"h": "vim::WrappingLeft",
"l": "vim::WrappingRight",
},
}
The Sneak motion feature allows for
quick navigation to any two-character sequence in your text. You can enable it
by adding the following keybindings to your keymap. By default, the s key is
mapped to vim::Substitute. Adding these bindings will override that behavior,
so ensure this change aligns with your workflow preferences.
{
"context": "vim_mode == normal || vim_mode == visual",
"bindings": {
"s": "vim::PushSneak",
"shift-s": "vim::PushSneakBackward",
},
}
The Helix-style jump-to-word action shows jump labels at visible word starts. It
has no default binding in Vim mode, but you can enable it by adding a keybinding
to your keymap. This example uses g w, which matches the default Helix
binding, but overrides Vim mode’s default rewrap binding.
{
"context": "vim_mode == normal || vim_mode == visual",
"bindings": {
"g w": "vim::HelixJumpToWord"
}
}
The vim-exchange feature does not
have a default binding for visual mode, as the shift-x binding conflicts with
the default shift-x binding for visual mode (vim::VisualDeleteLine). To
assign the default vim-exchange binding, add the following keybinding to your
keymap:
{
"context": "vim_mode == visual",
"bindings": {
"shift-x": "vim::Exchange",
},
}
Restoring common text editing and Gram keybindings
If you’re using vim mode on Linux or Windows, you may find it overrides
keybindings you can’t live without: ctrl+v to paste, ctrl+f to search, etc.
You can restore them by copying this data into your keymap:
{
"context": "Editor && !menu",
"bindings": {
"ctrl-c": "editor::Copy", // vim default: return to normal mode
"ctrl-x": "editor::Cut", // vim default: decrement
"ctrl-v": "editor::Paste", // vim default: visual block mode
"ctrl-y": "editor::Undo", // vim default: line up
"ctrl-f": "buffer_search::Deploy", // vim default: page down
"ctrl-o": "workspace::Open", // vim default: go back
"ctrl-s": "workspace::Save", // vim default: show signature
"ctrl-a": "editor::SelectAll", // vim default: increment
"ctrl-b": "workspace::ToggleLeftDock" // vim default: down
}
},
Changing vim mode settings
You can change the following settings to modify vim mode’s behavior:
| Property | Description | Default Value |
|---|---|---|
| default_mode | The default mode to start in. One of “normal”, “insert”, “replace”, “visual”, “visual_line”, “visual_block”, “helix_normal”. | “normal” |
| use_system_clipboard | Determines how system clipboard is used:
| “always” |
| use_multiline_find | deprecated | |
| use_smartcase_find | If true, f and t motions are case-insensitive when the target letter is lowercase. | false |
| toggle_relative_line_numbers | If true, line numbers are relative in normal mode and absolute in insert mode, giving you the best of both options. | false |
| custom_digraphs | An object that allows you to add custom digraphs. Read below for an example. | {} |
| highlight_on_yank_duration | The duration of the highlight animation(in ms). Set to 0 to disable | 200 |
Here’s an example of adding a digraph for the zombie emoji. This allows you to
type ctrl-k f z to insert a zombie emoji. You can add as many digraphs as you
like.
{
"vim": {
"custom_digraphs": {
"fz": "🧟♀️",
},
},
}
Here’s an example of these settings changed:
{
"vim": {
"default_mode": "insert",
"use_system_clipboard": "never",
"use_smartcase_find": true,
"relative_line_numbers": "enabled",
"highlight_on_yank_duration": 50,
"custom_digraphs": {
"fz": "🧟♀️",
},
},
}
Useful core Gram settings for vim mode
Here are a few general Gram settings that can help you fine-tune your Vim experience:
| Property | Description | Default Value |
|---|---|---|
| cursor_blink | If true, the cursor blinks. | true |
| relative_line_numbers | If "enabled", line numbers in the left gutter are relative to the cursor. If "wrapped", they also display for wrapped lines. | "disabled" |
| scrollbar | Object that controls the scrollbar display. Set to { "show": "never" } to hide the scroll bar. | { "show": "auto" } |
| scroll_beyond_last_line | If set to "one_page", allows scrolling up to one page beyond the last line. Set to "off" to prevent this behavior. | "one_page" |
| vertical_scroll_margin | The number of lines to keep above or below the cursor when scrolling. Set to 0 to allow the cursor to go up to the edges of the screen vertically. | 3 |
| gutter.line_numbers | Controls the display of line numbers in the gutter. Set the "line_numbers" property to false to hide line numbers. | true |
| command_aliases | Object that defines aliases for commands in the command palette. You can use it to define shortcut names for commands you use often. Read below for examples. | {} |
Here’s an example of these settings changed:
{
// Disable cursor blink
"cursor_blink": false,
// Use relative line numbers
"relative_line_numbers": "enabled",
// Hide the scroll bar
"scrollbar": { "show": "never" },
// Prevent the buffer from scrolling beyond the last line
"scroll_beyond_last_line": "off",
// Allow the cursor to reach the edges of the screen
"vertical_scroll_margin": 0,
"gutter": {
// Disable line numbers completely
"line_numbers": false,
},
"command_aliases": {
"W": "w",
"Wq": "wq",
"Q": "q",
},
}
The command_aliases property is a single object that maps keys or key
sequences to vim mode commands. The example above defines multiple aliases: W
for w, Wq for wq, and Q for q.
Regex differences
Gram uses a different regular expression engine from Vim. This means that you will have to use a different syntax in some cases. Here are the most common differences:
- Capture groups: Vim uses
\(and\)to represent capture groups, in Gram these are(and). On the flip side, in Vim,(and)represent literal parentheses, but in Gram these must be escaped to\(and\). - Matches: When replacing, Vim uses the backslash character followed by a
number to represent a matched capture group. For example,
\1. Gram uses the dollar sign instead. So, when in Vim you use\0to represent the entire match, in Gram the syntax is$0instead. Same for numbered capture groups:\1in Vim is$1in Gram. - Global option: By default, in Vim, regex searches only match the first
occurrence on a line, and you append
/gat the end of your query to find all matches. In Gram, regex searches are global by default. - Case sensitivity: Vim uses
/ito indicate a case-insensitive search. In Gram you can either write(?i)at the start of the pattern or toggle case-sensitivity with the shortcut search::ToggleCaseSensitive.
Note: To help with the transition, the command palette will fix parentheses and replace groups for you when you write a Vim-style substitute command,
:%s//. So, Gram will convert%s:/\(a\)(b)/\1/into a search for “(a)(b)” and a replacement of “$1”.
For the full syntax supported by Gram’s regex engine see the regex crate documentation.
Smaller tips for vim users
Space as leader and default keybindings
The default key bindings for space interfere with using space as leader, and in particular getting the which key-popup to stay open. To fix this, add this key binding to your user keymap:
// Make which-key persist longer by disabling
// the default action vim::WrappingRight
{
"context": "(VimControl && !menu)",
"bindings": {
"space": null
}
}
Note that this overrides a default binding, so this is mainly for those that want to use space as the leader key.
Keep selection during indent/outdent
This is a common rebinding used by vim users to retain the block selection after
indent and outdent using the < and < keys, allowing you to hit the keys
multiple times to indent/outdent to the desired depth:
// keep selection during indent/outdent
{
"context": "vim_mode == visual",
"bindings": {
"<": ["workspace::SendKeystrokes", "< g v"],
">": ["workspace::SendKeystrokes", "> g v"]
}
}
Visual Customization
Various aspects of Gram’s visual layout can be configured via either the
settings window or the settings.json file.
These commands can be used to open the settings UI or file:
- gram::OpenSettings (gram::OpenSettings)
- gram::OpenSettingsFile (gram::OpenSettingsFile)
See Configuring Gram for additional information and other non-visual settings.
Themes
Themes and Icon themes can be installed as extensions. Most Zed extension themes and icon themes should be compatible.
Command: gram::Extensions.
Preview and choose the current theme using the theme selectors: theme_selector::Toggle (theme_selector::Toggle) and icon_theme_selector::Toggle.
The selectors will modify these settings:
{
"theme": "One Dark",
"icon_theme": "Gram (Default)",
}
Distinct themes for light mode/dark mode can be set like this:
{
"theme": {
"dark": "One Dark",
"light": "One Light",
// Mode to use (dark, light) or "system" to follow the OS's light/dark mode (default)
"mode": "system",
},
"icon_theme": {
"dark": "Gram (Default)",
"light": "Gram (Default)",
// Mode to use (dark, light) or "system" to follow the OS's light/dark mode (default)
"mode": "system",
},
}
Fonts
// UI Font. Use ".SystemUIFont" to use the default system font (SF Pro on macOS),
// or ".GramSans" for the bundled default.
"ui_font_family": ".SystemUIFont",
"ui_font_weight": 400, // Font weight in standard CSS units from 100 to 900.
"ui_font_size": 16,
// Buffer Font - Used by editor buffers
// use ".GramMono" for the bundled default monospace
"buffer_font_family": "Berkeley Mono", // Font name for editor buffers
"buffer_font_size": 15, // Font size for editor buffers
"buffer_font_weight": 400, // Font weight in CSS units [100-900]
// Line height "comfortable" (1.618), "standard" (1.3) or custom: `{ "custom": 2 }`
"buffer_line_height": "comfortable",
// Terminal Font Settings
"terminal": {
"font_family": "",
"font_size": 15,
// Terminal line height: comfortable (1.618), standard(1.3) or `{ "custom": 2 }`
"line_height": "standard",
},
Font ligatures
Font ligatures visually combine certain adjacent characters. For example, =>
is displayed as → and != as ≠.
This is purely cosmetic and the individual characters remain unchanged.
To disable this behavior use:
{
"buffer_font_features": {
"calt": false, // Disable ligatures
},
}
Status Bar
{
// Whether to show full labels in line indicator or short ones
// - `short`: "2 s, 15 l, 32 c"
// - `long`: "2 selections, 15 lines, 32 characters"
"line_indicator_format": "long",
// Individual status bar icons can be hidden:
// "project_panel": {"button": false },
// "outline_panel": {"button": false },
// "git_panel": {"button": false },
// "debugger": {"button": false },
// "diagnostics": {"button": false },
// "search": {"button": false },
}
Titlebar
// Control which items are shown/hidden in the title bar
"title_bar": {
"show": true, // Show/hide the title bar itself
"show_branch_icon": false, // Show/hide branch icon beside branch switcher
"show_branch_name": true, // Show/hide branch name
"show_project_items": true, // Show/hide project host and name
"show_onboarding_banner": true, // Show/hide onboarding banners
"show_user_picture": true, // Show/hide user avatar
"show_menus": false // Show/hide menus
},
Workspace
{
// Force usage of Gram build in path prompts (file and directory pickers)
// instead of OS native pickers (false).
"use_system_path_prompts": true,
// Force usage of Gram built in confirmation prompts ("Do you want to save?")
// instead of OS native prompts (false). On linux this is ignored (always false).
"use_system_prompts": true,
// Active pane styling settings.
"active_pane_modifiers": {
// Inset border size of the active pane, in pixels.
"border_size": 0.0,
// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
"inactive_opacity": 1.0,
},
// Layout mode of the bottom dock: contained, full, left_aligned, right_aligned
"bottom_dock_layout": "contained",
// Whether to resize all the panels in a dock when resizing the dock.
// Can be a combination of "left", "right" and "bottom".
"resize_all_panels_in_dock": ["left"],
}
Editor
// Whether the cursor blinks in the editor.
"cursor_blink": true,
// Cursor shape for the default editor: bar, block, underline, hollow
"cursor_shape": null,
// Highlight the current line in the editor: none, gutter, line, all
"current_line_highlight": "all",
// When does the mouse cursor hide: never, on_typing, on_typing_and_movement
"hide_mouse": "on_typing_and_movement",
// Whether to highlight all occurrences of the selected text in an editor.
"selection_highlight": true,
// Visually show tabs and spaces (none, all, selection, boundary, trailing)
"show_whitespaces": "selection",
"whitespace_map": { // Which characters to show when `show_whitespaces` enabled
"space": "•",
"tab": "⟶" // use "→", for a shorter arrow
},
"unnecessary_code_fade": 0.3, // How much to fade out unused code.
// Defines window border radius for platforms that use client side decorations.
"client_side_decoration_rounding": 10.0,
// Defines window shadow size for platforms that use client side decorations.
"client_side_decoration_shadow": 10.0,
// Hide the values of in variables from visual display in private files
"redact_private_values": false,
// Soft-wrap and rulers
"soft_wrap": "none", // none, editor_width, preferred_line_length, bounded
"preferred_line_length": 80, // Column to soft-wrap
"show_wrap_guides": true, // Show/hide wrap guides (vertical rulers)
"wrap_guides": [], // Where to position wrap_guides (character counts)
// Gutter Settings
"gutter": {
"line_numbers": true, // Show/hide line numbers in the gutter.
"runnables": true, // Show/hide runnables buttons in the gutter.
"breakpoints": true, // Show/hide show breakpoints in the gutter.
"folds": true, // Show/hide show fold buttons in the gutter.
"min_line_number_digits": 4 // Reserve space for N digit line numbers
},
"relative_line_numbers": "enabled", // Show relative line numbers in gutter
// Indent guides
"indent_guides": {
"enabled": true,
"line_width": 1, // Width of guides in pixels [1-10]
"active_line_width": 1, // Width of active guide in pixels [1-10]
"coloring": "fixed", // disabled, fixed, indent_aware
"background_coloring": "disabled" // disabled, indent_aware
},
// Smooth scrolling
"smooth_scroll": {
"enabled": false // Whether to animate scrolling with a smooth easing effect. Disabled by default.
"duration": 160 // Duration of the scrolling animation (ms)
},
"sticky_scroll": {
"enabled": false // Whether to stick scopes to the top of the editor. Disabled by default.
}
Git Blame
"git": {
"split_diff": false, // Open diffs side by side
"inline_blame": {
"enabled": true, // Show/hide inline blame
"delay_ms": 0, // Show after delay (ms)
"min_column": 0, // Minimum column to inline display blame
"padding": 7, // Padding between code and inline blame (em)
"show_commit_summary": false // Show/hide commit summary
},
"hunk_style": "staged_hollow" // staged_hollow, unstaged_hollow
}
Editor Toolbar
// Editor toolbar related settings
"toolbar": {
"breadcrumbs": true, // Whether to show breadcrumbs.
"quick_actions": true, // Whether to show quick action buttons.
"selections_menu": true, // Whether to show the Selections menu
"code_actions": false // Whether to show code action buttons
}
Editor Scrollbar and Minimap
// Scrollbar related settings
"scrollbar": {
// When to show the scrollbar in the editor (auto, system, always, never)
"show": "auto",
"cursors": true, // Show cursor positions in the scrollbar.
"git_diff": true, // Show git diff indicators in the scrollbar.
"search_results": true, // Show buffer search results in the scrollbar.
"selected_text": true, // Show selected text occurrences in the scrollbar.
"selected_symbol": true, // Show selected symbol occurrences in the scrollbar.
"diagnostics": "all", // Show diagnostics (none, error, warning, information, all)
"axes": {
"horizontal": true, // Show/hide the horizontal scrollbar
"vertical": true // Show/hide the vertical scrollbar
}
},
// Minimap related settings
"minimap": {
"show": "never", // When to show (auto, always, never)
"display_in": "active_editor", // Where to show (active_editor, all_editor)
"thumb": "always", // When to show thumb (always, hover)
"thumb_border": "left_open", // Thumb border (left_open, right_open, full, none)
"max_width_columns": 80, // Maximum width of minimap
"current_line_highlight": null // Highlight current line (null, line, gutter)
},
// Control Editor scroll beyond the last line: off, one_page, vertical_scroll_margin
"scroll_beyond_last_line": "one_page",
// Lines to keep above/below the cursor when scrolling with the keyboard
"vertical_scroll_margin": 3,
// The number of characters to keep on either side when scrolling with the mouse
"horizontal_scroll_margin": 5,
// Scroll sensitivity multiplier
"scroll_sensitivity": 1.0,
// Scroll sensitivity multiplier for fast scrolling (hold alt while scrolling)
"fast_scroll_sensitivity": 4.0,
Editor Tabs
// Maximum number of tabs per pane. Unset for unlimited.
"max_tabs": null,
// Customize the tab bar appearance
"tab_bar": {
"show": true, // Show/hide the tab bar
"show_nav_history_buttons": true, // Show/hide history buttons on tab bar
"show_tab_bar_buttons": "on_pane_focus" // When to show tab bar buttons (new, split, zoom)
},
"tabs": {
"git_status": false, // Color to show git status
"close_position": "right", // Close button position (left, right, hidden)
"show_close_button": "hover", // Close button shown (hover, always, hidden)
"file_icons": false, // Icon showing file type
// Show diagnostics in file icon (off, errors, all). Requires file_icons=true
"show_diagnostics": "off"
}
Status Bar
"status_bar": {
// Show/hide a button that displays the active buffer's language.
// Clicking the button brings up the language selector.
// Defaults to true.
"active_language_button": true,
// Show/hide a button that displays the cursor's position.
// Clicking the button brings up an input for jumping to a line and column.
// Defaults to true.
"cursor_position_button": true,
// Show/hide a button that displays the buffer's line-ending mode.
// Clicking the button brings up the line-ending selector.
// Defaults to false.
"line_endings_button": false,
// Show/hide a button that displays the buffer's character encoding.
// If set to "non_utf8", the button is hidden only for UTF-8 without BOM.
// Defaults to "non_utf8".
"active_encoding_button": "non_utf8",
// Whether to show errors from language servers
// Defaults to true
"show_language_server_errors": true
},
"global_lsp_settings": {
// Show/hide the LSP button in the status bar.
// Activity from the LSP is still shown.
// Button is not shown if "enable_language_server" if false.
"button": true
},
Multibuffer
{
// The default number of lines to expand excerpts in the multibuffer by.
"expand_excerpt_lines": 5,
// The default number of lines of context provided for excerpts in the multibuffer by.
"excerpt_context_lines": 2,
}
Editor Completions, Snippets, Actions, Diagnostics
"snippet_sort_order": "inline", // Snippets completions: top, inline, bottom, none
"show_completions_on_input": true, // Show completions while typing
"show_completion_documentation": true, // Show documentation in completions
"auto_signature_help": false, // Show method signatures inside parentheses
// Whether to show the signature help after completion or a bracket pair inserted.
// If `auto_signature_help` is enabled, this setting will be treated as enabled also.
"show_signature_help_after_edits": false,
// Whether to show code action button at start of buffer line.
"inline_code_actions": true,
// Which level to use to filter out diagnostics displayed in the editor:
"diagnostics_max_severity": null, // off, error, warning, info, hint, null (all)
// How to render LSP `textDocument/documentColor` colors in the editor.
"lsp_document_colors": "inlay", // none, inlay, border, background
// When to show the scrollbar in the completion menu.
"completion_menu_scrollbar": "never", // auto, system, always, never
// How to display the LSP item kind (function, method, variable, etc.)
// of each entry in the completions menu. "symbol" shows a syntax-colored
// single-letter badge.
"completion_menu_item_kind": "off", // off, symbol
// What should the Supertab action do when not completing?
"supertab_fallback": "tab", // tab, indent
// Sync the kill ring (emacs mode)
"sync_kill_ring": "clipboard", // clipboard, primary or none
// Line number scale
"line_number_scale": "default", // default, small, xsmall
// Turn on colorization of brackets in editors (configurable per language)
"colorize_brackets": true,
Editor Inlay Hints
{
"inlay_hints": {
"enabled": false,
// Toggle certain types of hints on and off, all switched on by default.
"show_type_hints": true,
"show_parameter_hints": true,
"show_other_hints": true,
// Whether to show a background for inlay hints (theme `hint.background`)
"show_background": false, //
// Time to wait after editing before requesting hints (0 to disable debounce)
"edit_debounce_ms": 700,
// Time to wait after scrolling before requesting hints (0 to disable debounce)
"scroll_debounce_ms": 50,
// A set of modifiers which, when pressed, will toggle the visibility of inlay hints.
"toggle_on_modifiers_press": {
"control": false,
"shift": false,
"alt": false,
"platform": false,
"function": false,
},
},
}
File Finder
// File Finder Settings
"file_finder": {
"file_icons": true, // Show/hide file icons
"modal_max_width": "small", // Horizontal size: small, medium, large, xlarge, full
"git_status": true, // Show the git status for each entry
"include_ignored": null // gitignored files in results: true, false, null
},
Project Panel
The project panel can be shown/hidden using project_panel::ToggleFocus (project_panel::ToggleFocus) or pane::RevealInProjectPanel (pane::RevealInProjectPanel).
// Project Panel Settings
"project_panel": {
"button": true, // Show/hide button in the status bar
"default_width": 240, // Default panel width
"dock": "left", // Position of the dock (left, right)
"entry_spacing": "comfortable", // Vertical spacing (comfortable, standard)
"file_icons": true, // Show/hide file icons
"folder_icons": true, // Show/hide folder icons
"git_status": true, // Indicate new/updated files
"indent_size": 20, // Pixels for each successive indent
"auto_reveal_entries": true, // Show file in panel when activating its buffer
"auto_fold_dirs": true, // Fold dirs with single subdir
"sticky_scroll": true, // Stick parent directories at top of the project panel.
"drag_and_drop": true, // Whether drag and drop is enabled
"scrollbar": { // Project panel scrollbar settings
"show": null // Show/hide: (auto, system, always, never)
},
"show_diagnostics": "all", //
// Settings related to indent guides in the project panel.
"indent_guides": {
// When to show indent guides in the project panel. (always, never)
"show": "always"
},
// Sort order for entries (directories_first, smart_sort, mixed, files_first)
"sort_mode": "directories_first",
// Whether to hide the root entry when only one folder is open in the window.
"hide_root": false,
// Whether to hide the hidden entries in the project panel.
"hide_hidden": false
}
Terminal Panel
// Terminal Panel Settings
"terminal": {
"dock": "bottom", // Where to dock: left, right, bottom
"button": true, // Show/hide status bar icon
"default_width": 640, // Default width (left/right docked)
"default_height": 320, // Default height (bottom docked)
// Set the cursor blinking behavior in the terminal (on, off, terminal_controlled)
"blinking": "terminal_controlled",
// Default cursor shape for the terminal cursor (block, bar, underline, hollow)
"cursor_shape": "block",
// Environment variables to add to terminal's process environment
"env": {
// "KEY": "value"
},
// Terminal scrollbar
"scrollbar": {
"show": null // Show/hide: (auto, system, always, never)
},
// Terminal Font Settings
"font_family": "Fira Code",
"font_size": 15,
"font_weight": 400,
// Terminal line height: comfortable (1.618), standard(1.3) or `{ "custom": 2 }`
"line_height": "comfortable",
"max_scroll_history_lines": 10000, // Scrollback history (0=disable, max=100000)
}
See Terminal settings for additional non-visual customization options.
Other Panels
// Git Panel
"git_panel": {
"button": true, // Show/hide status bar icon
"dock": "left", // Where to dock: left, right
"default_width": 360, // Default width of the git panel.
"status_style": "icon", // label_color, icon
"sort_by_path": false, // Sort by path (false) or status (true)
"tree_view": false, // Tree (true) or flat list (false)
"diff_stats": true, // Show added/deleted line counts
"scrollbar": {
"show": null // Show/hide: (auto, system, always, never)
}
},
// Debugger Panel
"debugger": {
"dock": "bottom", // Where to dock: left, right, bottom
"button": true // Show/hide status bar icon
},
// Outline Panel
"outline_panel": {
"button": true, // Show/hide status bar icon
"default_width": 300, // Default width of the git panel
"dock": "left", // Where to dock: left, right
"file_icons": true, // Show/hide file_icons
"folder_icons": true, // Show file_icons (true), chevrons (false) for dirs
"git_status": true, // Show git status
"indent_size": 20, // Indentation for nested items (pixels)
"indent_guides": {
"show": "always" // Show indent guides (always, never)
},
"auto_reveal_entries": true, // Show file in panel when activating its buffer
"auto_fold_dirs": true, // Fold dirs with single subdir
"scrollbar": { // Project panel scrollbar settings
"show": null // Show/hide: (auto, system, always, never)
}
}
Gram on Windows
Installing Gram
There are now basic Windows binaries provided with the Codeberg releases.
Otherwise, the editor can be installed by building from source.
Uninstall
- Installed via installer: Use
Settings→Apps→Installed apps, search for Gram, and click Uninstall. - Built from source: Remove the build output directory you created (e.g., your target/install folder).
Settings and extensions are stored in your user profile. When uninstalling, you can choose to keep or remove them.
Remote Development (SSH)
Gram supports remote development on Windows through both SSH and WSL. You can connect to remote servers via SSH or work with files inside WSL distributions directly from Gram.
For detailed instructions on setting up and using remote development features, including SSH configuration, WSL setup, and troubleshooting, see the Remote Development documentation.
Troubleshooting
Gram fails to start or shows a blank window
- Check that your hardware and operating system version are compatible with Gram.
- Update your GPU drivers from your GPU vendor (Intel/AMD/NVIDIA/Qualcomm).
- Ensure hardware acceleration is enabled in Windows and not blocked by third‑party software.
- Try launching Gram with no extensions or custom settings to isolate conflicts.
Terminal issues
If activation scripts don’t run, update to the latest version and verify your shell profile files are not exiting early. For Git operations, confirm Git Bash or PowerShell is available and on PATH.
SSH remoting problems
When prompted for credentials, use the graphical askpass dialog. If it doesn’t appear, check for credential manager conflicts and that GUI prompts aren’t blocked by your terminal.
Graphics issues
Gram fails to open / degraded performance
Gram requires a DirectX 11 compatible GPU to run. If Gram fails to open, your GPU may not meet the minimum requirements.
To check if your GPU supports DirectX 11, run the following command:
dxdiag
This will open the DirectX Diagnostic Tool, which shows the DirectX version your
GPU supports under System → System Information → DirectX Version.
If you’re running Gram inside a virtual machine, it will use the emulated adapter provided by your VM. While Gram will work in this environment, performance may be degraded.
Developing Gram
See the platform-specific instructions for building Gram from source:
System Requirements
Rust is notoriously memory hungry, and Gram is a huge Rust project. The minimum requirement for compiling the project seems to be somewhere around 16GB of RAM, and at least 8GB available for compilation.
Linking is the part of the process which takes the most RAM, and alternative
linkers may offer better performance and lower RAM usage. Check the platform
specific instructions for more details on compiling with an alternative linker
like wild or mold.
If you have a lot of CPU cores, Rust will try to use all of them and may require
even more RAM as a consequence. You can limit the level of concurrency by
setting the CARGO_BUILD_JOBS environment variable. For example, if you have 16
CPU cores available, Cargo will run up to 16 jobs in parallel. By setting
CARGO_BUILD_JOBS=8 you can reduce RAM usage by only running up to 8 jobs in
parallel.
To build with less than 12GB of RAM, try setting these environment variables:
MAKEOPTS="-j2 -l2"
CARGO_BUILD_JOBS=1
It’s also possible that using an alternative linker like wild or mold may
use less memory.
Performance Measurements
Gram includes a frame time measurement system that can be used to profile how long it takes to render each frame. This is particularly useful when comparing rendering performance between different versions or when optimizing frame rendering code.
Using GRAM_MEASUREMENTS
To enable performance measurements, set the GRAM_MEASUREMENTS environment
variable:
export GRAM_MEASUREMENTS=1
When enabled, Gram will print frame rendering timing information to stderr, showing how long each frame takes to render.
Performance Comparison Workflow
Here’s a typical workflow for comparing frame rendering performance between different versions:
-
Enable measurements:
export GRAM_MEASUREMENTS=1 -
Test the first version:
- Checkout the commit you want to measure
- Run Gram in release mode and use it for 5-10 seconds:
cargo run --release &> version-a
-
Test the second version:
- Checkout another commit you want to compare
- Run Gram in release mode and use it for 5-10 seconds:
cargo run --release &> version-b
-
Generate comparison:
script/histogram.py version-a version-b
The script/histogram.py tool can accept as many measurement files as you like and
will generate a histogram visualization comparing the frame rendering
performance data between the provided versions.
Using util_macros::perf
For benchmarking unit tests, annotate them with the #[perf] attribute from the
util_macros crate. Then run cargo perf-test -p $CRATE to benchmark them. See
the rustdoc documentation on crates/util_macros and tooling/perf for
in-depth examples and explanations.
Bloat
My current focus is to reduce the size of the binary and make code more readble. So far I have mainly been trying to do this by removing dependencies and code wherever I can. These are some notes on tools and techniques that have been helpful.
First helpful source is the Rust performance book.
This repository had some helpful tips, mainly on cargo options: https://github.com/johnthagen/min-sized-rust
Unused dependencies
There are two tools to find unused dependencies:
cargo-machete: https://github.com/bnjbvr/cargo-machete.cargo-shear: https://github.com/Boshen/cargo-shear.
I run both. cargo-shear seems to be both more accurate / to find more unused
dependencies, and less prone to false positives.
Async cost
So far this is not something I’ve really looked at, but async code in rust has a significant cost in code amplification due to rewriting function bodies into state machines. See: https://tweedegolf.nl/en/blog/237/async-rust-never-left-the-mvp-state.
Since this code base is so heavily into async everywhere I expect that there should be a lot of wins possible by rewriting code that doesn’t need to be async into straight-line code and running longer tasks on background threads more.
Generic code amplification
Note
AKA. Monomorphization Bloat.
Functions and structs that take generic arguments are compiled as a separate copy for each variant in use. I found a couple of tools that help with finding flarge functions as well as functions that end up generating a lot of copies:
cargo-bloat: https://github.com/RazrFalcon/cargo-bloatcargo-llvm-lines: https://github.com/dtolnay/cargo-llvm-lines
cargo llvm-lines reveals how much code is generated for each function:
CARGO_PROFILE_RELEASE_LTO=fat cargo llvm-lines --release --sort copies -p gram --bin gram > llvm-lines.txt
Full LTO so all monomorphizations appear in the same crate, --sort copies to
get the functions with the most variants listed first.
This turned out to be huge: The settings code in particular generates crazy amounts of code, and while I have managed to reduce the size a lot just by finding ways to move code out of generic functions the whole settings implementation should probably be rewritten from scratch.
Using a debugger
DISCLAIMER: This is not documentation for configuring Gram’s debugger. Rather, it is intended to provide information on how to use a debugger while developing Gram itself.
Using Gram’s built-in debugger
While the Gram project is open you can open the New Process Modal and select
the Debug tab. There you can see to debug configurations to debug Gram with,
one for GDB and one for LLDB. Select the configuration you want and Gram will
build and launch the binary.
Note: GDB isn’t supported on ARM Macbooks.
Release build profile considerations
By default, builds using the release profile (release is the profile used for production builds, i.e. stable) include limited debug info.
This is done by setting the profile.(release).debug field in the root
Cargo.toml field to "limited".
The official documentation for the debug field can be found
here. But the
TLDR is that "limited" strips type and variable level debug info.
In release builds, this is done to reduce the binary size, as type and variable level debug info is not required, and does not impact the usability of generated stack traces.
However, while the type and variable level debug info is not required for good stack traces, it is very important for a good experience using debuggers, as without the type and variable level debug info, the debugger has no way to resolve local variables, inspect them, format them using pretty-printers, etc.
Therefore, in order to use a debugger to it’s fullest extent when debugging a release build, you must compile a new Gram binary, with full debug info.
The simplest way to do this, is to use the --config flag to override the
debug field in the root Cargo.toml file when running cargo run or
cargo build like so:
cargo run --config 'profile.release.debug="full"'
cargo build --config 'profile.release.debug="full"'
If you wish to avoid passing the
--configflag on every invocation ofcargo. You may also change the section in the rootCargo.tomlfrom
[profile.release] debug = "limited"to
[profile.release] debug = "full"This will ensure all invocations of
cargo run --releaseorcargo build --releasewill compile with full debug info.WARNING: Make sure to avoid committing these changes!
Running Gram with a shell debugger GDB/LLDB
Background
The recommended way to get rust for Gram development is via rustup. For more details, see the documentation for getting started on your platform.
When rust is installed via rustup, a few additional scripts are installed and
put on your path to assist with debugging binaries compiled with rust:
rust-gdb and rust-lldb. Learn more about these scripts and why they are
useful on
a bit of respite.
In summary, they are simple shell scripts that wrap the standard gdb and
lldb commands, injecting the relevant commands and flags to enable additional
rust-specific features such as pretty-printers and type information.
In order to use rust-gdb or rust-lldb, you must have gdb or lldb
installed on your system. If you don’t have them installed, you will need to
install them in a manner appropriate for your platform.
Quoting the article above,
“The minimum supported debugger versions are GDB 7.7 and LLDB 310. However, the general rule is: the newer the better.”
It is recommended to install the latest version of gdb or lldb if possible.
Note: On Windows,
rust-gdbis not installed by default asgdbsupport for Windows is not very stable. Uselldbwithrust-lldbinstead.
Usage
Follow the steps above to include full debug info when compiling Gram. Then, run
rust-gdb or rust-lldb on the compiled Gram binary after building it with
cargo build:
# for gdb:
rust-gdb target/debug/gram
# for lldb:
rust-lldb target/debug/gram
Alternatively, attach to a running instance of Gram (such as an instance of Gram
started using cargo run):
rust-gdb -p <pid>
rust-lldb -p <pid>
Where <pid> is the process ID of the Gram instance you want to attach to.
To get the process ID of a running Gram instance, you can use your systems
process management tools such as Task Manager on windows or Activity Monitor
on macOS, or from a terminal:
# Mac or Linux
ps aux | grep gram
# Windows (PowerShell)
Get-Process | Select-Object Id, ProcessName
Debugging Panics and Crashes
Debuggers can be an excellent tool for debugging the cause of panics and crashes in all programs, including Gram.
By default, when a process that gdb or lldb is attached to hits an exception
such as a panic, the debugger will automatically stop at the point of the panic
and allow you to inspect the state of the program.
Most likely, the point at which the debugger stops will be deep in the rust standard library panic or exception handling code, so you will need to navigate up the stack trace to find the actual cause of the panic.
This can be accomplished using the backtrace command in combination with the
frame select command in lldb, with similar commands available in gdb.
Once the program is stopped, you will not be able to continue execution as you can before an exception is hit. However, you can jump around to different stack frames, and inspect the values of variables and expressions within each frame, which can be very useful in identifying the root cause of the crash.
Read more on Debugging Crashes.
Debugging Crashes
To generate a minidump when Gram panics or crashes, set the environment variable
GRAM_GENERATE_MINIDUMPS=1:
$ GRAM_GENERATE_MINIDUMPS=1 gram
If set, Gram sends a message to a sidecar process which inspects the memory of
the crashing editor to create a
minidump
file in ~/Library/Logs/Gram or $XDG_DATA_HOME/gram/logs. This minidump can
be used to generate backtraces for the stacks of all threads.
These crash reports contain rich information; but they are hard to read because they don’t contain spans or symbol information. You can still work with them locally by downloading sources and an unstripped binary (or separate symbols file) for your Gram release and running:
zstd -d ~/.local/share/gram/<uuid>.dmp -o minidump.dmp
minidump-stackwalk minidump.dmp
Alongside the minidump file in your logs dir, there should be a <uuid>.json
which contains additional metadata like the panic message, span, and system
specs.
Using a Debugger
If you can reproduce the crash consistently, a debugger can be used to inspect the state of the program at the time of the crash, often providing useful insights into the cause of the crash.
You can read more about setting up and using a debugger with Gram, and specifically for debugging crashes here.
Building Gram for Linux (Flatpak)
To build a Flatpak, you will need Flatpak installed.
./script/linux.sh
./script/ci-flatpak-deps.sh
./script/ci-flatpak-bundle.sh
Building Gram for FreeBSD
Note, FreeBSD is not currently a supported platform, and so this is a work-in-progress.
Repository
Clone the Gram repository.
Dependencies
-
Install the necessary system packages and rustup:
script/freebsd.shIf preferred, you can inspect
script/freebsdand perform the steps manually.
Building from source
Once the dependencies are installed, you can build Gram using Cargo.
For a debug build of the editor:
cargo run
And to run the tests:
cargo test --workspace
In release mode, the primary user interface is the cli crate. You can run it
in development with:
cargo run -p cli
Troubleshooting
Cargo errors claiming that a dependency is using unstable features
Try cargo clean and cargo build.
Development: Glossary
Naming conventions
These are generally true for the whole codebase. Note that Name can be anything
here. An example would be AnyElement and LspStore.
AnyName: A type erased version of name. ThinkBox<dyn NameTrait>.NameStore: A wrapper type which abstracts over whether operations are running locally or on a remote.
GPUI
State management
App: A singleton which holds the full application state including all the entities. Crucially:Appis notSend, which means thatApponly exists on the thread that created it (which is the main/UI thread, usually). Thus, if you see a&mut App, know that you’re on UI thread.Context: A wrapper around theAppstruct with specialized behavior for a specificEntity. Think of it as(&mut App, Entity<V>). The specialized behavior is surfaced in the API surface ofContext. E.g.,App::spawntakes anAsyncFnOnce(AsyncApp) -> Ret, whereasContext::spawntakes anAsyncFnOnce(WeakEntity<V>, AsyncApp) -> Ret.AsyncApp: An owned version ofAppfor use in async contexts. This type is still notSend(soAsyncApp= you’re on the main thread) and any use of it may be fallible (to account for the fact that theAppmight’ve been terminated by the time this closure runs). The convenience ofAsyncApplies in the fact that you usually interface withAppvia&mut App, which would be inconvenient to use with async closures;AsyncAppis owned, so you can use it in async closures with no sweat.AppContextA trait which abstracts overApp,AsyncApp&Contextand their Test versions.Task: A future running or scheduled to run on the background or foreground executor. In contradiction to regular Futures Tasks do not need.awaitto start running. You do need to await them to get the result of the task.Executor: Used to spawn tasks that run either on the foreground or background thread. Try to run the tasks on the background thread.BackgroundExecutor: A threadpool runningTasks.ForegroundExecutor: The main thread runningTasks.
Entity: A strong, well-typed reference to a struct which is managed by gpui. Effectively a pointer/map key into theApp::EntityMap.WeakEntity: A runtime checked reference to anEntitywhich may no longer exist. Similar tostd::rc::Weak.Global: A singleton type which has only one value, that is stored in theApp.Event: A datatype which can be send by anEntityto subscribersAction: An event that represents a user’s keyboard input that can be handled by listeners Example:file finder: toggleObserving: reacting entities notifying they’ve changedSubscription: An event handler that is used to react to the changes of state in the application.- Emitted event handling
- Observing
{new,release,on notify}of an entity
UI
View: AnEntitywhich can produce anElementthrough its implementation ofRender.Element: A type that can be laid out and painted to the screen.element expression: An expression that builds an element tree, example:
#![allow(unused)]
fn main() {
h_flex()
.id(text[i])
.relative()
.when(selected, |this| {
this.child(
div()
.h_4()
.absolute()
etc etc
}
Component: A builder which can be rendered turning it into anElement.Dispatch tree: TODOFocus: The place where keystrokes are handled firstFocus tree: Path from the place that has the current focus to the UI Root. ExampleTODO
Gram UI
Window: A struct in gram representing a gram window in your desktop environment (see image below). There can be multiple if you have multiple gram instances open. Mostly passed around for rendering.Modal: A UI element that floats on top of the rest of the UIPicker: A struct representing a list of items in floating on top of the UI (Modal). You can select an item and confirm. What happens on select or confirm is determined by the picker’s delegate. (The ‘Model’ in the image below is a picker.)PickerDelegate: A trait used to specialize behavior for aPicker. ThePickerstores thePickerDelegatein the field delegate.Center: The middle of the gram window, the center is split into multiplePanes. In the codebase this is a field on theWorkspacestruct. (see image below).Pane: An area in theCenterwhere we can place items, such as an editor, multi-buffer or terminal (see image below).Panel: AnEntityimplementing thePaneltrait. These can be placed in aDock. In the image below we see the:ProjectPanelin the left dock and theDebugPanelin the bottom dock. NoteEditordoes not implementPaneland hence is not aPanel.Dock: A UI element similar to aPanewhich can be opened and hidden. There can be up to 3 docks open at a time, left right and below the center. A dock contains one or morePanels notPanes. (see image).
Project: One or moreWorktreesWorktree: Represents either local or remote files.
- Multibuffer: A list of Editors, a multi-buffer allows editing multiple files simultaneously. A multi-buffer opens when an operation in Gram returns multiple locations, examples: search or go to definition. See project search in the image below.
Editor
Editor: The text editor, nearly everything in gram is anEditor, even single line inputs. Each pane in the image above contains one or moreEditorinstances.Workspace: The root of the windowEntry: A file, dir, pending dir or unloaded dir.Buffer: The in-memory representation of a ‘file’ together with relevant data such as syntax trees, git status and diagnostics.pending selection: You have mouse down and you’re dragging but you have not yet released.
Debugger
DapStore: Is an entity that manages debugger sessionsdebugger::Session: Is an entity that manages the lifecycle of a debug session and communication with DAPSBreakpointStore: Is an entity that manages breakpoints states in local and remote instances of GramDebugSession: Manages a debug session’s UI and running stateRunningState: Directly manages all the views of a debug sessionVariableList: The variable and watch list view of a debug sessionConsole: TODOTerminal: TODOBreakpointList: TODO
Building Gram for Linux
Repository
Clone the Gram repository.
Dependencies
-
Install rustup
-
Install the necessary system libraries:
script/linux.shIf you prefer to install the system libraries manually, you can find the list of required packages in the
script/linux.shfile.
Linkers
On Linux, Rust’s default linker is
LLVM’s lld. Alternative
linkers, especially Wild and
Mold can significantly improve clean and
incremental build time.
For local development Wild is recommended because it’s 5-20% faster than Mold.
These linkers can be installed with script/install-mold.sh and
script/install-wild.sh.
To use Wild as your default, add these lines to your ~/.cargo/config.toml:
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=--ld-path=wild"]
[target.aarch64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=--ld-path=wild"]
To use Mold as your default:
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
Building from source
Once the dependencies are installed, you can build using Cargo.
For a debug build of the editor:
cargo run
To run the tests:
cargo test --workspace
In release mode, the primary user interface is the cli crate. You can run it
in development with:
cargo run -p cli
Installing a development build
You can install a local build on your machine with:
./script/install.sh --build
This will build gram and the cli in release mode and make them available at
~/.local/bin/gram, installing .desktop files to ~/.local/share.
Note: If you encounter linker errors similar to the following:
error: linking with `cc` failed: exit status: 1 ... = note: /usr/bin/ld: /tmp/rustcISMaod/libaws_lc_sys-79f08eb6d32e546e.rlib(f8e4fd781484bd36-bcm.o): in function `aws_lc_0_25_0_handle_cpu_env': /aws-lc/crypto/fipsmodule/cpucap/cpu_intel.c:(.text.aws_lc_0_25_0_handle_cpu_env+0x63): undefined reference to `__isoc23_sscanf' /usr/bin/ld: /tmp/rustcISMaod/libaws_lc_sys-79f08eb6d32e546e.rlib(f8e4fd781484bd36-bcm.o): in function `pkey_rsa_ctrl_str': /aws-lc/crypto/fipsmodule/evp/p_rsa.c:741:(.text.pkey_rsa_ctrl_str+0x20d): undefined reference to `__isoc23_strtol' /usr/bin/ld: /aws-lc/crypto/fipsmodule/evp/p_rsa.c:752:(.text.pkey_rsa_ctrl_str+0x258): undefined reference to `__isoc23_strtol' collect2: error: ld returned 1 exit status = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified = note: use the `-l` flag to specify native libraries to link = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib) error: could not compile `remote_server` (bin "remote_server") due to 1 previous errorCause: this is caused by known bugs in aws-lc-rs(doesn’t support GCC >= 14): FIPS fails to build with GCC >= 14 & GCC-14 - build failure for FIPS module
You can refer to linux: Linker error for remote_server when using script/install-linux for more information.
Workarounds: Set the remote server target to
x86_64-unknown-linux-gnulike soexport REMOTE_SERVER_TARGET=x86_64-unknown-linux-gnu; script/install-linux.sh
Wayland & X11
Gram supports both X11 and Wayland. By default, we pick whichever we can find at
runtime. If you’re on Wayland and want to run in X11 mode, use the environment
variable WAYLAND_DISPLAY=''.
Packaging Gram
Gram has two main binaries:
- You will need to build
crates/cliand make its binary available in$PATHwith the namegram. - You will need to build
crates/gramand put it at$PATH/to/cli/../../libexec/gram-editor. For example, if you are going to put the cli at~/.local/bin/gramput gram at~/.local/libexec/gram-editor. As some linux distributions (notably Arch) discourage the use oflibexec, you can also put this binary at$PATH/to/cli/../../lib/gram/gram-editor(e.g.~/.local/lib/gram/gram-editor) instead. - If you are going to provide a
.desktopfile you can find a template incrates/gram/resources/gram.desktop.in, and useenvsubstto populate it with the values required. This file should also be renamed to$APP_ID.desktopso that the file follows the FreeDesktop standards. Useapp.liten.Gramfor stable builds andapp.liten.Gram-Devfor development builds, matching the window application ID andStartupWMClass. Desktop entries installed undershare/applicationscan use mode644. - Install application icons under
share/icons/hicolor/scalable/appsand symbolic icons undershare/icons/hicolor/symbolic/apps. KeepIconas an icon name so the desktop can look it up through the selected icon theme. - You will need to ensure that the necessary libraries are installed. You can get the current list by inspecting the built binary on your system.
- For an example of a complete build script, see script/bundle-linux.
- Set the environment variable
GRAM_NO_BUNDLED_UNINSTALLto something like “Use flatpak to uninstall” so that the CLI uninstall command doesn’t try to run the uninstallation script.
Other things to note
Zed comes with some (in our opinion) pretty severe caveats:
- It automatically downloads and installs binaries without explicit user prompting in the same way as rustup/rbenv/pyenv, etc. They say that they “understand this is contentious”, and yet they insist on doing it. See here.
- They download and install extension binaries from zed-industries/extensions without explicit permission or any way to inspect what is being installed. These extensions may in turn install further software without explicit permission or control. For more details, see here.
- It does not play nice with sandboxes, see here
Our (Gram’s) intention is to resolve all of these problems.
Distro Packages
The Gram project includes scripts to build binary packages for various targets,
including .deb, .rpm and AppImage. The driver for all these is the
scripts/bundle-linux script which takes the following flags (among others):
--deb(requirescargo-deb)--rpm(requirescargo-generate-rpm)--appimage(requirespkg2appimage)
Adding any of these will build the corresponding package. Note that the
AppImage is created from the .deb. package so while you can only provide the
--appimage flag it will automatically build a .deb as well.
Note that each of these package builds requires an additional dependency as noted above.
Flatpak
Gram’s current Flatpak integration exits the sandbox on startup. Workflows that rely on Flatpak’s sandboxing may not work as expected.
To build & install the Flatpak package locally follow the steps below:
- Install Flatpak for your distribution as outlined here.
- Run
script/linux.shto install Linux dependencies. - Run
script/ci-flatpak-deps.shscript to install the required dependencies. - Run
script/ci-flatpak-bundle.sh. - Now the package has been installed and has a bundle available at
target/release/{app-id}.flatpak.
Memory profiling
heaptrack is quite useful for diagnosing
memory leaks. To install it:
$ sudo apt install heaptrack heaptrack-gui
$ cargo install cargo-heaptrack
Then, to build and run Gram with the profiler attached:
$ cargo heaptrack -b gram
When this editor instance is exited, terminal output will include a command to
run heaptrack_interpret to convert the *.raw.zst profile to a *.zst file
which can be passed to heaptrack_gui for viewing.
Perf recording
This section describes how to generate a flamegraph with resolved symbols from a running editor instance. This can be used to debug when the editor is using a lot of CPU. It’s not useful for debugging hangs or memory usage.
During the incident
-
Find the PID (process ID) using:
ps -eo size,pid,comm | grep gram | sort | head -n 1 | cut -d ' ' -f 2Or find the pid of the command gram-editor with the most ram usage in something like htop/btop/top. -
Install perf: On Ubuntu (derivatives) run
sudo apt install linux-tools. -
Perf Record: run
sudo perf record -p <pid you just found>, wait a few seconds to gather data then press Ctrl+C. You should now have a perf.data file -
Make the output file user owned: run
sudo chown $USER:$USER perf.data -
Get build info: Run gram again and type
gram: aboutin the command pallet to get the exact commit.
Later
-
Build Gram with symbols:
-
Check out the commit found previously and modify
Cargo.toml. -
Apply the following diff, then make a release build.
[profile.release] -debug = "limited" +debug = "full"
-
-
Add the symbols to perf database:
pref buildid-cache -v -a <path to release gram binary> -
Resolve the symbols from the db:
perf inject -i perf.data -o perf_with_symbols.data -
Install flamegraph:
cargo install cargo-flamegraph -
Render the flamegraph:
flamegraph --perfdata perf_with_symbols.data
Troubleshooting
Cargo errors claiming that a dependency is using unstable features
Try cargo clean and cargo build.
Building Gram for macOS
Repository
Clone down the Gram repository.
# Your apple ID (email)
export APPLE_ID=""
# App-specific password (create in account.apple.com)
export APPLE_PASSWORD_GRAM=""
# Apple Team ID (find it in XCode)
export APPLE_TEAM_ID=""
# Apple signing key: security find-identity -p codesigning
export APPLE_SIGNING_KEY=""
# Build, sign and notarise the app bundle
./script/bundle-mac.sh
Dependencies
-
Install rustup
-
Install Xcode from the macOS App Store, or from the Apple Developer website. Note this requires a developer account.
Ensure you launch Xcode after installing, and install the macOS components, which is the default option.
-
Install Xcode command line tools
xcode-select --install -
Ensure that the Xcode command line tools are using your newly installed copy of Xcode:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -license accept -
Install
cmake(required by a dependency)brew install cmake
Building Gram from Source
Once you have the dependencies installed, you can build Gram using Cargo.
For a debug build:
cargo run
For a release build:
cargo run --release
And to run the tests:
cargo test --workspace
Troubleshooting
Error compiling metal shaders
error: failed to run custom build command for gpui v0.1.0 (/Users/path/to/gram)`**
xcrun: error: unable to find utility "metal", not a developer tool or in PATH
Try sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
If you’re on macOS 26, try xcodebuild -downloadComponent MetalToolchain
Cargo errors claiming that a dependency is using unstable features
Try cargo clean and cargo build.
Error: ‘dispatch/dispatch.h’ file not found
If you encounter an error similar to:
src/platform/mac/dispatch.h:1:10: fatal error: 'dispatch/dispatch.h' file not found
Caused by:
process didn't exit successfully
--- stdout
cargo:rustc-link-lib=framework=System
cargo:rerun-if-changed=src/platform/mac/dispatch.h
cargo:rerun-if-env-changed=TARGET
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
This file is part of Xcode. Ensure you have installed the Xcode command line tools and set the correct path:
xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Additionally, set the BINDGEN_EXTRA_CLANG_ARGS environment variable:
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$(xcrun --show-sdk-path)"
Then clean and rebuild the project:
cargo clean
cargo run
Tests failing due to Too many open files (os error 24)
This error seems to be caused by OS resource constraints. Installing and running
tests with cargo-nextest should resolve the issue.
cargo install cargo-nextest --lockedcargo nextest run --workspace --no-fail-fast
Tips & Tricks
Avoiding continual rebuilds
If you are finding that Gram is continually rebuilding root crates, it may be because you are pointing your development Gram at the codebase itself.
This causes problems because cargo run exports a bunch of environment
variables which are picked up by the rust-analyzer that runs in the
development build of Gram. These environment variables are in turn passed to
cargo check, which invalidates the build cache of some of the crates we depend
on.
You can easily avoid running the built binary on the checked-out Gram codebase
using cargo run ~/path/to/other/project to ensure that you don’t hit this.
Speeding up verification
If you are building Gram a lot, you may find that macOS continually verifies new builds which can add a few seconds to your iteration cycles.
To fix this, you can:
- Run
sudo spctl developer-mode enable-terminalto enable the Developer Tools panel in System Settings. - In System Settings, search for “Developer Tools” and add your terminal (e.g. iTerm or Ghostty) to the list under “Allow applications to use developer tools”
- Restart your terminal.
Thanks to the nextest developers for publishing this.
GPUI: Ownership and data flow
In GPUI, every model or view in the application is actually owned by a single
top-level object called the App. When a new entity or view is created
(referred to collectively as entities), the application is given ownership of
their state to enable their participation in a variety of app services and
interaction with other entities.
To illustrate, consider the trivial app below. We start the app by calling run
with a callback, which is passed a reference to the App that owns all the
state for the application. This App is our gateway to all application-level
services, such as opening windows, presenting dialogs, etc. It also has an
insert_entity method, which is called below to create an entity and give
ownership of it to the application.
#![allow(unused)]
fn main() {
use gpui::{App, AppContext, Application, Entity};
struct Counter {
count: usize,
}
Application::new().run(|cx: &mut App| {
let _counter: Entity<Counter> = cx.new(|_cx| Counter { count: 0 });
// ...
});
}
The call to new_entity returns an entity handle, which carries a type
parameter based on the type of object it references. By itself, this
Entity<Counter> handle doesn’t provide access to the entity’s state. It’s
merely an inert identifier plus a compile-time type tag, and it maintains a
reference counted pointer to the underlying Counter object that is owned by
the app.
Much like an Rc from the Rust standard library, this reference count is
incremented when the handle is cloned and decremented when it is dropped to
enable shared ownership over the underlying model, but unlike an Rc it only
provides access to the model’s state when a reference to an App is available.
The handle doesn’t truly own the state, but it can be used to access the state
from its true owner, the App. Stripping away some of the setup code for
brevity:
#![allow(unused)]
fn main() {
use gpui::{App, AppContext, Application, Context, Entity};
struct Counter {
count: usize,
}
Application::new().run(|cx: &mut App| {
let counter: Entity<Counter> = cx.new(|_cx| Counter { count: 0 });
// Call `update` to access the model's state.
counter.update(cx, |counter: &mut Counter, _cx: &mut Context<Counter>| {
counter.count += 1;
});
});
}
To update the counter, we call update on the handle, passing the context
reference and a callback. The callback is yielded a mutable reference to the
counter, which can be used to manipulate state.
The callback is also provided a second Context<Counter> reference. This
reference is similar to the App reference provided to the run callback. A
Context is actually a wrapper around the App, including some additional data
to indicate which particular entity it is tied to; in this case the counter.
In addition to the application-level services provided by App, a Context
provides access to entity-level services. For example, it can be used it to
inform observers of this entity that its state has changed. Let’s add that to
our example, by calling cx.notify().
#![allow(unused)]
fn main() {
use gpui::{App, AppContext, Application, Entity};
struct Counter {
count: usize,
}
Application::new().run(|cx: &mut App| {
let counter: Entity<Counter> = cx.new(|_cx| Counter { count: 0 });
counter.update(cx, |counter, cx| {
counter.count += 1;
cx.notify(); // Notify observers
});
});
}
Next, these notifications need to be observed and reacted to. Before updating
the counter, we’ll construct a second counter that observes it. Whenever the
first counter changes, twice its count is assigned to the second counter. Note
how observe is called on the Context belonging to our second counter to
arrange for it to be notified whenever the first counter notifies. The call to
observe returns a Subscription, which is detached to preserve this
behavior for as long as both counters exist. We could also store this
subscription and drop it at a time of our choosing to cancel this behavior.
The observe callback is passed a mutable reference to the observer and a
handle to the observed counter, whose state we access with the read method.
#![allow(unused)]
fn main() {
use gpui::{App, AppContext, Application, Entity, prelude::*};
struct Counter {
count: usize,
}
Application::new().run(|cx: &mut App| {
let first_counter: Entity<Counter> = cx.new(|_cx| Counter { count: 0 });
let second_counter = cx.new(|cx: &mut Context<Counter>| {
// Note we can set up the callback before the Counter is even created!
cx.observe(
&first_counter,
|second: &mut Counter, first: Entity<Counter>, cx| {
second.count = first.read(cx).count * 2;
},
)
.detach();
Counter { count: 0 }
});
first_counter.update(cx, |counter, cx| {
counter.count += 1;
cx.notify();
});
assert_eq!(second_counter.read(cx).count, 2);
});
}
After updating the first counter, it can be noted that the observing counter’s state is maintained according to our subscription.
In addition to observe and notify, which indicate that an entity’s state has
changed, GPUI also offers subscribe and emit, which enables entities to emit
typed events. To opt into this system, the emitting object must implement the
EventEmitter trait.
Let’s introduce a new event type called CounterChangeEvent, then indicate that
Counter can emit this type of event:
#![allow(unused)]
fn main() {
use gpui::EventEmitter;
struct Counter {
count: usize,
}
struct CounterChangeEvent {
increment: usize,
}
impl EventEmitter<CounterChangeEvent> for Counter {}
}
Next, the example should be updated, replacing the observation with a
subscription. Whenever the counter is incremented, a Change event is emitted
to indicate the magnitude of the increase.
#![allow(unused)]
fn main() {
use gpui::{App, AppContext, Application, Context, Entity, EventEmitter};
struct Counter {
count: usize,
}
struct CounterChangeEvent {
increment: usize,
}
impl EventEmitter<CounterChangeEvent> for Counter {}
Application::new().run(|cx: &mut App| {
let first_counter: Entity<Counter> = cx.new(|_cx| Counter { count: 0 });
let second_counter = cx.new(|cx: &mut Context<Counter>| {
// Note we can set up the callback before the Counter is even created!
cx.subscribe(&first_counter, |second: &mut Counter, _first: Entity<Counter>, event, _cx| {
second.count += event.increment * 2;
})
.detach();
Counter {
count: first_counter.read(cx).count * 2,
}
});
first_counter.update(cx, |first, cx| {
first.count += 2;
cx.emit(CounterChangeEvent { increment: 2 });
cx.notify();
});
assert_eq!(second_counter.read(cx).count, 4);
});
}
Building Gram for Windows
The following commands may be executed in any shell.
Repository
Clone down the Gram repository.
Note
No idea if the Windows build still works, or what is required to get it working. Windows builds are also signed, so you will need a certificate.
Maybe something like this?
.\script\bundle-windows.ps1
Dependencies
-
Install rustup
-
Install either Visual Studio with the optional components
MSVC v*** - VS YYYY C++ x64/x86 build toolsandMSVC v*** - VS YYYY C++ x64/x86 Spectre-mitigated libs (latest)(v***is your VS version andYYYYis year when your VS was released. Pay attention to the architecture and change it to yours if needed.) -
Or, if you prefer to have a slimmer installer of only the MSVC compiler tools, you can install the build tools (+libs as above) and the “Desktop development with C++” workload. But beware this installation is not automatically picked up by rustup. You must initialize your environment variables by first launching the “developer” shell (cmd/powershell) this installation places in the start menu or in Windows Terminal and then compile.
-
Install Windows 11 or 10 SDK depending on your system, but ensure that at least
Windows 10 SDK version 2104 (10.0.20348.0)is installed on your machine. You can download it from the Windows SDK Archive -
Install CMake (required by a dependency). Or you can install it through Visual Studio Installer, then manually add the
bindirectory to yourPATH, for example:C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin.
If you can’t compile Gram, make sure that you have at least the following components installed in case of a Visual Studio installation:
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake",
"Microsoft.VisualStudio.Component.VC.CMake.Project",
"Microsoft.VisualStudio.Component.Windows11SDK.26100",
"Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
],
"extensions": [],
}
Or if in case of just Build Tools, the following components:
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.CoreBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
"Microsoft.VisualStudio.Component.Windows10SDK",
"Microsoft.VisualStudio.Component.VC.CoreBuildTools",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.Component.Windows11SDK.26100",
"Microsoft.VisualStudio.Component.VC.CMake.Project",
"Microsoft.VisualStudio.Component.TextTemplating",
"Microsoft.VisualStudio.Component.VC.CoreIde",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Workload.VCTools",
"Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
],
"extensions": [],
}
The list can be obtained as follows:
- Open the Visual Studio Installer
- Click on
Morein theInstalledtab - Click on
Export configuration
Notes
You should modify the pg_hba.conf file in the data directory to use trust
instead of scram-sha-256 for the host method. Otherwise, the connection will
fail with the error password authentication failed. The pg_hba.conf file
typically locates at C:\Program Files\PostgreSQL\17\data\pg_hba.conf. After
the modification, the file should look like this:
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Also, if you are using a non-latin Windows version, you must modify
thelc_messages parameter in the postgresql.conf file in the data directory
to English_United States.1252 (or whatever UTF8-compatible encoding you have).
Otherwise, the database will panic. The postgresql.conf file should look like
this:
# lc_messages = 'Chinese (Simplified)_China.936' # locale for system error message strings
lc_messages = 'English_United States.1252'
After this, you should restart the postgresql service. Press the win key +
R to launch the Run window. Type the services.msc and hit the OK button
to open the Services Manager. Then, find the postgresql-x64-XX service,
right-click on it, and select Restart.
Building from source
Once you have the dependencies installed, you can build Gram using Cargo.
For a debug build:
cargo run
For a release build:
cargo run --release
And to run the tests:
cargo test --workspace
Installing from msys2
Gram does not support unofficial MSYS2 Gram packages built for Mingw-w64, and instead uses mingw-w64-zed.
Please refer to MSYS2 documentation first.
Troubleshooting
Setting RUSTFLAGS env var breaks builds
If you set the RUSTFLAGS env var, it will override the rustflags settings in
.cargo/config.toml which is required to properly build Gram.
Since these settings can vary from time to time, the build errors you receive may vary from linker errors, to other stranger errors.
If you’d like to add extra rust flags, you may do 1 of the following in
.cargo/config.toml:
Add your flags in the build section
[build]
rustflags = ["-C", "symbol-mangling-version=v0", "--cfg", "tokio_unstable"]
Add your flags in the windows target section
[target.'cfg(target_os = "windows")']
rustflags = [
"--cfg",
"windows_slim_errors",
"-C",
"target-feature=+crt-static",
]
Or, you can create a new .cargo/config.toml in the same folder as the Gram
repo (see below). This is particularly useful if you are doing CI builds since
you don’t have to edit the original .cargo/config.toml.
upper_dir
├── .cargo // <-- Make this folder
│ └── config.toml // <-- Make this file
└── gram
├── .cargo
│ └── config.toml
└── crates
└── ...
In the new (above) .cargo/config.toml, if we wanted to add --cfg gles to our
rustflags, it would look like this
[target.'cfg(all())']
rustflags = ["--cfg", "gles"]
Cargo errors claiming that a dependency is using unstable features
Try cargo clean and cargo build.
STATUS_ACCESS_VIOLATION
This error can happen if you are using the “rust-lld.exe” linker. Consider trying a different linker.
If you are using a global config, consider moving the Gram repository to a
nested directory and add a .cargo/config.toml with a custom linker config in
the parent directory.
See this issue for more information #12041
Invalid RC path selected
Sometimes, depending on the security rules applied to your laptop, you may get the following error while compiling Gram:
error: failed to run custom build command for `gram(C:\Users\USER\src\gram\crates\gram)`
Caused by:
process didn't exit successfully: `C:\Users\USER\src\gram\target\debug\build\gram-b24f1e9300107efc\build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-changed=../../.git/logs/HEAD
cargo:rustc-env=GRAM_COMMIT_SHA=25e2e9c6727ba9b77415588cfa11fd969612adb7
cargo:rustc-link-arg=/stack:8388608
cargo:rerun-if-changed=resources/windows/app-icon.ico
package.metadata.winresource does not exist
Selected RC path: 'bin\x64\rc.exe'
--- stderr
The system cannot find the path specified. (os error 3)
warning: build failed, waiting for other jobs to finish...
In order to fix this issue, you can manually set the GRAM_RC_TOOLKIT_PATH
environment variable to the RC toolkit path. Usually, you can set it to:
C:\Program Files (x86)\Windows Kits\10\bin\<SDK_version>\x64.
See this issue for more information.
Graphics issues
Gram fails to launch
Currently, Gram uses Vulkan as its graphics API on Windows. However, Vulkan isn’t always the most reliable on Windows, so if Gram fails to launch, it’s likely a Vulkan-related issue.
You can check the Gram log at: C:\Users\YOU\AppData\Local\Gram\logs\Gram.log
If you see messages like:
Gram failed to open a window: NoSupportedDeviceFoundERROR_INITIALIZATION_FAILEDGPU CrashedERROR_SURFACE_LOST_KHR
Then Vulkan might not be working properly on your system. In most cases, updating your GPU drivers may help resolve this.
If there’s nothing Vulkan-related in the logs and you happen to have Bandicam installed, try uninstalling it. Gram is currently not compatible with Bandicam.
Extensions
Gram lets you add new functionality using user-defined extensions.
Extension Capabilities
The operations that Gram extensions are able to perform are governed by a capability system.
Restricting capabilities
As a user, you have the option of restricting the capabilities that are granted to extensions.
This is controlled via the granted_extension_capabilities setting.
Restricting or removing a capability will cause an error to be returned when an extension attempts to call the corresponding extension API without sufficient capabilities.
For instance, if you wanted to restrict downloads to just files from GitHub, you
could modify host for the download_file capability:
{
"granted_extension_capabilities": [
{ "kind": "process:exec", "command": "*", "args": ["**"] },
- { "kind": "download_file", "host": "*", "path": ["**"] },
+ { "kind": "download_file", "host": "github.com", "path": ["**"] },
{ "kind": "npm:install", "package": "*" }
]
}
If you don’t want extensions to be able to perform any capabilities, you can remove all granted capabilities:
{
"granted_extension_capabilities": []
}
Note that this will likely make many extensions non-functional, at least in their default configuration.
Capabilities
process:exec
The process:exec capability grants extensions the ability to invoke commands
using
zed_extension_api::process::Command.
Examples
To allow any command to be executed with any arguments:
{ kind = "process:exec", command = "*", args = ["**"] }
To allow a specific command (e.g., gem) to be executed with any arguments:
{ kind = "process:exec", command = "gem", args = ["**"] }
download_file
The download_file capability grants extensions the ability to download files
using
zed_extension_api::download_file.
Examples
To allow any file to be downloaded:
{ kind = "download_file", host = "github.com", path = ["**"] }
To allow any file to be downloaded from github.com:
{ kind = "download_file", host = "github.com", path = ["**"] }
To allow any file to be downloaded from a specific GitHub repository:
{ kind = "download_file", host = "github.com", path = ["zed-industries", "zed", "**"] }
npm:install
The npm:install capability grants extensions the ability to install npm
packages using
zed_extension_api::npm_install_package.
Examples
To allow any npm package to be installed:
{ kind = "npm:install", package = "*" }
To allow a specific npm package (e.g., typescript) to be installed:
{ kind = "npm:install", package = "typescript" }
Debugger Extensions
Debug Adapter Protocol Servers can be exposed as extensions for use in the debugger.
Defining Debugger Extensions
A given extension may provide one or more DAP servers. Each DAP server must be
registered in the extension.toml:
[debug_adapters.my-debug-adapter]
# Optional relative path to the JSON schema for the debug adapter configuration schema. Defaults to `debug_adapter_schemas/$DEBUG_ADAPTER_NAME_ID.json`.
# Note that while this field is optional, a schema is mandatory.
schema_path = "relative/path/to/schema.json"
Then, in the Rust code for your extension, implement the get_dap_binary method
on your extension:
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn get_dap_binary(
&mut self,
adapter_name: String,
config: DebugTaskDefinition,
user_provided_debug_adapter_path: Option<String>,
worktree: &Worktree,
) -> Result<DebugAdapterBinary, String>;
}
}
This method should return the command to start up a debug adapter protocol server, along with any arguments or environment variables necessary for it to function.
If you need to download the DAP server from an external source—like GitHub Releases or npm—you can also do that in this function. Make sure to check for updates only periodically, as this function is called whenever a user spawns a new debug session with your debug adapter.
You must also implement dap_request_kind. This function is used to determine
whether a given debug scenario will launch a new debuggee or attach to an
existing one. We also use it to determine that a given debug scenario requires
running a locator.
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn dap_request_kind(
&mut self,
_adapter_name: String,
_config: Value,
) -> Result<StartDebuggingRequestArgumentsRequest, String>;
}
}
These two functions are sufficient to expose your debug adapter in
debug.jsonc-based user workflows, but you should strongly consider
implementing dap_config_to_scenario as well.
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn dap_config_to_scenario(
&mut self,
_adapter_name: DebugConfig,
) -> Result<DebugScenario, String>;
}
}
dap_config_to_scenario is used when the user spawns a session via new process
modal UI. At a high level, it takes a generic debug configuration (that isn’t
specific to any debug adapter) and tries to turn it into a concrete debug
scenario for your adapter. Put another way, it is supposed to answer the
question: “Given a program, a list of arguments, current working directory and
environment variables, what would the configuration for spawning this debug
adapter look like?”.
Defining Debug Locators
Gram offers an automatic way to create debug scenarios with debug locators. A
locator locates the debug target and figures out how to spawn a debug session
for it. Thanks to locators, we can automatically convert existing user tasks
(e.g. cargo run) and convert them into debug scenarios (e.g. cargo build
followed by spawning a debugger with target/debug/my_program as the program to
debug).
Your extension can define its own debug locators even if it does not expose a debug adapter. We strongly recommend doing so when your extension already exposes language tasks, as it allows users to spawn a debug session without having to manually configure the debug adapter.
Locators can (but don’t have to) be agnostic to the debug adapter they are used with. They are simply responsible for locating the debug target and figuring out how to spawn a debug session for it. This allows for a more flexible and extensible debugging experience.
Your extension can define one or more debug locators. Each debug locator must be
registered in the extension.toml:
[debug_locators.my-debug-locator]
Locators have two components. First, each locator is ran on each available task
to figure out if any of the available locators can provide a debug scenario for
a given task. This is done by calling dap_locator_create_scenario.
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn dap_locator_create_scenario(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
_resolved_label: String,
_debug_adapter_name: String,
) -> Option<DebugScenario>;
}
}
This function should return Some debug scenario when that scenario defines a
debugging counterpart to a given user task. Note that a DebugScenario can
include a build task. If there is one, we will
execute run_dap_locator after a build task is finished successfully.
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn run_dap_locator(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
) -> Result<DebugRequest, String>;
}
}
run_dap_locator is useful in case you cannot determine a build target
deterministically. Some build systems may produce artifacts whose names are not
known up-front. Note however that you do not need to go through a 2-phase
resolution; if you can determine the full debug configuration with just
dap_locator_create_scenario, you can omit build property on a returned
DebugScenario. Please also note that your locator will be called with
tasks it’s unlikely to accept; thus you should take some effort to return None
early before performing any expensive operations.
Testing
To test your new Debug Adapter Protocol server extension, you can install it. Read more in Developing Extensions.
Developing Extensions
Extension Features
Extensions are able to provide the following features to Gram:
Developing an Extension
Before starting to develop an extension for Gram, be sure to install Rust via rustup.
Note: If you have installed rustup via Homebrew, you may need
to run rustup-init for the command to work properly.
When developing an extension, you can use it in Gram by installing it:
From the extensions page, click the Install Local button (or the {#action
gram::InstallExtensionFromFolder} action) and select the directory containing
your extension.
If you need to troubleshoot, you can check the Gram.log ({#action
gram::OpenLog}) for additional output. For debug output, close and relaunch the
editor with the flag gram --foreground from the command line which show more
verbose INFO level logging.
Directory Structure of a Gram Extension
A Gram extension is a Git repository that contains an extension.toml. This
file must contain some basic information about the extension:
id = "my-extension"
name = "My extension"
version = "0.0.1"
schema_version = 1
authors = ["Your Name <you@example.com>"]
description = "My cool extension"
repository = "https://github.com/your-name/my-gram-extension"
In addition to this, there are several other optional files and directories that can be used to add functionality to a Gram extension. An example directory structure of an extension that provides all capabilities is as follows:
my-extension/
extension.toml
Cargo.toml
src/
lib.rs
languages/
my-language/
config.toml
highlights.scm
themes/
my-theme.json
WebAssembly
Procedural parts of extensions are written in Rust and compiled to WebAssembly.
To develop an extension that includes custom code, include a Cargo.toml like
this:
[package]
name = "my-extension"
version = "0.0.1"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.1.0"
Use the latest version of the
zed_extension_api available on
crates.io. Make sure it’s still compatible with Gram versions you want to
support.
In the src/lib.rs file in your Rust crate you will need to define a struct for
your extension and implement the Extension trait, as well as use the
register_extension! macro to register your extension:
use zed_extension_api as zed;
struct MyExtension {
// ... state
}
impl gram::Extension for MyExtension {
// ...
}
gram::register_extension!(MyExtension);
stdout/stderris forwarded directly to the Gram process. In order to seeprintln!/dbg!output from your extension, you can start Gram in your terminal with a--foregroundflag.
Extension License
Extension repositories should include a license. The following licenses are recommended:
Your license file should be at the root of your extension repository. Any
filename that has LICENCE or LICENSE as a prefix (case insensitive).
Note: This license applies only to your extension code itself. It does not apply to any tools your extension may download or interact with, such as language servers or other external dependencies. If your repository contains both extension code and other projects (like a language server), you don’t need to relicense those other projects.
Icon Themes
Extensions may provide icon themes in order to change the icons Gram uses for folders and files.
Example extension
The Material Icon Theme serves as an example for the structure of an extension containing an icon theme.
Directory structure
There are two important directories for an icon theme extension:
icon_themes: This directory will contain one or more JSON files containing the icon theme definitions.icons: This directory contains the icon assets that will be distributed with the extension. You can created subdirectories in this directory, if so desired.
Each icon theme file should adhere to the JSON schema specified at
https://zed.dev/schema/icon_themes/v0.3.0.json.
Here is an example of the structure of an icon theme:
{
"$schema": "https://zed.dev/schema/icon_themes/v0.3.0.json",
"name": "My Icon Theme",
"author": "Your Name",
"themes": [
{
"name": "My Icon Theme",
"appearance": "dark",
"directory_icons": {
"collapsed": "./icons/folder.svg",
"expanded": "./icons/folder-open.svg"
},
"named_directory_icons": {
"stylesheets": {
"collapsed": "./icons/folder-stylesheets.svg",
"expanded": "./icons/folder-stylesheets-open.svg"
}
},
"chevron_icons": {
"collapsed": "./icons/chevron-right.svg",
"expanded": "./icons/chevron-down.svg"
},
"file_stems": {
"Makefile": "make"
},
"file_suffixes": {
"mp3": "audio",
"rs": "rust"
},
"file_icons": {
"audio": { "path": "./icons/audio.svg" },
"default": { "path": "./icons/file.svg" },
"make": { "path": "./icons/make.svg" },
"rust": { "path": "./icons/rust.svg" }
// ...
}
}
]
}
Each icon path is resolved relative to the root of the extension directory.
In this example, the extension would have a structure like so:
extension.toml
icon_themes/
my-icon-theme.json
icons/
audio.svg
chevron-down.svg
chevron-right.svg
file.svg
folder-open.svg
folder.svg
rust.svg
Installing Extensions
Some extensions, particularly extensions that add language support, need to
compile the extension into a Wasm bundle. To do this, Gram uses Rust together
with the wasm32-wasip2 target to build the Wasm extension on your local
machine.
You can either install these dependencies yourself, or alternatively if you have
installed Rust via rustup, Gram will
try to add the wasm32-wasip2 target for you.
If you have installed Rust via a package manager but don’t have the
wasm32-wasip2 target installed, installing the extension will not work.
The editor will also need the WASI SDK in order to compile the extension and
tree-sitter grammar for language extensions. If the system-installed version of
cargo is able to compile to Wasm, the editor will only download the WASI
sysroot instead.
Note: This is a core difference between Zed and Gram. Zed will download a precompiled Wasm bundle from the Zed website when installing an extension, to avoid having to build the extension locally.
You can manage your extensions by launching the Gram Extension Gallery.
Press {#kb gram::Extensions} , open the command palette and select {#action gram::Extensions} or select “Gram > Extensions” from the menu bar.
Here you can view the extensions that you currently have installed, and you can also install extensions for your local file system, or via a git URL. To get the git URL for a Zed extension, go to the Zed extensions website, find the extension you want to use and copy the “Visit Repository” link.
Requirements
The exact requirements for compiling Wasm extensions varies by OS and architecture, so giving exact instructions is very difficult.
You will probably need to install clang.
On Chimera Linux, you will need to install wasm-component-ld and wasi-clang.
On Manjaro, you will need rust-wasm and wasi-compiler-rt.
On Mac OS, you will need rustup, but it is not recommended to install it via
Homebrew as users have reported problems compiling extensions with the Homebrew
version. It is possible that compilation may work if the rust-wasm Homebrew
package is installed, but this is not verified.
Installing Local Extensions
From the extensions page, click the Install Local button (or the {#action
gram::InstallExtensionFromFolder} action) and select the directory containing
your extension. You should see the extension begin to install in the status bar.
System-installed extensions
If Gram is compiled or started with the environment variable
GRAM_SYSTEM_EXTENSIONS_DIR set, it will also look for installed extensions in
that directory. This way, a Linux distribution can provide packaged extensions
for Gram that are installed and managed using the system package manager.
System-installed extensions are always enabled and cannot be uninstalled from the editor.
Installing Extensions From A Git URL
From the extensions page, click the Install From URL button (or the {#action
gram::InstallExtensionFromUrl} action) and enter the git url for the extension.
You should see the extension begin to install in the status bar.
Note: The editor must be able to authenticate the git URL, but does not support SSH authentication. Using a public URL such as an
http(s)git URL is recommended. Check the logs to debug ({#action gram::OpenLog}).
Installation Location
- On macOS, extensions are installed in
~/Library/Application Support/Gram/extensions. - On Linux, they are installed in either
$XDG_DATA_HOME/gram/extensionsor~/.local/share/gram/extensions.
This directory contains two subdirectories:
installed, which contains the source code for each extension.workwhich contains files created by the extension itself, such as downloaded language servers.
Removing extensions
Remove extensions from the Extensions interface.
Language Extensions
Language support in Gram has several components:
- Language metadata and configuration
- Grammar
- Queries
- Language servers
Language Metadata
Each language supported by Gram must be defined in a subdirectory inside the
languages directory of your extension.
This subdirectory must contain a file called config.toml file with the
following structure:
name = "My Language"
grammar = "my-language"
path_suffixes = ["myl"]
line_comments = ["# "]
name(required) is the human readable name that will show up in the Select Language dropdown.grammar(required) is the name of a grammar. Grammars are registered separately, described below.path_suffixesis an array of file suffixes that should be associated with this language. Unlikefile_typesin settings, this does not support glob patterns.line_commentsis an array of strings that are used to identify line comments in the language. This is used for theeditor::ToggleCommentskeybind: {#kb editor::ToggleComments} for toggling lines of code.tab_sizedefines the indentation/tab size used for this language (default is4).hard_tabswhether to indent with tabs (true) or spaces (false, the default).first_line_patternis a regular expression, that in addition topath_suffixes(above) orfile_typesin settings can be used to match files which should use this language. For example Gram uses this to identify Shell Scripts by matching the shebangs lines in the first line of a script.debuggersis an array of strings that are used to identify debuggers in the language. When launching a debugger’sNew Process Modal, Gram will order available debuggers by the order of entries in this array.
Grammar
Gram uses the Tree-sitter parsing library to
provide built-in language-specific features. There are grammars available for
many languages, and you can also
develop your own grammar.
A growing list of Gram features are built using pattern matching over syntax
trees with Tree-sitter queries. As mentioned above, every language that is
defined in an extension must specify the name of a Tree-sitter grammar that is
used for parsing. These grammars are then registered separately in extensions’
extension.toml file, like this:
[grammars.gleam]
repository = "https://github.com/gleam-lang/tree-sitter-gleam"
rev = "58b7cac8fc14c92b0677c542610d8738c373fa81"
The repository field must specify a repository where the Tree-sitter grammar
should be loaded from, and the rev field must contain a Git revision to use,
such as the SHA of a Git commit. If you’re developing an extension locally and
want to load a grammar from the local filesystem, you can use a file:// URL
for repository. An extension can provide multiple grammars by referencing
multiple tree-sitter repositories.
Tree-sitter Queries
Gram uses the syntax tree produced by the Tree-sitter query language to implement several features:
- Syntax highlighting
- Bracket matching
- Code outline/structure
- Auto-indentation
- Code injections
- Syntax overrides
- Text redactions
- Runnable code detection
- Selecting classes, functions, etc.
The following sections elaborate on how Tree-sitter queries enable these features in Gram, using JSON syntax as a guiding example.
Syntax highlighting
In Tree-sitter, the highlights.scm file defines syntax highlighting rules for
a particular syntax.
Here’s an example from a highlights.scm for JSON:
(string) @string
(pair
key: (string) @property.json_key)
(number) @number
This query marks strings, object keys, and numbers for highlighting. The following is a comprehensive list of captures supported by themes:
| Capture | Description |
|---|---|
| @attribute | Captures attributes |
| @boolean | Captures boolean values |
| @comment | Captures comments |
| @comment.doc | Captures documentation comments |
| @constant | Captures constants |
| @constructor | Captures constructors |
| @embedded | Captures embedded content |
| @emphasis | Captures emphasized text |
| @emphasis.strong | Captures strongly emphasized text |
| @enum | Captures enumerations |
| @function | Captures functions |
| @hint | Captures hints |
| @keyword | Captures keywords |
| @label | Captures labels |
| @link_text | Captures link text |
| @link_uri | Captures link URIs |
| @number | Captures numeric values |
| @operator | Captures operators |
| @predictive | Captures predictive text |
| @preproc | Captures preprocessor directives |
| @primary | Captures primary elements |
| @property | Captures properties |
| @punctuation | Captures punctuation |
| @punctuation.bracket | Captures brackets |
| @punctuation.delimiter | Captures delimiters |
| @punctuation.list_marker | Captures list markers |
| @punctuation.special | Captures special punctuation |
| @string | Captures string literals |
| @string.escape | Captures escaped characters in strings |
| @string.regex | Captures regular expressions |
| @string.special | Captures special strings |
| @string.special.symbol | Captures special symbols |
| @tag | Captures tags |
| @tag.doctype | Captures doctypes (e.g., in HTML) |
| @text.literal | Captures literal text |
| @title | Captures titles |
| @type | Captures types |
| @variable | Captures variables |
| @variable.special | Captures special variables |
| @variant | Captures variants |
Bracket matching
The brackets.scm file defines matching brackets.
Here’s an example from a brackets.scm file for JSON:
("[" @open "]" @close)
("{" @open "}" @close)
("\"" @open "\"" @close)
This query identifies opening and closing brackets, braces, and quotation marks.
| Capture | Description |
|---|---|
| @open | Captures opening brackets, braces, and quotes |
| @close | Captures closing brackets, braces, and quotes |
Gram uses these to highlight matching brackets: painting each bracket pair with a different color (“rainbow brackets”) and highlighting the brackets if the cursor is inside the bracket pair.
To opt out of rainbow brackets colorization, add the following to the
corresponding brackets.scm entry:
(("\"" @open "\"" @close) (#set! rainbow.exclude))
Code outline/structure
The outline.scm file defines the structure for the code outline.
Here’s an example from an outline.scm file for JSON:
(pair
key: (string (string_content) @name)) @item
This query captures object keys for the outline structure.
| Capture | Description |
|---|---|
| @name | Captures the content of object keys |
| @item | Captures the entire key-value pair |
| @context | Captures elements that provide context for the outline item |
| @context.extra | Captures additional contextual information for the outline item |
| @annotation | Captures nodes that annotate outline item (doc comments, attributes, decorators)1 |
Auto-indentation
The indents.scm file defines indentation rules.
Here’s an example from an indents.scm file for JSON:
(array "]" @end) @indent
(object "}" @end) @indent
This query marks the end of arrays and objects for indentation purposes.
| Capture | Description |
|---|---|
| @end | Captures closing brackets and braces |
| @indent | Captures entire arrays and objects for indentation |
Code injections
The injections.scm file defines rules for embedding one language within
another, such as code blocks in Markdown or SQL queries in Python strings.
Here’s an example from an injections.scm file for Markdown:
(fenced_code_block
(info_string
(language) @injection.language)
(code_fence_content) @injection.content)
((inline) @content
(#set! injection.language "markdown-inline"))
This query identifies fenced code blocks, capturing the language specified in the info string and the content within the block. It also captures inline content and sets its language to “markdown-inline”.
| Capture | Description |
|---|---|
| @injection.language | Captures the language identifier for a code block |
| @injection.content | Captures the content to be treated as a different language |
Note that we couldn’t use JSON as an example here because it doesn’t support language injections.
Syntax overrides
The overrides.scm file defines syntactic scopes that can be used to override
certain editor settings within specific language constructs.
For example, there is a language-specific setting called word_characters that
controls which non-alphabetic characters are considered part of a word, for
example when you double click to select a variable. In JavaScript, “$” and “#”
are considered word characters.
There is also a language-specific setting called completion_query_characters
that controls which characters trigger autocomplete suggestions. In JavaScript,
when your cursor is within a string, “-” is should be considered a completion
query character. To achieve this, the JavaScript overrides.scm file contains
the following pattern:
[
(string)
(template_string)
] @string
And the JavaScript config.toml contains this setting:
word_characters = ["#", "$"]
[overrides.string]
completion_query_characters = ["-"]
You can also disable certain auto-closing brackets in a specific scope. For
example, to prevent auto-closing ' within strings, you could put the following
in the JavaScript config.toml:
brackets = [
{ start = "'", end = "'", close = true, newline = false, not_in = ["string"] },
# other pairs...
]
Range inclusivity
By default, the ranges defined in overrides.scm are exclusive. So in the
case above, if you cursor was outside the quotation marks delimiting the
string, the string scope would not take effect. Sometimes, you may want to
make the range inclusive. You can do this by adding the .inclusive suffix to
the capture name in the query.
For example, in JavaScript, we also disable auto-closing of single quotes within
comments. And the comment scope must extend all the way to the newline after a
line comment. To achieve this, the JavaScript overrides.scm contains the
following pattern:
(comment) @comment.inclusive
Text objects
The textobjects.scm file defines rules for navigating by text objects. This
was added in Gram v0.165 and is currently used only in Vim mode.
Vim provides two levels of granularity for navigating around files.
Section-by-section with [] etc., and method-by-method with ]m etc. Even
languages that don’t support functions and classes can work well by defining
similar concepts. For example CSS defines a rule-set as a method, and a
media-query as a class.
For languages with closures, these typically should not count as functions in Gram. This is best-effort however, as languages like JavaScript do not syntactically differentiate syntactically between closures and top-level function declarations.
For languages with declarations like C, provide queries that match
@class.around or @function.around. The if and ic text objects will
default to these if there is no inside.
If you are not sure what to put in textobjects.scm, both nvim-treesitter-textobjects, and the Helix editor have queries for many languages. You can refer to the Gram built-in languages to see how to adapt these.
| Capture | Description | Vim mode |
|---|---|---|
| @function.around | An entire function definition or equivalent small section of a file. | [m, ]m, [M,]M motions. af text object |
| @function.inside | The function body (the stuff within the braces). | if text object |
| @class.around | An entire class definition or equivalent large section of a file. | [[, ]], [], ][ motions. ac text object |
| @class.inside | The contents of a class definition. | ic text object |
| @comment.around | An entire comment (e.g. all adjacent line comments, or a block comment) | gc text object |
| @comment.inside | The contents of a comment | igc text object (rarely supported) |
For example:
; include only the content of the method in the function
(method_definition
body: (_
"{"
(_)* @function.inside
"}")) @function.around
; match function.around for declarations with no body
(function_signature_item) @function.around
; join all adjacent comments into one
(comment)+ @comment.around
Runnable code detection
The runnables.scm file defines rules for detecting runnable code.
Here’s an example from a runnables.scm file for JSON:
(
(document
(object
(pair
key: (string
(string_content) @_name
(#eq? @_name "scripts")
)
value: (object
(pair
key: (string (string_content) @run @script)
)
)
)
)
)
(#set! tag package-script)
(#set! tag composer-script)
)
This query detects runnable scripts in package.json and composer.json files.
The @run capture specifies where the run button should appear in the editor.
Other captures, except those prefixed with an underscore, are exposed as
environment variables with a prefix of GRAM_CUSTOM_$(capture_name) when
running the code.
| Capture | Description |
|---|---|
| @_name | Captures the “scripts” key |
| @run | Captures the script name |
| @script | Also captures the script name (for different purposes) |
Language Servers
Gram uses the Language Server Protocol to provide advanced language support.
An extension may provide any number of language servers. To provide a language
server from your extension, add an entry to your extension.toml with the name
of your language server and the language(s) it applies to. The entry in the list
of languages has to match the name field from the config.toml file for
that language:
[language_servers.my-language-server]
name = "My Language LSP"
languages = ["My Language"]
Then, in the Rust code for your extension, implement the
language_server_command method on your extension:
#![allow(unused)]
fn main() {
impl gram::Extension for MyExtension {
fn language_server_command(
&mut self,
language_server_id: &LanguageServerId,
worktree: &gram::Worktree,
) -> Result<gram::Command> {
Ok(gram::Command {
command: get_path_to_language_server_executable()?,
args: get_args_for_language_server()?,
env: get_env_for_language_server()?,
})
}
}
}
You can customize the handling of the language server using several optional
methods in the Extension trait. For example, you can control how completions
are styled using the label_for_completion method. For a complete list of
methods, see the
API docs for the Gram extension API.
Multi-Language Support
If your language server supports additional languages, you can use
language_ids to map Gram languages to the desired
LSP-specific languageId
identifiers:
[language-servers.my-language-server]
name = "Whatever LSP"
languages = ["JavaScript", "HTML", "CSS"]
[language-servers.my-language-server.language_ids]
"JavaScript" = "javascript"
"TSX" = "typescriptreact"
"HTML" = "html"
"CSS" = "css"
-
These annotations are used by Assistant when generating code modification steps. ↩
Themes
The themes directory in an extension should contain one or more theme files.
Each theme file should adhere to the JSON schema specified at
https://zed.dev/schema/themes/v0.2.0.json.
See this Zed blog post for more details about creating themes.
Theme JSON Structure
The structure of a Gram theme is defined in the Zed Theme JSON Schema.
A Gram theme consists of a Theme Family object including:
name: The name for the theme familyauthor: The name of the author of the theme familythemes: An array of Themes belonging to the theme family
The core components a Theme object include:
-
Theme Metadata:
name: The name of the themeappearance: Either “light” or “dark”
-
Style Properties under the
style, such as:background: The main background colorforeground: The main text coloraccent: The accent color used for highlighting and emphasis
-
Syntax Highlighting:
syntax: An object containing color definitions for various syntax elements (e.g., keywords, strings, comments)
-
UI Elements:
- Colors for various UI components such as:
element.background: Background color for UI elementsborder: Border colors for different states (normal, focused, selected)text: Text colors for different states (normal, muted, accent)
- Colors for various UI components such as:
-
Editor-specific Colors:
- Colors for editor-related elements such as:
editor.background: Editor background coloreditor.gutter: Gutter colorseditor.line_number: Line number colors
- Colors for editor-related elements such as:
-
Terminal Colors:
- ANSI color definitions for the integrated terminal
Language Support in Gram
Gram supports hundreds of programming languages and text formats. Some work out-of-the box and others rely on 3rd party extensions.
The ones included out-of-the-box, natively built into Gram, are marked with *.
Languages with Documentation
- Ansible
- AsciiDoc
- Astro
- Bash
- Biome
- C *
- C++ *
- C#
- Clojure
- CSS *
- Dart
- Deno
- Diff *
- Docker
- Elixir
- Elm
- Emmet
- Erlang *
- Fish
- GDScript
- Gleam *
- GLSL
- Go *
- Groovy
- Haskell
- Helm
- HTML *
- Java
- JavaScript *
- Julia
- JSON *
- Jsonnet
- Kotlin
- Lua *
- Luau
- Makefile
- Markdown *
- Nim
- Nix *
- OCaml
- Odin *
- OpenTofu *
- PHP
- Prisma
- Proto
- PureScript
- Python *
- R
- Rego
- ReStructuredText
- Racket
- Roc
- Roto *
- Ruby
- Rust *
- Scala
- Scheme *
- Shell Script
- SQL *
- Svelte
- Swift
- Tailwind CSS *
- Terraform
- TOML *
- TypeScript *
- Typst *
- Uiua
- Vue
- XML *
- YAML *
- Yara
- Yarn
- Zig *
Additional Language Extensions
- Ada
- Aiken
- Amber
- Assembly
- AWK
- Beancount
- Bend
- Blade
- Blueprint
- BQN
- Brainfuck
- Cadence
- Cairo
- Cap’n Proto
- Cedar
- CFEngine policy language
- CSV
- Cucumber/Gherkin
- CUE
- Curry
- D
- Database Markup Language (DBML)
- Earthfile
- EJS template
- Elisp
- Ember
- Env
- Exograph
- Fortran
- F#
- Git Firefly
- GraphQL
- Groq
- INI
- Java
- Justfiles
- LaTeX
- Ledger
- Less
- LilyPond
- Liquid
- Log
- Lox
- Markdown Oxide
- Marksman
- Matlab
- Meson
- Navi
- NeoCMake
- Nginx
- Nim
- Nix
- Noir
- Nu
- Pact
- Pest
- PICA200 assembly
- Pkl
- PlaydateSDK
- QML
- Rainbow CSV
- Rego
- Rescript
- Roclang
- Ron
- Metals
- SCSS
- Slim
- Slint
- Smithy
- Solidity
- Strace
- Swift
- Templ
- Tmux
- Twig
- Typst
- Unison
- UnoCSS
- Vlang
- Vala
- Vale
- Verilog
- VHS
- Wgsl
- WIT
Ansible
Support for Ansible in Gram is provided via a community-maintained Ansible extension.
- Tree-sitter: zed-industries/tree-sitter-yaml
- Language Server: ansible/vscode-ansible
Setup
File detection
To avoid mishandling non-Ansible YAML files, the Ansible Language is not
associated with any file extensions by default. To change this behavior you can
add a "file_types" section to Gram settings inside your project
(.gram/settings.jsonc) or your Gram user settings
(~/.config/gram/settings.jsonc) to match your folder/naming conventions. For
example:
"file_types": {
"Ansible": [
"**.ansible.yml",
"**.ansible.yaml",
"**/defaults/*.yml",
"**/defaults/*.yaml",
"**/meta/*.yml",
"**/meta/*.yaml",
"**/tasks/*.yml",
"**/tasks/*.yaml",
"**/handlers/*.yml",
"**/handlers/*.yaml",
"**/group_vars/*.yml",
"**/group_vars/*.yaml",
"**/host_vars/*.yml",
"**/host_vars/*.yaml",
"**/playbooks/*.yml",
"**/playbooks/*.yaml",
"**playbook*.yml",
"**playbook*.yaml"
]
}
Feel free to modify this list as per your needs.
Inventory
If your inventory file is in the YAML format, you can either:
- Append the
ansible-lintinventory json schema to it via the following comment at the top of your inventory file:
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json
- Or configure the yaml language server settings to set this schema for all your inventory files, that match your inventory pattern, under your Gram settings (ref):
"lsp": {
"yaml-language-server": {
"settings": {
"yaml": {
"schemas": {
"https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json": [
"./inventory/*.yaml",
"hosts.yml",
]
}
}
}
}
},
LSP Configuration
By default, the following default config is passed to the Ansible language server. It conveniently mirrors the defaults set by nvim-lspconfig for the Ansible language server:
{
"ansible": {
"ansible": {
"path": "ansible",
},
"executionEnvironment": {
"enabled": false,
},
"python": {
"interpreterPath": "python3",
},
"validation": {
"enabled": true,
"lint": {
"enabled": true,
"path": "ansible-lint",
},
},
},
}
[!NOTE] In order for linting to work, ensure that
ansible-lintis installed and discoverable on your PATH
When desired, any of the above default settings can be overridden under the
"lsp" section of your Gram settings file. For example:
"lsp": {
// Note, the Gram Ansible extension prefixes all settings with `ansible`
// so instead of using `ansible.ansible.path` use `ansible.path`.
"ansible-language-server": {
"settings": {
"ansible": {
"path": "ansible"
},
"executionEnvironment": {
"enabled": false
},
"python": {
"interpreterPath": "python3"
},
"validation": {
"enabled": false, // disable validation
"lint": {
"enabled": false, // disable ansible-lint
"path": "ansible-lint"
}
}
}
}
}
A full list of options/settings, that can be passed to the server, can be found at the project’s page here. Feel free to modify option values as needed.
AsciiDoc
AsciiDoc language support in Gram is provided by the community-maintained AsciiDoc extension. Report issues to: https://github.com/andreicek/zed-asciidoc/issues
- Tree-sitter: cathaysia/tree-sitter-asciidoc
Astro
Astro support is available through the Astro extension.
- Tree-sitter: virchau13/tree-sitter-astro
- Language Server: withastro/language-tools
Bash
Bash language support is provided natively by Gram.
- Tree-sitter: tree-sitter/tree-sitter-bash
- Language Server: bash-lsp/bash-language-server
Configuration
shellcheck
bash-language-server supports shellcheck and will make use of it
automatically, if installed. This must be done manually by the user.
brew install shellcheck # macOS (HomeBrew)
apt install shellcheck # Ubuntu / Debian
pacman -S shellcheck # Arch Linux
dnf install shellcheck # Fedora
yum install shellcheck # CentOS/RHEL
zypper install shellcheck # openSUSE
choco install shellcheck # Windows (Chocolatey)
And verify it is available from your path:
which shellcheck
shellcheck --version
If you wish to customize the warnings/errors reported you just need to create a
.shellcheckrc file. You can do this in the root of your project or in your
home directory (~/.shellcheckrc). See:
shellcheck documentation
for more.
smfmt
Similarly, bash-language-server will make automatic use of shfmt for
formatting, if it is available in $PATH. Install it with:
brew install shfmt # MacOS (HomeBrew)
apt install shfmt # Ubuntu / Debian
pacman -S shfmt # Arch Linux
choco install shfmt # Windows (chocolatey)
To control automatic formatting you can use format_on_save in your Gram
settings or manually invoke editor: format document from the command palette.
See also:
Biome
Biome support in Gram is provided by the community-maintained Biome extension. Report issues to: https://github.com/biomejs/biome-zed/issues
- Language Server: biomejs/biome
Biome Language Support
The Biome extension includes support for the following languages:
- JavaScript
- TypeScript
- JSX
- TSX
- JSON
- JSONC
- Vue.js
- Astro
- Svelte
- CSS
Configuration
By default, the biome.json file is required to be in the root of the
workspace.
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
}
For a full list of biome.json options see
Biome Configuration
documentation.
See the Biome Gram Extension README for a complete list of features and configuration options.
C
C support is available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-c
- Language Server: clangd/clangd
- Debug Adapter: CodeLLDB (primary), GDB (secondary, not available on Apple silicon)
Clangd: Force detect as C
Clangd out of the box assumes mixed C++/C projects. If you have a C-only project
you may wish to instruct clangd to treat all files as C using the -xc flag. To
do this, create a .clangd file in the root of your project with the following:
# yaml-language-server: $schema=https://json.schemastore.org/clangd.json
CompileFlags:
Add: [-xc]
By default clang and gcc will recognize *.C and *.H (uppercase extensions)
as C++ and not C and so Gram too follows this convention. If you are working
with a C-only project (perhaps one with legacy uppercase pathing like
FILENAME.C) you can override this behavior by adding this to your settings:
{
"file_types": {
"C": ["C", "H"],
},
}
Formatting
By default the editor will use the clangd language server for formatting C
code like the clang-format CLI tool. To configure this you can add a
.clang-format file. For example:
# yaml-language-server: $schema=https://json.schemastore.org/clang-format-21.x.json
---
BasedOnStyle: GNU
IndentWidth: 2
---
See Clang-Format Style Options for a complete list of options.
You can trigger formatting via {#kb editor::Format} or the editor: format
action from the command palette or by adding format_on_save to your Gram
settings:
"languages": {
"C": {
"format_on_save": "on",
"tab_size": 2
}
}
Compile Commands
For some projects Clangd requires a compile_commands.json file to properly
analyze your project. This file contains the compilation database that tells
clangd how your project should be built.
CMake Compile Commands
With CMake, you can generate compile_commands.json automatically by adding the
following line to your CMakeLists.txt:
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
After building your project, CMake will generate the compile_commands.json
file in the build directory and clangd will automatically pick it up.
Debugging
You can use CodeLLDB or GDB to debug native binaries. (Make sure that your build
process passes -g to the C compiler, so that debug information is included in
the resulting binary.) See below for examples of debug configurations that you
can add to .gram/debug.jsonc.
Build and Debug Binary
[
{
"label": "Debug native binary",
"build": {
"command": "make",
"args": ["-j8"],
"cwd": "$GRAM_WORKTREE_ROOT"
},
"program": "$GRAM_WORKTREE_ROOT/build/prog",
"request": "launch",
"adapter": "CodeLLDB"
}
]
Clojure
Clojure support is available through the Clojure extension.
- Tree-sitter: prcastro/tree-sitter-clojure
- Language Server: clojure-lsp/clojure-lsp
C++
C++ support is available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-cpp
- Language Server: clangd/clangd
Binary
You can configure which clangd binary Gram should use.
By default, Gram will try to find a clangd in your $PATH and try to use
that. If that binary successfully executes, it’s used. Otherwise, Gram will fall
back to installing its own clangd version and use that.
If you want to install a pre-release clangd version instead you can instruct
Gram to do so by setting pre_release to true in your settings.jsonc:
{
"lsp": {
"clangd": {
"fetch": {
"pre_release": true,
},
},
},
}
If you want to disable Gram looking for a clangd binary, you can set
ignore_system_version to true in your settings.jsonc:
{
"lsp": {
"clangd": {
"binary": {
"ignore_system_version": true,
},
},
},
}
If you want to use a binary in a custom location, you can specify a path and
optional arguments:
{
"lsp": {
"clangd": {
"binary": {
"path": "/path/to/clangd",
"arguments": [],
},
},
},
}
This "path" has to be an absolute path.
Arguments
You can pass any number of arguments to clangd. To see a full set of available
options, run clangd --help from the command line. For example with
--function-arg-placeholders=0 completions contain only parentheses for
function calls, while the default (--function-arg-placeholders=1) completions
also contain placeholders for method parameters.
{
"lsp": {
"clangd": {
"binary": {
"path": "/path/to/clangd",
"arguments": ["--function-arg-placeholders=0"],
},
},
},
}
Formatting
By default Gram will use the clangd language server for formatting C++ code.
The Clangd is the same as the clang-format CLI tool. To configure this you can
add a .clang-format file. For example:
# yaml-language-server: $schema=https://json.schemastore.org/clang-format-21.x.json
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
---
See Clang-Format Style Options for a complete list of options.
You can trigger formatting via {#kb editor::Format} or the editor: format
action from the command palette or by adding format_on_save to your Gram
settings:
"languages": {
"C++": {
"format_on_save": "on",
"tab_size": 2
}
}
More server configuration
In the root of your project, it is generally common to create a .clangd file
to set extra configuration.
# yaml-language-server: $schema=https://json.schemastore.org/clangd.json
CompileFlags:
Add:
- "--include-directory=/path/to/include"
Diagnostics:
MissingIncludes: Strict
UnusedIncludes: Strict
For more advanced usage of clangd configuration file, take a look into their official page.
Compile Commands
For some projects Clangd requires a compile_commands.json file to properly
analyze your project. This file contains the compilation database that tells
clangd how your project should be built.
CMake Compile Commands
With CMake, you can generate compile_commands.json automatically by adding the
following line to your CMakeLists.txt:
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
After building your project, CMake will generate the compile_commands.json
file in the build directory and clangd will automatically pick it up.
Debugging
You can use CodeLLDB or GDB to debug native binaries. (Make sure that your build
process passes -g to the C++ compiler, so that debug information is included
in the resulting binary.) See below for examples of debug configurations that
you can add to .gram/debug.json.
- CodeLLDB configuration documentation
- GDB configuration documentation
- GDB needs to be at least v14.1
Build and Debug Binary
[
{
"label": "Debug native binary",
"build": {
"command": "make",
"args": ["-j8"],
"cwd": "$GRAM_WORKTREE_ROOT"
},
"program": "$GRAM_WORKTREE_ROOT/build/prog",
"request": "launch",
"adapter": "CodeLLDB"
}
]
Protocol Extensions
Zed currently implements the following clangd
extensions:
Inactive Regions
Automatically dims inactive sections of code due to preprocessor directives,
such as #if, #ifdef, or #ifndef blocks that evaluate to false.
Switch Between Source and Header Files
Allows switching between corresponding C++ source files (e.g., .cpp) and
header files (e.g., .h). by running the command {#action
editor::SwitchSourceHeader} from the command palette or by setting a keybinding
for the editor::SwitchSourceHeader action.
{
"context": "Editor",
"bindings": {
"alt-enter": "editor::SwitchSourceHeader",
},
}
C#
Note language name is “CSharp” for settings not “C#’
C# support is available through the C# extension.
- Tree-sitter: tree-sitter/tree-sitter-c-sharp
- Language Server: OmniSharp/omnisharp-roslyn
Configuration
The OmniSharp binary can be configured in a Gram settings file with:
{
"lsp": {
"omnisharp": {
"binary": {
"path": "/path/to/OmniSharp",
"arguments": ["optional", "additional", "args", "-lsp"],
},
},
},
}
CSS
Gram has built-in support for CSS.
- Tree-sitter: tree-sitter/tree-sitter-css
- Language Servers:
Tailwind CSS
Gram also supports Tailwind CSS out-of-the-box for languages and frameworks like JavaScript, Astro, Svelte, and more.
Recommended Reading
Dart
Dart support is available through the Dart extension.
- Tree-sitter: UserNobody14/tree-sitter-dart
- Language Server: dart language-server
Pre-requisites
You will need to install the Dart SDK.
You can install dart from dart.dev/get-dart or via the Flutter Version Management CLI (fvm)
Configuration
The dart extension requires no configuration if you have dart in your path:
which dart
dart --version
If you would like to use a specific dart binary or use dart via FVM you can
specify the dart binary in your Gram settings.jsonc file:
{
"lsp": {
"dart": {
"binary": {
"path": "/opt/homebrew/bin/fvm",
"arguments": ["dart", "language-server", "--protocol=lsp"],
},
},
},
}
Formatting
Dart by-default uses a very conservative maximum line length (80). If you would like the dart LSP to permit a longer line length when auto-formatting, add the following to your Gram settings.jsonc:
{
"lsp": {
"dart": {
"settings": {
"lineLength": 140,
},
},
},
}
Please see the Dart documentation for more information on dart language-server capabilities.
Deno
Deno support is available through the Deno extension.
- Language server: Deno Language Server
Deno Configuration
To use the Deno Language Server with TypeScript and TSX files, you will likely
wish to disable the default language servers and enable deno by adding the
following to your settings.jsonc:
{
"lsp": {
"deno": {
"settings": {
"deno": {
"enable": true,
},
},
},
},
"languages": {
"JavaScript": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
"!eslint",
],
"formatter": "language_server",
},
"TypeScript": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
"!eslint",
],
"formatter": "language_server",
},
"TSX": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
"!eslint",
],
"formatter": "language_server",
},
},
}
See Configuring supported languages in the Gram documentation for more information.
Configuration completion
To get completions for deno.json or package.json you can add the following
to your settings.jsonc: (More info here ./json.md)
"lsp": {
"json-language-server": {
"settings": {
"json": {
"schemas": [
{
"fileMatch": [
"deno.json",
"deno.jsonc"
],
"url": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json"
},
{
"fileMatch": [
"package.json"
],
"url": "https://www.schemastore.org/package"
}
]
}
}
}
}
DAP support
To debug deno programs, add this to .gram/debug.jsonc
[
{
"adapter": "JavaScript",
"label": "Deno",
"request": "launch",
"type": "pwa-node",
"cwd": "$GRAM_WORKTREE_ROOT",
"program": "$GRAM_FILE",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--allow-all", "--inspect-wait"],
"attachSimplePort": 9229
}
]
Runnable support
To run deno tasks like tests from the ui, add this to .gram/tasks.jsonc
[
{
"label": "deno test",
"command": "deno test -A --filter '/^$GRAM_CUSTOM_DENO_TEST_NAME$/' '$GRAM_FILE'",
"tags": ["js-test"]
}
]
See also:
Diff
Diff support is available natively in Gram.
- Tree-sitter: zed-industries/the-mikedavis/tree-sitter-diff
Configuration
Gram will not attempt to format diff files and has
remove_trailing_whitespace_on_save
and
ensure-final-newline-on-save
set to false.
Gram will automatically recognize files with patch and diff extensions as
Diff files. To recognize other extensions, add them to file_types in your Gram
settings.jsonc:
"file_types": {
"Diff": ["dif"]
},
Docker
Support for Dockerfile and docker-compose.yaml in Gram is provided by
community-maintained extensions.
Docker Compose
Docker compose.yaml language support in Gram is provided by the
Docker Compose extension.
- Language Server: microsoft/compose-language-service
Dockerfile
Dockerfile language support in Gram is provided by the
Dockerfile extension.
- Tree-sitter: camdencheek/tree-sitter-dockerfile
- Language Server: rcjsuen/dockerfile-language-server
Elixir
Elixir support is available through the Elixir extension.
- Tree-sitter:
- Language servers:
Choosing a language server
The Elixir extension offers language server support for expert, elixir-ls,
next-ls, and lexical.
elixir-ls is enabled by default.
Expert
To switch to expert, add the following to your settings.jsonc:
"languages": {
"Elixir": {
"language_servers": ["expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
},
"HEEX": {
"language_servers": ["expert", "!elixir-ls", "!next-ls", "!lexical", "..."]
}
}
Next LS
To switch to next-ls, add the following to your settings.jsonc:
"languages": {
"Elixir": {
"language_servers": ["next-ls", "!expert", "!elixir-ls", "!lexical", "..."]
},
"HEEX": {
"language_servers": ["next-ls", "!expert", "!elixir-ls", "!lexical", "..."]
}
}
Lexical
To switch to lexical, add the following to your settings.jsonc:
"languages": {
"Elixir": {
"language_servers": ["lexical", "!expert", "!elixir-ls", "!next-ls", "..."]
},
"HEEX": {
"language_servers": ["lexical", "!expert", "!elixir-ls", "!next-ls", "..."]
}
}
Setting up elixir-ls
- Install
elixir:
brew install elixir
- Install
elixir-ls:
brew install elixir-ls
- Restart Gram
If
elixir-lsis not running in an elixir project, check the error log via the command palette actiongram: open log. If you find an error message mentioning:invalid LSP message header "Shall I install Hex? (if running non-interactively, use \"mix local.hex --force\") [Yn], you might need to installHex. You runelixir-lsfrom the command line and accept the prompt to installHex.
Formatting with Mix
If you prefer to format your code with Mix,
use the following snippet in your settings.jsonc file to configure it as an
external formatter. Formatting will occur on file save.
{
"languages": {
"Elixir": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "mix",
"arguments": ["format", "--stdin-filename", "{buffer_path}", "-"],
},
},
},
},
}
Additional workspace configuration options
You can pass additional elixir-ls workspace configuration options via lsp
settings in settings.jsonc.
The following example disables dialyzer:
"lsp": {
"elixir-ls": {
"settings": {
"dialyzerEnabled": false
}
}
}
See ElixirLS configuration settings for more options.
HEEx
Gram also supports HEEx templates. HEEx is a mix of EEx (Embedded Elixir) and HTML, and is used in Phoenix LiveView applications.
- Tree-sitter: phoenixframework/tree-sitter-heex
Elm
Elm support is available through the Elm extension.
- Tree-sitter: elm-tooling/tree-sitter-elm
- Language Server: elm-tooling/elm-language-server
Setup
Gram support for Elm requires installation of elm, elm-format, and
elm-review.
- Install Elm (or run
brew install elmon macOS). - Install
elm-reviewto support code linting:npm install elm-review --save-dev - Install
elm-formatto support automatic formattingnpm install -g elm-format
Configuring elm-language-server
Elm language server can be configured in your settings.jsonc, e.g.:
{
"lsp": {
"elm-language-server": {
"initialization_options": {
"disableElmLSDiagnostics": true,
"onlyUpdateDiagnosticsOnSave": false,
"elmReviewDiagnostics": "warning",
},
},
},
}
elm-format, elm-review and elm need to be installed and made available in
the environment or configured in the settings. See the
full list of server settings here.
Emmet
Emmet support is available through the Emmet extension.
Emmet is a web-developer’s toolkit that can greatly improve your HTML & CSS workflow.
- Language Server: olrtg/emmet-language-server
Erlang
Erlang support is built into the editor.
- Tree-sitter: WhatsApp/tree-sitter-erlang
- Language Servers:
Choosing a language server
The Erlang extension offers language server support for erlang_ls and
erlang-language-platform.
erlang_ls is enabled by default.
To switch to erlang-language-platform, add the following to your
settings.jsonc:
{
"languages": {
"Erlang": {
"language_servers": ["elp", "!erlang-ls", "..."],
},
},
}
See also:
Fish
Fish language support in Gram is provided by the community-maintained Fish extension. Report issues to: https://github.com/hasit/zed-fish/issues
- Tree-sitter: ram02z/tree-sitter-fish
Formatting
Gram supports auto-formatting fish code using external tools like
fish_indent, which
is included with fish.
- Ensure
fish_indentis available in your path and check the version:
which fish_indent
fish_indent --version
- Configure Gram to automatically format fish code with
fish_indent:
"languages": {
"Fish": {
"formatter": {
"external": {
"command": "fish_indent"
}
}
}
},
GDScript
Godot GDScript language support in Gram is provided by the community-maintained GDScript extension. Report issues to: https://github.com/GDQuest/zed-gdscript/issues
- Tree-sitter: PrestonKnopp/tree-sitter-gdscript and PrestonKnopp/tree-sitter-godot-resource
- Language Server: gdscript-language-server
Pre-requisites
You will need:
- Godot.
- netcat (
ncorncat) on your system PATH.
Setup
- Inside your Godot editor, open Editor Settings, look for
Text Editor -> Externaland set the following options:- Exec Path:
/path/to/zed - Exec Flags:
{project} {file}:{line}:{col} - Use External Editor: “✅ On”
- Exec Path:
- Open any *.gd file through Godot and Gram will launch.
Usage
When Godot is running, the GDScript extension will connect to the language
server provided by the Godot runtime and will provide jump to definition,
hover states when you hold Ctrl/cmd and other language server features.
Gleam
Gleam support is built into the editor.
Gleam is a friendly language for building type-safe systems that scale!
To learn more:
The Gleam language server is built into the gleam compiler and has a lot of helpful features, including go-to definition, automatic imports, and more.
See also:
GLSL
GLSL (OpenGL Shading Language) support is available through the GLSL Extension
- Tree-sitter: theHamsta/tree-sitter-glsl
- Language Server: nolanderc/glsl_analyzer
Go
Go support is available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-go
- Language Server: golang/tools/tree/master/gopls
- Debug Adapter: delve
Setup
We recommend installing gopls via go’s package manager and not via Homebrew or your Linux distribution’s package manager.
- Make sure you have uninstalled any version of gopls you have installed via your package manager:
# MacOS homebrew
brew remove gopls
# Ubuntu
sudo apt-get remove gopls
sudo snap remove gopls
# Arch
sudo pacman -R gopls
- Install/Update
goplsto the latest version using the go module tool:
go install golang.org/x/tools/gopls@latest
- Ensure that
goplsis in your path:
which gopls
gopls version
If gopls is not found you will likely need to add
export PATH="$PATH:$HOME/go/bin" to your .zshrc / .bash_profile
Inlay Hints
Gram sets the following initialization options for inlay hints:
"hints": {
"assignVariableTypes": true,
"compositeLiteralFields": true,
"compositeLiteralTypes": true,
"constantValues": true,
"functionTypeParameters": true,
"parameterNames": true,
"rangeVariableTypes": true
}
to make the language server send back inlay hints when Gram has them enabled in the settings.
Use
"lsp": {
"gopls": {
"initialization_options": {
"hints": {
// ....
}
}
}
}
to override these settings.
See gopls inlayHints documentation for more information.
Debugging
Gram supports zero-configuration debugging of Go tests and entry points
(func main) using Delve. Run {#action debugger::Start} ({#kb debugger::Start})
to see a contextual list of these preconfigured debug tasks.
For more control, you can add debug configurations to .gram/debug.jsonc. See
below for examples.
Debug Go Packages
To debug a specific package, you can do so by setting the Delve mode to “debug”. In this case “program” should be set to the package name.
[
{
"label": "Go (Delve)",
"adapter": "Delve",
"program": "$GRAM_FILE",
"request": "launch",
"mode": "debug"
},
{
"label": "Run server",
"adapter": "Delve",
"request": "launch",
"mode": "debug",
// For Delve, the program can be a package name
"program": "./cmd/server"
// "args": [],
// "buildFlags": [],
}
]
Debug Go Tests
To debug the tests for a package, set the Delve mode to “test”. The “program” is
still the package name, and you can use the “buildFlags” to do things like set
tags, and the “args” to set args on the test binary. (See go help testflags
for more information on doing that).
[
{
"label": "Run integration tests",
"adapter": "Delve",
"request": "launch",
"mode": "test",
"program": ".",
"buildFlags": ["-tags", "integration"]
// To filter down to just the test your cursor is in:
// "args": ["-test.run", "$GRAM_SYMBOL"]
}
]
Build and debug separately
If you need to build your application with a specific command, you can use the “exec” mode of Delve. In this case “program” should point to an executable, and the “build” command should build that.
[
{
"label": "Debug Prebuilt Unit Tests",
"adapter": "Delve",
"request": "launch",
"mode": "exec",
"program": "${GRAM_WORKTREE_ROOT}/__debug_unit",
"args": ["-test.v", "-test.run=${GRAM_SYMBOL}"],
"build": {
"command": "go",
"args": [
"test",
"-c",
"-tags",
"unit",
"-gcflags\"all=-N -l\"",
"-o",
"__debug_unit",
"./pkg/..."
]
}
}
]
Attaching to an existing instance of Delve
You might find yourself needing to connect to an existing instance of Delve
that’s not necessarily running on your machine; in such case, you can use
tcp_arguments to instrument Gram’s connection to Delve.
[
{
"adapter": "Delve",
"label": "Connect to a running Delve instance",
"program": "/Users/gram/Projects/language_repositories/golang/hello/hello",
"cwd": "/Users/gram/Projects/language_repositories/golang/hello",
"args": [],
"env": {},
"request": "launch",
"mode": "exec",
"stopOnEntry": false,
"tcp_connection": { "host": "127.0.0.1", "port": 53412 }
}
]
In such case Gram won’t spawn a new instance of Delve, as it opts to use an existing one. The consequence of this is that there will be no terminal in Gram; you have to interact with the Delve instance directly, as it handles stdin/stdout of the debuggee.
Go Mod
- Tree-sitter: camdencheek/tree-sitter-go-mod
- Language Server: N/A
Go Sum
- Tree-sitter: amaanq/tree-sitter-go-sum
- Language Server: N/A
Go Work
- Tree-sitter: tree-sitter-go-work
- Language Server: N/A
Groovy
Groovy language support in Gram is provided by the community-maintained Groovy extension. Report issues to: https://github.com/valentinegb/zed-groovy/issues
- Tree-sitter: murtaza64/tree-sitter-groovy
- Language Server: GroovyLanguageServer/groovy-language-server
Haskell
Haskell support is available through the Haskell extension.
- Tree-sitter: tree-sitter-haskell
- Language Server: haskell-language-server
Installing HLS
Recommended method to
install haskell-language-server
(HLS) is via ghcup
(curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh ):
ghcup install hls
which haskell-language-server-wrapper
Configuring HLS
If you need to configure haskell-language-server (hls) you can add configuration
options to your Gram settings.jsonc:
{
"lsp": {
"hls": {
"initialization_options": {
"haskell": {
"formattingProvider": "fourmolu",
},
},
},
},
}
See the official configuring haskell-language-server docs for more options.
If you would like to use a specific hls binary, or perhaps use static-ls as a drop-in replacement instead, you can specify the binary path and arguments:
{
"lsp": {
"hls": {
"binary": {
"path": "static-ls",
"arguments": ["--experimentalFeatures"],
},
},
},
}
Helm
Support for Helm in Gram is provided by the community-maintained Helm extension.
- Tree-sitter: tree-sitter-go-template
- Language Server: mrjosh/helm-ls
Setup
Enable Helm language for Helm files by editing your .gram/settings.jsonc and
adding:
"file_types": {
"Helm": [
"**/templates/**/*.tpl",
"**/templates/**/*.yaml",
"**/templates/**/*.yml",
"**/helmfile.d/**/*.yaml",
"**/helmfile.d/**/*.yml",
"**/values*.yaml"
]
}
This will also mark values.yaml files as the type helm, since helm-ls supports this.
HTML
HTML support is built into the editor, both syntax highlighting and language server support.
There is language server support available from two different servers:
By default, the Microsoft language server is disabled and SuperHTML enabled. To
switch language server, add the following to your settings.jsonc:
{
"languages": {
"HTML": {
"language_servers": ["vscode-html-language-server", "!superhtml", "..."],
},
},
}
Formatting
By default Gram uses Prettier for formatting HTML.
You can disable format_on_save by adding the following to your Gram
settings.jsonc:
"languages": {
"HTML": {
"format_on_save": "off",
}
}
You can still trigger formatting manually with {#kb editor::Format} or by opening the Command Palette ({#kb command_palette::Toggle}) and selecting “Format Document”.
LSP Formatting
To use the language server auto-formatting instead of Prettier, add the following to your Gram settings:
"languages": {
"HTML": {
"formatter": "language_server",
}
}
You can customize various
formatting options
for vscode-html-language-server via your Gram settings.json:
"lsp": {
"vscode-html-language-server": {
"settings": {
"html": {
"format": {
// Indent under <html> and <head> (default: false)
"indentInnerHtml": true,
// Disable formatting inside <svg> or <script>
"contentUnformatted": "svg,script",
// Add an extra newline before <div> and <p>
"extraLiners": "div,p"
}
}
}
}
}
See also
Java
Java language support in Gram is provided by:
- Gram Java: zed-extensions/java
- Tree-sitter: tree-sitter/tree-sitter-java
- Language Server: eclipse-jdtls/eclipse.jdt.ls
Install OpenJDK
You will need to install a Java runtime (OpenJDK).
- macOS:
brew install openjdk - Ubuntu:
sudo add-apt-repository ppa:openjdk-23 && sudo apt-get install openjdk-23 - Windows:
choco install openjdk - Arch Linux:
sudo pacman -S jre-openjdk-headless
Or manually download and install OpenJDK 23.
Extension Install
You can install by opening {#action gram::Extensions}({#kb gram::Extensions})
and searching for java.
Quick start and configuration
For the majority of users, Java support should work out of the box.
-
It is generally recommended to open projects with the Gram-project root at the Java project root folder (where you would commonly have your
pom.xmlorbuild.gradlefile). -
By default the extension will download and run the latest official version of JDTLS for you, but this requires Java version 21 to be available on your system via either the
$JAVA_HOMEenvironment variable or as ajava(.exe)executable on your$PATH. If your project requires a lower Java version in the environment, you can specify a different JDK to use for running JDTLS via thejava_homeconfiguration option. -
You can provide a custom launch script for JDTLS, by adding an executable named
jdtls(orjdtls.baton Windows) to your$PATHenvironment variable. If this is present, the extension will skip downloading and launching a managed instance and use the one from the environment. -
To support Lombok, the lombok-jar must be downloaded and registered as a Java-Agent when launching JDTLS. By default the extension automatically takes care of that, but in case you don’t want that you can set the
lombok_supportconfiguration-option tofalse.
Here is a common settings.jsonc including the above mentioned configurations:
{
"lsp": {
"jdtls": {
"settings": {
"java_home": "/path/to/your/JDK21+",
"lombok_support": true,
},
},
},
}
Debugging
Debug support is enabled via our Fork of Java Debug, which the extension will automatically download and start for you. Please refer to the Debugger Documentation for general information about how debugging works in Gram.
To get started with Java, click the edit debug.jsonc button in the Debug menu,
and replace the contents of the file with the following:
[
{
"adapter": "Java",
"request": "launch",
"label": "Launch Debugger",
// if your project has multiple entry points, specify the one to use:
// "mainClass": "com.myorganization.myproject.MyMainClass",
//
// this effectively sets a breakpoint at your program entry:
"stopOnEntry": true,
// the working directory for the debug process
"cwd": "$GRAM_WORKTREE_ROOT",
},
]
You should then be able to start a new Debug Session with the “Launch Debugger” scenario from the debug menu.
Launch Scripts (aka Tasks) in Windows
This extension provides tasks for running your application and tests from within Gram via little play buttons next to tests/entry points. However, due to current limitations of Gram’s extension interface, we can not provide scripts that will work across Maven and Gradle on both Windows and Unix-compatible systems, so out of the box the launch scripts only work on Mac and Linux.
There is a fairly straightforward fix that you can apply to make it work on Windows by supplying your own task scripts. Please see this Issue for information on how to do that and read the Tasks section in Grams documentation for more information.
Advanced Configuration/JDTLS initialization Options
JDTLS provides many configuration options that can be passed via the
initialize LSP-request. The extension will pass the JSON-object from
lsp.jdtls.settings.initialization_options in your settings on to JDTLS. Please
refer to the
JDTLS Configuration Wiki Page
for the available options and values. Below is an example settings.jsonc that
would pass on the example configuration from the above wiki page to JDTLS:
{
"lsp": {
"jdtls": {
"settings": {
// this will be sent to JDTLS as initializationOptions:
"initialization_options": {
"bundles": [],
// use this if your gram project root folder is not the same as the java project root:
"workspaceFolders": ["file:///home/snjeza/Project"],
"settings": {
"java": {
"home": "/usr/local/jdk-9.0.1",
"errors": {
"incompleteClasspath": {
"severity": "warning",
},
},
"configuration": {
"updateBuildConfiguration": "interactive",
"maven": {
"userSettings": null,
},
},
"import": {
"gradle": {
"enabled": true,
},
"maven": {
"enabled": true,
},
"exclusions": [
"**/node_modules/**",
"**/.metadata/**",
"**/archetype-resources/**",
"**/META-INF/maven/**",
"/**/test/**",
],
},
"referencesCodeLens": {
"enabled": false,
},
"signatureHelp": {
"enabled": false,
},
"implementationCodeLens": "all",
"format": {
"enabled": true,
},
"saveActions": {
"organizeImports": false,
},
"contentProvider": {
"preferred": null,
},
"autobuild": {
"enabled": false,
},
"completion": {
"favoriteStaticMembers": [
"org.junit.Assert.*",
"org.junit.Assume.*",
"org.junit.jupiter.api.Assertions.*",
"org.junit.jupiter.api.Assumptions.*",
"org.junit.jupiter.api.DynamicContainer.*",
"org.junit.jupiter.api.DynamicTest.*",
],
"importOrder": ["java", "javax", "com", "org"],
},
},
},
},
},
},
},
}
See also
Gram Java Repo Eclipse JDTLS Repo
JavaScript
JavaScript support is available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-javascript
- Language Server: yioneko/vtsls
- Alternate Language Server: typescript-language-server/typescript-language-server
- Debug Adapter: vscode-js-debug
Code formatting
Formatting on save is enabled by default for JavaScript, using TypeScript’s built-in code formatting. But many JavaScript projects use other command-line code-formatting tools, such as Prettier. You can use one of these tools by specifying an external code formatter for JavaScript in your settings. See the configuration docs for more information.
For example, if you have Prettier installed and on your PATH, you can use it
to format JavaScript files by adding the following to your settings.jsonc:
{
"languages": {
"JavaScript": {
"formatter": {
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"],
},
},
},
},
}
JSX
Gram supports JSX syntax highlighting out of the box.
In JSX strings, the tailwindcss-language-server is used to
provide autocompletion for Tailwind CSS classes.
JSDoc
Gram supports JSDoc syntax in JavaScript and TypeScript comments that match the JSDoc syntax. Gram uses tree-sitter/tree-sitter-jsdoc for parsing and highlighting JSDoc.
ESLint
You can configure Gram to format code using eslint --fix by running the ESLint
code action when formatting:
{
"languages": {
"JavaScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true,
},
},
},
}
You can also only execute a single ESLint rule when using fixAll:
{
"languages": {
"JavaScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true,
},
},
},
"lsp": {
"eslint": {
"settings": {
"codeActionOnSave": {
"rules": ["import/order"],
},
},
},
},
}
Note: the other formatter you have configured will still run, after ESLint. So if your language server or Prettier configuration don’t format according to ESLint’s rules, then they will overwrite what ESLint fixed and you end up with errors.
If you only want to run ESLint on save, you can configure code actions as the formatter:
{
"languages": {
"JavaScript": {
"formatter": [],
"code_actions_on_format": {
"source.fixAll.eslint": true,
},
},
},
}
Configure ESLint’s nodePath:
You can configure ESLint’s nodePath setting:
{
"lsp": {
"eslint": {
"settings": {
"nodePath": ".yarn/sdks",
},
},
},
}
Configure ESLint’s problems:
You can configure ESLint’s problems setting.
For example, here’s how to set problems.shortenToSingleLine:
{
"lsp": {
"eslint": {
"settings": {
"problems": {
"shortenToSingleLine": true,
},
},
},
},
}
Configure ESLint’s rulesCustomizations:
You can configure ESLint’s rulesCustomizations setting:
{
"lsp": {
"eslint": {
"settings": {
"rulesCustomizations": [
// set all eslint errors/warnings to show as warnings
{ "rule": "*", "severity": "warn" },
],
},
},
},
}
Configure ESLint’s workingDirectory:
You can configure ESLint’s workingDirectory setting:
{
"lsp": {
"eslint": {
"settings": {
"workingDirectory": {
"mode": "auto",
},
},
},
},
}
Debugging
Gram supports debugging JavaScript code out of the box with vscode-js-debug.
The following can be debugged without writing additional configuration:
- Tasks from
package.json - Tests written using several popular frameworks (Jest, Mocha, Vitest, Jasmine, Bun, Node)
Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks.
Note: Bun test is automatically detected when
@types/bunis present inpackage.json.Note: Node test is automatically detected when
@types/nodeis present inpackage.json(requires Node.js 20+).
As for all languages, configurations from .vscode/launch.json are also
available for debugging in Gram.
If your use-case isn’t covered by any of these, you can take full control by
adding debug configurations to .gram/debug.jsonc. See below for example
configurations.
Configuring JavaScript debug tasks
JavaScript debugging is more complicated than other languages because there are
two different environments: Node.js and the browser. vscode-js-debug exposes a
type field, that you can use to specify the environment, either node or
chrome.
Debug the current file with Node
[
{
"adapter": "JavaScript",
"label": "Debug JS file",
"type": "node",
"request": "launch",
"program": "$GRAM_FILE",
"skipFiles": ["<node_internals>/**"]
}
]
Launch a web app in Chrome
[
{
"adapter": "JavaScript",
"label": "Debug app in Chrome",
"type": "chrome",
"request": "launch",
"file": "$GRAM_WORKTREE_ROOT/index.html",
"webRoot": "$GRAM_WORKTREE_ROOT",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
}
]
See also
- Yarn documentation for a walkthrough of configuring your project to use Yarn.
- TypeScript documentation
JSON
JSON is natively supported in the editor.
- Tree-sitter: tree-sitter/tree-sitter-json
- Language Server: zed-industries/json-language-server
JSONC
Gram also supports a super-set of JSON called JSONC, which allows single line
comments (//) in JSON files. While editing these files you can use cmd-/
(macOS) or ctrl-/ (Linux) to toggle comments on the current line or selection.
JSONC Prettier Formatting
If you use files with the *.jsonc extension when using Format Document or
have format_on_save enabled, Gram invokes Prettier as the formatter. Prettier
has an outstanding issue
where it will add trailing commas to files with a jsonc extension. JSONC files
which have a .json extension are unaffected.
To workaround this behavior you can add the following to your .prettierrc
configuration file:
{
"overrides": [
{
"files": ["*.jsonc"],
"options": {
"parser": "json",
"trailingComma": "none",
},
},
],
}
JSON Language Server
Gram automatically out of the box supports JSON Schema validation of
package.json and tsconfig.json files, but json-language-server can use
JSON Schema definitions in project files, from the
JSON Schema Store or other publicly available
URLs for JSON validation.
Inline Schema Specification
To specify a schema inline with your JSON files, add a $schema top level key
linking to your json schema file.
For example to for a .luarc.json for use with
lua-language-server:
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
}
Schema Specification via Settings
You can alternatively associate JSON Schemas with file paths by via Gram LSP settings.
To
"lsp": {
"json-language-server": {
"settings": {
"json": {
"schemas": [
{
"fileMatch": ["*/*.luarc.json"],
"url": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json"
}
]
}
}
}
}
You can also pass any of the
supported settings
to json-language-server by specifying them in your Gram settings.jsonc:
Jsonnet
Jsonnet language support in Gram is provided by the community-maintained Jsonnet extension.
- Tree-sitter: sourcegraph/tree-sitter-jsonnet
- Language Server: grafana/jsonnet-language-server
Configuration
Workspace configuration options can be passed to the language server via the
lsp settings of the settings.jsonc.
The following example enables support for resolving tanka
import paths in jsonnet-language-server:
{
"lsp": {
"jsonnet-language-server": {
"settings": {
"resolve_paths_with_tanka": true,
},
},
},
}
Julia
Julia language support in Gram is provided by the community-maintained Julia extension. Report issues to: https://github.com/JuliaEditorSupport/zed-julia/issues
- Tree-sitter: tree-sitter/tree-sitter-julia
- Language Server: julia-vscode/LanguageServer.jl
Kotlin
Kotlin language support in Gram is provided by the community-maintained Kotlin extension. Report issues to: https://github.com/zed-extensions/kotlin/issues
- Tree-sitter: fwcd/tree-sitter-kotlin
- Language Server: fwcd/kotlin-language-server
Configuration
Workspace configuration options can be passed to the language server via lsp
settings in settings.jsonc.
The full list of lsp settings can be found
here
under class Configuration and initialization_options under
class InitializationOptions.
JVM Target
The following example changes the JVM target from default (which is 1.8) to
17:
{
"lsp": {
"kotlin-language-server": {
"settings": {
"compiler": {
"jvm": {
"target": "17",
},
},
},
},
},
}
JAVA_HOME
To use a specific java installation, just specify the JAVA_HOME environment
variable with:
{
"lsp": {
"kotlin-language-server": {
"binary": {
"env": {
"JAVA_HOME": "/Users/whatever/Applications/Work/Android Studio.app/Contents/jbr/Contents/Home",
},
},
},
},
}
Lua
Lua support is built into the editor.
- Tree-sitter: tree-sitter-grammars/tree-sitter-lua
- Language server: LuaLS/lua-language-server
luarc.json
To configure LuaLS you can create a .luarc.json file in the root of your
workspace.
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
"format.enable": true,
"workspace.library": ["../somedir/library"],
}
See LuaLS Settings Documentation for
all available configuration options, or when editing this file in Gram available
settings options will autocomplete, (e.g runtime.version will show
"Lua 5.1", "Lua 5.2", "Lua 5.3", "Lua 5.4" and "LuaJIT" as allowed
values). Note when importing settings options from VS Code, remove the Lua.
prefix. (e.g. runtime.version instead of Lua.runtime.version).
LuaCATS Definitions
LuaLS can provide enhanced LSP autocompletion suggestions and type validation
with the help of LuaCATS (Lua Comment and Type System) definitions. These
definitions are available for many common Lua libraries, and local paths
containing them can be specified via workspace.library in luarc.json. You
can do this via relative paths if you checkout your definitions into the same
partent directory of your project (../playdate-luacats, ../love2d, etc).
Alternatively you can create submodule(s) inside your project for each LuaCATS
definition repo.
LÖVE (Love2D)
To use LÖVE (Love2D) in Gram, checkout
LuaCATS/love2d into a folder called
love2d-luacats into the parent folder of your project:
cd .. && git clone https://github.com/LuaCATS/love2d love2d-luacats
Then in your .luarc.json:
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
"workspace.library": ["../love2d-luacats"],
"runtime.special": {
"love.filesystem.load": "loadfile"
}
}
PlaydateSDK
To use Playdate Lua SDK in Gram, checkout playdate-luacats into the parent folder of your project:
cd .. && git clone https://github.com/notpeter/playdate-luacats
Then in your .luarc.json:
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
"runtime.nonstandardSymbol": [
"+=",
"-=",
"*=",
"/=",
"//=",
"%=",
"<<=",
">>=",
"&=",
"|=",
"^=",
],
"diagnostics.severity": { "duplicate-set-field": "Hint" },
"diagnostics.globals": ["import"],
"workspace.library": ["../playdate-luacats"],
"format.defaultConfig": {
"indent_style": "space",
"indent_size": "4",
},
"format.enable": true,
"runtime.builtin": { "io": "disable", "os": "disable", "package": "disable" },
}
Inlay Hints
To enable Inlay Hints for LuaLS in Gram
- Add the following to your Gram settings.jsonc:
"languages": {
"Lua": {
"inlay_hints": {
"enabled": true,
"show_type_hints": true,
"show_parameter_hints": true,
"show_other_hints": true
}
}
}
- Add
"hint.enable": trueto your.luarc.json.
Formatting
LuaLS Formatting
To enable auto-formatting with your LuaLS (provided by
CppCXY/EmmyLuaCodeStyle) make sure
you have "format.enable": true, in your .luarc.json:
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"format.enable": true,
}
Then add the following to your Gram settings.jsonc:
{
"languages": {
"Lua": {
"format_on_save": "on",
"formatter": "language_server",
},
},
}
You can customize various EmmyLuaCodeStyle style options via .editorconfig,
see
lua.template.editorconfig
for all available options.
StyLua Formatting
Alternatively to use StyLua for auto-formatting:
- Install StyLua:
brew install styluaorcargo install stylua --features lua52,lua53,lua54,luau,luajit(feel free to remove any Lua versions you don’t need). - Add the following to your
settings.jsonc:
{
"languages": {
"Lua": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "stylua",
"arguments": [
"--syntax=Lua54",
"--respect-ignores",
"--stdin-filepath",
"{buffer_path}",
"-",
],
},
},
},
},
}
You can specify various options to StyLua either on the command line above (like
--syntax=Lua54) or in a stylua.toml in your workspace:
syntax = "Lua54"
column_width = 100
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "All"
[sort_requires]
enabled = true
For a complete list of available options, see: StyLua Options.
Luau
Luau is a fast, small, safe, gradually typed, embeddable scripting language derived from Lua. Luau was developed by Roblox and is available under the MIT license.
Luau language support in Gram is provided by the community-maintained Luau extension. Report issues to: https://github.com/4teapo/zed-luau/issues
- Tree-sitter: 4teapo/tree-sitter-luau
- Language Server: JohnnyMorganz/luau-lsp
Configuration
Configuration instructions are available in the Luau Gram Extension README.
Formatting
To support automatically formatting your code, you can use JohnnyMorganz/StyLua, a Lua code formatter.
Install with:
# macOS via Homebrew
brew install stylua
# Or via Cargo
cargo install stylua --features lua52,lua53,lua54,luau
Then add the following to your Gram settings.json:
"languages": {
"Luau": {
"formatter": {
"external": {
"command": "stylua",
"arguments": ["-"]
}
}
}
}
Makefile
Makefile language support in Gram is provided by the community-maintained Make extension. Report issues to: https://github.com/caius/zed-make/issues.
- Tree-sitter: caius/tree-sitter-make
Markdown
Markdown support is available natively in Gram.
- Tree-sitter: tree-sitter-markdown
- Language Server: zk
Syntax Highlighting Code Blocks
Gram supports language-specific syntax highlighting of markdown code blocks by leveraging tree-sitter language grammars. All Gram supported languages, including those provided by official or community extensions, are available for use in markdown code blocks. All you need to do is provide a language name after the opening ``` code fence like so:
```python
import functools as ft
@ft.lru_cache(maxsize=500)
def fib(n):
return n if n < 2 else fib(n - 1) + fib(n - 2)
```
Configuration
Language Server (zk)
Gram comes with support for the zk zettelkasten language server built in.
To enable it, add this to your settings.json:
"languages": {
"Markdown": {
"language_servers": ["zk"],
}
},
See the documentation more information
about zk and the zettelkasten system for note taking.
Format
Gram supports using Prettier to automatically re-format Markdown documents. You
can trigger this manually via the {#action editor::Format} action or via the
{#kb editor::Format} keyboard shortcut. Alternately, you can automatically
format by enabling format_on_save in
your settings.json:
"languages": {
"Markdown": {
"format_on_save": "on"
}
},
Trailing Whitespace
By default Gram will remove trailing whitespace on save. If you rely on
invisible trailing whitespace being converted to <br /> in Markdown files you
can disable this behavior with:
"languages": {
"Markdown": {
"remove_trailing_whitespace_on_save": false
}
},
Nim
Nim language support in Gram is provided by the community-maintained Nim extension. Report issues to: https://github.com/foxoman/zed-nim/issues
- Tree-sitter: alaviss/tree-sitter-nim
- Language Server: nim-lang/langserver
Formatting
To use arnetheduck/nph as a formatter,
follow the
nph installation instructions
and add this to your Gram settings.json:
"languages": {
"Nim": {
"formatter": {
"external": {
"command": "nph",
"arguments": ["-"]
}
}
}
}
Nix
Nix support is built into the editor.
Choosing a language server
There is support for two different language servers: nil and nixd.
To only enable nil:
"languages": {
"Nix": {
"language_servers": ["nil", "!nixd", "..."]
},
}
To only enable nixd:
"languages": {
"Nix": {
"language_servers": ["!nil", "nixd", "..."]
},
}
Configuration
Language server options can be set in the settings.jsonc file. See the
Configuring Languages documentation for more
information.
nixd
For more details, see the nixd documentation.
{
"lsp": {
"nixd": {
"settings": {
"diagnostic": {
"suppress": [ "sema-extra-with" ]
}
}
}
}
}
nil
For more details, see the nil documentation.
{
"lsp": {
"nil": {
"settings": {
"diagnostics": {
"ignored": [ "unused_binding" ]
}
}
}
}
}
OCaml
OCaml support is available through the OCaml extension.
- Tree-sitter: tree-sitter/tree-sitter-ocaml
- Language Server: ocaml/ocaml-lsp
Setup Instructions
If you have the development environment already setup, skip to Launching Gram
Using Opam
Opam is the official package manager for OCaml and is highly recommended for getting started with OCaml. To get started using Opam, please follow the instructions provided here.
Proceed once opam is installed and you have setup a switch with your development environment as per the instructions.
Launching Gram
Verify that the ocamllsp command line tool for LSP is installed:
ocamllsp --help
If the command is missing or fails to display the help text, revisit the
installation instructions for ocamllsp and ensure it’s properly installed.
Note: Given how the OCaml package manager works, Gram needs to run from the terminal, so make sure to install the Gram cli.
From a terminal, navigate to an OCaml project and run
gram .
Gram should now be running with OCaml support.
Odin
Odin support is built into the editor.
Odin is a general-purpose programming language with distinct typing built for high performance, modern systems and data-oriented programming.
Odin is the C alternative for the Joy of Programming.
OpenTofu
OpenTofu support is built into the editor. It is the properly open-source alternative to Terraform to provision your infrastructure as code.
PHP
PHP support is available through the PHP extension.
- Tree-sitter: https://github.com/tree-sitter/tree-sitter-php
- Language Servers:
Choosing a language server
The PHP extension offers both phpactor and intelephense language server
support.
phpactor is enabled by default.
Phpactor
The Gram PHP Extension can install phpactor automatically but requires php
to be installed and available in your path:
# brew install php # macOS
# sudo apt-get install php # Debian/Ubuntu
# yum install php # CentOS/RHEL
# pacman -S php # Arch Linux
which php
Intelephense
Intelephense is a proprietary language server for PHP operating under a freemium model. Certain features require purchase of a premium license.
To switch to intelephense, add the following to your settings.json:
{
"languages": {
"PHP": {
"language_servers": ["intelephense", "!phpactor", "!phptools", "..."],
},
},
}
To use the premium features, you can place your
licence.txt file at
~/intelephense/licence.txt inside your home directory. Alternatively, you can
pass the licence key or a path to a file containing the licence key as an
initialization option for the intelephense language server. To do this, add
the following to your settings.jsonc:
{
"lsp": {
"intelephense": {
"initialization_options": {
"licenceKey": "/path/to/licence.txt",
},
},
},
}
PHPDoc
Gram supports syntax highlighting for PHPDoc comments.
- Tree-sitter: claytonrcarter/tree-sitter-phpdoc
Setting up Xdebug
Gram’s PHP extension provides a debug adapter for PHP and Xdebug. The adapter
name is Xdebug. Here a couple ways you can use it:
[
{
"label": "PHP: Listen to Xdebug",
"adapter": "Xdebug",
"request": "launch",
"port": 9003
},
{
"label": "PHP: Debug this test",
"adapter": "Xdebug",
"request": "launch",
"program": "vendor/bin/phpunit",
"args": ["--filter", "$GRAM_SYMBOL"]
}
]
In case you run into issues:
- ensure that you have Xdebug installed for the version of PHP you’re running
- ensure that Xdebug is configured to run in
debugmode - ensure that Xdebug is actually starting a debugging session
- check that the host and port matches between Xdebug and Gram
- look at the diagnostics log by using the
xdebug_info()function in the page you’re trying to debug
PowerShell
PowerShell language support in Gram is provided by the community-maintained Gram PowerShell extension. Please report issues to: github.com/wingyplus/zed-powershell/issues
- Tree-sitter: airbus-cert/tree-sitter-powershell
- Language Server: PowerShell/PowerShellEditorServices
Setup
Install PowerShell 7+
- macOS:
brew install powershell/tap/powershell - Alpine: Installing PowerShell on Alpine Linux
- Debian: Install PowerShell on Debian Linux
- RedHat: Install PowerShell on RHEL
- Ubuntu: Install PowerShell on RHEL
- Windows: Install PowerShell on Windows
The Gram PowerShell extension will default to the pwsh executable found in
your path.
Install PowerShell Editor Services (Optional)
The Gram PowerShell extensions will attempt to download PowerShell Editor Services automatically.
If want to use a specific binary, you can specify in your that in your Gram settings.json:
"lsp": {
"powershell-es": {
"binary": {
"path": "/path/to/PowerShellEditorServices"
}
}
}
Prisma
Prisma support is available through the Prisma extension.
- Tree-sitter: victorhqc/tree-sitter-prisma
- Language-Server: prisma/language-tools
Proto
Proto/proto3 (Protocol Buffers definition language) support is available through the Proto extension.
- Tree-sitter: coder3101/tree-sitter-proto
- Language Servers: protobuf-language-server
Setup
There are two available language server implementations for Protobuf: Pick one and follow the installation instructions below.
Install protobuf-language-server
Install protobuf-language-server and make sure it’s in your PATH:
go install github.com/lasorda/protobuf-language-server@latest
which protobuf-language-server
Install ProtoLS
Install protols and make sure it’s in your PATH:
cargo install protols
which protols
Configuration
"lsp": {
"protobuf-language-server": {
"binary": {
"path": "protols"
}
}
}
Formatting
ProtoLS supports formatting if you have clang-format installed.
# MacOS:
brew install clang-format
# Ubuntu
sudo apt-get install clang-format
# Fedora
sudo dnf install clang-tools-extra
To customize your formatting preferences, create a .clang-format file, e.g.:
IndentWidth: 4
ColumnLimit: 120
Or you can have gram directly invoke clang-format by specifying it as a
formatter in your settings:
"languages": {
"Proto": {
"format_on_save": "on",
"tab_size": 4,
"formatter": {
"external": {
"command": "clang-format",
"arguments": ["-style={IndentWidth: 4, ColumnLimit: 0}"]
}
}
},
}
PureScript
PureScript support is available through the PureScript extension.
- Tree-sitter: postsolar/tree-sitter-purescript
- Language-Server: nwolverson/purescript-language-server
How to Set Up Python in Gram
Python support is available natively in Gram.
- Tree-sitter: tree-sitter-python
- Language Servers:
- Debug Adapter: debugpy
Install Python
You’ll need both Gram and Python installed before you can begin.
Step 1: Install Python
Gram does not bundle a Python runtime, so you’ll need to install one yourself. Choose one of the following options:
- uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
To learn more, visit Astral’s installation guide.
- Homebrew:
brew install python
- Python.org installer: Download the latest version from python.org/downloads.
Step 2: Verify Python Installation
Confirm Python is installed and available in your shell:
python3 --version
You should see an output like Python 3.x.x.
Open Your First Python Project in Gram
Once Gram and Python are installed, open a folder containing Python code to start working.
Step 1: Launch Gram with a Python Project
Open Gram. From the menu bar, choose File > Open Folder, or launch from the terminal:
gram path/to/your/project
Gram will recognize .py files automatically using its native
tree-sitter-python parser, with no plugins or manual setup required.
Step 2: Use the Integrated Terminal (Optional)
Gram includes an integrated terminal, accessible from the bottom panel. If Gram
detects that your project is using a
virtual environment, it will be activated automatically
in newly-created terminals. You can configure this behavior with the
detect_venv setting.
Configure Python Language Servers in Gram
Gram provides several Python language servers out of the box. By default, basedpyright is the primary language server, and Ruff is used for formatting and linting.
Other built-in language servers are:
- Ty, an up-and-coming language server from Astral, built for speed.
- Pyright, the basis for basedpyright.
- PyLSP, a plugin-based
language server that integrates with tools like
pycodestyle,autopep8, andyapf.
These are disabled by default, but can be enabled in your settings. For example:
{
"languages": {
"Python": {
"language_servers": [
// Disable basedpyright and enable Ty, and otherwise
// use the default configuration.
"ty",
"!basedpyright",
"...",
],
},
},
}
See: Working with Language Servers for more information about how to enable and disable language servers.
Basedpyright
basedpyright is the primary Python language server in Gram beginning with Gram v0.204.0. It provides core language server functionality like navigation (go to definition/find all references) and type checking. Compared to Pyright, it adds support for additional language server features (like inlay hints) and checking rules.
Note that while basedpyright in isolation defaults to the recommended
type-checking mode,
Gram configures it to use the less-strict standard mode by default, which
matches the behavior of Pyright. You can set the type-checking mode for your
project using the typeCheckingMode setting in pyrightconfig.json or
pyproject.toml, which will override Gram’s default. Read on more for more
details about how to configure basedpyright.
Basedpyright Configuration
basedpyright reads configuration options from two different kinds of sources:
- Language server settings (“workspace configuration”), which must be configured
per-editor (using
settings.jsonin Gram’s case) but apply to all projects opened in that editor - Configuration files (
pyrightconfig.json,pyproject.toml), which are editor-independent but specific to the project where they are placed
As a rule of thumb, options that are only relevant when using basedpyright from an editor must be set in language server settings, and options that are relevant even if you’re running it as a command-line tool must be set in configuration files. Settings related to inlay hints are examples of the first category, and the diagnostic category settings are examples of the second category.
Examples of both kinds of configuration are provided below. Refer to the basedpyright documentation on language server settings and configuration files for comprehensive lists of available options.
Language server settings
Language server settings for basedpyright in Gram can be set in the lsp
section of your settings.json.
For example, in order to:
- diagnose all files in the workspace instead of the only open files default
- disable inlay hints on function arguments
You can use the following configuration:
{
"lsp": {
"basedpyright": {
"settings": {
"basedpyright.analysis": {
"diagnosticMode": "workspace",
"inlayHints": {
"callArgumentNames": false,
},
},
},
},
},
}
Configuration files
basedpyright reads project-specific configuration from the pyrightconfig.json
configuration file and from the [tool.basedpyright] and [tool.pyright]
sections of pyproject.toml manifests. pyrightconfig.json overrides
pyproject.toml if configuration is present in both places.
Here’s an example pyrightconfig.json file that configures basedpyright to use
the strict type-checking mode and not to issue diagnostics for any files in
__pycache__ directories:
{
"typeCheckingMode": "strict",
"ignore": ["**/__pycache__"],
}
PyLSP
python-lsp-server, more commonly known as PyLSP, by default integrates with a number of external tools (autopep8, mccabe, pycodestyle, yapf) while others are optional and must be explicitly enabled and configured (flake8, pylint).
See Python Language Server Configuration for more.
Virtual Environments
Virtual environments are a useful tool for fixing a Python version and set of dependencies for a specific project, in a way that’s isolated from other projects on the same machine. Gram has built-in support for discovering, configuring, and activating virtual environments, based on the language-agnostic concept of a toolchain.
Note that if you have a global Python installation, it is also counted as a toolchain for Gram’s purposes.
Create a Virtual Environment
If your project doesn’t have a virtual environment set up already, you can create one as follows:
python3 -m venv .venv
Alternatively, if you’re using uv, running uv sync will create a virtual
environment the first time you run it.
How Gram Uses Python Toolchains
Gram uses the selected Python toolchain for your project in the following ways:
- Built-in language servers will be automatically configured with the path to the toolchain’s Python interpreter and, if applicable, virtual environment. This is important so that they can resolve dependencies. (Note that language servers provided by extensions can’t be automatically configured like this currently.)
- Python tasks (such as pytest tests) will be run using the toolchain’s Python interpreter.
- If the toolchain is a virtual environment, the environment’s activation script will be run automatically when you launch a new shell in Gram’s integrated terminal, giving you convenient access to the selected Python interpreter and dependency set.
- If a built-in language server is installed in the active virtual environment, that binary will be used instead of Gram’s private automatically-installed binary. This also applies to debugpy.
Selecting a Toolchain
For most projects, Gram will automatically select the right Python toolchain. In complex projects with multiple virtual environments, it might be necessary to override this selection. You can use the toolchain selector to pick a toolchain from the list discovered by Gram, or specify the path to a toolchain manually if it’s not on the list.
Code Formatting & Linting
Gram provides the Ruff formatter and linter for
Python code. (Specifically, Gram runs Ruff as an LSP server using the
ruff server subcommand.) Both formatting and linting are enabled by default,
including format-on-save.
Configuring formatting
You can disable format-on-save for Python files in your settings.json:
{
"languages": {
"Python": {
"format_on_save": "off",
},
},
}
Alternatively, you can use the black command-line tool for Python formatting,
while keeping Ruff enabled for linting:
{
"languages": {
"Python": {
"formatter": {
"external": {
"command": "black",
"arguments": ["--stdin-filename", "{buffer_path}", "-"],
},
},
// Or use `"formatter": null` to disable formatting entirely.
},
},
}
Configuring Ruff
Like basedpyright, Ruff reads options from both Gram’s language server settings
and configuration files (ruff.toml) when used in Gram. Unlike basedpyright,
all options can be configured in either of these locations, so the choice of
where to put your Ruff configuration comes down to whether you want it to be
shared between projects but specific to Gram (in which case you should use
language server settings), or specific to one project but common to all Ruff
invocations (in which case you should use ruff.toml).
Here’s an example of using language server settings in Gram’s settings.json to
disable all Ruff lints in Gram (while still using Ruff as a formatter):
{
"lsp": {
"ruff": {
"initialization_options": {
"settings": {
"exclude": ["*"],
},
},
},
},
}
And here’s an example ruff.toml with linting and formatting options, adapted
from the Ruff documentation:
[lint]
# Avoid enforcing line-length violations (`E501`)
ignore = ["E501"]
[format]
# Use single quotes when formatting.
quote-style = "single"
For more details, refer to the Ruff documentation about configuration files and language server settings, and the list of options.
Embedded Language Highlighting
Gram supports syntax highlighting for code embedded in Python strings by adding a comment with the language name.
# sql
query = "SELECT * FROM users"
# sql
query = """
SELECT *
FROM users
"""
result = func( # sql
"SELECT * FROM users"
)
Debugging
Gram supports Python debugging through the debugpy adapter. You can start with
no configuration or define custom launch profiles in .gram/debug.json.
Start Debugging with No Setup
Gram can automatically detect debuggable Python entry points. Press F4 (or run debugger: start from the Command Palette) to see available options for your current project. This works for:
- Python scripts
- Modules
- pytest tests
Gram uses debugpy under the hood, but no manual adapter configuration is
required.
Define Custom Debug Configurations
For reusable setups, create a .gram/debug.jsonc file in your project root.
This gives you more control over how Gram runs and debugs your code.
Debug Active File
[
{
"label": "Python Active File",
"adapter": "Debugpy",
"program": "$GRAM_FILE",
"request": "launch"
}
]
This runs the file currently open in the editor.
Debug a Flask App
For projects using Flask, you can define a full launch configuration:
.venv/
app/
init.py
main.py
routes.py
templates/
index.html
static/
style.css
requirements.txt
…the following configuration can be used:
[
{
"label": "Python: Flask",
"adapter": "Debugpy",
"request": "launch",
"module": "app",
"cwd": "$GRAM_WORKTREE_ROOT",
"env": {
"FLASK_APP": "app",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--reload", // Enables Flask reloader that watches for file changes
"--debugger" // Enables Flask debugger
],
"autoReload": {
"enable": true
},
"jinja": true,
"justMyCode": true
}
]
These can be combined to tailor the experience for web servers, test runners, or custom scripts.
Troubleshoot and Maintain a Productive Python Setup
Gram is designed to minimize configuration overhead, but occasional issues can still arise—especially around environments, language servers, or tooling. Here’s how to keep your Python setup working smoothly.
Resolve Language Server Startup Issues
If a language server isn’t responding or features like diagnostics or autocomplete aren’t available:
- Check your Gram log (using the {#action gram::OpenLog} action) for errors related to the language server you’re trying to use. This is where you’re likely to find useful information if the language server failed to start up at all.
- Use the language server logs view to understand the lifecycle of the affected
language server. You can access this view using the {#action
dev::OpenLanguageServerLogs} action, or by clicking the lightning bolt icon in
the status bar and selecting your language server. The most useful pieces of
data in this view are:
- “Server Logs”, which shows any errors printed by the language server
- “Server Info”, which shows details about how the language server was started
- Verify your
settings.jsonorpyrightconfig.jsonis syntactically correct. - Restart Gram to reinitialize language server connections, or try restarting the language server using the {#action editor::RestartLanguageServer}
If the language server is failing to resolve imports, and you’re using a virtual
environment, make sure that the right environment is chosen in the selector. You
can use “Server Info” view to confirm which virtual environment Gram is sending
to the language server. Look for the * Configuration section at the end.
R
R support is available via multiple R Gram extensions:
-
- Tree-sitter: r-lib/tree-sitter-r
- Language-Server: REditorSupport/languageserver
-
- Formatter: posit-dev/air
Installation
- Download and Install R.
- Install the R packages
languageserverandlintr:
install.packages("languageserver")
install.packages("lintr")
-
Install the R extension through Gram’s extensions manager for basic R language support (syntax highlighting, tree-sitter support) and for REditorSupport/languageserver support.
-
Install the Air extension through Gram’s extensions manager for R code formatting via Air.
Linting
REditorSupport/languageserver bundles support for
r-lib/lintr as a linter. This can be
configured via the use of a .lintr inside your project (or in your home
directory for global defaults).
linters: linters_with_defaults(
line_length_linter(120),
commented_code_linter = NULL
)
exclusions: list(
"inst/doc/creating_linters.R" = 1,
"inst/example/bad.R",
"tests/testthat/exclusions-test"
)
Or exclude it from linting anything,
exclusions: list(".")
See Using lintr for a complete list of options,
Formatting
Air
Air provides code formatting for R, including support for format-on-save. The Air documentation for Gram contains the most up-to-date advice for running Air in Gram.
Ensure that you have installed both the ocsmit/zed-r extension (for general R language awareness in Gram) and the Air extension.
Enable Air in your settings.json:
{
"languages": {
"R": {
"language_servers": ["air"],
},
},
}
If you use the "r_language_server" from REditorSupport/languageserver, but
would still like to use Air for formatting, use the following configuration:
{
"languages": {
"R": {
"language_servers": ["air", "r_language_server"],
"use_on_type_format": false,
},
},
}
Note that "air" must come first in this list, otherwise
r-lib/styler will be invoked via
"r_language_server".
"r_language_server" provides on-type-formatting that differs from Air’s
formatting rules. To avoid this entirely and let Air be fully in charge of
formatting your R files, also set "use_on_type_format": false as shown above.
Configuring Air
Air is minimally configurable via an air.toml file placed in the root
directory of your project:
[format]
line-width = 80
indent-width = 2
For more details, refer to the Air documentation about configuration.
Styler
REditorSupport/languageserver bundles support for
r-lib/styler as a formatter. See
Customizing Styler
for more information on how to customize its behavior.
Racket
Racket support is available through the Racket extension.
- Tree-sitter: zed-industries/tree-sitter-racket
The racket-language-server is not yet supported in Gram, please see Issue #15789 for more information.
Rego
Rego language support in Gram is provided by the community-maintained Rego extension.
- Tree-sitter: FallenAngel97/tree-sitter-rego
- Language Server: StyraInc/regal
Installation
The extension is largely based on the Regal language server which should be installed to make use of the extension. Read the getting started instructions for more information.
Configuration
The extension’s behavior is configured in the .regal/config.yaml file. The
following is an example configuration which disables the todo-comment rule,
customizes the line-length rule, and ignores test files for the opa-fmt
rule:
rules:
style:
todo-comment:
# don't report on todo comments
level: ignore
line-length:
# custom rule configuration
max-line-length: 100
# warn on too long lines, but don't fail
level: warning
opa-fmt:
# not needed as error is the default, but
# being explicit won't hurt
level: error
# files can be ignored for any individual rule
# in this example, test files are ignored
ignore:
files:
- "*_test.rego"
Read Regal’s configuration documentation for more information.
Roc
Roc is a fast, friendly, functional language.
Roc language support in Gram is provided by the community-maintained Roc extension. Report issues to: https://github.com/h2000/zed-roc/issues
- Tree-sitter: faldor20/tree-sitter-roc
- Language Server: roc-lang/roc/tree/main/crates/language_server
Setup
- Follow instructions to Install Roc from the Roc-Lang website.
- Ensure
rocandroc_language_serverare in your PATH.
Roto
Roto support is built into the editor.
A statically-typed, compiled embedded scripting language for Rust.
ReStructuredText (rst)
ReStructuredText language support in Gram is provided by the community-maintained reST extension. Report issues to: https://github.com/elmarco/zed-rst/issues
- Tree-sitter: stsewd/tree-sitter-rst.git
- Language Server: swyddfa/esbonio
Ruby
Ruby support is available through the Ruby extension.
- Tree-sitters:
- Language Servers:
- Debug Adapter:
rdbg
The Ruby extension also provides support for ERB files.
Language Servers
There are multiple language servers available for Ruby. Gram supports the two following:
They both have an overlapping feature set of autocomplete, diagnostics, code actions, etc. and it’s up to you to decide which one you want to use. Note that you can’t use both at the same time.
In addition to these two language servers, Gram also supports:
- rubocop which is a static code analyzer and linter for Ruby. Under the hood, it’s also used by Gram as a language server, but its functionality is complimentary to that of solargraph and ruby-lsp.
- sorbet which is a static type checker for Ruby with a custom gradual type system.
- steep which is a static type checker for Ruby that leverages Ruby Signature (RBS).
- Herb which is a language server for ERB files.
When configuring a language server, it helps to open the LSP Logs window using the ‘dev: Open Language Server Logs’ command. You can then choose the corresponding language instance to see any logged information.
Configuring a language server
The Ruby extension offers both
solargraph and ruby-lsp language server support.
Language Server Activation
For all supported Ruby language servers (solargraph, ruby-lsp, rubocop,
sorbet, and steep), the Ruby extension follows this activation sequence:
- If the language server is found in your project’s
Gemfile, it will be used throughbundle exec. - If not found in the
Gemfile, the Ruby extension will look for the executable in your systemPATH. - If the language server is not found in either location, the Ruby extension will automatically install it as a global gem (note: this will not install to your current Ruby gemset).
You can skip step 1 and force using the system executable by setting
use_bundler to false in your settings:
{
"lsp": {
"<SERVER_NAME>": {
"settings": {
"use_bundler": false,
},
},
},
}
Using solargraph
solargraph is enabled by default in the Ruby extension.
Using ruby-lsp
To switch to ruby-lsp, add the following to your settings.json:
{
"languages": {
"Ruby": {
"language_servers": ["ruby-lsp", "!solargraph", "!rubocop", "..."],
},
// Enable herb and ruby-lsp for *.html.erb files
"HTML+ERB": {
"language_servers": ["herb", "ruby-lsp", "..."],
},
// Enable ruby-lsp for *.js.erb files
"JS+ERB": {
"language_servers": ["ruby-lsp", "..."],
},
// Enable ruby-lsp for *.yaml.erb files
"YAML+ERB": {
"language_servers": ["ruby-lsp", "..."],
},
},
}
That disables solargraph and rubocop and enables ruby-lsp.
Using rubocop
The Ruby extension also provides support for rubocop language server for
offense detection and autocorrection.
To enable it, add the following to your settings.json:
{
"languages": {
"Ruby": {
"language_servers": ["ruby-lsp", "rubocop", "!solargraph", "..."],
},
},
}
Or, conversely, you can disable ruby-lsp and enable solargraph and rubocop
by adding the following to your settings.json:
{
"languages": {
"Ruby": {
"language_servers": ["solargraph", "rubocop", "!ruby-lsp", "..."],
},
},
}
Setting up solargraph
Solargraph has formatting and diagnostics disabled by default. We can tell Gram
to enable them by adding the following to your settings.json:
{
"lsp": {
"solargraph": {
"initialization_options": {
"diagnostics": true,
"formatting": true,
},
},
},
}
Configuration
Solargraph reads its configuration from a file called .solargraph.yml in the
root of your project. For more information about this file, see the
Solargraph configuration documentation.
Setting up ruby-lsp
You can pass Ruby LSP configuration to initialization_options, e.g.
{
"languages": {
"Ruby": {
"language_servers": ["ruby-lsp", "!solargraph", "..."],
},
},
"lsp": {
"ruby-lsp": {
"initialization_options": {
"enabledFeatures": {
// "someFeature": false
},
},
},
},
}
LSP settings and initialization_options can also be project-specific. For
example to use standardrb/standard as
a formatter and linter for a particular project, add this to a
.gram/settings.jsonc inside your project repo:
{
"lsp": {
"ruby-lsp": {
"initialization_options": {
"formatter": "standard",
"linters": ["standard"],
},
},
},
}
Setting up rubocop LSP
Rubocop has unsafe autocorrection disabled by default. We can tell Gram to
enable it by adding the following to your settings.json:
{
"languages": {
"Ruby": {
// Use ruby-lsp as the primary language server and rubocop as the secondary.
"language_servers": ["ruby-lsp", "rubocop", "!solargraph", "..."],
},
},
"lsp": {
"rubocop": {
"initialization_options": {
"safeAutocorrect": false,
},
},
"ruby-lsp": {
"initialization_options": {
"enabledFeatures": {
"diagnostics": false,
},
},
},
},
}
Setting up Sorbet
Sorbet is a popular static type checker for Ruby that includes a language server.
To enable Sorbet, add \"sorbet\" to the language_servers list for Ruby in
your settings.json. You may want to disable other language servers if Sorbet
is intended to be your primary LSP, or if you plan to use it alongside another
LSP for specific features like type checking.
{
"languages": {
"Ruby": {
"language_servers": [
"ruby-lsp",
"sorbet",
"!rubocop",
"!solargraph",
"...",
],
},
},
}
For all aspects of installing Sorbet, setting it up in your project, and configuring its behavior, please refer to the official Sorbet documentation.
Setting up Steep
Steep is a static type checker for Ruby that uses RBS files to define types.
To enable Steep, add \"steep\" to the language_servers list for Ruby in your
settings.json. You may need to adjust the order or disable other LSPs
depending on your desired setup.
{
"languages": {
"Ruby": {
"language_servers": [
"ruby-lsp",
"steep",
"!solargraph",
"!rubocop",
"...",
],
},
},
}
Setting up Herb
Herb is enabled by default for the HTML+ERB language.
Using the Tailwind CSS Language Server with Ruby
It’s possible to use the Tailwind CSS Language Server in Ruby and ERB files.
In order to do that, you need to configure the language server so that it knows
about where to look for CSS classes in Ruby/ERB files by adding the following to
your settings.json:
{
"languages": {
"Ruby": {
"language_servers": ["tailwindcss-language-server", "..."],
},
},
"lsp": {
"tailwindcss-language-server": {
"settings": {
"experimental": {
"classRegex": ["\\bclass:\\s*['\"]([^'\"]*)['\"]"],
},
},
},
},
}
With these settings you will get completions for Tailwind CSS classes in HTML
attributes inside ERB files and inside Ruby/ERB strings that are coming after a
class: key. Examples:
# Ruby file:
def method
div(class: "pl-2 <completion here>") do
p(class: "mt-2 <completion here>") { "Hello World" }
end
end
# ERB file:
<%= link_to "Hello", "/hello", class: "pl-2 <completion here>" %>
<a href="/https/gram-editor.com/hello" class="pl-2 <completion here>">Hello</a>
Running tests
To run tests in your Ruby project, you can set up custom tasks in your local
.gram/tasks.jsonc configuration file. These tasks can be defined to work with
different test frameworks like Minitest, RSpec, quickdraw, and tldr. Below are
some examples of how to set up these tasks to run your tests from within your
editor.
Minitest with Rails
[
{
"label": "test $GRAM_RELATIVE_FILE -n /$GRAM_CUSTOM_RUBY_TEST_NAME/",
"command": "bin/rails",
"args": [
"test",
"$GRAM_RELATIVE_FILE",
"-n",
"\"$GRAM_CUSTOM_RUBY_TEST_NAME\""
],
"cwd": "$GRAM_WORKTREE_ROOT",
"tags": ["ruby-test"]
}
]
Minitest
Plain minitest does not support running tests by line number, only by name, so
we need to use $GRAM_CUSTOM_RUBY_TEST_NAME instead:
[
{
"label": "-Itest $GRAM_RELATIVE_FILE -n /$GRAM_CUSTOM_RUBY_TEST_NAME/",
"command": "bundle",
"args": [
"exec",
"ruby",
"-Itest",
"$GRAM_RELATIVE_FILE",
"-n",
"\"$GRAM_CUSTOM_RUBY_TEST_NAME\""
],
"cwd": "$GRAM_WORKTREE_ROOT",
"tags": ["ruby-test"]
}
]
RSpec
[
{
"label": "test $GRAM_RELATIVE_FILE:$GRAM_ROW",
"command": "bundle",
"args": ["exec", "rspec", "\"$GRAM_RELATIVE_FILE:$GRAM_ROW\""],
"cwd": "$GRAM_WORKTREE_ROOT",
"tags": ["ruby-test"]
}
]
Similar task syntax can be used for other test frameworks such as quickdraw or
tldr.
Debugging
The Ruby extension provides a debug adapter for debugging Ruby code. Gram’s name
for the adapter (in the UI and debug.json) is rdbg, and under the hood, it
uses the debug gem. The extension uses the
same activation logic as the language servers.
Examples
Debug a Ruby script
[
{
"label": "Debug current file",
"adapter": "rdbg",
"request": "launch",
"script": "$GRAM_FILE",
"cwd": "$GRAM_WORKTREE_ROOT"
}
]
Debug Rails server
[
{
"label": "Debug Rails server",
"adapter": "rdbg",
"request": "launch",
"command": "./bin/rails",
"args": ["server"],
"cwd": "$GRAM_WORKTREE_ROOT",
"env": {
"RUBY_DEBUG_OPEN": "true"
}
}
]
Formatters
erb-formatter
To format ERB templates, you can use the erb-formatter formatter. This
formatter uses the erb-formatter
gem to format ERB templates.
{
"HTML+ERB": {
"formatter": {
"external": {
"command": "erb-formatter",
"arguments": ["--stdin-filename", "{buffer_path}"],
},
},
},
}
Rust
Rust support is available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-rust
- Language Server: rust-lang/rust-analyzer
- Debug Adapter: CodeLLDB (primary), GDB (secondary, not available on Apple silicon)
Inlay Hints
The following configuration can be used to change the inlay hint settings for
rust-analyzer in Rust:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"inlayHints": {
"maxLength": null,
"lifetimeElisionHints": {
"enable": "skip_trivial",
"useParameterNames": true,
},
"closureReturnTypeHints": {
"enable": "always",
},
},
},
},
},
}
See Inlay Hints in the Rust Analyzer Manual for more information.
Target directory
The rust-analyzer target directory can be set in initialization_options:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"rust": {
"analyzerTargetDir": true,
},
},
},
},
}
A true setting will set the target directory to target/rust-analyzer. You
can set a custom directory with a string like "target/analyzer" instead of
true.
Binary
You can configure which rust-analyzer binary Gram should use.
By default, Gram will try to find a rust-analyzer in your $PATH and try to
use that. If that binary successfully executes rust-analyzer --help, it’s
used.
To use the binary specified by rustup respecting the project-specific setting in
rust-toolchain.toml, point it to the symlink maintained by rustup:
{
"lsp": {
"rust-analyzer": {
"binary": {
"path": "~/.cargo/bin/rust-analyzer",
},
},
},
}
You can set the allow_binary_download setting for rust-analyzer and the editor will
download and install a recent version automatically for you.
If you want to install pre-release rust-analyzer version instead you can
instruct Gram to do so by setting pre_release to true in your
settings.json:
{
"lsp": {
"rust-analyzer": {
"fetch": {
"pre_release": true,
},
},
},
}
If you want to disable Gram looking for a rust-analyzer binary, you can set
ignore_system_version to true in your settings.json:
{
"lsp": {
"rust-analyzer": {
"binary": {
"ignore_system_version": true,
},
},
},
}
If you want to use a binary in a custom location, you can specify a path and
optional arguments:
{
"lsp": {
"rust-analyzer": {
"binary": {
"path": "/Users/example/bin/rust-analyzer",
"arguments": [],
},
},
},
}
This "path" has to be an absolute path.
Alternate Targets
If you want rust-analyzer to provide diagnostics for a target other than your current platform (e.g. for windows when running on macOS) you can use the following Gram lsp settings:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"cargo": {
"target": "x86_64-pc-windows-msvc",
},
},
},
},
}
If you are using rustup, you can find a list of available target triples
(aarch64-apple-darwin, x86_64-unknown-linux-gnu, etc) by running:
rustup target list --installed
LSP tasks
Gram provides tasks using tree-sitter, but rust-analyzer has an LSP extension method for querying file-related tasks via LSP. This is enabled by default and can be configured as
"lsp": {
"rust-analyzer": {
"enable_lsp_tasks": true,
}
}
Manual Cargo Diagnostics fetch
By default, rust-analyzer has checkOnSave: true enabled, which causes every
buffer save to trigger a cargo check --workspace --all-targets command. If
disabled with checkOnSave: false (see the example of the server configuration
json above), it’s still possible to fetch the diagnostics manually, with the
editor: run/clear/cancel flycheck commands in Rust files to refresh cargo
diagnostics; the project diagnostics editor will also refresh cargo diagnostics
with editor: run flycheck command when the setting is enabled.
More server configuration
Rust-analyzer manual describes various features and configuration options for rust-analyzer language server. Rust-analyzer in Gram runs with the default parameters.
Large projects and performance
One of the main caveats that might cause extensive resource usage on large projects, is the combination of the following features:
rust-analyzer.checkOnSave (default: true)
Run the check command for diagnostics on save.
rust-analyzer.check.workspace (default: true)
Whether --workspace should be passed to cargo check. If false, -p <package> will be passed instead.
rust-analyzer.cargo.allTargets (default: true)
Pass --all-targets to cargo invocation
Which would mean that every time Gram saves, a
cargo check --workspace --all-targets command is run, checking the entire
project (workspace), lib, doc, test, bin, bench and
other targets.
While that works fine on small projects, it does not scale well.
The alternatives would be to use tasks, as Gram already provides
a cargo check --workspace --all-targets task and the ability to cmd/ctrl-click
on the terminal output to navigate to the error, and limit or turn off the check
on save feature entirely.
Check on save feature is responsible for returning part of the diagnostics based on cargo check output, so turning it off will limit rust-analyzer with its own diagnostics.
Consider more rust-analyzer.cargo. and rust-analyzer.check. and
rust-analyzer.diagnostics. settings from the manual for more fine-grained
configuration. Here’s a snippet for Gram settings.json (the language server will
restart automatically after the lsp.rust-analyzer section is edited and
saved):
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
// get more cargo-less diagnostics from rust-analyzer,
// which might include false-positives (those can be turned off by their names)
"diagnostics": {
"experimental": {
"enable": true,
},
},
// To disable the checking entirely
// (ignores all cargo and check settings below)
"checkOnSave": false,
// To check the `lib` target only.
"cargo": {
"allTargets": false,
},
// Use `-p` instead of `--workspace` for cargo check
"check": {
"workspace": false,
},
},
},
},
}
Multi-project workspaces
If you want rust-analyzer to analyze multiple Rust projects in the same folder
that are not listed in [members] in the Cargo workspace, you can list them in
linkedProjects in the local project settings:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"linkedProjects": ["./path/to/a/Cargo.toml", "./path/to/b/Cargo.toml"],
},
},
},
}
Snippets
There’s a way to get custom completion items from rust-analyzer, that will transform the code according to the snippet body:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"completion": {
"snippets": {
"custom": {
"Arc::new": {
"postfix": "arc",
"body": ["Arc::new(${receiver})"],
"requires": "std::sync::Arc",
"scope": "expr",
},
"Some": {
"postfix": "some",
"body": ["Some(${receiver})"],
"scope": "expr",
},
"Ok": {
"postfix": "ok",
"body": ["Ok(${receiver})"],
"scope": "expr",
},
"Rc::new": {
"postfix": "rc",
"body": ["Rc::new(${receiver})"],
"requires": "std::rc::Rc",
"scope": "expr",
},
"Box::pin": {
"postfix": "boxpin",
"body": ["Box::pin(${receiver})"],
"requires": "std::boxed::Box",
"scope": "expr",
},
"vec!": {
"postfix": "vec",
"body": ["vec![${receiver}]"],
"description": "vec![]",
"scope": "expr",
},
},
},
},
},
},
},
}
Debugging
Gram supports debugging Rust binaries and tests out of the box with CodeLLDB
and GDB. Run {#action debugger::Start} ({#kb debugger::Start}) to launch one
of these preconfigured debug tasks.
For more control, you can add debug configurations to .gram/debug.jsonc. See
the examples below.
Build binary then debug
[
{
"label": "Build & Debug native binary",
"build": {
"command": "cargo",
"args": ["build"]
},
"program": "$GRAM_WORKTREE_ROOT/target/debug/binary",
// sourceLanguages is required for CodeLLDB (not GDB) when using Rust
"sourceLanguages": ["rust"],
"request": "launch",
"adapter": "CodeLLDB"
}
]
Automatically locate a debug target based on build command
When you use cargo build or cargo test as the build command, Gram can infer
the path to the output binary.
[
{
"label": "Build & Debug native binary",
"adapter": "CodeLLDB",
"build": {
"command": "cargo",
"args": ["build"]
},
// sourceLanguages is required for CodeLLDB (not GDB) when using Rust
"sourceLanguages": ["rust"]
}
]
Scala
Scala language support in Gram is provided by the community-maintained Scala extension. Report issues to: https://github.com/scalameta/metals-zed/issues
- Tree-sitter: tree-sitter/tree-sitter-scala
- Language Server: scalameta/metals
Setup
- Install Scala with
cs setup(Coursier): https://www.scala-lang.org/download/brew install coursier/formulas/coursier && cs setup
- REPL (Almond) Setup Instructions https://almond.sh/docs/quick-start-install
brew install --cask temurin(Eclipse foundation official OpenJDK binaries)brew install coursier/formulas/coursier && cs setupcoursier launch --use-bootstrap almond -- --install
Configuration
Behavior of the Metals language server can be controlled with:
.scalafix.conffile - See Scalafix Configuration.scalafmt.conffile - See Scalafmt Configuration
You can place these files in the root of your project or specifying their location in the Metals configuration. See Metals User Configuration for more.
Scheme
Formatting
To support automatically formatting your code, you can use raviqqe/schemat, a Scheme code formatter.
Install with:
cargo install schemat
Then add the following to your Gram settings.json:
"languages": {
"Scheme": {
"formatter": {
"external": {
"command": "schemat",
"arguments": [""]
}
}
}
}
Tree-sitter
- Tree-sitter: 6cdh/tree-sitter-scheme
Shell Scripts
Shell Scripts (bash, zsh, dash, sh) are supported natively by Gram.
- Tree-sitter: tree-sitter/tree-sitter-bash
Settings
You can configure various settings for Shell Scripts in your Gram User Settings
(~/.config/gram/settings.json) or Gram Project Settings
(.gram/settings.json):
"languages": {
"Shell Script": {
"tab_size": 2,
"hard_tabs": false
}
}
Formatting
Gram supports auto-formatting Shell Scripts using external tools like
shfmt.
- Install
shfmt:
brew install shfmt # macos (homebrew)
sudo apt-get install shfmt # debian/ubuntu
dnf install shfmt # fedora
yum install shfmt # redhat
pacman -Sy shfmt # archlinux
choco install shfmt # windows (chocolatey)
- Ensure
shfmtis available in your path and check the version:
which shfmt
shfmt --version
- Configure Gram to automatically format Shell Scripts with
shfmton save:
"languages": {
"Shell Script": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "shfmt",
// Change `--indent 2` to match your preferred tab_size
"arguments": ["--filename", "{buffer_path}", "--indent", "2"]
}
}
}
}
See also:
SQL
Syntax highlighting and formatting support for SQL is built into the editor.
Formatting
SQL auto-formatting can be added to the editor using external tools like
sql-formatter.
- Install
sql-formatter:
npm install -g sql-formatter
- Ensure
sql-formatteris available in your path and check the version:
which sql-formatter
sql-formatter --version
- Configure Gram to automatically format SQL with
sql-formatter:
"languages": {
"SQL": {
"formatter": {
"external": {
"command": "sql-formatter",
"arguments": ["--language", "mysql"]
}
}
}
},
Substitute your preferred [SQL Dialect] for mysql above (duckdb, hive,
mariadb, postgresql, redshift, snowflake, sqlite, spark, etc).
You can add this to Gram project settings (.gram/settings.json) or via your
Gram user settings (~/.config/gram/settings.json).
Advanced Formatting
Sql-formatter also allows more precise control by providing
sql-formatter configuration options.
To provide these, create a .sql-formatter.json file in your project:
{
"language": "postgresql",
"tabWidth": 2,
"keywordCase": "upper",
"linesBetweenQueries": 2,
}
When using a .sql-formatter.json file you can use a more simplified set of
Gram settings since the language need not be specified inline:
"languages": {
"SQL": {
"formatter": {
"external": {
"command": "sql-formatter"
}
}
}
},
Svelte
Svelte support is available through the Svelte extension.
- Tree-sitter: tree-sitter-grammars/tree-sitter-svelte
- Language Server: sveltejs/language-tools
Extra theme styling configuration
You can modify how certain styles, such as directives and modifiers, appear in attributes:
"syntax": {
// Styling for directives (e.g., `class:foo` or `on:click`) (the `on` or `class` part of the attribute).
"attribute.function": {
"color": "#ff0000"
},
// Styling for modifiers at the end of attributes, e.g. `on:<click|preventDefault|stopPropagation>`
"attribute.special": {
"color": "#00ff00"
}
}
Inlay Hints
When inlay hints is enabled in Gram, to make the language server send them back, Gram sets the following initialization options:
"inlayHints": {
"parameterNames": {
"enabled": "all",
"suppressWhenArgumentMatchesName": false
},
"parameterTypes": {
"enabled": true
},
"variableTypes": {
"enabled": true,
"suppressWhenTypeMatchesName": false
},
"propertyDeclarationTypes": {
"enabled": true
},
"functionLikeReturnTypes": {
"enabled": true
},
"enumMemberValues": {
"enabled": true
}
}
To override these settings, use the following:
"lsp": {
"svelte-language-server": {
"initialization_options": {
"configuration": {
"typescript": {
// ......
},
"javascript": {
// ......
}
}
}
}
}
See
the TypeScript language server package.json
for more information.
Swift
Swift language support in Gram is provided by the community-maintained Swift extension. Report issues to: https://github.com/zed-extensions/swift/issues
- Tree-sitter: alex-pinkus/tree-sitter-swift
- Language Server: swiftlang/sourcekit-lsp
- Debug Adapter:
lldb-dap
Language Server Configuration
You can modify the behavior of SourceKit LSP by creating a
.sourcekit-lsp/config.json under your home directory or in your project root.
See
SourceKit-LSP configuration file
for complete documentation.
Debugging
The Swift extension provides a debug adapter for debugging Swift code. Gram’s
name for the adapter (in the UI and debug.jsonc) is Swift, and under the
hood it uses
lldb-dap,
as provided by the Swift toolchain. The extension tries to find an lldb-dap
binary using swiftly, using xcrun, and by searching $PATH, in that order
of preference. The extension doesn’t attempt to download lldb-dap if it’s not
found.
Examples
Build and debug a Swift binary
[
{
"label": "Debug Swift",
"build": {
"command": "swift",
"args": ["build"]
},
"program": "$GRAM_WORKTREE_ROOT/swift-app/.build/arm64-apple-macosx/debug/swift-app",
"request": "launch",
"adapter": "Swift"
}
]
Tailwind CSS
Gram has built-in support for Tailwind CSS autocomplete, linting, and hover previews.
- Language Server: tailwindlabs/tailwindcss-intellisense
Configuration
To configure the Tailwind CSS language server, refer
to the extension settings
and add them to the lsp section of your settings.json:
{
"lsp": {
"tailwindcss-language-server": {
"settings": {
"classFunctions": ["cva", "cx"],
"experimental": {
"classRegex": ["[cls|className]\\s\\:\\=\\s\"([^\"]*)"],
},
},
},
},
}
Languages which can be used with Tailwind CSS in Gram:
Prettier Plugin
Gram supports Prettier out of the box, which means that if you have the Tailwind CSS Prettier plugin installed, adding it to your Prettier configuration will make it work automatically:
// .prettierrc
{
"plugins": ["prettier-plugin-tailwindcss"],
}
Terraform
Terraform support is available through the Terraform extension.
- Tree-sitter: MichaHoffmann/tree-sitter-hcl
- Language Server: hashicorp/terraform-ls
Configuration
The Terraform language server can be configured in your settings.jsonc, e.g.:
{
"lsp": {
"terraform-ls": {
"initialization_options": {
"experimentalFeatures": {
"prefillRequiredFields": true,
},
},
},
},
}
See the full list of server settings here.
TOML
TOML support is built into the editor.
-
Tree-sitter: tree-sitter/tree-sitter-toml
-
Crate: adot-tree-sitter-toml
There’s LSP support for Tombi and Taplo. Tombi is the default.
To only enable tombi:
"languages": {
"TOML": {
"language_servers": ["!taplo", "tombi", "..."]
},
}
To only enable taplo:
"languages": {
"TOML": {
"language_servers": ["taplo", "!tombi", "..."]
},
}
Tombi additionally supports being used as a formatter (enabled by default). If you wish to use prettier with taplo instead, change the formatter setting from language_server to prettier:
"languages": {
"TOML": {
"language_servers": ["taplo", "!tombi", "..."]
"formatter": "prettier",
"format_on_save": "off",
},
}
TypeScript
TypeScript and TSX support are available natively in Gram.
- Tree-sitter: tree-sitter/tree-sitter-typescript
- Language Server: yioneko/vtsls
- Alternate Language Server: typescript-language-server/typescript-language-server
- Debug Adapter: vscode-js-debug
Language servers
By default Gram uses vtsls for TypeScript, TSX, and JavaScript files. You can configure the use of typescript-language-server per language in your settings file:
{
"languages": {
"TypeScript": {
"language_servers": ["typescript-language-server", "!vtsls", "..."],
},
"TSX": {
"language_servers": ["typescript-language-server", "!vtsls", "..."],
},
"JavaScript": {
"language_servers": ["typescript-language-server", "!vtsls", "..."],
},
},
}
Prettier will also be used for TypeScript files by default. To disable this:
{
"languages": {
"TypeScript": {
"prettier": { "allowed": false },
},
//...
},
}
Large projects
vtsls may run out of memory on very large projects. We default the limit to
8092 (8 GiB) vs. the default of 3072 but this may not be sufficient for you:
{
"lsp": {
"vtsls": {
"settings": {
// For TypeScript:
"typescript": { "tsserver": { "maxTsServerMemory": 16184 } },
// For JavaScript:
"javascript": { "tsserver": { "maxTsServerMemory": 16184 } },
},
},
},
}
Inlay Hints
Gram sets the following initialization options to make the language server send back inlay hints (that is, when Gram has inlay hints enabled in the settings).
You can override these settings in your Gram settings.jsonc when using
typescript-language-server:
{
"lsp": {
"typescript-language-server": {
"initialization_options": {
"preferences": {
"includeInlayParameterNameHints": "all",
"includeInlayParameterNameHintsWhenArgumentMatchesName": true,
"includeInlayFunctionParameterTypeHints": true,
"includeInlayVariableTypeHints": true,
"includeInlayVariableTypeHintsWhenTypeMatchesName": true,
"includeInlayPropertyDeclarationTypeHints": true,
"includeInlayFunctionLikeReturnTypeHints": true,
"includeInlayEnumMemberValueHints": true,
},
},
},
},
}
See typescript-language-server inlayhints documentation for more information.
When using vtsls:
{
"lsp": {
"vtsls": {
"settings": {
// For JavaScript:
"javascript": {
"inlayHints": {
"parameterNames": {
"enabled": "all",
"suppressWhenArgumentMatchesName": false,
},
"parameterTypes": {
"enabled": true,
},
"variableTypes": {
"enabled": true,
"suppressWhenTypeMatchesName": true,
},
"propertyDeclarationTypes": {
"enabled": true,
},
"functionLikeReturnTypes": {
"enabled": true,
},
"enumMemberValues": {
"enabled": true,
},
},
},
// For TypeScript:
"typescript": {
"inlayHints": {
"parameterNames": {
"enabled": "all",
"suppressWhenArgumentMatchesName": false,
},
"parameterTypes": {
"enabled": true,
},
"variableTypes": {
"enabled": true,
"suppressWhenTypeMatchesName": true,
},
"propertyDeclarationTypes": {
"enabled": true,
},
"functionLikeReturnTypes": {
"enabled": true,
},
"enumMemberValues": {
"enabled": true,
},
},
},
},
},
},
}
Debugging
Gram supports debugging TypeScript code out of the box with vscode-js-debug.
The following can be debugged without writing additional configuration:
- Tasks from
package.json - Tests written using several popular frameworks (Jest, Mocha, Vitest, Jasmine, Bun, Node)
Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks.
Note: Bun test is automatically detected when
@types/bunis present inpackage.json.Note: Node test is automatically detected when
@types/nodeis present inpackage.json(requires Node.js 20+).
As for all languages, configurations from .vscode/launch.json are also
available for debugging in Gram.
If your use-case isn’t covered by any of these, you can take full control by
adding debug configurations to .gram/debug.jsonc. See below for example
configurations.
Configuring JavaScript debug tasks
JavaScript debugging is more complicated than other languages because there are
two different environments: Node.js and the browser. vscode-js-debug exposes a
type field, that you can use to specify the environment, either node or
chrome.
Attach debugger to a server running in web browser (npx serve)
Given an externally-ran web server (e.g., with npx serve or npx live-server)
one can attach to it and open it with a browser.
[
{
"label": "Launch Chrome (TypeScript)",
"adapter": "JavaScript",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5500",
"program": "$GRAM_FILE",
"webRoot": "${GRAM_WORKTREE_ROOT}",
"build": {
"command": "npx",
"args": ["tsc"]
},
"skipFiles": ["<node_internals>/**"]
}
]
See also
- Gram Yarn documentation for a walkthrough of configuring your project to use Yarn.
- Gram Deno documentation
Typst
Typst support is built into the editor.
Typst is a powerful typesetting system which is similar to LaTeX in spirit, but tends to be easier to get started with. For more information see here.
- Crate: codebook-tree-sitter-typst
There is LSP support via tinymist.
Uiua
Uiua is a general purpose, stack-based, array-oriented programming language with a focus on simplicity, beauty, and tacit code.
Uiua support is available through the Uiua extension.
- Tree-sitter: shnarazk/tree-sitter-uiua
- Language Server: uiua-lang/uiua
Vue
Vue support is available through the Vue extension.
- Tree-sitter: tree-sitter-grammars/tree-sitter-vue
- Language Server: vuejs/language-tools/
XML
XML syntax highlighting is supported natively.
- Tree-sitter: tree-sitter-grammars/tree-sitter-xml
Configuration
If you have additional file extensions that are not being automatically recognized as XML just add them to file_types in your Gram settings:
"file_types": {
"XML": ["rdf", "gpx", "kml"]
}
Formatters
You can also set a different formatter for XML files through the language specific configuration. xmllint is a popular XML parsing tool that can also format XML files, and usually is pre-installed, as part of libxml2:
"languages": {
"XML": {
"formatter": {
"external": {
"command": "xmllint",
"arguments": ["--format", "-"]
},
}
}
}
YAML
YAML support is available natively in Gram.
- Tree-sitter: zed-industries/tree-sitter-yaml
- Language Servers: redhat-developer/yaml-language-server, home-operations/yayamlls
Choosing a language server
yaml-language-server is Node.js LSP used by default. yayamlls is a static Go
binary with Kubernetes and Flux support, but no formatter.
With the yayamlls extension installed, which downloads the binary for you:
"languages": {
"YAML": {
"language_servers": ["yayamlls", "!yaml-language-server"]
}
}
Without the extension, install yayamlls yourself and override the bundled
binary, since the lsp key only accepts known LSP identifiers:
"lsp": {
"yaml-language-server": {
"binary": {
"path": "yayamlls",
"arguments": [],
"ignore_system_version": true
}
}
}
Note
argumentsmust be empty: Gram launches this server with--stdio, whichyayamllsdoes not accept.
Formatting
By default, Gram uses Prettier for formatting YAML files. For example, to use
single quotes in yaml files add the following to your .prettierrc:
{
"overrides": [
{
"files": ["*.yaml", "*.yml"],
"options": {
"singleQuote": true
}
}
]
}
LSP Formatting
To use yaml-language-server instead of Prettier for YAML formatting, add the
following to your Gram settings.jsonc:
"languages": {
"YAML": {
"formatter": "language_server"
}
}
yayamlls has no formatting.
Configuration
Language server options can be set in the settings.jsonc file. See the
Configuring Languages documentation for more
information.
yaml-language-server
For more details, see the
yaml-language-server settings.
Settings keys must be nested, so yaml.keyOrdering becomes {"yaml": {"keyOrdering": true}}:
"lsp": {
"yaml-language-server": {
"settings": {
"yaml": {
"keyOrdering": true,
"format": {
"singleQuote": true
},
"schemas": {
"https://getcomposer.org/schema.json": ["/*"],
"../relative/path/schema.json": ["/config*.yaml"]
},
"schemaStore": {
"enable": true
},
"customTags": [
"!Ref scalar",
"!Sub mapping",
"!GetAtt sequence"
]
}
}
}
}
Schemas are auto-detected from Json Schema Store. The
schemas key overrides that, schemaStore.enable: false turns it off.
Custom tags
need a scalar, mapping or sequence suffix, e.g. for CloudFormation.
A modeline pins the schema for a single file and works with both servers:
# yaml-language-server: $schema=https://www.schemastore.org/github-action.json
name: Issue Assignment
on:
issues:
types: [opened]
yayamlls
For more details, see the
yayamlls documentation.
Configuration lives in .yayamlls.yaml at the workspace root, which keeps it
editor-agnostic:
schemas:
"https://json.schemastore.org/github-workflow.json":
- ".github/workflows/*.yml"
catalog: true
kubernetes:
enabled: false
customTags:
- "!Ref"
The same keys can be set from Gram, flat and without the yaml wrapper. Use the
yayamlls key with the extension, or yaml-language-server with the binary
override above:
"lsp": {
"yayamlls": {
"initialization_options": {
"catalog": true,
"kubernetes": { "enabled": false }
}
}
}
Schemas resolve per document: modeline, schemas globs, the Schema Store
catalog (catalog: false disables it), then Kubernetes apiVersion+kind.
Custom tags are listed bare, and nodes carrying one skip validation.
Diagnostics can be muted with # yayamlls-disable-line, # yayamlls-disable
and # yayamlls-enable around a block, or # yayamlls-disable-file.
Flux HelmRelease and Kustomization documents are also validated against
their rendered manifests, with View rendered and Diff rendered code
lenses. The lenses use window/showDocument, which Zed ignores for local files
(zed#53123).
For CI, yayamlls validate [--render] <paths> resolves schemas the same way and
exits 1 on errors, 2 on usage or I/O failures, 0 otherwise.
Yara
Yara language support in Gram is provided by the
Yara language extension. Please report
issues to
https://github.com/egibs/yara.gram/issues.
- Tree-sitter: egibs/tree-sitter-yara
- Language Server: avast/yls
Yarn
Yarn is a versatile package manager that improves dependency management and workflow efficiency for JavaScript and other languages. It ensures a deterministic dependency tree, offers offline support, and enhances security for reliable builds.
Setup
- Run
yarn dlx @yarnpkg/sdks baseto generate a.yarn/sdksdirectory. - Set your language server (e.g. VTSLS) to use TypeScript SDK from
.yarn/sdks/typescript/libdirectory in LSP initialization options. The actual setting for that depends on language server; for example, for VTSLS you should settypescript.tsdk. - Voilla! Language server functionalities such as Go to Definition, Code Completions and On Hover documentation should work.
Zig
Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.
Zig support is built into the editor.
Migrate from other editors
Gram has some built-in support to migrate settings and configuration from other, similar editors.
How to Migrate from VS Code to Gram
This guide is for developers who spent serious time in VS Code and want to try Gram without starting from scratch.
If you’re here, you are probably a VS Code user frustrated by the slow, Electron-based implementation and the increasing reliance on flaky AI tooling that is creeping into editors like VS Code and Zed, created by US-based corporations that want to trap you in a subscription-based model of code editing.
Gram is a fully open source editor without any AI, telemetry or subscriptions, with support for many of the same languages that VS Code supports.
Install Gram
Gram is available for macOS, Windows, and Linux.
To install the editor, you will need to build it from source. Fortunately, building a Rust project is really easy. All you need is https://rustup.rs, which will help you install the compiler and tooling that compiling Gram requires.
After installation, you can launch Gram in the same way that you usually run applications on your platform.
Import Settings from VS Code
During setup, you have the option to import key settings from VS Code. Gram imports the following settings:
Settings Imported from VS Code
The following VS Code settings are automatically imported when you use Import Settings from VS Code:
Editor
| VS Code Setting | Gram Setting |
|---|---|
editor.fontFamily | buffer_font_family |
editor.fontSize | buffer_font_size |
editor.fontWeight | buffer_font_weight |
editor.tabSize | tab_size |
editor.insertSpaces | hard_tabs (inverted) |
editor.wordWrap | soft_wrap |
editor.wordWrapColumn | preferred_line_length |
editor.cursorStyle | cursor_shape |
editor.cursorBlinking | cursor_blink |
editor.renderLineHighlight | current_line_highlight |
editor.lineNumbers | gutter.line_numbers, relative_line_numbers |
editor.showFoldingControls | gutter.folds |
editor.minimap.enabled | minimap.show |
editor.minimap.autohide | minimap.show |
editor.minimap.showSlider | minimap.thumb |
editor.minimap.maxColumn | minimap.max_width_columns |
editor.stickyScroll.enabled | sticky_scroll.enabled |
editor.scrollbar.horizontal | scrollbar.axes.horizontal |
editor.scrollbar.vertical | scrollbar.axes.vertical |
editor.mouseWheelScrollSensitivity | scroll_sensitivity |
editor.fastScrollSensitivity | fast_scroll_sensitivity |
editor.cursorSurroundingLines | vertical_scroll_margin |
editor.hover.enabled | hover_popover_enabled |
editor.hover.delay | hover_popover_delay |
editor.parameterHints.enabled | auto_signature_help |
editor.multiCursorModifier | multi_cursor_modifier |
editor.selectionHighlight | selection_highlight |
editor.roundedSelection | rounded_selection |
editor.find.seedSearchStringFromSelection | seed_search_query_from_cursor |
editor.rulers | wrap_guides |
editor.renderWhitespace | show_whitespaces |
editor.guides.indentation | indent_guides.enabled |
editor.linkedEditing | linked_edits |
editor.autoSurround | use_auto_surround |
editor.formatOnSave | format_on_save |
editor.formatOnPaste | auto_indent_on_paste |
editor.formatOnType | use_on_type_format |
editor.trimAutoWhitespace | remove_trailing_whitespace_on_save |
editor.suggestOnTriggerCharacters | show_completions_on_input |
editor.suggest.showWords | completions.words |
editor.inlineSuggest.enabled | show_edit_predictions |
Files & Workspace
| VS Code Setting | Gram Setting |
|---|---|
files.autoSave | autosave |
files.autoSaveDelay | autosave.milliseconds |
files.insertFinalNewline | ensure_final_newline_on_save |
files.associations | file_types |
files.watcherExclude | file_scan_exclusions |
files.watcherInclude | file_scan_inclusions |
files.simpleDialog.enable | use_system_path_prompts |
search.smartCase | use_smartcase_search |
search.useIgnoreFiles | search.include_ignored |
Terminal
| VS Code Setting | Gram Setting |
|---|---|
terminal.integrated.fontFamily | terminal.font_family |
terminal.integrated.fontSize | terminal.font_size |
terminal.integrated.lineHeight | terminal.line_height |
terminal.integrated.cursorStyle | terminal.cursor_shape |
terminal.integrated.cursorBlinking | terminal.blinking |
terminal.integrated.copyOnSelection | terminal.copy_on_select |
terminal.integrated.scrollback | terminal.max_scroll_history_lines |
terminal.integrated.macOptionIsMeta | terminal.option_as_meta |
terminal.integrated.{platform}Exec | terminal.shell |
terminal.integrated.env.{platform} | terminal.env |
Tabs & Panels
| VS Code Setting | Gram Setting |
|---|---|
workbench.editor.showTabs | tab_bar.show |
workbench.editor.showIcons | tabs.file_icons |
workbench.editor.tabActionLocation | tabs.close_position |
workbench.editor.tabActionCloseVisibility | tabs.show_close_button |
workbench.editor.focusRecentEditorAfterClose | tabs.activate_on_close |
workbench.editor.enablePreview | preview_tabs.enabled |
workbench.editor.enablePreviewFromQuickOpen | preview_tabs.enable_preview_from_file_finder |
workbench.editor.enablePreviewFromCodeNavigation | preview_tabs.enable_preview_from_code_navigation |
workbench.editor.editorActionsLocation | tab_bar.show_tab_bar_buttons |
workbench.editor.limit.enabled / value | max_tabs |
workbench.editor.restoreViewState | restore_on_file_reopen |
workbench.statusBar.visible | status_bar.show |
Project Panel (File Explorer)
| VS Code Setting | Gram Setting |
|---|---|
explorer.compactFolders | project_panel.auto_fold_dirs |
explorer.autoReveal | project_panel.auto_reveal_entries |
explorer.excludeGitIgnore | project_panel.hide_gitignore |
problems.decorations.enabled | project_panel.show_diagnostics |
explorer.decorations.badges | project_panel.git_status |
Git
| VS Code Setting | Gram Setting |
|---|---|
git.enabled | git_panel.button |
git.defaultBranchName | git_panel.fallback_branch_name |
git.decorations.enabled | git.inline_blame, project_panel.git_status |
git.blame.editorDecoration.enabled | git.inline_blame.enabled |
Window & Behavior
| VS Code Setting | Gram Setting |
|---|---|
window.confirmBeforeClose | confirm_quit |
window.nativeTabs | use_system_window_tabs |
window.closeWhenEmpty | when_closing_with_no_tabs |
accessibility.dimUnfocused.enabled / opacity | active_pane_modifiers.inactive_opacity |
Other
| VS Code Setting | Gram Setting |
|---|---|
http.proxy | proxy |
npm.packageManager | node.npm_path |
outline.icons | outline_panel.file_icons, outline_panel.folder_icons |
Gram doesn’t import extensions or keybindings, but this is the fastest way to get a familiar feel while trying something new. If you skip that step during setup, you can still import settings manually later via the command palette:
Cmd+Shift+P → Gram: Import VS Code Settings
Set Up Editor Preferences
You can also configure settings manually in the Settings Editor.
To edit your settings:
Cmd+,to open the Settings Editor.- Run
gram: open settingsin the Command Palette.
Here’s how common VS Code settings translate:
| VS Code | Gram | Notes |
|---|---|---|
| editor.fontFamily | buffer_font_family | Gram uses Fira Code by default |
| editor.fontSize | buffer_font_size | Set in pixels |
| editor.tabSize | tab_size | Can override per language |
| editor.insertSpaces | insert_spaces | Boolean |
| editor.formatOnSave | format_on_save | Works with formatter enabled |
| editor.wordWrap | soft_wrap | Supports optional wrap column |
Gram also supports per-project settings. You can find these in the Settings Editor as well.
Open or Create a Project
After setup, press Cmd+O (Ctrl+O on Linux) to open a folder. This becomes
your workspace in Gram. There’s no support for multi-root workspaces or
.code-workspace files like in VS Code. Gram keeps it simple: one folder, one
workspace.
To start a new project, create a directory using your terminal or file manager, then open it in Gram. The editor will treat that folder as the root of your project.
You can also launch Gram from the terminal inside any folder with: gram .
Once inside a project, use Cmd+P to jump between files quickly. Cmd+Shift+P
(Ctrl+Shift+P on Linux) opens the command palette for running actions / tasks,
toggling settings, or running other actions.
Open buffers appear as tabs across the top. The sidebar shows your file tree and
Git status. Collapse it with Cmd+B for a distraction-free view.
Differences in Keybindings
If you chose the VS Code keymap during onboarding, you’re likely good to go, and most of your shortcuts should already feel familiar. Here’s a quick reference guide for how our keybindings compare to what you’re used to coming from VS Code.
Common Shared Keybindings (Gram <> VS Code)
| Action | Shortcut |
|---|---|
| Find files | Cmd + P |
| Run a command | Cmd + Shift + P |
| Search text (project-wide) | Cmd + Shift + F |
| Find symbols (project-wide) | Cmd + T |
| Find symbols (file-wide) | Cmd + Shift + O |
| Toggle left dock | Cmd + B |
| Toggle bottom dock | Cmd + J |
| Open terminal | Ctrl + ~ |
| Open file tree explorer | Cmd + Shift + E |
| Close current buffer | Cmd + W |
| Close whole project | Cmd + Shift + W |
| Refactor: rename symbol | F2 |
| Change theme | Cmd + K, Cmd + T |
| Wrap text | Opt + Z |
| Navigate open tabs | Cmd + Opt + Arrow |
| Syntactic fold / unfold | Cmd + Opt + { or } |
Different Keybindings (Gram <> VS Code)
| Action | VS Code | Gram |
|---|---|---|
| Open recent project | Ctrl + R | Cmd + Opt + O |
| Move lines up/down | Opt + Up/Down | Cmd + Ctrl + Up/Down |
| Split panes | Cmd + \ | Cmd + K, Arrow Keys |
| Expand Selection | Shift + Alt + Right | Opt + Up |
Unique to Gram
| Action | Shortcut | Notes |
|---|---|---|
| Toggle right dock | Cmd + R or Cmd + Alt + B | |
| Syntactic selection | Opt + Up/Down | Selects code by structure (e.g., inside braces). |
How to Customize Keybindings
To edit your keybindings:
- Open the command palette (
Cmd+Shift+P) - Run
Gram: Open Keymap Editor
This opens a list of all available bindings. You can override individual shortcuts, remove conflicts, or build a layout that works better for your setup.
Gram also supports chords (multi-key sequences) like Cmd+K Cmd+C, like VS Code
does.
Differences in User Interfaces
No Workspace
VS Code uses a dedicated Workspace concept, with multi-root folders,
.code-workspace files, and a clear distinction between “a window” and “a
workspace.” Gram simplifies this model.
In Gram:
-
There is no workspace file format. Opening a folder is your project context.
-
Gram does not support multi-root workspaces. You can only open one folder at a time in a window.
-
Most project-level behavior is scoped to the folder you open. Search, Git integration, tasks, and environment detection all treat the opened directory as the project root.
-
Per-project settings are optional. You can add a
.gram/settings.jsonfile inside a project to override global settings, but Gram does not use.code-workspacefiles and won’t import them. -
You can start from a single file or an empty window. Gram doesn’t require you to open a folder to begin editing.
The result is a simpler model: Open a folder → work inside that folder → no additional workspace layer.
Navigating in a Project
In VS Code, the standard entry point is opening a folder. From there, the left-hand sidebar is central to your navigation. Gram takes a different approach:
- You can still open folders, but you don’t need to. Opening a single file or even starting with an empty workspace is valid.
- The Command Palette (
Cmd+Shift+P) and File Finder (Cmd+P) are your primary navigation tools. The File Finder searches across the entire workspace instantly; files, symbols and commands. - Instead of a persistent sidebar, Gram encourages you to:
- Fuzzy-find files by name (
Cmd+P) - Jump directly to symbols (
Cmd+Shift+O) - Use split panes and tabs for context, rather than keeping a large file tree open (though you can do this with the Project Panel if you prefer).
- Fuzzy-find files by name (
The UI is intentionally minimal. Panels slide in only when needed, then get out of your way. The focus is on flowing between code instead of managing panes.
Extensions vs. Marketplace
Gram does not offer as many extensions as VS Code. The available extensions are focused on language support, themes, syntax highlighting, and other core editing enhancements.
However there are several features that typically require extensions in VS Code which we built directly into Gram:
- Vim modal editing mode (as well as a Helix mode)
- Built-in terminal panel
- Project-wide fuzzy search
- Task runner with JSON config
- Inline diagnostics and code actions via LSP
You won’t find one-to-one replacements for every VS Code extension, especially if you rely on tools for DevOps, containers, or test runners. Gram’s extension ecosystem is still growing, and the catalog is smaller by design.
Advanced Config and Productivity Tweaks
Gram exposes advanced settings for power users who want to fine-tune their environment.
Here are a few useful tweaks:
Format on Save:
"format_on_save": "on"
Enable direnv support:
"load_direnv": "shell_hook"
Custom Tasks: Define build or run commands in your tasks.jsonc (accessed
via command palette: gram: open tasks):
[
{
"label": "build",
"command": "cargo build"
}
]
Bring over custom snippets Copy your VS Code snippet JSON directly into
Gram’s snippets folder (gram: configure snippets).
Migrating from Zed to Gram
Gram is a fork of the Zed code editor made roughly around the version 0.217.
From there, a lot of “features” have been stripped out:
- All telemetry was removed
- All AI-related functionality was removed
- Collaboration and its proprietary server component were removed
- Automatic extension installation was removed
- Auto-updates were removed
- There is no license agreement to accept beyond the GPL open source license
However, some functionality has also been added or changed that is not available in Zed.
- Integrated documentation viewer
- Various bugfixes
- Rewritten documentation
- Modified defaults
- More themes included
Configuration
The configuration should be mostly compatible: Try copying your keymap.json
and settings.json files from ~/.config/zed/ to ~/.config/gram/ and
renaming them keymap.jsonc and settings.jsonc. It might work.
Extension support
Since Zed extensions in the Zed editor are installed as binary blobs from the proprietary servers owned by Zed Industries, this installation method has been removed from Gram. Instead, extensions can be installed using the extension repository URL directly. Language extensions that need to be compiled to Wasm require a rustup toolchain to do the compilation.
If the extension doesn’t work, check the Gram log file using
cmd-shift-p Open Log (also available in the Command Palette).
Currently, this functionality is very crude, and as Zed continues to develop it is likely that extensions that compile to Wasm will stop being compatible with Gram. Therefore, the plan is to eventually replace the extension system from Zed with something else, but also to integrate language support for the most popular languages directly into Gram so that language extensions aren’t needed in most cases.
Note: This is a work in progress. The goal is not to keep up with Zed and to stay a stripped-down version of the same editor. I am not interested in Zed. The goal is simply to have a good-enough baseline editor which is simple to install and use, and can replace VS Code as the editor to recommend to beginners.