Skip to content

lua/config/plugins/lang/yaml.lua registers an LspAttach autocmd outside the plugin config callback #154

@ooloth

Description

@ooloth

Current state

lua/config/plugins/lang/yaml.lua calls vim.api.nvim_create_autocmd('LspAttach', ...) at the top level of the file, before the return block. This call runs when the lang file is evaluated by require_all_files_in_config_directory — outside any plugin config callback — so the autocmd is registered regardless of whether associated plugins have loaded. The same issue is tracked for nvim-dap-ui.lua (#54) and nvim-lspconfig.lua (#55); yaml.lua has the same pattern unaddressed.

Ideal state

  • The LspAttach autocmd is registered inside the config function of the relevant plugin spec in yaml.lua
  • The top level of yaml.lua contains only a return table of plugin specs, with no imperative calls before the return
  • The autocmd still fires on LSP attach for yaml files

Starting points

  • lua/config/plugins/lang/yaml.lua — the LspAttach autocmd at the top level

QA plan

  1. Open lua/config/plugins/lang/yaml.lua — expect no imperative calls before the return statement
  2. Run nvim --headless -c "qall" — expect exit 0 with no Lua errors
  3. Open a .yaml file in Neovim — expect LSP attach behavior to work as before (keymaps and formatting on save)

Done when

lua/config/plugins/lang/yaml.lua has no imperative calls outside the return block.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions