parsonsmatt / intero-neovim

A neovim plugin for Intero, forked from ghcmod-vim
218 stars 28 forks source link

intero-neovim causes stack script files to have filetype=conf #67

Open tsoernes opened 7 years ago

tsoernes commented 7 years ago

Whenever I enable intero-neovim, as in include the line Plug .., syntax highlighting no longer works for Haskell files. If I remove the line, highlighting comes back. Here's my init.vim: init.vim.txt

(EDIT: The below is from Matt Parsons, annotating this issue with more information)

The problem is reproducible by loading the following file into neovim with Intero enabled:

#!/usr/bin/env stack
-- stack --resolver lts-8 script

main = print "hello world"

Removing the shebang fixes the issue. set filetype returns conf for this file when Intero is loaded. Otherwise, it knows it is a Haskell file.

tsoernes commented 7 years ago

I have the same problem on two different computers, both Fedora 26 with neovim v0.2.0. If I disable intero autostart, but otherwise keep the vim config the same, the highlighting is there.

jez commented 7 years ago

Was a recent change, or has it only ever done this for you? (Even better, it'd be great to find the commit that introduced this behavior) On Fri, Jul 21, 2017 at 7:48 AM tsoernes notifications@github.com wrote:

I have the same problem on two different computers, both Fedora 26 with neovim v0.2.0. If I disable intero autostart, but otherwise keep the vim config the same, the highlighting is there.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/parsonsmatt/intero-neovim/issues/67#issuecomment-316992084, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSaVEYaZM5eYdklhbJhIE3hovflDaOOks5sQJ40gaJpZM4OcscL .

tsoernes commented 7 years ago

I first installed intero-neovim a couple of days ago and it's been that way from the start.

2017-07-21 19:22 GMT+02:00 Jake Zimmerman notifications@github.com:

Was a recent change, or has it only ever done this for you? (Even better, it'd be great to find the commit that introduced this behavior) On Fri, Jul 21, 2017 at 7:48 AM tsoernes notifications@github.com wrote:

I have the same problem on two different computers, both Fedora 26 with neovim v0.2.0. If I disable intero autostart, but otherwise keep the vim config the same, the highlighting is there.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/parsonsmatt/intero-neovim/issues/67#issuecomment- 316992084, or mute the thread https://github.com/notifications/unsubscribe-auth/ AFSaVEYaZM5eYdklhbJhIE3hovflDaOOks5sQJ40gaJpZM4OcscL .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/parsonsmatt/intero-neovim/issues/67#issuecomment-317061083, or mute the thread https://github.com/notifications/unsubscribe-auth/AGd9xDqkuQ1cyZjikg290SfF-m-HlFR9ks5sQN43gaJpZM4OcscL .

tsoernes commented 7 years ago

With intero enabled, I get filetype=conf, when disabled, I get filetype=haskell on the very same .hs file, when querying :set ft?.

parsonsmatt commented 7 years ago

That's really bizarre. There's nothing in intero that sets the filetype. Thanks for reporting. What's your OS and vim version?

tsoernes commented 7 years ago

Nvim 0.2.0 on Fedora 26 KDE xorg.

tsoernes commented 7 years ago

I found the culprit: In my .hs file I had

#!/usr/bin/env stack

at the top to allow it to be run as a script. Removing that line and syntax highlighting works.

tsoernes commented 7 years ago

When saving hs files without the aforementioned line (so that intero-neovim actually starts), and without a stack.yaml (which is not wanted when scripting with haskell), the following appear in terminal after :wq

Error detected while processing function <SNR>51_on_stdout[26]..<SNR>51_new_response[22]..intero#maker#write_update:
line    3:
E482: Can't open file /tmp/nvimWuC10t/3 for writing: no such file or directory

Intero-neovim seems to be working fine for hs files without stack env variable and with stack.yaml file.

parsonsmatt commented 7 years ago

Hmmm, that's tricky. In order for the Neomake maker to work, we do assume the presence of a .stack-work directory to stuff the process log, which is then read from neomake to display errors. We'll need to handle the case of no stack directory somehow.

Can you disable the Neomake integration and see if Intero works on non-project Haskell files?

parsonsmatt commented 7 years ago

@tsoernes Would it be fair to say we've identified two issues?

  1. The she-bang causes Intero to fail to load the file
  2. Non-stack projects don't work with the Neomake maker?
tsoernes commented 7 years ago

Yes, I very much agree. Regarding 2., for starters it would perhaps be possible to skip checking for .stack-work if neomake is disabled, which it is in my case (g:intero_use_neomake=0).

parsonsmatt commented 7 years ago

I'm going to retitle this issue Syntax highlighting fails on Haskell files with a shebang and open a new issue for the Neomake integration on bare files using STACK_YAML env var.

unode commented 7 years ago

Also saw the same issue (filetype=conf) after installation. My workaround was to set au BufRead,BufNewFile *.hs set filetype=haskell on init.vim.