From: Lukas Krickl Date: Mon, 21 Aug 2023 16:40:06 +0000 (+0200) Subject: Added W command that writes and formats X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a6b30f10c2cee92da4fea4b617f5f93cb511292a;p=dotfiles%2F.git Added W command that writes and formats --- diff --git a/nvim/lua/plugin/lspzero.lua b/nvim/lua/plugin/lspzero.lua index 4ff81f9..d80151d 100644 --- a/nvim/lua/plugin/lspzero.lua +++ b/nvim/lua/plugin/lspzero.lua @@ -24,9 +24,13 @@ lsp.on_attach(function(client, bufnr) -- autocmd format on save -- vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] vim.keymap.set('n', 'gp', + vim.lsp.buf.format, { buffer = true }) + + vim.api.nvim_create_user_command("W", function() vim.lsp.buf.format() - end, { buffer = true }) + vim.cmd('w') + end, { nargs = 0, desc = 'Write and format' }) end)