[Nix-dev] Vim script: haskell-mode
Marc Weber
marco-oweber at gmx.de
Thu Mar 22 15:12:20 CET 2012
Hi Alexander Foremny,
> > vim -c "so % | qa" "$src"
What should it do?
so = source
% = current buf - which buf?
first, learn to listen. On irc I gave a tip:
lookup at vim-addon-manager which contains this code:
elseif s:EndsWith(a:archive, '.vba','.vmb')
" .vba reuse vimball#Vimball() function
exec 'sp '.fnameescape(a:archive)
call vimball#Vimball(1,a:targetDir)
" wipe out buffer
bw!
The sp is used so that the buffer can be wiped again - thus the user
doesn't see any change. In your case it doesn't matter.
>From this sample code you could have learned that you have to open the
vimball file first.
This works for you (you can skip the -V20 logging):
installPhase = ''
VIMDIR=$(ls ${vim}/share/vim)
export HOME=$TMP
ensureDir $out
yes | vim -V20$out/log -c "set nocp" -c "source \$VIMRUNTIME/plugin/vimballPlugin.vim | e 'vba-file' | UseVimball '$out/usr/share'<CR> " -c 'qa!'
# shorter, using autoload function
yes | vim -V20$out/log -c "set nocp" -c "e 'vba-file' | call vimball#Vimball(1,'$out/usr/share')" -c 'qa!'
'';
set nocp = set nocompatible mode.
I personally don't believe in this solution unless it covers *all* vim plugins.
This currently isn't that easy, see vim-addon-manager[-known-repositories].
which tries to be a repository of all known vim plugins. Its partially
generated by cron-jobs (sources from www.vim.org) - and partially
maintained manually (scm sources such as bzr,git,hg,svn, ..)
What would be required to package all vim plugins?
Create hashes of all plugins.
This solution immediately works for you, but doesn't use nix.
Its my personal favorite solution for managing vim plugins (I initiated
it). It gets the job done.
It allows you to copy paste this into your .vimrc and it'll checkout/
download/ vba unpack all plugins requested.
I've filled in your haskell-mode plugin. The docs for VAM tell you more
about it.
fun! SetupVAM()
let vam_install_path = expand('$HOME') . '/.vim/vim-addons'
exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager'
if !filereadable(vam_install_path.'/vim-addon-manager/.git/config') && 1 == confirm("git clone VAM into ".vam_install_path."?","&Y\n&N")
call confirm("Remind yourself that most plugins ship with documentation (README*, doc/*.txt). Its your first source of knowledge. If you can't find the info you're looking for in reasonable time ask maintainers to improve documentation")
exec '!p='.shellescape(vam_install_path).'; mkdir -p "$p" && cd "$p" && git clone --depth 1 git://github.com/MarcWeber/vim-addon-manager.git'
exec 'helptags '.fnameescape(vam_install_path.'/vim-addon-manager/doc')
endif
call vam#ActivateAddons(['haskell-mode'], {'auto_install' : 0})
endfun
call SetupVAM()
Marc Weber
More information about the nix-dev
mailing list