summaryrefslogtreecommitdiffstats
path: root/nvim/lua/kickstart/plugins/autoformat.lua
diff options
context:
space:
mode:
authorChris Patti <feoh@feoh.org>2023-06-04 16:10:59 +0000
committerChris Patti <feoh@feoh.org>2023-06-04 16:10:59 +0000
commit0b27e37a70826bb30821c6f76c231ce332292359 (patch)
treeab97deeace7bcedf002ad285b2a2467be019e1fd /nvim/lua/kickstart/plugins/autoformat.lua
parentef49ada08c0ff2d8c2abb41e1b5826c1b009b511 (diff)
downloaddots-0b27e37a70826bb30821c6f76c231ce332292359.tar.gz
Revert "Refactor theme and status line into their own file"
This reverts commit 4dd2f71906c4278356f80736ee7f3faaf3cdb3ca.
Diffstat (limited to 'nvim/lua/kickstart/plugins/autoformat.lua')
-rw-r--r--nvim/lua/kickstart/plugins/autoformat.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/nvim/lua/kickstart/plugins/autoformat.lua b/nvim/lua/kickstart/plugins/autoformat.lua
index 855f350..bc56b15 100644
--- a/nvim/lua/kickstart/plugins/autoformat.lua
+++ b/nvim/lua/kickstart/plugins/autoformat.lua
@@ -5,7 +5,6 @@
return {
'neovim/nvim-lspconfig',
-
config = function()
-- Switch for controlling whether you want autoformatting.
-- Use :KickstartFormatToggle to toggle autoformatting on or off
@@ -29,9 +28,11 @@ return {
return _augroups[client.id]
end
+ -- Whenever an LSP attaches to a buffer, we will run this function.
+ --
+ -- See `:help LspAttach` for more information about this autocmd event.
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
-
-- This is where we attach the autoformatting for reasonable clients
callback = function(args)
local client_id = args.data.client_id
@@ -49,6 +50,8 @@ return {
return
end
+ -- Create an autocmd that will run *before* we save the buffer.
+ -- Run the formatting command for the LSP that has just attached.
vim.api.nvim_create_autocmd('BufWritePre', {
group = get_augroup(client),
buffer = bufnr,
@@ -57,7 +60,12 @@ return {
return
end
- vim.lsp.buf.format { async = false }
+ vim.lsp.buf.format {
+ async = false,
+ filter = function(c)
+ return c.id == client.id
+ end,
+ }
end,
})
end,