Skip to content

Commit

Permalink
Version 2.0.1
Browse files Browse the repository at this point in the history
* Add notes to README
  • Loading branch information
lukas-reineke committed Mar 3, 2022
1 parent c5af542 commit 9ce61a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()" <bar> wq]]
```

## FAQ

### How is it different to `autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()`?
Expand Down
5 changes: 4 additions & 1 deletion doc/format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


Author: Lukas Reineke <[email protected]>
Version: 2.0.0
Version: 2.0.1

==============================================================================
CONTENTS *lsp-format*
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 9ce61a5

Please sign in to comment.