Vim plugin Align fails to work. Can it be installed without vimball? - vim

I've happily installed the vim Align plugin on my home computer, but on the Red Hat servers at work, the installation doesn't work. The servers at work have a very old copy (2006) of vimball, which from Googling I know doesn't support more recent vimballs, including Align. I can't get the systems group (IT department) to upgrade vimball, so I thought perhaps I could simply copy the various files into ~/.vim/plugin by hand. I copied the 3 files from my home system AlignMapsPlugin.vim AlignPlugin.vim cecutil.vim, but when I attempt to use Align from within vim I get the following error message
E117: Unknown function: Align#Align
I know that it's seeing the plugin, because when I remove the plugin the error message is different (it says "Not an editor command Align").
Is there a workaround for this? I love "Align" and would sure like to use it at work as well as at home.

{rtp}/plugin is not the only location where plugin files can be placed. The name of the function suggests that there is at least one file in {rtp}/autoload named Align.vim (autoloaded functions must have names looking like path#to#file#with#function#without#leading#autoload#function_name(), this example is for function located in {rtp}/autoload/path/to/file/with/function/without/leading/autoload.vim). But I strongly suggest that if #LucHermitte’s solution is not acceptable, you should use something that supports holding plugins in separate directories. If you used VAM all you needed to do (assuming that you have already installed align using VAM) is to look for files in ~/.vim/vim-addons/Align%294 and copy all of them.
Update: Forgot to say, you may try to install newer vimball plugin into your ~/.vim. In order to do this you need copy a file placed in /usr/share/vim/vim73/autoload/vimball.vim to ~/.vim/autoload (there is another related file, /usr/share/vim/vim73/plugin/vimballPlugin.vim, but it is not likely to be changed). No need to make IT department to upgrade anything, unless the newest version uses the newest vim features.

Install a recent (/the latest) vim in your $HOME. I've been doing this for ages now. It's the easiest way to get the job done (i.e. to have a proper environment).

Related

Do build tools for Vimscript exist?

I'd like to build a small set of vimscript libraries, however, it seems that the only way to use them would be to load them all globally into vim.
Furthermore, it means that if i wanted to share a single script that depends on those, i'd have to share to them all, which sounds tiresome.
What i was hoping for is some common.js and webpack style approach to vimscript,
does such a thing exist. Something that:
Resolves dependencies
Allows for vimscript files to be "bundled" together into one file.
Everything that i found, winds up being a plugin manager, rather than a plugin build tool.
Do such things exist?
The situation so far, up to Vim 8.
There is no script isolation. When a script is loaded, it's globally. The script can hide variables and functions, but that's all.
Sharing/exporting a function is quite easy: we drop it in an autoload plugin, and we just have to use that function named dirrelatativeto_rtp#subdir#suddir...#scriptname#funcname(). If the script scriptname.vim is installed in dirrelatativeto_rtp/subdir/subdir somewhere in a directory registered in 'runtimepath', it'll get loaded automatically.
Regarding commands, abbreviations, mappings... they are meant to be defined in plugin files, or ftplugin files -- other approaches are possible when we want submodes. Also we cannot use them naively from an autoload plugin or when a script is being loaded -- we'll have to explicitly use :runtime to load the script where this command/mapping/... is defined (as we'd do an import in Python).
Yet, like with Python, scripts aren't installed automagically on our system. It's still up to us to trigger manually the installation of scripts.
We can decide to have library plugins and other plugins that depend on these libraries. But, we need either to tell the end-user everything that must be installed manually, or kindly tell him/her to stop using a plugin manager that don't understand dependencies.
This has been a personal rant of mine for years, the trendy plugin managers don't understand dependencies. There are so far only two plugin managers that do so:
Vim-Addon-Manager (aka VAM): it relies on a central repository (vim-pi) to install a plugin (and its dependencies) with just its name (e.g. :InstallAddon fugitive, :InstallAddon lh-cpp). Unfortunately the central repository is no longer maintained and we can't register new names. Fortunately, we can always install anything with :InstallAddon github:{N}/{repo}. Other functions are available for installing from the .vimrc.
and vim-flavor which is written in ruby, and which install plugins as Vim 8 packages.
Both have their own syntax to declare dependencies. Unlike VAM, we can specify constraints on plugin versions with vim-flavor.
Last thing, if we don't want to distribute all files, we can organize them as several "plugins". But beware of cyclic dependencies. And be kind to end users that are using these trendy plugins managers that don't understand dependencies as they'll need to explicitly install many "plugins"
Starting from Vim 9
We can start to isolate imported plugins in the sense that two plugins can define a function or a command with a same name. Again, this feature seems to mimic Python way of doing things.
However, I expect global stuff like autocommands to continue to operate globally. For instance: I don't see how we could have two template expander plugins running concurrently.
Vim 9 new scripting language won't change anything to the installation of plugins we depend on.
Disclaimer: It has been almost 2 decades now that I've been maintaining my plugins as a bunch of interdependent plugins, organized around a few library plugins, as I don't like to duplicate a same thing several times. In my rant about dependencies & co, I explore quickly other alternative approaches available to us.
Back to the bundling/packaging question (EDIT)
We have ways to package files together.
We can always manually define plugins: put files together in a directory tree, play with git and so on.
We can define tarballs.
We can also define vimballs. Vimballs are a quite old solution for installable archives: files are put in their right directory and documentation tags are produced. There are ways to produce vimballs. I continue to maintain scripts that help producing them for all my plugins. But in all honesty, this is not what people expect to have nowadays to install plugins. I just keep them around in case I release new versions of my plugins on vim.org.
In any case, neither of these solutions end up defining one single file we put somewhere in our ~/.vim/ directory. And I think we will never have something like that because:
Isolation is not perfect. Even with Vim 9 new scripting language: I don't see how we could correctly handle duplication of autocommands. If a same file, that defines autocommands, is duplicated in different versions in several distributed "plugins" I don't see how Vim could handle that correctly.
Vim expects different files in different places: ftplugins, plugins (the original meaning in vim context, not the set of files that could be installed together), syntax files, fold plugins, indent plugins, colorschemes, langmaps, and so on. Vim architecture does not expect everything in a single file.
For these reasons, I cannot see how we could have build systems that build single files ready to be distributed. It could work in some cases (pure collections of functions and "classes"), but not in the general case.

How to setup with vim YCM

i want to move from using CMake to Premake for my current project, but im usig vim and the YCM plugin which is really great for making my setup like an IDE. However, the plugin needs compilation flags file which is produced when running CMake. Is there something for Premake to generate a file like that as well?
Premake does not do this in its current state (alpha 13). If you have some insights as to what is necessary for getting it to work, the best thing to do would be to submit a ticket in the issue tracker.
I'm afraid, if your new build system does not generate that compilation flags file (yet), you'll need to maintain your own (hand-crafted) one. You can find an example at https://github.com/Valloric/ycmd/blob/0e999dbee209ea79a522259816ce3a68b7d6cddc/examples/.ycm_extra_conf.py.
I would advice to have (at least) one per project rather than one generic one in your $HOME.
Although I have to admit, that it would be beneficial to get it created and in sync with the actual build system, I don't find it too troublesome to maintain it manually. At the end of the day it only contains the C++ standard you want to use, a set of preprocessor symbols and a set of both system and user include directories.

Move Emacs from Linux to Windows

I've had a break from programming the last two years and want to start up again. Right now I'm using a Windows computer, but my work and compiler is on my Linux computer.
My question is:
Is it possible to move my entire emacs work environment from Ubuntu to Windows 10? I did some changes in emacs back in the days that I got used to and would love to continue like that on my Windows computer.
Briefly...
The most important things to copy are your ~/.emacs.d directory and your init file (see C-hig (emacs)Init File for the different filenames this might have, or check with C-hv user-init-file).
See C-hig (emacs)Windows HOME regarding where the .emacs.d directory should live on your Windows system.
Note the comments in that Info node on the site-lisp directory as well, in case you've been using elisp libraries in there (possibly without realising), as they can form part of your Emacs configuration as well.
Any byte-compiled elisp (.elc files) should remain compatible so long as you're moving to an equal-or-newer version of Emacs (which sounds likely in this case). Natuarally things do change between releases, though, and it's possible to encounter incompatibilities when upgrading, but I wouldn't worry about that in advance -- try the latest version first, and if you run into problems that you can't solve (which shouldn't be very likely), you can always install the version of Emacs you were originally using.

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.

Load the ftplugin folder via janus

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.

Resources