prabirshrestha / asyncomplete.vim

async completion in pure vim script for vim8 and neovim
MIT License
932 stars 60 forks source link

Avoid crlf line endings #274

Closed fekir closed 1 year ago

fekir commented 2 years ago

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.

mattn commented 2 years ago

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.

fekir commented 2 years ago

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...

mattn commented 2 years ago

What do you get with?

$ wget https://raw.githubusercontent.com/prabirshrestha/asyncomplete.vim/master/autoload/asyncomplete.vim
$ file asyncomplete.vim
fekir commented 2 years ago
$ 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

stale[bot] commented 2 years ago

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.

fekir commented 2 years ago

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

Do you need other information?

mattn commented 2 years ago

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 commented 2 years ago

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

k-takata commented 2 years ago

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.)
fekir commented 2 years ago

@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.

mattn commented 2 years ago

@prabirshrestha What reason for adding * text=auto ?

stale[bot] commented 1 year ago

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.

fekir commented 1 year ago

Ping