pathogen vim indent-guides not showing - macos

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.

Related

Pathogen not recognizing syntax files of bundles

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.

How can I debug issues in VimL?

I'd like to know more about debugging in vim. What features does vim have that can help me to diagnose a problem I might have?
I'd basically like to know:
How can I diagnose a problem with my .vimrc and other configuration files?
What are some strategies to debugging a script in VimL?
How can I diagnose a problem with .vimrc and other configuration files?
If you're having some unexpected behavior in vim and you're not sure where the
problem is originating, there are a few approaches to honing in on the source
of the issue. One of the best first steps is to find out if your problem is
normal vim behavior, caused by a plugin or caused by your .vimrc.
If your vim instance is setting a particular 'option' and you're not sure
where it is being set. You can use the :verbose command to find out. For
instance
:verbose set nocompatible?
nocompatible
Last set from ~/.vimrc
To run an instance of vim without any plugins or configuration files run
vim -N -u NONE
I set this as to alias called cleanvim in my .bashrc file. The -u NONE is
what's doing the magic here. The -N simply puts vim into nocompatible mode,
which generally is desired. You can also use the option NORC to only exclude
your vimrc. Note that if you use something like pathogen or vundle to
instantiate your plugins from within your vimrc, then your plugins will also
not load properly.
If you are using a plugin manager like pathogen or vundle then excluding your
plugins is simple; just comment out the line in your .vimrc that calls
pathogen or vundle. However if you have other plugins loaded from your .vim
directory you can exclude them with the --noplugin flag.
If your problem is being caused by a plugin, try adding back plugins one by one
to determine which one is causing the issue. From there you can either report
the bug to the plugin's maintainer or try to diagnose the problem yourself
using the tips from the rest of this answer.
If your problem is caused by your .vimrc there are some ways to hone in on
the problem further. Once simple method is to add the finish command at some
point in your .vimrc. Once this command is encountered the script will stop
being sourced and no commands after it will be executed. In this way you can
exclude large portions of your .vimrc and try to find out the general region
where the problem is coming from.
What are some strategies to debugging a script in VimL?
Vim has a help section on this topic at :h debug-scripts. This describes
vim's debug mode in detail, which will allow you to set breakpoints and step
through a sourced file or user function. You can add a breakpoint on a specific
function or a specific line in a file. For instance...
" set a breakpoint on the function MyCoolFunc
:breakadd func MyCoolFunc
" set a breakpoint on line 43 of your .vimrc
:breakadd file 43 .vimrc
" set a breakpoint at this location
:breakadd here
After you set a breakpoint you can source the file again to begin debug mode at
that line. If you'd like to use debug mode on an entire file start vim with the
-D flag. You could also run debug mode on a particular command. For example,
say you're having trouble with a particular command :MyCommand. You can start
debugging mode on this command with :debug MyCommand.
Once debug mode has been started you can use the usual set of vim commands.
This is useful because you can now check the value of variables using the
echo command to try and diagnose an issue. You can also use the verbose
option to provide extra information about the following lines. See :h 'verbose'
for its options.
The scriptease is very helpful to debug vimL:
provide commands for easier insertion of Vim breakpoints
:Runtime allows easy reload of plugins, even unleting include guards
:Disarm {file}: attempt to disable a runtime file by removing its mappings, commands and autocmds
:Time {command}: profilling
:Verbose {command}: like :verbose, but capture the results to a file and load it in the preview window
For cases where you need to restart Vim several times (e.g.: incremental removal of plugins) the :RestartVim command of session plugin can be useful.
For vimL I find those 2 plugins awesome:
BreakPts
Set/View Vim breakpoints and browse functions visually
Decho
Better echo functionality suitable for debugging scripts
I also use this to quickly source the selected vimL lines:
fu! SourceRange() range
let tmpsofile = tempname()
call writefile(getline(a:firstline, a:lastline), l:tmpsofile)
execute "source " . l:tmpsofile
call delete(l:tmpsofile)
let n = a:lastline - a:firstline + 1
echo 'Sourced ' . n . ' line' . (n > 1 ? 's' : '')
endf
com! -range Source <line1>,<line2>call SourceRange()
nn gs m`:Source<cr>``
vn gs m`:Source<cr>``

zsh tab completion messes up command line formatting

I'm running zsh with oh-my-zsh on OS X. Every time I use zsh's awesome tab-completion, formatting on the current command line prompt gets really screwed up. For example:
I'll be typing cd fo and try to tab-complete for the 'foo' directory; zsh prompts for completion but changes the command line to cd fo cd fo while it's waiting for me to complete. It's not a big deal but very annoying. Any suggestions?
I had the same issue on PopOS and Arch linux. I tried a bunch of solutions from various places but the only solution that worked for me was this suggestion by romkatv on an issue on the oh-my-zsh github repository.
The solution is to make a copy of the .zsh-theme file of whatever theme you're using in oh-my-zsh and surround all non-ASCII characters (like emojis) with %{%G<CHARACTER>%}
For example, the default oh-my-zsh theme robbyrussel contains 2 non-ASCII characters. The '➜' character in the prompt
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
and the '✗' character in the prompt for git directories
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
Using %{%G<character>%} around the 2 non-ASCII characters like this
PROMPT="%(?:%{$fg_bold[green]%}%{%G➜%} :%{$fg_bold[red]%}%{%G➜%} )"
and this
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%{%G✗%}"
solved the issue for me.
I have faced the same problem before, my solution was disabling some zsh plugins. The second probability is that your colour theme may contain a bug which causing this.
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)
This is the final version of my plugin section in the ~/.zshrc file. Any other plugin between parenthesis may be the reason of your situation.
If your problem still continues you need to post your ~/.zshrc to let us check what is in there.
I had the same issue. Interestingly, I saw the problem only iterm2 while the prompt is correctly displayed in the standard terminal of OS X (after reverse-i-search/tab-completion). The reason seems to be that iterm2 defaults to Unicode (UTF-8) default encoding, which however is not correctly interpreted if the corresponding language variable is not set in the shell.
Solution: add the following to your .zshrc
export LC_ALL=en_US.UTF-8
The prompts will be displayed correctly.

Zsh tab completion duplicating command name

I'm on OS X Mountain Lion, running the included ZSH shell (4.3.11) with Oh-My-ZSH installed over the top.
When using tab completion with commands such as homebrew, when ZSH lists the available commands, it is also duplicating the command. For example:
$ brew {tab}
will result in:
$ brew brew
[list of homebrew commands]
I'm unsure what is causing this error, as when I resize the terminal window, the first instance of the command name disappears.
If I hit backspace when the duplicates are displayed, I can only delete the second instance of the command, zsh won't let me backspace any further. Also, if I do remove the duplicate with backspace, zsh then acts as if there is no command typed at all.
My .zshrc along with all my other .configuration files can be found at https://github.com/daviesjamie/dotfiles
UPDATE: I found this post about someone having the same problem on Ubuntu. However, I don't understand the given solution, and I'm not even sure if it applies to my set up?
This effect also could be reproduced if you use any of fancy UTF-8 characters like arrow, "git branch" character and so on.
Just remove this chars from prompt and duplication will not occur.
Also adding
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
to ~/.profile can help
The problem is likely to arise from misplaced %{ %} brackets that tell zsh that text inside has zero width. The only things that should be enclosed in them are escape sequences that change color or boldness of the text. If you are using new zsh (>=4.3.{unknown version}) I would even suggest to use %F{color}...%f, %K{color}...%k, %B...%b instead of %{${fg[green]}%} or what you have there.
The problem with them is that there is no way to query the terminal with a question like “Hey, I outputted some text. Where is the cursor now?” and zsh has to compute the length of its prompt by itself. When you type some text and ask zsh to complete zsh will say terminal to move cursor to specific location and type completed cmdline there. With misplaced %{%} brackets this specific location is wrong.
If you use iTerm on Mac, be sure to check "Set locale variables automatically" in your profile preferences. I had it unchecked for an SSH connection and it resulted in the same bug and I fixed it by leaving that option checked.
It's an old thread but I faced similar issue in my zsh setup with oh-my-zsh configuration.
Setting export LC_ALL=en_US.UTF-8 fixed the issue.
A lot of answers in a lot of places suggest the export LC_ALL=en_US.UTF-8 solution. This, however did not work for me. I continued to have this issue using oh-my-zsh on both Arch linux and PopOS.
The only solution that worked for me was this suggestion by romkatv on an issue on the oh-my-zsh github repository.
It turns out, at least in my case, that the autocomplete duplication issue would only show up if there was a non-ASCII character somewhere on the line (like an emoji). And ZSH would incorrectly assume that this non-ASCII character needs to take up 2 character spaces instead of 1.
So the solution that worked was to open up the .zsh-theme file of whatever theme you're using, find all non-ASCII characters and use %{%G%} to tell ZSH to only use one character width for that character
For example, the default oh-my-zsh theme robbyrussel contains 2 non-ASCII characters. The '➜' character in the prompt
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
and the '✗' character in the prompt for git directories
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
Using %{%G<character>%} around the 2 non-ASCII characters like this
PROMPT="%(?:%{$fg_bold[green]%}%{%G➜%} :%{$fg_bold[red]%}%{%G➜%} )"
and this
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%{%G✗%}"
is what finally fixed the issue for me.
So all you need to do is make a copy of the theme file you want to use and edit all the non-ASCII characters as shown above and you should hopefully never see the duplication issue again.
My solution to make both local and ssh work is something like a combination of #Marc's and #neotohin's answers:
Set export LANG=en_US.UTF-8 (simply uncomment that part in the template .zshrc; exporting LC_ALL, as in #neotohin's answer, instead of LANG may also work, I didn't try)
Uncheck "Set locale environment variables on startup" in the Terminal profile's "Advanced" section (reason: that setting sets LC_CTYPE=UTF-8 instead of en_US.UTF-8, which brakes the locale for me in ssh)

How to set my GVim to be feel like IDE?

Currently, I'm using GEdit as my text editor for editing Ruby and Javascript source codes. I would like to give GVim a try to be my editor choice. I have tried to follow https://github.com/akitaonrails/vimfiles and few others instructions, but I don't get any luck, when I source ~/.vimrc, then I always get:
bash: /home/samnang/.vimrc: line 5: syntax error near unexpected token ('
bash: /home/samnang/.vimrc: line 5:call pathogen#runtime_append_all_bundles()'
Could you point me somewhere to get the instruction or configuration?
Environment: Ubuntu 10.10
Edit: If I don't source it, when I type vim or gvim, then I got:
Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation fault
You need to run source ~/.vimrc as an Ex mode command. That is, inside Vim itself, hit : and enter the command:
:source ~/.vimrc
Right now, you're running Bash's source command, which is entirely not what you want to do.
~/.vimrc is the configuration file for vim, and will automatically be read by vim when it launches in order to know how you want it set up. You can add your non-graphical vim commands, such as key mappings, abbreviations to ~/.vimrc/. In ~/.gvimrc you can add commands to set your colorscheme, the default number of columns and rows displayed at startup, etc.
If you aren't familiar with vim itself type vimtutor at the command-line and go through the tutorial.
To start gvim, type gvim at the command-line. To edit a file you can either open gvim, then use :e file/to/load in comman-mode, or do gvim file/to/load at the command-line. gvim supports multiple windows and tabs as does vim, so study those things to make the most use of them.
You can also try integrating Vim with eclipse if you want to bring IDE functionality to Vim (like projects, error highlighting, code completion, etc).
If you're interested check out the eclim project. It supports most of the modern languages, including Ruby, and I highly recommend it.
Try adding a .vim or vimfiles in your $HOME directory. If it still fails, add a file to the .vim directory. I did a
cd
mkdir .vim
cd .vim
touch .netrwhist
chmod g+w .netrwhist
I discovered this while learning about building your own syntax files at vim wikia creating your own syntax files

Resources