DrKJeff16/wezterm-types

website github github
neovim-lua-development
stars 167
issues 1
subscribers 3
forks 23
CREATED

UPDATED


wezterm-types

Mentioned in Awesome WezTerm | Mentioned in Awesome Neovim

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

Example videos can be found in EXAMPLES.md.

NOTE: For any missing or unclear types you should always double-check the WezTerm Lua Reference. If using an annotated plugin featured in this repository please refer to its author for any unclear types.

Features


Table of Contents


Installation

LuaRocks

You can install wezterm-types using LuaRocks:

luarocks install wezterm-types # Global install
luarocks install --local wezterm-types # Local install

To get it running in Neovim please refer to this discussion.

Neovim

We recommend using folke/lazy.nvim as a package manager:

{
  'DrKJeff16/wezterm-types',
  version = false, -- Get the latest version
},

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.

Using lazydev.nvim

Install lazydev.nvim as suggested:

{
  'folke/lazydev.nvim',
  ft = 'lua',
  dependencies = { 'DrKJeff16/wezterm-types' },
  opts = {
    library = {
      -- Other library configs...
      { path = 'wezterm-types', mods = { 'wezterm' } },
    },
  },
}

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

{
  'folke/lazydev.nvim',
  ft = 'lua',
  dependencies = {
    {
      'DrKJeff16/wezterm-types',
      name = '<my_custom_name>', -- CUSTOM DIRECTORY NAME
    },
  },
  opts = {
    library = {
      -- MAKE SURE TO MATCH THE PLUGIN DIRECTORY'S NAME
      { path = '<my_custom_name>', mods = { 'wezterm' } },
    },
  },
}

Using The Built-in Neovim LSP

Add the install path of wezterm-types in your lua_ls config.

return {
  cmd = { 'lua-language-server' },
  filetypes = { 'lua' },
  settings = {
    Lua = {
      workspace = {
        library = {
          -- Other library paths...
          '</path/to/wezterm-types>',
        },
      },
    },
  },
}

Featured Plugins

This project also features type annotations for various WezTerm plugins.

If you want to have your plugin featured please request it through an issue.

You can import type annotations for ChrisGVE/dev.wezterm as shown below:

---@type Dev
local dev = wezterm.plugin.require("https://github.com/ChrisGVE/dev.wezterm")

This integration also adds the following events to wezterm.on():

  • dev.wezterm-plugin-not-found
  • dev.wezterm.invalid_hashkey
  • dev.wezterm.invalid_opts
  • dev.wezterm.no_keywords
  • dev.wezterm.require_path_not_set
---Either no `hashkey` or an invalid one provided.
---
---@param event "dev.wezterm.invalid_hashkey" This is for `dev.wezterm` only!
---@param callback function
function Wezterm.on(event, callback) end

---Invalid options provided to plugin setup.
---
---@param event "dev.wezterm.invalid_opts" This is for `dev.wezterm` only!
---@param callback function
function Wezterm.on(event, callback) end

---No keywords were provided for searching the plugin.
---
---@param event "dev.wezterm.no_keywords" This is for `dev.wezterm` only!
---@param callback function
function Wezterm.on(event, callback) end

---The plugin was not found and thus `package.path` could not be set.
---
---@param event "dev.wezterm.require_path_not_set" This is for `dev.wezterm` only!
---@param callback function
function Wezterm.on(event, callback) end

---The provided keywords did not allow for the plugin to be found.
---
---@param event "dev.wezterm-plugin-not-found" This is for `dev.wezterm` only!
---@param callback function
function Wezterm.on(event, callback) end

You can import type annotations for dimao/ai-commander.wezterm as shown below:

---@type AICommander
local ai_commander = wezterm.plugin.require("https://github.com/dimao/ai-commander.wezterm")

You can import type annotations for Michal1993r/ai-helper.wezterm as shown below:

---@type AIHelper
local ai_helper = wezterm.plugin.require("https://github.com/Michal1993r/ai-helper.wezterm")

You can import type annotations for MLFlexer/modal.wezterm as shown below:

---@type ModalWezterm
local modal = wezterm.plugin.require("https://github.com/MLFlexer/modal.wezterm")

You can import type annotations for xarvex/presentation.wez as shown below:

---@type PresentationWez
local presentation = wezterm.plugin.require("https://github.com/xarvex/presentation.wez")

You can import type annotations for michaelbrusegard/tabline.wez as show below:

---@type TablineWez
local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")

You can import type annotations for sei40kr/wez-pain-control as shown below:

---@type WezPainControl
local wez_pain_control = wezterm.plugin.require("https://github.com/sei40kr/wez-pain-control")

Or, if you've installed it locally:

---@type WezPainControl
local wez_pain_control = require("wez-pain-control.plugin")

You can import type annotations for sei40kr/wez-tmux as shown below:

---@type WezTmux
local wez_tmux = wezterm.plugin.require("https://github.com/sei40kr/wez-tmux")

Or, if you've installed it locally:

---@type WezTmux
local wez_tmux = require("plugins.wez-tmux.plugin")

You can import type annotations for winter-again/wezterm-config.nvim as shown below:

---@type weztermConfig
local wezterm_config_nvim = wezterm.plugin.require('https://github.com/winter-again/wezterm-config.nvim')

Collaborators

Contributors


License

MIT