Ticket #11 (closed defect: invalid)

Opened 5 years ago

Last modified 4 years ago

vim recognizes imports in some places, not in others

Reported by: jdgallag Owned by: claus
Priority: minor Milestone:
Component: compiler/ghc.vim Version: 20090407
Keywords: Cc:

Description

I am playing with the Vim-haskellmode which seems really nice overall. However, I have a headache I cannot resolve. I created four files Ta.hs Tb.hs Tc.hs Td.hs in a single folder. Each incrementally imports and uses a function from the prior. At first, I could not get Tb even to work unless it was in the same directory as .vimrc (\home\user\). Then, if I make exactly one change, copy .vimrc to \home\, then Tc works. Yet, Td does not yet work. Further, this is confusing because there is no problem with running any of the files from normal ghci on a terminal. I suspect I have a configuration problem (I have not used vim really). Any suggestions?

Thanks, Jon

Change History

in reply to: ↑ description   Changed 5 years ago by claus

Replying to jdgallag:

I am playing with the Vim-haskellmode which seems really nice overall.

Thanks! But are you really using the old version you've specified in this ticket?

However, I have a headache I cannot resolve. I created four files Ta.hs Tb.hs Tc.hs Td.hs in a single folder. Each incrementally imports and uses a function from the prior.

This should just work, given that you say all files load without error in GHCi.

At first, I could not get Tb even to work unless it was in the same directory as .vimrc (\home\user\). Then, if I make exactly one change, copy .vimrc to \home\, then Tc works. Yet, Td does not yet work.

This is very confusing indeed. First of all, what platform are you on? The .vimrc suggests you are on some unix, but the backslashes in paths suggest otherwise. Next, .vimrc usually goes into your $HOME (see :help vimrc and :help VIMINIT for the details for your platform). It sounds a bit as if you might be using a cygwin Vim on windows, which I haven't tried (I use cygwin, but with the native Vim/GVim from the binary releases).

What do you mean with "Tc works, Td doesn't"? If both import other modules in the same directory, and both load into GHCi, either both or neither should be useable for haskellmode (provided that you're using the same GHC in both cases, with the same settings - :echo g:ghc tells you which GHC haskellmode is using).

Further, this is confusing because there is no problem with running any of the files from normal ghci on a terminal. I suspect I have a configuration problem (I have not used vim really). Any suggestions?

I would need some more details to make any suggestions. For starters, could you try the following commands in Vim

:redir > settings.txt
:echo g:ghc
:DocSettings
:scriptnames
:redir END

and attach the settings.txt file to this ticket?

It usually takes a while to get used to Vim. Just use :help for a general overview, user and reference manuals, and learn a bit more every day, or try the other resources listed at vim.org.

  Changed 5 years ago by jdgallag

I am on arch linux i686, got the slashes wrong.

Thank you for the suggestions. I found out the source of the problem, but I have no idea how to fix it. For some reason, only $HOME is searched for files to import. I oringally had Ta and Tb in $HOME, then I copied them over to another directory "Test", Ta and Tb were in two separate directories. Tc.hs and Td.hs were created only in "Test". Hence Tc.hs could see the imported Tb.hs, but Td.hs could not import Tc.hs. To convince myself of this as true I deleted Ta and Tb from Test, if Tc.hs was finding Ta in the same directory as itself, it would have necessarily stopped working. However, everything did indeed work. Further, I moved all four files to $HOME and everything worked great. The problem is that it only works in $HOME and I would like to edit in project specific directories if possible.

Any further suggestions?

Settings.txt

ghc

g:haddock_browser = /usr/bin/firefox g:haddock_browser_callformat = %s %s >/dev/null 2>&1 & g:haddock_docdir = g:haddock_indexfiledir = s:ghc_libdir = s:ghc_version = s:docdir = /usr/share/doc/ghc/ s:libraries = /usr/share/doc/ghc/libraries/ s:guide = /usr/share/doc/ghc/users_guide/ s:haddock_indexfile = /home/jon/haddock_index.vim

1: /etc/vimrc 2: /usr/share/vim/syntax/syntax.vim 3: /usr/share/vim/syntax/synload.vim 4: /usr/share/vim/syntax/syncolor.vim 5: /usr/share/vim/filetype.vim 6: /usr/share/vim/menu.vim 7: /usr/share/vim/autoload/paste.vim 8: /usr/share/vim/ftplugin.vim 9: /usr/share/vim/indent.vim

10: /home/jon/.vimrc 11: /usr/share/vim/syntax/nosyntax.vim 12: /usr/share/vim/plugin/getscriptPlugin.vim 13: /usr/share/vim/plugin/gzip.vim 14: /usr/share/vim/plugin/matchparen.vim 15: /usr/share/vim/plugin/netrwPlugin.vim 16: /usr/share/vim/plugin/project.vim 17: /usr/share/vim/plugin/rrhelper.vim 18: /usr/share/vim/plugin/spellfile.vim 19: /usr/share/vim/plugin/tarPlugin.vim 20: /usr/share/vim/plugin/tohtml.vim 21: /usr/share/vim/plugin/vimballPlugin.vim 22: /usr/share/vim/plugin/workspace.vim 23: /usr/share/vim/plugin/zipPlugin.vim 24: /etc/gvimrc 25: /home/jon/.gvimrc 26: /usr/share/vim/ftplugin/haskell.vim 27: /usr/share/vim/ftplugin/haskell_doc.vim 28: /usr/share/vim/ftplugin/haskell_hpaste.vim 29: /usr/share/vim/syntax/haskell.vim 30: /usr/share/vim/compiler/ghc.vim

  Changed 5 years ago by jdgallag

Thanks again for your help.

http://vim.wikia.com/wiki/Change_to_directory_of_the_opened_file

Fixes the problem immediately. Thanks again for the nice plugin!

  Changed 4 years ago by haskellmode

  • status changed from new to closed
  • resolution set to invalid

reporter says: not a bug (vim current directory was not in source directory).

Note: See TracTickets for help on using tickets.