asyncomplete.vim icon indicating copy to clipboard operation
asyncomplete.vim copied to clipboard

Avoid crlf line endings

Open fekir opened this issue 2 years ago • 4 comments

On Windows, when starting vim, I have following error/warning:

Error detected while processing <...>/asyncomplete.vim/plugin/asyncomplete.vim:
line    1:
E488: Trailing characters: ^M
line   26:
E171: Missing :endif
Press ENTER or type command to continue

The root cause seems to be the .gitattibutes file, that contains * text=auto. Simply deleting it fixes the issue.

I cannot even override the settings by setting globally in git

	safecrlf = false
	autocrlf = false

and since vim wants config files with lf as line-ending, I do not think there are many use-cases for setting line endings conversions.

fekir avatar Jul 07 '22 05:07 fekir

Probably, you are using Vim on WSL that is sharing ~/.vim with Windows? And probably you clone the repository on Windows. Right? Then, you should not set autocrlf=true in your .gitconfig.

mattn avatar Jul 07 '22 08:07 mattn

No, I'm not using WSL. I've cloned the repo with git-for-windows:

> git config core.autocrlf
false
> git clone https://github.com/prabirshrestha/asyncomplete.vim.git
[...]
> file asyncomplete.vim/plugin/asyncomplete.vim
asyncomplete.vim/plugin/asyncomplete.vim: ASCII text, with CRLF line terminators

I have explicitly set autocrlf = false in my git configuration, but this decision is overridden by .gitattibutes.

Instead of deleting the .gitattibutes, you might want to consider setting * text=auto eol=lf...

fekir avatar Jul 07 '22 09:07 fekir

What do you get with?

$ wget https://raw.githubusercontent.com/prabirshrestha/asyncomplete.vim/master/autoload/asyncomplete.vim
$ file asyncomplete.vim

mattn avatar Jul 07 '22 13:07 mattn

$ wget https://raw.githubusercontent.com/prabirshrestha/asyncomplete.vim/master/autoload/asyncomplete.vim
$ file asyncomplete.vim
asyncomplete.vim: ASCII text

Note that I also have lf line terminators if I clone the repository with WSL.

It is a windows-specific "feature" that text files have crlf line terminator, and git-for-windows is honoring that convention with the given .gitattributes

fekir avatar Jul 07 '22 20:07 fekir

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 01:09 stale[bot]

@mattn considering the fact that the issue is trivial to fix could you revert what the bot decided?

Do you need other information?

fekir avatar Sep 21 '22 05:09 fekir

Pleaes try this solution https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows/33424884#33424884

Anyway, this is not an issue of vim-lsp.

mattn avatar Sep 21 '22 05:09 mattn

At least, AFAIK, you must not set * text=auto

mattn avatar Sep 21 '22 06:09 mattn

I think there are two issues:

  1. The * text=auto setting. This setting is only useful if someone wants to checkout a file in CRLF on Windows and LF on other systems. Nowadays, Windows Notepad supports both CRLF and LF. Only a few filetypes like batch files and VisualStudio project files need to be in CRLF. Of course, no need to checkout vim files in CRLF. So, I don't think that this setting is needed.
  2. The E488: Trailing characters: ^M error. This is most likely a setup issue. This can happen when someone try to source a CRLF vim file into Vim on a unix-like system. Here "unix-like" includes Vim in WSL, Cygwin, MSYS2, and Git for Windows. If you use Vim on a unix-like system, you should use Git on that system. (Vim in Git for Windows is an exception, though.)

k-takata avatar Sep 21 '22 07:09 k-takata

@mattn I think we are talking past each other.

I've already configured git not to make any conversion, but the .gitattibutes file that is checked in overwrites any configuration.

* text=auto is not set by me, it is set in this repository, and leads to the described error.

fekir avatar Sep 21 '22 07:09 fekir

@prabirshrestha What reason for adding * text=auto ?

mattn avatar Sep 21 '22 08:09 mattn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 03 '23 00:04 stale[bot]

Ping

fekir avatar Apr 03 '23 05:04 fekir