How to recognize javascript libraries/frameworks in Vim?
Asked Answered
J

1

8

I've switched from Textmate to Vim for about a year ago, so I've been immersed in books, screencasts and forums about Vim, and how people customize their .vimrc's.

I'm not a beginner anymore, however by no means I'm an advanced or intermediate user, I'm in the stage when I feel confortable using Vim in an efficient way.

Here is the question:

How can I get the vim statusbar to show me which Javascript library/framework is in use? Obviously the most popular like jQuery, Prototype, YUI2/3, Dojo, etc.

Maybe it is just a trivial thing and some people may think that by looking at the code, you may be able to find which library is being used. But for the same reason, people has git, hg, rvm, tags, cwd showing in their statusline, I want to see that in my statusline.

Jefferyjeffie answered 4/2, 2011 at 2:23 Comment(2)
Can you precise what you mean by "in use" ? For example for jquery, you want to display the label if you are editing a Jquery files or you want to display the label if you are opening a html file from a project including jquery.js ?Gabel
when using in a js file: $(#id) jquery, YUI({ filter: 'raw' }).use("node", function (Y) { YUI3, etc. Also omnicompletion and syntax highlighting will be nice as well.Jefferyjeffie
S
1

Basically, you need to write a vim script to do this and then put that in your .vimrc file.

If you have a vim containing Python or Ruby or PERL, then this is pretty straighforward, just look for a script tag with src=someframework and set the statusline.

But if you want a more general solution then you would need to learn the vim scripting language which is a bit of a chore. My suggestion would be to get a binary that includes a proper scripting language and roll your own solution.

Stellate answered 6/2, 2011 at 1:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.