Skip to content

vim.lsp.enable called outside vim.schedule block in json.lua and yaml.lua — server may start before schema settings are applied #161

@ooloth

Description

@ooloth

Current state

In lua/config/plugins/lang/json.lua (line 16) and lua/config/plugins/lang/yaml.lua (line 32), vim.lsp.enable is called synchronously after a vim.schedule block that registers vim.lsp.config. Because vim.schedule defers execution until after the current synchronous pass, vim.lsp.enable fires first — the LSP server can attach to a buffer before its schema validation and completion settings have been registered.

Ideal state

  • vim.lsp.enable('jsonls') is called inside the same vim.schedule callback as vim.lsp.config('jsonls', ...) in json.lua
  • vim.lsp.enable('yamlls') is called inside the same vim.schedule callback as vim.lsp.config('yamlls', ...) in yaml.lua
  • The JSON and YAML language servers are only enabled after their schema settings have been registered with vim.lsp.config

Starting points

  • lua/config/plugins/lang/json.luavim.schedule block on lines 5–15; vim.lsp.enable('jsonls') on line 16
  • lua/config/plugins/lang/yaml.luavim.schedule block on lines 14–31; vim.lsp.enable('yamlls') on line 32

QA plan

  1. Open lua/config/plugins/lang/json.lua — confirm vim.lsp.enable('jsonls') is on line 16, after the closing end) of the vim.schedule block
  2. Open lua/config/plugins/lang/yaml.lua — confirm vim.lsp.enable('yamlls') is on line 32, after the closing end) of the vim.schedule block (lines 14–31)
  3. After the fix: confirm vim.lsp.enable appears inside the vim.schedule callback in both files
  4. Run stylua --check . — expect no formatting issues

Done when

vim.lsp.enable is called inside the same vim.schedule callback as vim.lsp.config in both json.lua and yaml.lua.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions