Adding VIM plugins to Janus setup - ruby

I recently switched over to using Janus from a custom set of vim plugins and .vimrc. I'm really enjoying the setup, but one thing I'm missing is the automatic completion of blocks in Ruby.
For example, when I type:
def method <enter>
It would complete the block:
def method
# cursor here
end
I was using some of Tim Pope's plugins and can't recall which one provided the functionality (Rails maybe?) Is there a way to get this functionality using Janus? Is there a reason why someone wouldn't want this? It seems really convenient to have.

According to janus documentation documentation:
If you want to add additional Vim plugins you can do so by adding a ~/.janus.rake like so:
vim_plugin_task "zencoding", "git://github.com/mattn/zencoding-vim.git"
vim_plugin_task "minibufexpl", "git://github.com/fholgado/minibufexpl.vim.git"
ant then just run rake or run rake for the pluging you setup, on ~/.vim, for example:
rake zenconding

You're talking about endwise.
Presumably you could just add this repo to the Janus rakefile, however I've not tested. This is likely not included in Janus because this can pretty much be emulated with snipMate which is included in Janus.

The janus customization documentation currently reccommends using the ~/.janus directory for vim plugins.
You can use git clone to install vim plugins into the ~/.janus directory. E.g.
cd ~/.janus
git clone https://github.com/vim-scripts/Rename2.git rename2
The old method for customization, using rakefile is in a separate branch that is not maintained.

Related

Activate/deactivate conda virtualenvs on entering/leaving directories

pyenv-virtualenv offers a nice way of activating the environment on the very instant of entering or leaving the directory which contains a .python-version text file which specifies the environment to activate. It works for the directory it is in and all directories contained in it.
The environment is deactivated once we change the directory to something above it. This allows to easily switch between projects or analyses using different python versions (just by changing the directories).
Is there a way of achieving the same behaviour with (ana)conda?
Edit: added bash tag, because - as far as I understand - pyenv achieves this by hooking a custom script into .bashrc (which allows it to monitor the directory changes). If there is no build-in way in conda, how to create a script which would make it possible?
As mentioned in my comment, this is currently not supported. There is however an open issue on conda's GitHub asking for this feature.
In the meantime you could use autoenv, a small tool that'll automatically run the code in a .env file when entering a directory and that in a .env.leave when leaving the directory (supports bash/zsh and a couple others).
A simple example taken from their readme which illustrates the feature quite nicely:
$ echo "echo 'whoa'" > project/.env
$ cd project
whoa
To load a conda environment your .env would simply look like this:
conda activate <my_env>
Note 1: Check out the Configuration section of their GitHub readme before you start using it.
Note 2: The author of autoenv actually suggests trying direnv instead. However I've never used it, so I can't comment on it.
From autoenv's readme:
you should probably use direnv instead. Simply put, it is higher quality software. But, autoenv is still great, too. Maybe try both? :)

The 'gems' configuration option has been renamed to 'plugins'.?

When I use the latest jekyll and start its server, a certain warning below shows up:
$ jekyll serve Configuration file:
/Users/ishida/git/gipcompany.github.io/_config.yml
Deprecation: The 'gems' configuration option has been renamed to 'plugins'. Please update your config file accordingly.
I guess the following gems should be replaced with plugins, and then the warning won't show up, but I couldn't find any official documentation. Is my guess correct?
$ cat _config.yml
(omit)
gems:
- jekyll-feed
Your guess is correct, gems key is now plugins.
In jekyll/lib/jekyll/configuration.rb you can find:
def backwards_compatibilize
...
renamed_key "gems", "plugins", config
It is part of this Pull Request: plugins config key as replacement for gems (#5130)
And it was the result of this issue:
What do you think about renaming the gems config directive to plugins,
with full backwards compatibility?
The idea being, if you're not from the Ruby world, "gems" isn't a very
intuitive term (even though that's what they are). Further, users
shouldn't have to care about (or see) the behind-the-scenes plumbing,
in terms of how things are distributed.
Instead, let's call the key "plugins", a term which has a broader
understanding outside the Ruby ecosystem, and one that should be
familiar to any user coming from a more traditional CMS like WordPress
or Drupal.
In terms of practicality, it'd just be a matter of combining the gems
and plugins arrays, if they exist when we load the config, and
updating the docs in the next minor release.
You're right, in order to fix that, follow these steps:
Open your _config.yml file
Find the line beginning with gems:
Replace gems with plugins

How can I package Ruby code in an NPM package?

I'm writing a node module to be open sourced and there's a dependency on some Ruby code (see Can I include a Ruby Gem in a Node.js project? for details). I made a Ruby project that requires some gems and all of that works well. In my node_module, I want to interface it via exec to the Ruby code.
But now there's Ruby dependencies as well. So can I somehow specify the Ruby version, and the gemset required to run my node package?
Ambiguous question perhaps. I can clarify if anything is unclear.
I don't think you can/should specify the Ruby version to use when executing your code. That should be up the library consumer so choose. Since you want to execute your code with exec, the library consumer will have the added responsbility of making ruby accessible to the node process. How that happens is not up to you as the library developer.
As for dependencies/gemsets, just use bundler.
Maybe you could do something like this - without more information it's hard to say.
On the ruby side, build your gem to do whatever it needs to do and then add a rake task to it. How you build this rake task is obviously up to the demands of the project and how it will be used, but it will provide a way for you to interface from the outside.
In the 'middle' build a bash script that includes RVM - this way you can require a specific gemset/do specifc things before running the rake task. Another benefit is that if you want to change the gemset or other implementation details, you just change the bash script.
On the node side, call the bash script. More info on that in this answer.

Installing RSense for VIM

I am trying to install RSense for vim in fedora. I read this manual. I downloaded the tar ball of rsense and extracted it. Then I copied it to the root/opt directory as given on that page. Then I made a directory vim/plugin in the opt directory and copied the rsense.vim in the plugin directory. But when I write :RSenseVersion in the vim editor,I get a message that the command is not recognized.What have I missed ?
Till now I have not installed vim-ruby plugin as staged on the documentation page. What is this plugin meant for ? Can't RSense alone solve my purpose of writing a neat ruby code with auto-completion,code hinting ?
No, you didn't read the manual.
Once all the dependancies are dealt with you must put the plugin in ~/.vim/plugin.
As for the differences between vim-ruby and RSense, I don't do Ruby so I don't know for sure. Looking quickly at their doc, it looks like they are very different in scope and have slightly overlapping features. I'd install both: vim-ruby for all the low-level Vim tuning and RSense for its supposed code intelligence.
But I have a feeling none of them will help you write "neat" ruby code. Only your programing/ruby skills will.

Ruby support in vim

If I want to work with Ruby in Vim, how can I add Ruby support to it?
First of all, you would need a Vim version that is compiled with Ruby support enabled. You achieve this with:
./configure <the rest of your options> --enable-rubyinterp
on a Linux system, for example.
The next steps would be installing the plugins of your choice, you probably want NERDTree, snipMate, vim-ruby-debugger....
There are a lot of plugins to make your life easier, but there is always the option to run arbitrary shell commands from within Vim, no extra plugin needed:
!ruby /path/to/script.rb
This will execute script.rb and print the shell output directly in Vim itself.
I would visit https://github.com/ and put "ruby vim" into search box. You should find plenty interesting add-ons for vim this way.

Resources