mirror of
https://github.com/neovim/neovim.git
synced 2026-02-22 02:11:33 +10:00
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().
(cherry picked from commit fd45bc8cab)
This commit is contained in:
committed by
github-actions[bot]
parent
1b7c56db1e
commit
b1f2fe46cd
@@ -632,7 +632,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
|
||||
|
||||
Reference in New Issue
Block a user