Pathogen not recognizing syntax files of bundles - macos

I'm trying to figure out how to get Syntax highlighting or getting the colorscheme in my .vimrc to work with my current VIM instance, version 7.4.335, installed via Homebrew. I used Pathogen to download a lot of plugins and I can tell it's working with a few of them, Syntastic and NERDTree for instance, but when I open say a GO file I don't get any syntax highlighting.
I'm fairly new to VIM and Pathogen but I'd prefer to stay with VIM over MacVim, I use it for quick scripting and prototyping and the speed of startup is the main reason I want to keep using it instead of waiting for a GUI to load. Here's what's in my .vimrc
set runtimepath+=~/.vim_runtime
set mouse=a
set term=xterm
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_confic.vim
source ~/.vim_runtime/vimrcs/extened.vim
try
source ~/.vim_runtime/my_configs.vim
catch
endtry
set nocompatible
call pathogen#infect()
syntax on
filetype plugin indent on
colorscheme solarized
let g:soloarized_termcolors=256
"ack
let g:ack_autofold_results = 1
"syntastic
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_error_symbol = "X"
let g:syntastic_style_error_symbol = ">"
let g:syntastic_warning_symbol = "1"
let g:syntastic_sytle_warning_symbol = ">"
I've checked these posts but they don't seem to quite fix my problem:
Why does Pathogen "magically" solve Vim syntax highlighting problems?
Vim: Can't get pathogen to load bundles
Vim Solarized Color scheme: Should I have to set `call pathogen#infect()` in my .vimrc to make the syntax highlighting work properly?
Syntax highlighting in terminal vim but not gVIM
Thanks in advance!

I don't think you used Pathogen to "download a lot of plugins".
Anyway…
set runtimepath+=~/.vim_runtime
That line is pointless: your plugins and colorschemes and whatnot are supposed to go into ~/.vim/ and nowhere else.
set term=xterm
That line is useless: Vim is smart enough to know by itself what terminal type it's executed in.
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_confic.vim
source ~/.vim_runtime/vimrcs/extened.vim
Again, put your stuff in ~/.vim/ and there's no point whatsoever to split your config like that, especially if you are a beginner. There's a typo on the 4th line, by the way.
Also, the whole point of the runtimepath… line at the top of your ~/.vimrc is to tell Vim where to search for vim scripts with the :runtime command so, even using :source, here, is wrong.
try
source ~/.vim_runtime/my_configs.vim
catch
endtry
You might as well try/catch the four others. Again, just put all that in your ~/.vimrc.
set nocompatible
nocompatible is set when Vim finds a ~/.vimrc file or a ~/.vim/vimrc file so that line is useless too.
call pathogen#infect()
That line should be execute pathogen#infect(), as per Pathogen's README.
colorscheme solarized
let g:soloarized_termcolors=256
The let… line acts as an option for that colorscheme, it should come before the colorscheme… line and… it has a typo.
Also, set term=xterm forces Vim to run in 8/16 colors while your solarized option tells solarized and Vim to assume 256 colors. Make up your mind.
Basically, your ~/.vimrc is a mess… let's clean it up, shall we?
execute pathogen#infect()
syntax on
filetype plugin indent on
set mouse=a
" here comes all the stuff from your other `vimrcs`
let g:solarized_termcolors=256
colorscheme solarized
let g:ack_autofold_results = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_error_symbol = "X"
let g:syntastic_style_error_symbol = ">"
let g:syntastic_warning_symbol = "1"
let g:syntastic_sytle_warning_symbol = ">"

So it's an issue with iTerm, syntax highlighting works perfectly fine through the regular terminal.
Thank you for the assistance. If I figure out how to get iTerm to work with VIM syntax highlighting I'll post it here.

Related

pathogen vim indent-guides not showing

I happened to already have pathogen installed and running with JSHint and Janus, which works just fine. However, when I try to use the plug-in vim-indent-guide, it does not show at all.
According to pathogen as well as the github for the vim indent guides, it would seem that the only really necessary step would be to clone the repository into my ~/.vim/bundles. I am aware that the .vim file of the add-on needs to be in a subdirectory called plugins, which I confirmed. My indent-guides are installed into ~/.vim/bundle/vim-indent-guides/plugin/indent_guides.vim. I also am using VIM 7.3 which should mean version is not a problem.
To test my theory that pathogen is working, I made a file that would clearly raise a JSHint error
Given that assumption was proven correct, I tested to see if the files were loading, using :scriptnames in the file I was editing. Sure enough, I see two files there matching the name
104: ~/.vim/bundle/vim-indent-guides/plugin/indent_guides.vim
105: ~/.vim/bundle/vim-indent-guides/autoload/indent_guides.vim
however, I see no visible results of tabs or spacing in any files.
Perhaps it is a display issue or Janus "overwriting" this add-on's settings, but to be honest, I'm stumped. Anyone have any ideas?
I don't have a colorscheme yet and this is what i've added to the .vimrc file after installation:
...
" Indent Guides Settings
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_guide_size = 1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
colorscheme default
...
Good Luck.
Check your $TERM variable by echo $TERM in bash. If TERM=xterm instead of TERM=xterm-256color, it only handle 8 colors (instead of 256) and the colors will not be displayed properly.
You may fix to the correct value by this line in ~/.profile:
export TERM=xterm-256color
By doing so, re-enter vim and type :set t_Co should show t_Co=256, which is correct.

Set up vim automatic coloring for FORTRAN

I cannot set the automatic coloring on vim for FORTRAN. I looked at the other thread on stackoverflow, and both of these lines in my .vimrc do not work:
syntax on
au BufNewFile,BufRead *.f08 set filetype=fortran
The "syntax on" does actually works, but just underlines some part of the code. I want to have the conventional FORTRAN colors.
Actually you were quite close to the solution. Adding the following lines to .vimrc works on my mac.
:syntax enable
:au BufNewFile,BufRead *.f08 set filetype=fortran
PS.: I'm using the Terminal.app. If you use another Termial, the problem might be caused due to the value of TERM. Typing
echo $TERM
should e.g. give xterm-color. Alternatively it might be VT100, which doesn't support colors. But you can easily change this by setting:
TERM=xterm-color
in your Terminal. This you can of course also add to your .bash_profile or .bashrc or whatever file which is read on start-up.

set gvim font in .vimrc file

I am using gVim 7.2 on Windows 7. I can set the gui font as Consolas 10 (font size) from the menu. I am trying to set this in .vimrc file like below:
set guifont=Consolas\ 10
But it doesn't work. Does anyone know how to set this?
I use the following (Uses Consolas size 11 on Windows, Menlo Regular size 14 on Mac OS X and Inconsolata size 12 everywhere else):
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
endif
Edit: And while you're at it, you could take a look at Coding Horror's Programming Fonts blog post.
Edit²: Added MacVim.
Try setting your font from the menu and then typing
:set guifont?
This should display to you the string that Vim has set this option to. You'll need to escape any spaces.
I am trying to set this in .vimrc file like below
For GUI specific settings use the .gvimrc instead of .vimrc, which on Windows is either $HOME\_gvimrc or $VIM\_gvimrc.
Check the :help .gvimrc for details. In essence, on start-up VIM reads the .vimrc. After that, if GUI is activated, it also reads the .gvimrc. IOW, all VIM general settings should be kept in .vimrc, all GUI specific things in .gvimrc. (But if you do no use console VIM then you can simply forget about the .vimrc.)
set guifont=Consolas\ 10
The syntax is wrong. After :set guifont=* you can always check the proper syntax for the font using :set guifont?. VIM Windows syntax is :set guifont=Consolas:h10. I do not see precise specification for that, though it is mentioned in the :help win32-faq.
Start a graphical vim session.
Do :e $MYGVIMRC Enter
Use the graphical font selection dialog to select a font.
Type :set guifont= Tab Enter.
Type G o to start a new line at the end of the file.
Type Ctrl+R followed by :.
The command in step 6 will insert the contents of the : special register
which contains the last ex-mode command used. Here that will be the command
from step 4, which has the properly formatted font name thanks to the tab
completion of the value previously set using the GUI dialog.
For Windows do the following:
Note down the font name and font size from the "Edit-Select Font..." menu of "gvim.exec".
Then do :e $MYGVIMRC
Search for "guifont" string and change it to
set guifont=<font name as noted>:h<font size>
Save the file and quit.
Next time when you execute gvim.exec, you will see the effect.
Although this is an old thread I thought that I would add a comment as I have come across it whilst trying to solve a similar issue; this might help anyone else who may find themselves here:
The backslash character is used to ignore the next character; once added to the font name in my gvimrc it worked; I am on a GNU/Linux machine which does not like spaces. I suspect that the initial post was an error due to the back slash being used on a windows machine.
In example:
:set guifont? ## From gvim command, would give the following:
set guifont=DejaVu Sans Mono for Powerline 11
Where as I needed to add this line to the gvimrc file for it to be read:
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11
When I try:
set guifont=Consolas:h16
I get: Warning: Font "Consolas" reports bad fixed pitch metrics
and the following is work, and don't show the waring.
autocmd vimenter * GuiFont! Consolas:h16
by the way, if you want to use the mouse wheel to control the font-size, then you can add:
function! AdjustFontSize(amount)
let s:font_size = s:font_size + a:amount
:execute "GuiFont! Consolas:h" . s:font_size
endfunction
noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
and if you want to pick the font, you can set
set guifont=*
will bring up a font requester, where you can pick the font you want.
I had to end up doing
:set guifont=Courier:h10:cANSI
Ubuntu 14.04 LTS
:/$ cd etc/vim/
:/etc/vim$ sudo gvim gvimrc
After if - endif block, type
set guifont=Neep\ 10
save the file (:wq!). Here "Neep" (your choice) is the font style and "10" is respect size of the font. Then build the font - cache again.
:/etc/vim$ fc-cache -f -v
Your desired font will set to gvim.

How can I activate Vim color schemes in OS X's Terminal?

I'm working with the Vim 7.2 that comes with Mac OS 10.6.1 (Leopard), using the Mac's "Terminal" app. I'd like to use a fancy color scheme. I did this...
:syntax on
Then this...
:colorscheme slate
:colorscheme elflord
:colorscheme desert
etc...
Syntax highlighting is working, but I'm finding that regardless of the scheme I choose, the only colors displayed are the basic Red, Blue, Cyan, Gray, etc.
Is there a way to get the Terminal app to display a larger collection of colors to allow some more subtle schemes?
Create a .vimrc file on your home ~/ folder and then edit it with vim ~/.vimrc. You can try adding syntax on inside ~/.vimrc file. The following command does that:
echo "syntax on" >> ~/.vimrc
It will highlight your code syntax on vim
You need to create file ~/.vimrc and add syntax on in that file
vi ~/.vimrc
syntax on
save the file
and run your vim
Add "syntax on" to the file /usr/share/vim/vimrc and you'll get highlighting in your files every time you edit one.
# vi /usr/share/vim/vimrc
Add this line at the end of the file:
syntax on
Now you'll get highlighting when you edit whatever's file.
The Terminal.app supports AFAIK only 16 colors; iTerm supports more colors or you use mvim (as suggested by Daniel).
You might want to consider using a version of Vim that is a native Mac app (that runs in a window).
MacVim has great color schemes and you can still launch it from Terminal like so:
$ mvim file.txt
That will open your file in a new Vim window.
#ashcatch - Can't leave a comment, but wanted to add that iTerm has other advantages over Terminal.app such as sensible copy and paste (configurable 'word' regex for easy double click selection of paths/urls, middle click paste) and terminal mouse support (:se mouse=a in vi to get mouse text selection, moving of window borders etc.)
I'd be lost without it.

How can I invoke VIM with C-X e for long, complex, tricky commands?

I found an awesome tip here. You can "[r]apidly invoke an editor to write a long, complex, or tricky command". However, when I press the key combination above, I get Emacs open. I would like to switch it to Vim. How can I invoke Vim with C-X e?
[1. Problem SOLVED by Brian Cambell]
export EDITOR=vim
Add to your .bashrc or appropriate shell rc file
[2. Problem SOLVED thanks to Pax]
I was unable to get the tricky command back to Bash. The errors were:
> Error detected while processing BufRead Auto commands for "*":
> E117: Unknown function: JumpToLastPosition
Quotes in .vimrc solved the second problem. I am still unsure about the part in my .vimrc:
" augroup misc
" autocmd!
" autocmd BufReadPost * call JumpToLastPosition()
" autocmd FileChangedShell * call WarningMsg("File changed outside of vim")
" augroup end
[3. Problem]
What do the above part in .vimrc do?
On most Linux installs (all the ones I tested), bash recognizes both the Emacs and Vi command history keys (or you can use "set -o vi" to force it).
So, you can just use the vi-mode "<ESC>v" to to enter visual mode, this will start editing in a Vim session.
To run the command, you just save and exit from Vim ("ZZ" or ":wq"). To cancel the command, you need to delete the contents, save and exit ("1GdGZZ").
In addition to running it by exiting, you can also save it while in the editor to another location (":w /tmp/myscript").
Keep in mind that visual mode will work with the currently selected line so you don't have to start with a blank command ("<ESC>v"). You can use the normal vi-mode tools to select a line from the history first and then enter visual mode ("<ESC>kv" for last command, "<ESC>/grep<ENTER>nnv" for third-last grep command and so on).
Using this method has the advantage of not changing the "EDITOR" variable which may be used for other things (unless you want Vim for everything, which is a very sensible position to take IMNSHO).
Update:
Regarding your error, posted after the question:
JumpToLastPosition() is the function called by Vim for all files to put the cursor where it was when you last edited the file. I'm going to assume you're actually getting this error when the editing starts, not when you exit, since this is the auto function following a buffer read.
Can you start a "normal" vim session ("vim xx.txt" and then "vim xx") without this error occurring? You may find you get the same problem (and possibly only on the last one).
If you do have the same problem, you need to look at your startup files. It's possible the autocmd for BufRead is broken somehow. Have a look inside your vimrc and you filetype.vim files to see where that function is called and/or defined (I suspect it's called but not defined and that may be a mismatch between the two files or one of them has been damaged).
export EDITOR=vim
Add to your .bashrc or appropriate shell rc file
The link that you provided contains the answer:
Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR.
You need to set the EDITOR environment variable (like #Brian Campbell)

Resources