586a4015008928ba7e1246a3175492bbd61051c4 — glacambre 2 years ago 6f8752c
README.md: mention how to have firenvim autosave text

Related issue: https://github.com/glacambre/firenvim/issues/117
1 files changed, 25 insertions(+), 0 deletions(-)

M README.md => README.md +25 -0
@@ 119,6 119,31 @@ let g:firenvim_config = {
Note that it is not necessary to specify the `priority` key because it defaults to 1, except for the `.*` pattern, which has a priority of 0.

Since Firenvim just uses the BufWrite event in order to detect when it needs to write neovim's buffers to the page, Firenvim can be made to automatically synchronize all changes like this:
au TextChanged * ++nested write
au TextChangedI * ++nested write
Depending on how large the edited buffer is, this could be a little slow. A better approach would then be to delay writes, like this:
let g:dont_write = v:false
function! My_Write(timer) abort
	let g:dont_write = v:false

function! Delay_My_Write() abort
	if g:dont_write
	let g:dont_write = v:true
	call timer_start(10000, 'My_Write')

au TextChanged * ++nested call Delay_My_Write()
au TextChangedI * ++nested call Delay_My_Write()

## Configuring Neovim's behavior

You can detect when Firenvim connects to Neovim with the following code: