Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically, annoyingly removes spaces as you type with codi.vim #12

Open
dylan-chong opened this issue Jul 1, 2018 · 5 comments
Open

Comments

@dylan-chong
Copy link

As you type into the buffer when Codi is started, Codi evaluates the code. Unfortunately, a side effect of this behaviour is that this plug-in decides to strip the white space as you type - as you are still in insert mode. This is rather annoying, especially when you are trying to type code that is indented.

To illustrate this behaviour, see this:

ezgif-1-d3a9dd2f53

I have mentioned this in this issue here metakirby5/codi.vim#90

@thirtythreeforty
Copy link
Owner

thirtythreeforty commented Jul 2, 2018

Hey thanks for opening an issue. Sorry you're having trouble. Unfortunately it looks like both pieces of software are working as intended...

I'm having trouble completely understanding the Codi docs, but it looks like your best option is to change the opt_autocmd option to InsertLeave. I think this will trigger Codi when you leave Insert mode, rather than on every text change. LessSpace only runs when you leave Insert mode or when you make a change in normal mode, so that might fix the symptom you're hitting. (Under the hood, I think Codi leaves insert mode to evaluate.)

LessSpace has a mechanism to work around conflicting plugins—if you're curious, search the source code for "temporary," although it isn't a documented API right now. But I don't think it would be useful in this case, because Codi sometimes doesn't call the CodiUpdatePost autocommand that I would otherwise use to stop LessSpace from updating. I'd be happy to hear suggestions about how to make this work.

Another option may just be adding an autocommand or blacklist to disable LessSpace in Codi buffers.

Sorry I don't have an immediate band-aid. What would work best for you? See below.

@thirtythreeforty
Copy link
Owner

Actually, upon further reading, it looks like the CodiUpdatePre and CodiUpdatePost commands may work. Can you try running the following either in a vimrc or in the Vim command line?

augroup lessspace_codi
  autocmd!
  autocmd User CodiUpdatePre call lessspace#TemporaryDisableBegin()
  autocmd User CodiUpdatePost call lessspace#TemporaryDisableEnd()
augroup END

@dylan-chong
Copy link
Author

it looks like your best option is to change the opt_autocmd option to InsertLeave.

Yup this works for me, only problem is that when you make modifications in normal mode (for example x, or pasting) Codi does not get updated

Actually, upon further reading, it looks like the CodiUpdatePre and CodiUpdatePost commands may work. Can you try running the following either in a vimrc or in the Vim command line?

I have just tried this, but less space does not seem to strip the white space at all

@thirtythreeforty
Copy link
Owner

does not seem to strip the white space at all

Yeah I was afraid of that. I think Codi never calls the Post hook, because it's async.

That's an interesting normal mode problem. I would think that would Just Work. I will download Codi in a day or two when I have some time and see what I can come up with.

@dylan-chong
Copy link
Author

dylan-chong commented Jul 3, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants