Load the ftplugin folder via janus - vim

I posted an issue at github about this as well, but I figured this would also be a good spot to ask:
Does anyone know how to accomplish this functionality? I've been trying for the past couple of days to figure this out all to no avail aside from putting directly into my ~/.vim/ folder.
I'm trying to install the jslint ftplugin to give me error highlighting while eding javascript files. I have tried all the following combinations to try and get this ftplugin to work within the contexts of janus:
~/.janus/langs/javascript/ftplugin/jslint/
~/.janus/ftplugin/javascript/jslint/
~/.vim/janus/vim/langs/javascript/ftplugin/jslint/
~/.vim/janus/ftplugin/javascript/jslint/
All of those above fail to recognize this ftplugin. The only one that works is this:
~/.vim/ftplugin/javascript/jslint/
but that is not ideal since this is not core to janus. Any ideas on where this folder (or any other ftplugin folders for that matter) can be put so macvim to recognize this functionality?

The solution to this is to put it in
~/.janus/jslint/ftplugin/javascript/jslint.vim
Each folder inside the .janus should have the same file structure as a normal .vim folder. (So the ~/.janus/jslint folder is equivalent to .vim)
Note janus made this task really hard. Using plugin distributions like janus might lead to easy set up in the beginning but changing them or debugging them will be hard. You should set up your vim environment the way you want so that you know everything in it. This will lead to easier maintenance later on in life. And you will know how to use everything because everything was installed one at a time instead of all at once.

Related

Mulitple vimrc-files, multiple vim-directories.

I'm trying to get better with Vim at Ubuntu 14.04, but I struggle to understand it's structure. I've been Googling around for quite some time, but this questions I haven't gotten answered anywhere.
I'm trying to install some plugins and make a good .vimrc-file for myself, in the future. But when I have to install plugins, then the Readme-files tell me, to put the files in the 'plugin'-directory in the vim-folder. But I've discovered that I have two vim-folders:
- One in /etc/vim/
- and one in ~/.vim/
I tried putting the plugin in each folder, and it worked, in the latter one. But I don't understand why. Can anyone explain it?
And it's the same thing for the vimrc-file. If I run a :version in vim, then I get, that there's a vimrc-file here /etc/vim/vimrc and theres one here ~/.vimrc . Now - why is one hidden and one is not? I'm a Windows-kid originally, and if confuses me, because it looks like that the format is different, from one file to the next. But mainly; where is it good manners to insert the custom changes to the vimrc-file? For the system-vimrc file, or for the user I'm using?
Files and directories under /etc/vim/ make up Vim's system-wide runtime files.
You must never touch them.
because they will be overwritten next time you update Vim,
because messing with them puts Vim in an unstable state,
because you need to escalate privileges.
All your configuration must happen in your $HOME:
your settings/mappings go into ~/.vimrc,
your plugins and colorschemes and anything you download from third parties go into ~/.vim/.
That said, most (all?) plugins clearly use ~/.vim and ~/.vimrc or their $HOME variants in their install instructions. If they don't, complain to their author.

Which plugins make assumptions about current directory

I'm thinking about setting the following in vimrc
set autochdir
In vim.wikia.com it states that
...Unfortunately, when this option is set some plugins may not work
correctly if they make assumptions about the current directory....
Am I better just changing the working directory manually when required? Which plugins will not work properly when using autochdir?
I've been using :set autochdir since I've started with Vim in 2002, I use a lot of plugins, but I haven't experienced many problems. (And those problems were rather easy to fix; I think I've sent some such patches to plugin authors.)
In the end, it greatly depends on the individual plugins. Don't be afraid and just try it; it's trivial to switch back, anyway. Look out for problems with plugins that create new buffers or access / navigate to other buffers, especially when those are distributed over different directories. Problems ususally manifest themselves into the wrong buffer (or an empty one in the wrong directory) being opened.

How does vim-pathogen make anything easier?

If I understand it correctly, with pathogen it makes things easy because all you have to do to install/uninstall plugins is place or remove the plugin from a certain directory.
But isn't this what the plugin directory is for? How is it any better?
A plugin can be a single plugin_name.vim file that you toss into ~/.vim/plugin/. If every plugins were single files we wouldn't "need" any plugin management solutions.
But most plugins are actually collections of files that need to be placed in certain directories like ~/.vim/autoload/, ~/.vim/after/, ~/.vim/doc/ and so on. This has been considered "messy" for a while and Pathogen is one of many answers to this problem:
Vimball :help vimball
Vundle
VAM
VAM
Unbundle
possibly others…
If you don't think that it's a problem then you obviously don't need a solution (pathogen or whatever).
I think that it's a problem (I like my things well organized), Pathogen is the first solution I came across and it served me well.
It's better because you can store your plugin in isolation in the ~/.vim/bundle directory. That makes easier for you to have all your configuration directory under a version control system. Take a look at my vimfiles for example.
All the plugins I use are stored as a git submodule and this makes updates easy to handle. Furthermore, if you want to remove a plugin it's just a matter of removing the relative directory in the bundle one.

Create a "project" in VIM/MacVim/GVIM

I'm a VIM noob, and have revisited it time and again, and I'm hoping to actually stick with it this time. Primarily I'm programming in TextMate with Ruby on Rails. On advice from someone, I have installed Janus (https://github.com/carlhuda/janus) and its helping a lot. But one thing I miss is having a "project" so that I can easily get back into a project quickly.
I want to be able to start a copy of macvim, pointing it to a file, or giving it a command, to load a project back to where I last left it. This means:
CD to the root of the project
Set back up any tabs / splits I had set, at their same locations
Reopen the files I was working on last.
I'm going to explore Conque Shell today (http://code.google.com/p/conque/) and if that works, I would want those shells to also reload and fire off their startup commands. (CD to the project root, fire up the rails server, tail a log, etc.)
Suggestions? I'm looking to streamline my process so that I can just click a shortcut or run a command and after a few seconds be staring at my dev environment right where I left it last.
Bonus: I often use windows too, so being able to do the same in GVim would be great as well.
Thanks for your help
You may want to check out Vim's built-in ability to create a restore sessions. These allow you to save pretty much everything you have setup including cwd, folds, splits, buffers, vars etc. See :help :mksession.
Here are two plugins that help with saving and restoring sessions:
sessionman: http://www.vim.org/scripts/script.php?script_id=2010
session.vim: http://www.vim.org/scripts/script.php?script_id=3150
You might also want to check out the project plugin: http://www.vim.org/scripts/script.php?script_id=69
I too have heard good things about rails.vim.
For Rails developer, there is a well-known plugin by Tim Pope named rails.vim.
Once you are at the root of a rails project (You can change Vim current directory with :cd /path/to/project/root ), rails.vim provides quick way to access your file like :
:Rcontroller file
:Rview file
:Rstylesheet file
They are other options to refactor using partials. Install it and type :help rails.txt. There is plenty of nice features like that. It is really useful to speed up access to your project files.
You can probably combine it with session.vim which provides a way to restore your previous session automatically.
If you don't want to type the path of your project, one possible solution, is to add at the end of your .vimrc the following code :
if isdirectory("~/workspace/project1")
cd ~/workspace/project1
endif
This way you always start Vim into your current workspace. Obviously if you need to switch to another directory you have to manually edit your .vimrc... which is kinda sub optimal.
Terminitor (a Ruby Gem) won't specifically solve your vim "project" goal, but it will solve the rest of your problems. You can setup your terminal windows and then execute a command to capture the terminal positions and sizes, edit the configuration to add any other commands (in Ruby) that you want executed and this will allow you to restore your environment.

A few vim questions

So I was hoping that some old school Vim'ers could help me out. These are all separate questions and normally I would put them up each on their own but I'm not sure if that qualifies as question whoring here.
Plus I think if you know enough to be asking any of these questions they will all be coming up in the near future:
I have a library I'm writing and a series of applications that use that library. There doesn't seem to be an easy way(from what I can tell) to build a ctags file for the library and build one for each of my applications and make sure one references the other when I'm in vim.
Using gf to open files from command mode is awesome, but a lot of my include files
don't contain the full path. They refer to an include directory I set in the IDE. How can I set this directory as another point for Vim to start looking for files?
Is there a way to compile a file inside Vim and send the output to a buffer? I'm currently using MSVS 2k3 but I'll be porting over to Linux in a few weeks so if this is possible on either system I'd appreciate it.
Re 3)
If you put a makefile in your root dir, you can simply write
:make
This will run make and (iirc) put any errors into a seperate buffer, and make vim goto the first compile error. From there you can navigate all erroring lines using :next-error
Also, see this page
http://wiki.beyondunreal.com/Legacy:Vim
and
http://linux.byexamples.com/archives/287/perform-grep-and-make-in-vim/
for details on how to show the result in a seperate console.
1- tags files are independent, and can be used together. See :h 'tags'
I can't tell what is the easy way to build tags files. I have one that consists in using two plugins of mine:
one (draft) plugin that knows how to update C++ tags files (it should be easy to adapt it to other filetypes),
and another (local_vimrc) that helps me define directories-local .vimrc. Thus for any files within a given directory hierarchy, I can adapt the &tags options to use the relevant tag files, and the current tag file that will be rebuilt automatically (or when a keybinding is triggered). (Plugins like project should do the trick as well)
2- :h 'path'
3- :h :make
HTH.
2)
:cd {path}
For help:
:he cd
A few others like :lcd might be better suited. Just scroll down that help page.
This is rather off topic, but might still be useful: if you're using Visual Studio a lot and like Vim, you might want to look at ViEmu. It's the best Vim-emulation for any IDE I've yet seen, and the cost is really low. :) And no, I'm not getting a commission. :P
It's not obvious, but if you open a directory instead of a file, it's nicely browseable.
e.g.
:e . (colon-e-dot)
:e .. (colon-e-dot-dot)
will let you browse from your current directory or its parent.
(understanding that you were probably hoping for a capability to have vim accept e.g.
:e abc.txt
and have it look in several directories, which I don't know how to do.)

Resources