Skip to content

Fix for Crystal support#651

Merged
w0rp merged 3 commits into
dense-analysis:masterfrom
TheLonelyGhost:crystal-fix
Jun 15, 2017
Merged

Fix for Crystal support#651
w0rp merged 3 commits into
dense-analysis:masterfrom
TheLonelyGhost:crystal-fix

Conversation

@TheLonelyGhost

@TheLonelyGhost TheLonelyGhost commented Jun 14, 2017

Copy link
Copy Markdown
Contributor

Fixes #650.

If the linter requires the target file (e.g., lint_file attribute is set), skip the linting for that file if it does not yet exist. This can happen if you open vim at a location for a new file and the buffer for that file has not been written out to disk yet.

Also includes a fix for Crystal compiler output defaulting to colorized output now, which should be removed for display in the vim output.

@w0rp w0rp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glob can be slow some times. I'll see if there's another way to check that later.

@TheLonelyGhost

TheLonelyGhost commented Jun 14, 2017

Copy link
Copy Markdown
Contributor Author

I did notice a slight hit to performance, but that was the easiest way I found to check if the file exists. Definitely open to suggestions.

EDIT: Ugh, I'm stupid. Amended the prior commit (for nicer history). https://stackoverflow.com/a/3098685/1236035

@TheLonelyGhost

Copy link
Copy Markdown
Contributor Author

Alright. Now I'm confused. WIth empty(glob(expand('#' . l:buffer . ':p'))) it worked without any test failures, but filereadable(expand('#' . l:buffer . ':p'))) results in some issues.

Wat? o_O

@w0rp w0rp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You needed to invert your filereadable check. I simplified that.

@w0rp w0rp merged commit fb682be into dense-analysis:master Jun 15, 2017
@TheLonelyGhost TheLonelyGhost deleted the crystal-fix branch June 16, 2017 03:12
Comment thread autoload/ale.vim
unlet s:should_lint_file_for_buffer[l:buffer]
let l:should_lint_file = 1
" Lint files if they exist.
let l:should_lint_file = filereadable(expand('#' . l:buffer . ':p'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't ALE also use temporary files in this case, like with modified files?!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. That's a check for linters which cannot use temporary files.

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

Successfully merging this pull request may close these issues.

Crystal linter errors when buffer for new file

3 participants