Skip to content

DrKJeff16/wezterm-types

Repository files navigation

wezterm-types

Mentioned in Awesome WezTerm | Mentioned in Awesome Neovim

Roadmap | Discussions

This project aims to provide LuaCATS-like Lua Language Server type annotations for your WezTerm config.

Important

While this was made with an aim to be thorough, you should always double-check the WezTerm Lua Reference for any missing or unclear types.


Example in Neovim
wezterm_types.mp4
Example in VSCodium/VSCode
wezterm-types_code.mp4

Table of Contents

  1. Features
  2. Installation
    1. Neovim
  3. Usage
  4. Credits
    1. Maintainers
    2. Maintainers
  5. Structure
  6. License

Features

  • LuaCATS-like type annotations
  • Built-in colorschemes included (config.color_scheme)
  • Up-to-date descriptions
  • Function overrides (e.g. wezterm.on())
  • Neovim support through folke/lazydev.nvim
  • VSCode/VSCodium support by cloning this into ~/.config/wezterm, and editing your config in that directory

Installation

Neovim

For Neovim users, we recommend using folke/lazy.nvim as a package manager, to be used with folke/lazydev.nvim:

require('lazy').setup({
  spec = {
    {
      'folke/lazydev.nvim',
      ft = 'lua',
      dependencies = {
        {
          'DrKJeff16/wezterm-types',
          lazy = true,
          version = false, -- Get the latest version
        },
      },
      opts = {
        library = {
          -- Other library configs...
          { path = 'wezterm-types', mods = { 'wezterm' } },
        },
      },
    },
  },
})

Tip

If you download this repo under a diferent name, you can use the following instead:

{
  {
    'folke/lazydev.nvim',
    ft = 'lua',
    dependencies = {
      {
        'DrKJeff16/wezterm-types',
        lazy = true,
        name = '<my_custom_name>', -- CUSTOM DIRECTORY NAME
        version = false, -- Get the latest version
      },
    },
    opts = {
      library = {
        -- Other library configs...
        { path = '<my_custom_name>', mods = { 'wezterm' } }, -- MAKE SURE TO MATCH THE PLUGIN DIRECTORY'S NAME
      },
    },
  },
}

Usage

After installing the types, add the type annotations to wezterm and config respectively when running require("wezterm") in your configuration.

A useful example:

local wezterm = require("wezterm") ---@type Wezterm

local config = wezterm.config_builder() ---@type Config

config.window_decorations = "RESIZE|MACOS_FORCE_DISABLE_SHADOW"

return config

These annotations enable the Lua Language Server to provide proper type checking and autocompletion for WezTerm configuration options.


Credits

Maintainers

Contributors


Structure

The project is structured as such.
/lua/wezterm/types/
├── colorschemes.lua  <==  Contains the builtin `config.color_schemes` values
├── config.lua  <==  Contains the `Config` class and related data types
├── enum.lua  <==   Imports all the `enum/` files
├── enum/  <==   Enum types
│   ├── copy-mode-assignment.lua  <==  `CopyModeAssignment` enum types
│   └── key-assignment.lua  <==   `KeyAssignment` enum types
├── events.lua  <==  Imports all the `events/` files
├── events/  <==  Events type files
│   ├── gui.lua  <==  `Gui` event types
│   ├── multiplexer.lua  <==  `Mux` event types
│   └── window.lua  <==  `Window` event types
├── objects.lua  <==  Imports all the `objects/` files
├── objects/  <==  Objects type files
│   ├── color.lua  <==  `Color` object types
│   ├── exec-domain.lua  <==  `ExecDomain` object types
│   ├── local-process-info.lua  <==  `LocalProcessInfo` object types
│   ├── mux-domain.lua  <==  `MuxDomain` object types
│   ├── mux-tab.lua  <==  `MuxTab` object types
│   ├── mux-window.lua  <==  `MuxWindow` object types
│   ├── pane-information.lua  <==  `PaneInformation` object types
│   ├── pane.lua  <==  `Pane` object types
│   ├── spawn-command.lua  <==  `SpawnCommand` object types
│   ├── ssh-domain.lua  <==  `SshDomain` object types
│   ├── tab-information.lua  <==  `TabInformation` object types
│   ├── time.lua  <==  `Time` object types
│   ├── tls-domain-client.lua  <==  `TlsDomainClient` object types
│   ├── tls-domain-server.lua  <==  `TlsDomainServer` object types
│   ├── window.lua  <==  `Window` object types
│   └── wsl-domain.lua  <==  `WslDomain` object types
├── wezterm.lua  <==  Imports all the surrounding files, including the `wezterm/` directory
├── wezterm/  <==  Types for the `wezterm` module
│   ├── color.lua  <==  `Wezterm.Color` module types
│   ├── gui.lua  <==  `Wezterm.Gui` module types
│   ├── mux.lua  <==  `Wezterm.Mux` module types
│   ├── nerdfonts.lua  <==  `Wezterm.NerdFonts` module types
│   ├── plugin.lua  <==  `Wezterm.Plugin` module types
│   ├── procinfo.lua  <==  `Wezterm.ProcInfo` module types
│   ├── serde.lua  <==  `Wezterm.Serde` module types
│   ├── time.lua  <==  `Wezterm.Time` module types
└───└── url.lua  <==  `Wezterm.Url` module types

License

MIT