Vim E854: path too long for completion - ruby-on-rails

I have a Rails RSpec file which looks something like
require 'spec_helper'
describe "Something" do
...
end
When I try to use Ctrl+N to autocomplete anything in that file, I get:
Text version:
Scanning included file: spec_helper.rb
E854: path too long for completion
Press ENTER or type command to continue
If I Ctrl+C this, it completes my word perfectly.
To avoid Vim to autocomplete by using included files I can do:
:set complete-=i
But that's not the root of the issue.
How can I fix this?

Ok,
It results that I am using MacVim, and like romainl commented in the original post, the issue is related to a bug in ruby.vim. In this Stack Overflow post the third answer candidate actually suggests a possible cause (correctly), which is related to a bug in ruby.vim ( an old version is using a deprecated function ).
MacVim (Snapshot 64) is supplied with the old rails.vim, so to fix this I went into MacVim.app/Contents/Resources/vim/runtime/ftplugin and did wget to the raw file in the official rails.vim plug-in repo
This fixed the issue for me.

Related

valid YAML hash

Every time I use a ruby involving command I get a line that goes like this:
"Failed to load /home/s/.gemrc because it doesn't contain valid YAML hash".
It doesn't cause any inconvenience, only appears after every ruby command.
Couldn't find any straightforward instructions on how to get rid of this so I thought I'd ask you
try the following:
rm -f /home/s/.gemrc
Edit
It would remove your file so make sure about the file content but this will solve your problem. or you may have a backup of it and try the solution.

Lua: require fails to find submodule, but searchpath succeeds?

usually when I have a question about something remotely software related I find that someone else has already asked the very same thing, and gotten good answers that works for me too.
This time, though, I've failed to find an answer to my predicament.
Here we go:
I'm currently trying to move up my Lua-programming a notch or three and want to use modules. So, I've got a structure like this:
main.lua
foo/bar.lua
Now, in main.lua I do
require("foo.bar")
which fails,
main.lua:1 module 'foo.bar' not found:
no field package.preload['foo.bar']
no file 'foo.bar.lua'
no file 'foo.bar.lua'
no file 'foo.lua'
Ok, something might be wrong with my package.path so I use package.searchpath("foo.bar", package.path) to see what I', doing wrong.
The problem is that package.searchpath resolves foo.bar to foo/bar.lua which is exactly right.
As I've understood it, package.searchpath tries to find the module in the same way as require, but there seems to be som glitch in my case.
What strikes me as odd is the repetition of the no file 'foo.bar.lua' in the error output
Have I misunderstood the use of require?
I'm using LuaJIT-2.0.0 to run my chunks
Update:
I'm using LuaJIT-2.0.0 to run my chunks <- This was the reason for my problem, stock Lua-5.2.2 behaves as expected
package.path = debug.getinfo(1,"S").source:match[[^#?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
require("foo.bar")
This line causes require to look in the same directory as the
current file when asked to load other files. If you want it to instead
search a directory relative to the current directory, insert the
relative path between " and ?.lua
Here is part of require description:
[...] Otherwise require searches for a Lua loader using the path stored in
package.path. If that also fails, it searches for a C loader using the
path stored in package.cpath. If that also fails, it tries an
all-in-one loader (see package.loaders).
Default path for package.path is always the .exe that executes specified script.

In rails.vim why do I get "E345 can't find file in path" errors?

I've been learning Ruby/Rails with vim. Tim Pope's rails.vim seems like a really good tool to traverse files with, but I keep getting these pesky "E345 can't find file in path" errors. I'm not vim expert yet, so the solution isn't obvious. Additionally, I've tried this and it doesn't apply to my problem.
As an example of the problem. I have a method format_name defined in app/helpers/application_helper.rb and it is used in app/helpers/messages_helper.rb. Within the latter file I put my cursor over the usage of format_name and then hit gf and I get that error. Similar disfunction with commands like ]f and [f
However, it works sometimes. I was able to gf from user to the app/models/user.rb
Ideas?
I think that is a limitation of rails.vim. It does not support “finding” bare methods. Supporting something like that would require one of the following:
an exhaustive search of all the source files for each “find” request
(which could be expensive with large projects),
“dumb” indexing of method names
(e.g. Exuberant Ctags and gControl-]; see :help g_CTRL-]), or
smart enough parsing of the code to make a good guess where the method might be defined
(which is hard to do properly).
If you know where the method is, you can extend many of the navigation commands with a method name:
:Rhelper application#format_name
But, you do not have to type all of that in. Assuming the cursor is on format_name you can probably just type:RhTabspaceappTab#Control-R Control-W (see :help c_CTRL-R_CTRL-W).

How to put capybara output html to a specific folder?

When I use the "Show me the page" step, with Capybara / Cucumber, can I control where the files get output? I can't seem to find the config for this, and my google fu is failing me.
Right now it appears that by default they go to the root of my rails folder and clutter up things there.
There is indeed a config option that allows you to specify where to output the files:
Capybara.save_and_open_page_path
I believe it was added in the latest version (0.3.9)
In your env.rb file you can do something like:
Capybara.save_and_open_page_path = '/Users/jsboulanger/my-rails-project/tmp'
In Capybara 2.10, Capybara::save_and_open_page= is deprecated. Instead, call Capybara::save_path=
Nice. Thanks for this.
To be really neat about it I added the config line to config/environments/test.rb, since you generally only use capybara in test, and that works fine.
Since there's a bunch of subfolders in tmp/ I used:
Capybara.save_and_open_page_path = 'tmp/capybara'
and created that folder.

How to debug broken vim completefunc in haml files?

I'm using rails.vim and I love how you can use ctrl-x ctrl-u in insert mode to autocomplete long method names like distance_of_time_in_words and accepts_nested_attributes_for. But for some reason it doesn't work in haml files and I can't seem to figure out what's wrong or how to fix it.
:help i_CTRL-X_CTRL-U says the autocompletion is using completefunc. The haml file says its completefunc=syntaxcomplete#Complete (and it's the same in erb and helper files where ctrl-x ctrl-u works fine.) I can't find where the syntaxcomplete#Complete magic is defined, but presumably it has something to do with the filetype syntax. My .vim/syntax/haml.vim comes from vim-haml, so I tried removing it but the problem persists.
Commenting out my entire .vimrc didn't help either. What else can I try?
UPDATE: I searched my vim config files and the only place that looks like it's doing anything with syntaxcomplete#Complete is in autoload/rails.vim and looks like this:
function! s:resetomnicomplete()
if exists("+completefunc") && &completefunc == 'syntaxcomplete#Complete'
if exists("g:loaded_syntax_completion")
" Ugly but necessary, until we have our own completion
unlet g:loaded_syntax_completion
silent! delfunction syntaxcomplete#Complete
endif
endif
endfunction
Functions with # in name are defined in autoload scripts:
A function that can be autoloaded has a name
like this:
:call filename#funcname()
When such a function is called, and it is not defined yet, Vim will search the
"autoload" directories in 'runtimepath' for a script file called
"filename.vim". For example "~/.vim/autoload/filename.vim".
See :help autoload.
Looks like the file you're looking for is part of vim:
$ find /usr/share/vim/ -iname "syntaxcomplete.vim"
/usr/share/vim/vim72/autoload/syntaxcomplete.vim
There's a vim.org page with the latest version of the script.
If you want to customize the completion, you can just write your own completion function. See :help complete-functions
You can also use Ctrl+n to use vim's simple completion. It completes with text from any of the open files, but can be customized. (See :help 'complete')

Resources