diff options
| author | glepnir <glephunter@gmail.com> | 2024-10-04 14:59:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-04 14:59:14 +0800 |
| commit | 3f9fe72100b5f8ca8da00e54ab70707647c822b3 (patch) | |
| tree | efec83c9be749215dc770b5cb5732da31534b7b5 /lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar.gz nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar.bz2 nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar.lz nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar.xz nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.tar.zst nvim-lspconfig-3f9fe72100b5f8ca8da00e54ab70707647c822b3.zip | |
Revert "fix: autostart=false: attach when editing new, nonexistent file #2712" (#3347)
This reverts commit fb453a1a443b6ea6b54a1e4c101b1160c9d37950.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs.lua | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 0e4caa34..391a329b 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -101,15 +101,11 @@ function configs.__newindex(t, config_name, config_def) if config.autostart == true then local event_conf = config.filetypes and { event = 'FileType', pattern = config.filetypes } - or { event = { 'BufReadPost', 'BufNewFile' } } + or { event = 'BufReadPost' } api.nvim_create_autocmd(event_conf.event, { pattern = event_conf.pattern or '*', callback = function(opt) - -- Use vim.schedule() to ensure filetype detection happens first. - -- Sometimes, BufNewFile triggers before 'filetype' is set. - vim.schedule(function() - M.manager:try_add(opt.buf) - end) + M.manager:try_add(opt.buf) end, group = lsp_group, desc = string.format( @@ -146,18 +142,13 @@ function configs.__newindex(t, config_name, config_def) end if root_dir then - api.nvim_create_autocmd({ 'BufReadPost', 'BufNewFile' }, { + api.nvim_create_autocmd('BufReadPost', { pattern = fn.fnameescape(root_dir) .. '/*', callback = function(arg) if #M.manager:clients() == 0 then return true end - - -- Use vim.schedule() to ensure filetype detection happens first. - -- Sometimes, BufNewFile triggers before 'filetype' is set. - vim.schedule(function() - M.manager:try_add_wrapper(arg.buf, root_dir) - end) + M.manager:try_add_wrapper(arg.buf, root_dir) end, group = lsp_group, desc = string.format( |
