Merge pull request #14262 from mjlbach/feature/lsp_did_save_autocommand

lsp: clear did_save handler autocommand on each attach
This commit is contained in:
Michael Lingelbach 2021-04-01 00:53:47 -07:00 committed by GitHub
commit f738f089da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -931,7 +931,13 @@ function lsp.buf_attach_client(bufnr, client_id)
all_buffer_active_clients[bufnr] = buffer_client_ids
local uri = vim.uri_from_bufnr(bufnr)
nvim_command(string.format("autocmd BufWritePost <buffer=%d> lua vim.lsp._text_document_did_save_handler(0)", bufnr))
local buf_did_save_autocommand = [=[
augroup lsp_c_%d_b_%d_did_save
au!
au BufWritePost <buffer=%d> lua vim.lsp._text_document_did_save_handler(0)
augroup END
]=]
vim.api.nvim_exec(string.format(buf_did_save_autocommand, client_id, bufnr, bufnr), false)
-- First time, so attach and set up stuff.
vim.api.nvim_buf_attach(bufnr, false, {
on_lines = text_document_did_change_handler;