Synchronize vim settings across mac and Ubuntu server when using NeoBundle - linux

I want to synchronize the vim settings across my Mac and remote linux Ubuntu server. I am using NeoBundle for package management. I did the following:
On the Mac I installed NeoBundle and created a vimrc file in ~/.vim/. See below for the .vimrc file.
On the Mac I symlinked to this vimrc file using ln -s ~/.vim/vimrc ~/.vimrc
I entered .vim directory and made it into a git repository adding everything to the repository except .netrwhist and *.swp
Then I pushed this repository to bitbucket.
I logged into the server. Deleted .vim and .vimrc. Created a symlink ln -s ~/.vim/vimrc ~/.vimrc.
Then I created .vim on the server and ran git clone of the pushed repository. I see all the files on the server that I see on my mac.
The bundles are all in .vim/bundles. So they are available.
The Vim versions are different. Is that the problem?
On Mac it says:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)
whereas on the server it says:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Problem: Vim works great on the Mac. But on the server when I run vim I get the following error:
Error detected while processing /home/admin/.vimrc:
line 16:
E117: Unknown function: neobundle#begin
line 20:
E492: Not an editor command: NeoBundleFetch 'Shougo/neobundle.vim'
line 26:
E117: Unknown function: neobundle#end
line 33:
E492: Not an editor command: NeoBundleCheck
line 38:
E492: Not an editor command: NeoBundle 'scrooloose/nerdtree'
line 39:
E492: Not an editor command: NeoBundle 'terryma/vim-multiple-cursors'
line 40:
E492: Not an editor command: NeoBundle 'tomasr/molokai'
line 41:
E492: Not an editor command: NeoBundle '29decibel/codeschool-vim-theme'
line 42:
E492: Not an editor command: NeoBundle 'Lokaltog/vim-easymotion'
line 43:
E492: Not an editor command: NeoBundle 'jnurmine/Zenburn'
line 64:
E185: Cannot find color scheme 'zenburn'
The .vimrc contains:
"================================================================================
" NeoBundle settings (copied from NeoBundle github page)
"================================================================================
" Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"================================================================================
" Install these packages
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'tomasr/molokai'
NeoBundle '29decibel/codeschool-vim-theme'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'jnurmine/Zenburn'
"================================================================================
" Editor view settings
"================================================================================
syntax on
set number
" size of a hard tabstop
set tabstop=4
" size of an indent
set shiftwidth=4
" always use spaces instead of tab characters
set expandtab
set guifont=Monaco:h16
if has("gui_running")
colorscheme codeschool
else
colorscheme zenburn
endif
"=================================================================================
" Other settings
"=================================================================================
" Use Ctrl-s to save a file in insert mode.
inoremap <C-s> <C-c>:w<ENTER>
" make working directory same as the file being edited
" may interfere with some plugins (see here: http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file)
set autochdir

Even though this post is aging, as there is still no answers, I figured I might give my take on this issue. As I'm synchronizing my configuration directories across computers mixing OSX and Linux, I thought I'd share the way I've done it, for future reference, if you did solve your question.
First of all, I split my vim configuration in two directories:
~/.vim/ that contains the vimrc configuration file and neobundle, meant to be shared across all computers
~/.local/vim that contains the bundles, swap files and undo files.
Here's a tree of the first ~/.vim/:
$HOME/.vim
├── README.md
├── neobundle.vim
│   ├── LICENSE-MIT.txt
│   ├── Makefile
│ └── […] (all neobundle contents)
└── vimrc
First let's set up undofiles in the ~/.vim/vimrc file:
" undo file
set undofile
set undodir=~/.local/vim/undofiles
set undolevels=2000
set history=200
and swapfiles:
" swap files
set directory=~/.local/vim/swapfiles
so that they're not synchronized between computers and mess up with each others. No, you don't want the undo of computer A on computer B, and even worst, you don't want all your standard unix /home/foo/* mixed with the non-standard /Users/foo/*…
Then, in my ~/.vim/vimrc, I setup neobundle the following way:
" NeoBundle setup {{{
filetype off
set runtimepath+=~/.vim/neobundle.vim/
call neobundle#begin(expand('~/.local/vim/bundle'))
NeoBundleFetch 'Shougo/neobundle.vim'
" }}}
that's where the trick is: you set up the runtimepath to add the neobundle.vim addon bundle "manually" to the runtimepath of vim within ~/.vim, then you start neobundle by telling him where to find/install bundles. Following that in the vimrc file, you setup all your favorite bundles, and finally you end it with:
" NeoBundle Prologue {{{
call neobundle#end()
filetype plugin indent on " required!
NeoBundleCheck
" }}}
So, now, when I'm deploying vim on a new computer, all I have to do, is:
git clone https://github.com/guyzmo/vimrc ~/.vimrc
mkdir -p ~/.local/vim/bundle
mkdir ~/.local/vim/undofiles
mkdir ~/.local/vim/swapfiles
vim +NeoBundleInstall +qall
Finally, if that solution answers your question is that you keep in sync only the necessary static stuff (what plugins and what configuration), and generate all the dynamic stuff locally to each computer. So, you leave Neobundle do its job, cloning git repositories, compiling and installing files. For example, look at youcompleteme setup, where it is defined how to install it depending on the host you're running your vim on. And also, you'll never have any more git issues.
HTH

Related

Easy way to get syntax highlighting for Julia in Vim

I am trying to get Julia to have syntax highlighting in Vim. Unfortunately, at the moment, I there is no syntax highlighting (here is a small snippet of my code so you can see what it currently looks like). I tried installing julia-vim and putting it in the .vimrc file and installing it, but it doesn't actually change the highlighting. Below is the .vimrc file:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own
plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or
just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append
`!` to auto-approve removal
"
Plugin 'JuliaEditorSupport/julia-vim'
"
"
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
I'm also note sure how to fix it after reading the julia-vim documentation. Am I doing anything incorrectly, or is there another way to add some syntax highlighting to Julia?
I have seen from one of the answers to this question asked by #Thomas that it might be how I have set up my terminal, but I'd prefer to keep the terminal with the present color scheme if possible. See here for my current settings.
EDIT: Thanks to #axwr, I was able to get some syntax highlighting by putting
syntax on
at the end of the .vimrc file and then running
:so %
while editing the .vimrc file. However, as you can see here, the color coding seems to be less than ideal. Only certain packages come up as yellow, the majority is still green, and random things (usually numbers) come up as purple. Is this how julia-vim colors things, or am I doing something wrong?
Okay, so.
There are two steps to syntax highlighting in Vim; actually turning it on, and, having the ability to highlight the specific language you want to work in. For most languages vim can do this by default, however some languages, like Julia, require a little help. In this case you have done step two by using vundle to install a Julia plugin.
To acheive step one, you just need the line: syntax on in your vimrc file.
A minimal example vimrc for you, might look like:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'JuliaEditorSupport/julia-vim'
call vundle#end()
set nocompatible
set backspace=indent,eol,start
set number
set hidden
syntax on
filetype plugin indent on
Given the above settings, and a terminal that has the "solarised" colorscheme, a julia file looks like:
Here is the little fizzbuzz julia snippet so you can compare against your highlighting:
for i in 1:100
if i % 15 == 0
println("FizzBuzz")
elseif i % 3 == 0
println("Fizz")
elseif i % 5 == 0
println("Buzz")
else
println(i)
end
end
So, Step by step:
Add syntax on to your .vimrc
Add filetype plugin indent on to your .vimrc
Install the relevant plugin
Source your .vimrc or close vim.
open a file with the correct extension, i.e: test.jl

How to Keep Syntax Color but Disable Highlighting in Vim?

I recently activated auto-complete and syntax color in Vim. However, a red highlighting color appeared.
I tried to disable syntax color with syntax off, but this highlighting color is still there.
Here's my ~/.vimrc
syntax on
set nocompatible " be iMproved, required
filetype on " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'ycm-core/YouCompleteMe'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
:set number
It's hard to see my code with color highlights. I want to keep the syntax color, but without the highlighting. I couldn't find the setting in ~/.vimrc. How do I disable this ?
Apparently, this is from auto-completion. As mentioned in YouCompleteMe github about Diagnostic UI,
This turns on YCM's diagnostic display features including like the gutter signs, text highlighting, diagnostic echo and auto location list population. To disable this, I put :
let g:ycm_show_diagnostics_ui = 1
and the highlights are gone.
Have you tried googling first? Highlighting can be turned off easily with :noh, alternatively you can use :let #/="", as mentioned here, one of the first google search results... You can map these commands to some shortcuts in your .vimrc (I personally use ,/ combination to disable highlighting)
:noh command does not affect syntax colouring. Is this what you need?
EDIT:
I am sorry, I didn't see the pictures, as they are blocked on network I am currently connected to. This looks more like the syntax check. Try :set nospell instead :)

Moved .vimrc in a new dir, trying to get it to work

Disclaimer: I'm new to vim/tmux. I'm on a Mac using MacVim
I was told to use version control on my dotfiles.
Before my dot files were all placed in my root ~ like so:
~/
.vimrc
.tmux.conf
.vim
/bundle
/autoload
.viminfo
etc
But then I figured it would be a good idea to make a folder named "dotfiles", and house them all in there and then upload it to github so I can have them anywhere.
Like so:
~/
/dotfiles
.vimrc
.tmux.conf
.vim
/bundle
/autoload
.viminfo
etc
At first I thought everything was okay, becuase I never closed Vim, but when I reloaded it later, I realized none of my commands were working anymore. So I went in an changed some paths in my .vimrc and in my .tmux.conf in hopes that it would work again, but no luck.
Here is my full .vimrc:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/dotfiles/.vim/bundle/Vundle.vim
call vundle#begin()
" " alternatively, pass a path where Vundle should install plugins
" "call vundle#begin('~/some/path/here')
"
" " let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'christoomey/vim-tmux-navigator'
" " All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" " To ignore plugin indent changes, instead use:
" "filetype plugin on
" "
" " Brief help
" " :PluginList - lists configured plugins
" " :PluginInstall - installs plugins; append `!` to update or just
" :PluginUpdate
" " :PluginSearch foo - searches for foo; append `!` to refresh local cache
" " :PluginClean - confirms removal of unused plugins; append `!` to
" auto-approve removal
" "
" " see :h vundle for more details or wiki for FAQ
" " Put your non-Plugin stuff after this line
execute pathogen#infect()
syntax on
filetype plugin indent on
set mouse=a
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <c-/> :TmuxNavigatePrevious<cr>
let g:tmux_navigator_save_on_switch = 1
vnoremap <C-c> "*y
set runtimepath^=~/dotfiles/.vim/bundle/ctrlp.vim
As you can see, the paths have been corrected to incorporate the /dotfiles/ directory, yet anytime I try to run a plugin or something in my .vimrc, I get a generic 'Not an editor command' error.
Incidentally, tmux and all its configuration seems to be working fine after it being moved around.
Any Ideas?
I was told to use version control on my dotfiles.
Maybe you should turn to the people who told you to do that for support, don't you think?
Putting all your dotfiles in a single repo is not a requisite or even an objectively good idea. It could work for some people but only if you manage to point your programs to that centralized place (great) or if you symlink those files to their regular location (which kind of defeats the point). The people who told you to use version control on your dotfiles should have told you how to do that from start to finish.
Vim expects your vim directory and your vimrc to be in default locations:
~/.vim
~/.vimrc or ~/.vim/vimrc
It won't look elsewhere so you'll have to symlink them from your repo to their expected location:
$ ln -s /Users/username/dotfiles/.vim /Users/username/.vim
$ ln -s /Users/username/dotfiles/.vimrc /Users/username/.vimrc
This idea to put all of your dotfiles in a same directory is not bad as #romainl said in his answer you have to symlink them to their original place.
That's what I did so you may be interested in the script I created to automatically save the current dotfiles in my home directory and replace them with a simlink to the dotfiles in my repo. (You can also clone my repo, replace the dotfiles by yours and execute the script. I tried to make the readme as clear as possible but if you're interested in using my solution don't hesitate to message me for support)

Vim vundle colorschemes - vimrc

Hi I have been trying to configure vim on ubuntu.
All the packages seem to install fine. However if installing a colorscheme via vundle and then using colorscheme name it doesn't appear to find the scheme.
I have attempted to install railscasts, solarized and desert-warm but all have failed to load.
This is my .vimrc am I doing something wrong?
set nocompatible " be iMproved
filetype off " required!
colorscheme desert-warm
" next tab
map <F7> :tabn
" previous tab
map <F8> :tabp
" Close Tab abd save
map <F9> ZZ
" open and edit file
map <F6> :tabedit
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
Bundle 'desert-warm-256'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'https://github.com/vim-scripts/perl-support.vim.git'
Bundle 'https://github.com/Raimondi/delimitMate.git'
Bundle 'https://github.com/altercation/vim-colors-solarized.git'
Bundle 'https://github.com/jpo/vim-railscasts-theme.git'
" ...
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
Try moving the colorscheme call to the end of the file.
Also, the color scheme name from your example doesn't work for me—it should be colorscheme desert-warm-256. To see a list of color schemes currently installed, try entering :colorscheme <TAB> interactively.
I think the answer to this question is that there is no call vundle#end() or syntax on in the original poster's .vimrc.
Adding these two lines and for example the colorscheme solarized line anywhere after the call vundle#end() would have solved the issue.
colorscheme desert-warm must come after Bundle 'desert-warm-256' since it is the Bundle command that adds things to the path:
Bundle 'desert-warm-256'
colorscheme desert-warm
Source: same question on GitHub issue.
Note: Vundle has recently (2014-03-18) swapped to using Plugin instead of Bundle, so after you git pull it will be:
Plugin 'desert-warm-256'
colorscheme desert-warm
You should write your "colorsheme desert bla bla" line AFTER the Plugin line. Because Vundle first needs to install this color plugin, and after than it can use it. Sorry my tiresome English.

vim can't open syntax.vim

In my .vimrc I have the following snippet:
if has('autocmd')
filetype plugin indent on
syntax on
but when I start vim it shows the following error:
Can't open file /usr/share/vim/syntax/syntax.vim
error seems to have occurred on syntax on line in .vimrc.
I do not have syntax.vim in path /usr/share/vim/syntax though I have others like clojure.vim cpp.vim java.vim etc...
I searched but can't seem to find the default syntax.vim if it comes with default version of vim.
I've been stuck with this for a while and would like some help.
I use Arch and build vim from the AUR using the vim-git PKGBUILD. For me, it was the case of using vim-git, but vim-runtime from the official repos, not vim-runtime-git from the AUR.
Switching to vim-runtime-git solved this issue for me and provided the syntax file (and colours, and...).
It should be there so there may be other files missing. I would suggest you re-install!.
For a QDF here is what the
syntax.vim file should look like this:-
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last Change: 2001 Sep 04
" This file is used for ":syntax on".
" It installs the autocommands and starts highlighting for all buffers.
if !has("syntax")
finish
endif
" If Syntax highlighting appears to be on already, turn it off first, so that
" any leftovers are cleared.
if exists("syntax_on") || exists("syntax_manual")
so <sfile>:p:h/nosyntax.vim
endif
" Load the Syntax autocommands and set the default methods for highlighting.
runtime syntax/synload.vim
" Load the FileType autocommands if not done yet.
if exists("did_load_filetypes")
let s:did_ft = 1
else
filetype on
let s:did_ft = 0
endif
" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
au! FileType * exe "set syntax=" . expand("<amatch>")
augroup END
" Execute the syntax autocommands for the each buffer.
" If the filetype wasn't detected yet, do that now.
" Always do the syntaxset autocommands, for buffers where the 'filetype'
" already was set manually (e.g., help buffers).
doautoall syntaxset FileType
if !s:did_ft
doautoall filetypedetect BufRead
endif
I had this problem as well after upgrading to 7.3 (I'm using cygwin). Check whether running "vi" instead of "vim" has the same problem. I found that vim was actually the old 7.2 executable, but the syntax files were in the location expected by 7.3; vi was the correct 7.3 executable.
I have been using compiled vim from source without explicitly installing it on my system (due to missing sudo privileges).
I was able to solve the issue by adding the following line to my .bashrc:
export VIMRUNTIME=<path to cloned vim repo>/runtime
Thus: Pointing this env variable to the runtime director in the git tree, makes vim find the needed file(s).

Resources