File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66return {
77 ' neovim/nvim-lspconfig' ,
8-
98 config = function ()
109 -- Switch for controlling whether you want autoformatting.
1110 -- Use :KickstartFormatToggle to toggle autoformatting on or off
@@ -29,9 +28,11 @@ return {
2928 return _augroups [client .id ]
3029 end
3130
31+ -- Whenever an LSP attaches to a buffer, we will run this function.
32+ --
33+ -- See `:help LspAttach` for more information about this autocmd event.
3234 vim .api .nvim_create_autocmd (' LspAttach' , {
3335 group = vim .api .nvim_create_augroup (' kickstart-lsp-attach-format' , { clear = true }),
34-
3536 -- This is where we attach the autoformatting for reasonable clients
3637 callback = function (args )
3738 local client_id = args .data .client_id
@@ -49,6 +50,8 @@ return {
4950 return
5051 end
5152
53+ -- Create an autocmd that will run *before* we save the buffer.
54+ -- Run the formatting command for the LSP that has just attached.
5255 vim .api .nvim_create_autocmd (' BufWritePre' , {
5356 group = get_augroup (client ),
5457 buffer = bufnr ,
@@ -57,7 +60,12 @@ return {
5760 return
5861 end
5962
60- vim .lsp .buf .format { async = false }
63+ vim .lsp .buf .format {
64+ async = false ,
65+ filter = function (c )
66+ return c .id == client .id
67+ end ,
68+ }
6169 end ,
6270 })
6371 end ,
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments