From 9ce61a5cc368da471e59fb0545527b7e7bc148ed Mon Sep 17 00:00:00 2001 From: Lukas Reineke Date: Thu, 3 Mar 2022 11:50:41 +0900 Subject: [PATCH] Version 2.0.1 * Add notes to README --- README.md | 21 +++++++++++++++++++++ doc/format.txt | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index feafd6f..f00adb0 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,27 @@ end require "lspconfig".gopls.setup { on_attach = on_attach } ``` +That's it, saving a buffer will format it now. + +## Notes + +#### Make sure you remove any old format on save code + +You don't want to run formatting twice. If you had setup formatting on save before, remove it. +You can check if something is listening on buffer write events with `:autocmd BufWritePre` and `:autocmd BufWritePost` + +#### `:wq` will not format + +Because formatting is async now, you can't save and quit in the same command. The formatting results will not get back +in time and Neovim will close without applying the changes. +In this case you need to use `vim.lsp.buf.formatting_sync()` + +Add this abbreviation into your dotfiles to do the right thing when doing `:wq` + +```lua +vim.cmd [[cabbrev wq execute "lua vim.lsp.buf.formatting_sync()" wq]] +``` + ## FAQ ### How is it different to `autocmd BufWritePre lua vim.lsp.buf.formatting_sync()`? diff --git a/doc/format.txt b/doc/format.txt index 0c7243f..eb60c47 100644 --- a/doc/format.txt +++ b/doc/format.txt @@ -2,7 +2,7 @@ Author: Lukas Reineke -Version: 2.0.0 +Version: 2.0.1 ============================================================================== CONTENTS *lsp-format* @@ -77,6 +77,9 @@ format options. ============================================================================== 4. CHANGELOG *lsp-format-changelog* +2.0.1 + * Add notes to README + 2.0.0 * Removed formatting from the plugin itself, and use LSP instead.