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.lua — vim.schedule block on lines 5–15; vim.lsp.enable('jsonls') on line 16
lua/config/plugins/lang/yaml.lua — vim.schedule block on lines 14–31; vim.lsp.enable('yamlls') on line 32
QA plan
- 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
- 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)
- After the fix: confirm
vim.lsp.enable appears inside the vim.schedule callback in both files
- 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.
Current state
In
lua/config/plugins/lang/json.lua(line 16) andlua/config/plugins/lang/yaml.lua(line 32),vim.lsp.enableis called synchronously after avim.scheduleblock that registersvim.lsp.config. Becausevim.scheduledefers execution until after the current synchronous pass,vim.lsp.enablefires 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 samevim.schedulecallback asvim.lsp.config('jsonls', ...)injson.luavim.lsp.enable('yamlls')is called inside the samevim.schedulecallback asvim.lsp.config('yamlls', ...)inyaml.luavim.lsp.configStarting points
lua/config/plugins/lang/json.lua—vim.scheduleblock on lines 5–15;vim.lsp.enable('jsonls')on line 16lua/config/plugins/lang/yaml.lua—vim.scheduleblock on lines 14–31;vim.lsp.enable('yamlls')on line 32QA plan
lua/config/plugins/lang/json.lua— confirmvim.lsp.enable('jsonls')is on line 16, after the closingend)of thevim.scheduleblocklua/config/plugins/lang/yaml.lua— confirmvim.lsp.enable('yamlls')is on line 32, after the closingend)of thevim.scheduleblock (lines 14–31)vim.lsp.enableappears inside thevim.schedulecallback in both filesstylua --check .— expect no formatting issuesDone when
vim.lsp.enableis called inside the samevim.schedulecallback asvim.lsp.configin bothjson.luaandyaml.lua.