Vim quickfix double path to file with Ghc-mod - vim

I use Ghc-mod Vim for Haskell source file check. I run it on Windows with gvim. Run :GhcModCheck it passes file for Ghc-mod utility and outputs in a quickfix error like:
G:\Haskell\G:\Haskell\huffman.hs|5 col 1 warning| The import of foldl' from module `Data.List' is redundant
As you can see, it includes path to file two times. Of course I can't jump in that location.
It looks like Ghc-mod itself doesn't output any paths at all, then it ether vim's errorformat or Ghc-mod for Vim plugin. Strangely enough, I haven't found such cases anywhere, so it maybe my _vimrc
Could anyone kindly point me out where to search for clues?

I've checked standard quickfix window after :vimgrep and it appeared allright. It left me only ghcmod-vim as main suspect. I've carefully traced all paths manipulation and have found that utils use some function, which reads a path and searches [a-z] regexp in it.
The problem was that my drive letters were uppercase, so plugin treated it like a usual filename.
I've commited a pull request to ghcmod-vim repo. Hope it'll help.
Thanks you for a concearn.

Related

How do I go to a file in vim/nerdtree?

I'm trying to transition to vim, but I'm having a hard time mapping over some functionalities in pycharm over to vim.
The first being how do I directly go to a filepath. In pycharm, I believe it is cmd-shift P. You'll type the file-path and it'll take you there. I think there's auto-complete too?
Like -- I know that there's a .css file I want to access. So I'd instinctively start typing: cmd shift p .css and this would return the .css files.
How do I do that in vim?
Thanks!
:edit is the most basic command for editing an existing file.
:edit <your file name>
To get a list of all the files ending in ".css" use :edit e *.css and then press Ctrl+d. See :help c_CTRL-D in Vim for more information.
:find <file> is a more powerful version of :edit. It searches for <file> from the directories listed in your path option. For example, if your current directory is project and the value of the path contains
/path/to/project/**, then :find file.css will search all the subdirectories of project for the "file.css".
There is also a plugin called "ctrlp.vim" that should be similar to what you used in pycharm.
For more information about file navigation, I highly recommend reading "Death by a thousand files", an excellent article by Romain Lafourcade.

How to get to long directory quickly when writting code in VIM

I am writing Bash script using VIM. I need to cd to a directory and run the command tool. The command tool is deep inside the directory. How do I quickly cd to that directory instead of manually typing the directory out in VIM ? In terminal prompt, I can get to the directory quickly using tab. It does not work in VIM.
Thanks
ffl3883
You can change to the currently edited file's directory with :cd %:h; see :help filename-modifiers. Likewise, if you trigger the tool from Vim :! % can do this quickly (and repeat with :!!). Or just :set autochdir, so that the current directory within Vim always follows the currently edited file (and you can then just reference the file via ./).
When typing file paths in vim (as I often do for shell scripts), I find filename-complete invaluable. Simply type <C-X><C-F> in insert mode.
N.B. It does not work in all cases (generally vim prefers the path to be a separate WORD), but a quick edit-complete-fixup isn’t terrible.

How to open files from within Vim

I am trying to learn how to use Vim. Apparently I have failed at the first hurdle since Vim (certainly on my computers) cannot open files from within itself. I know this must somehow be a mistake on my part since how can Vim still be around with such a flaw??
Anyway I have searched for the last day or so with no solution.
I have tried:
:e .
And Vim helpfully tells me that: "." is a directory. I was under the impression that this command would open a file browser in current directory, but it doesn't.
Similarly I have attempted other commands:
:Ex
:Explore
:Sexplore
:Sex
:Vexplore
:Vex
:Hexplore
:Hex
I have tested these from How do you open a file from within Vim? but nothing suggested there works.
All of these produce: E492: Not an editor command: <insert any of the above commands here>.
I am left with the conclusion Vim can't open files unless Vim is called from the terminal and the file is passed as an argument or the files happen to be in the current directory (where ever that may be) and you know the file's name.
Can someone help? I would like to be able to open files in other directories and list them but for the life of me nothing is working despite every guide I have read saying it would.
Thanks.
At the request from Zaffy this question has been solved.
At Robby Cornelissen's prompting I checked the MX's Linux's package manager and found that vim-common was installed but weirdly not vim. Once I'd installed vim :e . worked and I can now navigate the filesystem.
I have no idea the difference between vim-common and vim or the reason for the separate packages; Robby Cornelissen suggests that vim-common is probably a minimal or tiny version of vim.

How do I get netrw (in Vim) to use the absolute path?

I've got Vim73 on Windows, and I'm trying to move files through the file browser.
It had been giving me an error about "move" not being executable (see this post). After some debugging I discovered the issue was in my vim73\autoload\netrw.vim file. I got the move command working, but there's another issue - apparently the directory that I'm browsing in with :Ex is not my current working directory, so the mv.exe command (from UnxUtils) can't find the source or destination.
The line from netrw that causes the problems is this one:
let ret= system(g:netrw_localmovecmd." ".shellescape(fname)." ".shellescape(s:netrwmftgt))
I tried wrapping the shellescape() functions in expand(), but that didn't seem to help.
Any idea how I can get the absolute path for the source and destinations?
Rather than trying for the absolute path, would setting g:netrw_keepdir to 0 work for you? It's not exactly what you want (which I suspect is to take the vim CWD and apply it to netrw instead of the other way 'round), but if you're OK with using netrw to manage your vim CWD, your commands might just work as-is.
Edit: Look at :help netrw-c for the verbose explanation. The c command in netrw might be enough.
Well, as it turns out, when your cursor is on the .. in the file list it considers that a directory.
All I really needed to do was move the cursor into the banner area before trying to mt - or mt from the parent directory.
Whoops!

Separate srcdir and objdir with vim and gcc

When I'm working in vim, my current working directory (./) contains all my source. I build in an objdir, let's call it ./builddir/. When I build from vim, using makeprg=make\ -C\ builddir, the compiler warnings and errors all have a prefix of ../, which means vim brings the cursor to a file which doesn't exist.
If I try a different tactic, launching vim from the objdir, then I can't do commands like gf or :e myfile.h simply.
Is there a middle ground where all of this will work, like giving vim a second directory to search from if it can't find files in the current working directory? Or maybe getting gcc to use a different prefix?
The most simple solution would be to filter make outputs with sed to replace the output pathnames. (I've implemented a very similar thing to convert cygwin pathnames into windows pathnames for the win32 flavour of vim).
Something like:
:let &makeprg .= '2>&1 | sed "s#^\.\./##g"'
(It may be \| and not |, I don't remember)

Resources