diff options
| author | phanium <91544758+phanen@users.noreply.github.com> | 2026-01-28 06:59:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-27 17:59:36 -0500 |
| commit | fd45bc8caba2b7f40bdb64aec4c997cc9849fff6 (patch) | |
| tree | 87f96249d43d7435a32cadccb0fd9bd9463bc703 /runtime/lua | |
| parent | 6291256868f033cae7c3ef2b30406a2c17090046 (diff) | |
| download | rneovim-fd45bc8caba2b7f40bdb64aec4c997cc9849fff6.tar.gz rneovim-fd45bc8caba2b7f40bdb64aec4c997cc9849fff6.tar.bz2 rneovim-fd45bc8caba2b7f40bdb64aec4c997cc9849fff6.zip | |
fix: lsp.enable() don't work correctly inside FileType event #37538
Problem:
Two cases lsp.enable() won't work in the first FileType event
1. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim a.lua
```
2. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim -> :edit a.lua -> :mksession! | restart +qa! so Session.vim
```
Solution:
Currently `v:vim_did_enter` is used to detected two cases:
1. "maunally enabled" (lsp.enable() or `:lsp enable`)
2. "inside FileType event"
To detect 2. correctly we use did_filetype().
Diffstat (limited to 'runtime/lua')
| -rw-r--r-- | runtime/lua/vim/lsp.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index a464ed47df..db17f992ba 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -590,7 +590,7 @@ function lsp.enable(name, enable) -- Ensure any pre-existing buffers start/stop their LSP clients. if enable ~= false then - if vim.v.vim_did_enter == 1 and next(lsp._enabled_configs) then + if (vim.v.vim_did_enter == 1 or vim.fn.did_filetype() == 1) and next(lsp._enabled_configs) then vim.cmd.doautoall('nvim.lsp.enable FileType') end else |