Closed jumski closed 11 years ago
This problem is near and dear to me. First, a workaround:
autocmd User Rails exe 'source ' .
\ fnameescape(rails#app().path('config/myunsafecommands.vim'))
Basically, :sandbox source config/rails.vim
is a crude hammer to swing at the problem of allowing a safe way to provide per-project configuration. I don't think it's a good idea to drop the :sandbox
and allow arbitrary code to be executed.
I think probably the best solution is a new config file, config/vim.json
or some such (JSON because it's relatively easy to parse in Vim):
{
"navcommands": {
"jcollection": {
"path": "app/assets/javascripts/backbone/collections",
"glob": "**/*",
"suffix": ".js.coffee",
}
}
}
The navigation code is pretty old (it's still written with Vim 6 compatibility in mind, ugh), so I've been reticent to tackle this. But I want it just as bad as you do.
Okay, I made a first pass at this. Went with a dumb data structure inside of config/rails.vim
. Details are subject to change. Give it a spin!
Great!
Wanted to test it immediately, so I updated my rails-vim and put following into config/rails.vim
:
let b:rails_file_types = {
\ 'jmodel': {
\ 'prefix': ['app/assets/javascripts/backbone/models'],
\ 'suffix': '.js.coffee',
\ 'affinity': 'model'}}
It looks like it is not sourced, :Rjmodel
is not working and i cannot inspect this variable with let b:rails_file_types
First i thought maybe neo-bundle fucked something up and i do not have recent commits for vim-rails, but looking into :help rails
I have confirmed that i have recent version, so I assume problem is somewhere else.
Do you have any ideas? Thanks! Wojtek
Try with a fresh Vim instance.
On Sat, Jan 5, 2013 at 2:22 PM, Wojtek Majewski notifications@github.comwrote:
Great!
Wanted to test it immediately, so I updated my rails-vim and put following into config/rails.vim:
let b:rails_file_types = { \ 'jmodel': { \ 'prefix': ['app/assets/javascripts/backbone/models'], \ 'suffix': '.js.coffee', \ 'affinity': 'model'}}
It looks like it is not sourced, :Rjmodel is not working and i cannot inspect this variable with let b:rails_file_types
First i thought maybe neo-bundle fucked something up and i do not have recent commits for vim-rails, but looking into :help rails I have confirmed that i have recent version, so I assume problem is somewhere else.
Do you have any ideas? Thanks! Wojtek
— Reply to this email directly or view it on GitHubhttps://github.com/tpope/vim-rails/issues/195#issuecomment-11918366.
Oh, far more likely explanation. You need modelines enabled now. What does :verbose set modeline?
report.
That was a modeline thing.
Now everything works like a charm.
Thanks :)
Decided on a different approach: https://github.com/tpope/vim-rails/commit/8d10657107f56f19c9010cfb12c8705d101452e0
The config/rails.vim
way still works for now, but I'm probably going to yank it.
Aaaand renaming classifications to projections. I never liked classifications: It makes me think of OO classes.
im creating config/environment.rb and config/editor.json like crazy ;] using it for non-rails projects too
thanks:)
Yep, there's definitely another plugin hiding in all this, which is why I've started a very slow transition from :Rmodel
to :Emodel
, :RSmodel
to :Smodel
, and so on. No reason to use R
in a non-Rails app.
Annnd I've completely changed the format and file name. I'd appreciate it if you'd try migrating and let me know if you have any issues. You'll be a good test for if the docs are clear. It should be straightforward, if a bit tedious.
It's backwards compatible, so you don't have to switch all your projects at once.
Just migrated my main project's editor.json
.
It was not working when i renamed editor.json
to projections.json
(commands were not defined), but it works with old name (i've pull-rebased vim-rails of course:)).
One thing worth adding to docs is that all the projections-related stuff should go under root projections
key in the json, because now it is not clear enough for a newcomer and it must be guessed. I've found no other issues tho.
Migration seems to be pretty straightforward. This thing rocks and saves hundreds of keystrokes, What more can i say - I really enjoy it, thank you:)
It doesn't go under the projections key when you use projections.json
. Which is probably why it didn't work for you. :)
Haha. Confirmed :)
Hmpf, I'm having a similar problem whilst migrating from config/editor.json to config/projections.json
https://gist.github.com/74a1c50f75c34b27364a
Projections are just not loading - :cry: (I have a fresh install of vim via Homebrew and vim-rails@master)
Hey!
Syntax you have used is a vim lang - you can place it in your vimrc.
If you want to use config/projections.json
, use pure json object, not a vim variable
Hi!
I want to have project-specific navcommands (3 of last backbone-js projects i was working on have different convention for storing models/views/collections).
I have created config/rails.vim file and put some navcommand definitions there:
I've got this error while starting vim:
Do you know if it is possible at all? Where to look for solution?
Thanks in advance