How I Manage My Vim Plugins

Way before tools like Vundler and the like came out for vim, as a perpetual automation junkie, I was constantly refining my workbench when it came to how to manage my vim plugins. What started off as a basic script has turned into a tiny ruby configuration tool that I can use to manage the downloading of my vim plugins. As a play on the tool it is mimics, I’ve called in VRundler, and since it evolved (very slightly) from basic script I wrote, there is no coverage (gasp!). I’ve ran my current configuration script successfully on Windows, OSX, and Linux and it works great. I’m just throwing this out there to demonstrate how I manage one of my tools. I’m not remotely suggesting people use this in place of Vundle, this is just another example of a different style of automation. Here is my current configuration script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def windows?
  RUBY_PLATFORM =~ /(ming|cyg)/
end

bundles_folder = File.expand_path("~/repositories/developwithpassion/devtools/shared/dotfiles/vim/.vim_runtime/bundle")
open_source_folder = File.expand_path("~/repositories/open_source")

#A utility method I am using to build a qualified github user name that uses an ssh config host from my ssh configuration file
def github_user(name)
  "github:#{name}/"
end

# Specify the path where you want your bundles installed
bundles_dir bundles_folder

# A git group allows you to specify a git user you wish to clone vim plugins from
git github_user('vim-scripts') do
  # A bundle is a named vim plugin repo for the user, you can specify
  # multiple as the method accepts a splat of bundles, this is useful if you are
  # getting multiple plugins from a single author, you can also specify each plugin
  # with separate calls to: bundle '[PLUGIN]'
  bundle 'dbext.vim',
    'vimgrep.vim'
end

git github_user(:altercation) do
  bundle 'vim-colors-solarized'
end

git github_user(:benmills) do
  bundle 'vimux'
end

git github_user(:developwithpassion) do
  bundle 'TwitVim'
end

# A symlink bundle is just a vim plugin that is on your local file system somewhere 
# and you want it symlinked into your vim bundle folder, the first argument is 
# the name the symlink will be given in your plugin folder
symlink :dwp_vim_general, File.join(open_source_folder, 'dwp_vim_general')

git github_user(:ecomba) do
  bundle 'vim-ruby-refactoring'
end

git github_user(:elzr) do
  bundle 'vim-json'
end

git github_user(:ervandew) do
  bundle 'supertab'
end

git github_user(:OrangeT) do
  bundle 'vim-csharp'
end

git github_user(:nanotech) do
  bundle 'jellybeans.vim'
end

git github_user(:kana) do
  bundle 'vim-fakeclip'
end

git github_user(:kien) do
  bundle 'ctrlp.vim'
end

git github_user(:MarcWeber) do
  bundle 'vim-addon-mw-utils'
end

git github_user(:scrooloose) do
  bundle 'syntastic' ,
    'nerdtree'
end

git github_user(:jistr) do
  bundle 'vim-nerdtree-tabs'
end

git github_user(:sukima) do
  bundle 'xmledit'
end

git github_user(:timcharper) do
  bundle 'textile.vim'
end

git github_user(:thoughtbot) do
  bundle 'vim-rspec'
end

git github_user(:pangloss) do
  bundle 'vim-javascript'
end

git github_user(:SirVer) do
  bundle 'ultisnips'
end unless windows?

git github_user(:garbas) do
  bundle 'vim-snipmate'
end if windows?

git github_user(:tomtom) do
  bundle 'tcomment_vim',
    'tlib_vim'
end

git github_user(:tpope) do
  bundle 'vim-cucumber',
    'vim-endwise',
    'vim-fugitive',
    'vim-git',
    'vim-haml',
    'vim-markdown',
    'vim-rails',
    'vim-repeat',
    'vim-surround',
    'vim-vividchalk'
end

git github_user(:Lokaltog) do
  bundle 'vim-distinguished'
end

git github_user(:rizzatti) do
  bundle 'dash.vim'
end

git github_user(:Valloric) do
  unless windows?
    # This demonstrates configuring the bundle using a block, in this 
    # example I am chdir'ing into the bundle folder after it has downloaded
    # and running a system command to configure the plugin, in this case for 
    # YouCompleteMe it initializes its submodules and then installs 
    # the native extensions
    bundle 'YouCompleteMe' do |b, context|
      b.after_download do
        Dir.chdir(context.output_folder(b)) do
          system("git submodule update --init --recursive && ./install.sh")
        end
      end
    end
  end
  bundle 'MatchTagAlways'
end

git github_user('vim-ruby') do
  bundle 'vim-ruby'
end

git github_user('zweifisch') do
  bundle 'pipe2eval'
end

git github_user('hdima') do
  bundle 'python-syntax'
end

# A vimscripts group allows you to pull down individual script files from vimscripts.org
vimscripts do

  # when you define a group inside a vimscripts section, the first arugment specifies
  # what type of plugin the script is
  group :plugins do
    script 'IndexedSearch', 7062
    script 'autotag', 12473
    script 'DirDiff', 13435
  end

  group :syntax do
    script 'jquery', 12276
  end
end

# A vimzips group allows you to pull down individual zip files from vimscripts.org
vimzips do
  zip :vimgrep, 3407
  zip :bufexplorer, 20953
end

The above config file (which is just a ruby script) demonstrates all fo the main type of vim plugins:

  • Git based
  • Script based
  • Zip based
  • Symlinked from local machine

I should also mention, that I am using pathogen for plugin resolution, so this utility primarily just deals with the downloading of said plugins!

Develop With Passion®

Fixing SSL_connect Error With Ruby on Windows

Been a while since I’ve worked on a windows project!

Just needed to update some of my gems in an automation project and ran into the following error:

1
Gem::RemoteFetcher::FetchError: SSL_connect returned=1

I did not want to do the easy thing and update the Gemfile to use the unsecured gem location, so I used the following script which I ran inside of an msys shell:

1
2
3
4
5
6
mkdir /c/transient
cd /c/transient
curl http://curl.haxx.se/ca/cacert.pem -o cert.pem
SSL_CERT_FILE="cert.pem" gem update --system
cd ..
rm -rf transient

This script just simply downloads the latest SSL cert and updates the gem program. Once that was completed I uninstalled and installed the latest version of bunder and then was able to happily bundle install.

Develop With Passion®

Unix Based Development on Windows (Redux)

I wrote a post a couple of years ago on how to setup RVM in a cygwin environment on windows.

There have been quite a few people who have been able to follow this post successfully. There is an equally high number of people who were not able to get the setup working correctly. My current take is the following:

Don’t bother trying to do any unix style development under windows”

Please, do yourself a favour, install vagrant and setup a virtual machine for your project. Everyone on the team will be using the same machine setup, you won’t have to fight with annoying windows/unix based irregularities. And the tools that you are probably trying to develop with will more than likely just work the way you expect.

It’s been a number of years since I have been on a windows based project. And if I had to be on a windows based project again, it would more than likely be a C++, .Net or some other development environment that is a first class citizen under windows.

When I’m working on a unix based project, I’ll be working in a fully supported unix development environment, and based off of current history, with a vagrant backed vm that can be shared by the other team members.

My current dev setups are OSX/Unix based hosts, with Vagrant vms configured per project.

Develop With Passion®

Embrace the Time in the Valley

I’m sure lots of us have questioned the purpose for God allowing us to experience the deep valleys in our life. The knowledge that the purpose of the valley is sometimes necessary for the development/refinement/elimination of character or heart attributes, often does not make the walk through the valley any easier.

It’s also funny that often, when we are in the valley, we can reach out for God and sometimes get the “feeling” that He has abandoned us. I think, also, this period is for strengthening our resolve of “knowing” that He is there even when our emotions are trying to tell us otherwise. These periods can help transition our faith to something more than just fleeting/extended periods of emotional euphoria to something much deeper and rooted in something a lot more solid than our flimsy human emotions!

I was reading the Screwtape Letters earlier today and came across this fantastic excerpt that I wanted to share. As you read this keep in mind the fact that this is being written from the perspective of the demons!

Do not be deceived, Wormwood, Our cause is never more in danger that when a human, no longer desiring, but still indending, to do our Enemy’s will, looks round upon a universe from which every trace of Him seems to have vanished, and asks why he has been forsaken, and still obeys.

CS Lewis The Screwtape Letters

Develop With Passion®

Quickly Generate a README Under Every Direct Folder of a Folder

Quickly needed to generate a README.md under every folder of a folder that contains custom node packages

The output of the following command:

find
1
find . -type dir -depth 1

gives me this:

lang: Custom Node Modules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
./containers
./core_utils
./defining_classes
./delegation
./expect
./extensions
./fakes
./jspecs
./key_generator
./load_path
./logging
./matching
./namespace
./node_bootstrap
./resolution_root

.

I was getting tired of seeing missing readme warning when vagrant provisioning, so I wrote the following:

Generate Readme
1
2
3
4
5
6
for module in $(find . -type dir -depth 1 | sed "s/\.\///");
do
  pushd $module
  echo \#$module > README.md
  popd
done

I used sed to get rid of the the leading ./ so I can use the output for the title in the readme file.

That quickly generates a file called readme.md under each custom node package that is being maintained in the folder that I am in.

It’s good to break out the shell scripting foo every now and then!!

Develop With Passion®

SSL - Generating an Unencrypted Key and Csr for a Cert Request

Had to generate a new ssh key and cert request the other day for a dreamhost server. Accidentally made the mistake of putting a passphrase on the key, so my first request came back no good.

Here is the script that I used to generate a new private key and csr request to submit to the certificate authority:

1
openssl req -nodes --newkey rsa:2048 --keyout new_key.key -out new_csr.csr

The -nodes argument is what ensures that the new private key will remain unencrypted, which is essential if you are installing the certificate on a web server through some sort of admin interface, vs having access to the box yourself.

Develop With Passion®

Speak Life

Our message series for this year in Church is all about “Mountains will move”.

One of the aspects that our pastor has talked about in the last couple of weeks (event though I’ve missed quite a bit this year!) is speaking to our mountains.

Our words have power, God’s word says:

The tongue has the power of life and death, and those who love it will eat its fruit.

When we choose to use our words to speak life into people as opposed to tearing them down, we can literally transform a heart.

This song is an awesome song that reminds me of the impact that “Speaking Life” can have.

Develop With Passion®

Unix Tool 1 - Nohup

This post, along with many others to come is serving as a pointer to people that I have worked/will work with about lots of useful unix utilities. Where there is an existing good reference I will just post a link, otherwise I’ll write my own post. Current time demands warrant that I’m going to be link posting a lot!!

The tools are not mentioned in any particular order, so don’t place any significance on which order I choose to mention them.

I am of the opinion that every developer owes it to themselves to get a grounding in unix and its accompanying toolchain, though that’s a discussion for a whole other blog post!

Following posts will be absent of the prior blurb and just get right to the tool.

nohup

Used to keep background jobs running when you exit from a shell session.

Develop With Passion®