vimrc not being respected in terminal vim - vim

some settings in the vimrc file i use are not being respected in terminal vim but when i use the gui mvim it works perfectly fine. I was wondering what I am doing wrong. I am also running iterm2 and using the same theme as being used in vim (Gotham). You can see the differences in the pictures I attach below.
Notice specifically the difference in colors, the gui version uses the correct colors.
terminal vim(incorrect version):
GUI version(correct colors):
here is the .vimrc I'm using
let g:startify_custom_header =
\ map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['','']
let g:startify_custom_footer = [
\ '',
\ ]
let &t_Co=256
let base16colorspace=256
syntax enable
if strftime("%H") < 16
set background=light
colorscheme solarized
else
set background=dark
colorscheme gotham256
endif
set ttyfast
set magic
set showmatch
set clipboard=unnamed
set autoread
set encoding=utf8
set paste
set ignorecase
set smartcase
set number
set numberwidth=6
set guifont=Sauce_Code_Pro_Plus_Nerd_File_Types:h15
set guioptions-=L
set guioptions-=r
set invlist
set listchars=tab:▸\ ,eol:¬,trail:⋅,extends:❯,precedes:❮
highlight SpecialKey ctermbg=none " make the highlighting of tabs less annoying
set showbreak=↪
set wrap "turn on line wrapping
set wrapmargin=8 " wrap lines when coming within n characters from side
set linebreak " set soft wrapping
set showbreak=… " show ellipsis at breaking
set autoindent " automatically set indent of new line
set smartindent
let g:NERDTreeQuitOnOpen=1
" remove some files by extension
let NERDTreeIgnore = ['\.js.map$']
" Toggle NERDTree
nmap <silent> <leader>k :NERDTreeToggle<cr>
" expand to the path of the file in the current buffer
nmap <silent> <leader>y :NERDTreeFind<cr>
set ts=2 sw=2 et
let g:indent_guides_start_level = 1
let g:indent_guides_auto_colors = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:webdevicons_enable_airline_statusline = 0
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
highlight SyntasticErrorSign ctermfg=red ctermbg=237
highlight SyntasticWarningSign ctermfg=yellow ctermbg=237
highlight SyntasticStyleErrorSign ctermfg=red ctermbg=237
highlight SyntasticStyleWarningSign ctermfg=yellow ctermbg=237
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/syntastic'
Plug 'bling/vim-airline'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'Valloric/YouCompleteMe'
Plug 'mhinz/vim-startify'
Plug 'scrooloose/nerdcommenter'
Plug 'chriskempson/base16-vim'
Plug 'tpope/vim-fugitive'
Plug 'altercation/vim-colors-solarized'
Plug 'whatyouhide/vim-gotham'
Plug 'benmills/vimux'
Plug 'ryanoasis/vim-devicons'
call plug#end()

Related

How to make gruvbox background black?

I spent around 2 hours to find and figure out why my background color is grey... Does anyone have a clue? Very frustrating
syntax on
set guicursor=
set relativenumber
"set nohlsearch
set hidden
set noerrorbells
set tabstop=2 softtabstop=2
set shiftwidth=2
set expandtab
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set termguicolors
set scrolloff=8
set noshowmode
set completeopt=menuone,noinsert,noselect
set cursorline
set cursorcolumn
set splitright
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=50
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
call plug#begin('~/.vim/plugged')
"Basic
Plug 'preservim/nerdtree'
Plug 'unkiwii/vim-nerdtree-sync'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar' "not working...
Plug 'vim-airline/vim-airline'
"Plug 'nathanaelkane/vim-indent-guides'
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter'
Plug 'blueyed/vim-diminactive'
Plug 'mattn/emmet-vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'stsewd/fzf-checkout.vim'
Plug 'mileszs/ack.vim'
"Color Scheme"
Plug 'gruvbox-community/gruvbox'
"Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'sheerun/vim-polyglot'
Plug 'colepeters/spacemacs-theme.vim'
"Plug 'sainnhe/gruvbox-material' "somehow this is laggy
"Plug 'phanviet/vim-monokai-pro'
Plug 'flazz/vim-colorschemes'
Plug 'chriskempson/base16-vim'
"lsp
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
"auto-complete"
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-lua/telescope.nvim'
Plug 'nvim-lua/diagnostic-nvim'
"auto-linting
Plug 'dense-analysis/ale'
"vim game
Plug 'ThePrimeagen/vim-be-good'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" automatically clear search highlights after you move your cursor
Plug 'haya14busa/is.vim'
call plug#end()
"let g:dracula_colorterm = 0
"colorscheme dracula
"set colorcolumn=80
colorscheme gruvbox
highlight Normal ctermbg=0
set termguicolors
"highlight Normal ctermbg=none
"highlight NonText ctermbg=none
"highlight Normal guibg=black guifg=white
set background=dark
"highlight Normal ctermfg=black ctermbg=black
"highlight Normal ctermfg=grey ctermbg=darkblue
let loaded_matchparen = 1
let mapleader = " "
let g:lsp_diagnostics_echo_cursor = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:fzf_layout = { 'window': { 'window': 0.8, 'height': 0.8 } }
let $FZF_DEFAULT_OPTS='--reverse'
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
lua require'nvim_lsp'.tsserver.setup{ on_attach=require'completion'.on_attach }
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
let g:ale_fixers = {
\'javascript': ['eslint'],
\'json': ['prettier'],
\'typescript': ['eslint'],
\'typescriptreact': ['eslint'],
\'markdown': ['prettier'],
\'css': ['stylelint'],
\'scss': ['stylelint']}
let g:ale_fix_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_enter = 0
let g:NERDTreeHighlightCursorline = 1
let g:NERDTreeShowHidden=1
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeQuitOnOpen=0
...
let g:gruvbox_contrast_dark = 'hard' fixed the issue.
Looks like contrast normal bg has grey color as a default.
Try:
set bg=dark
that should solve it.
To get the blackest black (hex color code #000000) go into the gruvbox.vim file (I use vim's native package manager so ~/.vim/pack/colorscheme/start/gruvbox/colors/gruvbox.vim), under "palate find the line:
let s:gb.dark0_hard =[#1d2021]
Change it to
let s:gb.dark0_hard =[#000000]
In your vimrc have the lines:
let g:gruvbox_contrast_dark='hard'
set background=dark
colorscheme gruvbox
hi Normal guibg=NONE ctermbg=NONE
Save, restart vim. Enjoy
(You can use the same process to customize any other color in gruvbox as well.

My Neovim LSP error message doesn't have a red color

My Neovim LSP error message doesn't have a red color:
Here is my vimrc file. I really don't know what the issue is.
syntax on
set guicursor=
set relativenumber
set noerrorbells
set tabstop=2 softtabstop=2
set shiftwidth=2
set expandtab
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set cursorline
set cursorcolumn
set updatetime=50
call plug#begin('~/.vim/plugged')
Plug 'gruvbox-community/gruvbox'
Plug 'preservim/nerdtree'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'vim-airline/vim-airline'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'airblade/vim-gitgutter'
Plug 'blueyed/vim-diminactive'
Plug 'mattn/emmet-vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'mileszs/ack.vim'
"Plug 'mxw/vim-jsx'
"Plug 'leafgarland/typescript-vim'
"Plug 'peitalin/vim-jsx-typescript'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
call plug#end()
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection='0'
colorscheme gruvbox
set background=dark
let loaded_matchparen = 1
let mapleader = " "
let g:airline#extensions#tabline#enabled = 1
let g:fzf_layout = { 'window': { 'window': 0.8, 'height': 0.8 } }
let $FZF_DEFAULT_OPTS='--reverse'
set completeopt=menuone,noinsert,noselect
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
lua require'nvim_lsp'.tsserver.setup{ on_attach=require'completion'.on_attach }
map <C-\> :NERDTreeToggle<CR>
map <C-/> :TagbarToggle<CR>
nnoremap <leader>h :wincmd h<CR>
let g:gitgutter_map_keys = 0
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
I am on Windows 10 and use the new Windows Terminal + NeoVim, my config is similar to yours with the same colorscheme. I fixed the color issue by adding this to my 'init.vim' file, before setting the colorscheme:
set termguicolors
The following options were recommended as a solution in different GitHub discussions, but they had no effect for me whatsoever:
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection='0'
set background=dark
To change the colors of diagnostic messages:
set termguicolors
hi DiagnosticError guifg=Red
hi DiagnosticWarn guifg=DarkOrange
hi DiagnosticInfo guifg=Blue
hi DiagnosticHint guifg=Green
Setting LspDiagnosticsVirtualTextError did not change colors in my case.
To see the highlights that you're currently using, run :hi. Since the list of highlights can be pretty long, you might want to open that list in a Vim buffer for easier searching and navigating:
:enew|pu=execute('hi')
See also this discussion on how to set LSP colors using Lua. The link was provided in a deleted answer to this question by user Marcel Arie.
For future reference, the old answers will probably fail, now there are more organized highlight groups for you to customize the colors of those, for example:
highlight LspDiagnosticsDefaultError guifg=#FF0000
For more detailed information read :help lsp-highlight-diagnostics and :help highlight.
Edit: Notice this needs to go after more general colorscheme settings such as colorscheme whatever that might overwrite your highlight
Here is the one that worked for me
hi LspDiagnosticsVirtualTextError guifg=Red ctermfg=Red
guifg is for GUI clients and ctermfg is for terminal clients
This should work for both terminal and gui clients
You can use
Plug 'folke/lsp-colors.nvim'
I removed "Plug 'leafgarland/typescript-vim' and it removed it fixed :D

Getting solarized theme working with vim + vim-airline-themes

I'm trying to get a vim-airline theme working with my vim, the theme I'm after is solarized dark.
The following is my .vimrc file:
# .vimrc
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
call vundle#begin()
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
<more plugins>
call vundle#end()
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'default'
let g:airline_theme='solarized'
let g:airline_solarized_bg='dark'
And the following is what my editor looks like currently:
What am I missing here?
I only have the following configs in my Vimfiles and airline theme follows the main theme:
set laststatus=2
let g:airline_powerline_fonts = 1

I want vim YouCompleteMe plugin to complete parenthesis

I installed YCM plugin. And I want YCM to complete left, right parenthesis.
I made a simple cpp source file. In main function, I declared
vector<int> v(10, 0);
when I pressed dot(.), vector member functions were shown.
member functions were shown
Then, I pressed downward arrow key and reached empty() function.
Everytime I press arrow key, YCM automatically complete function name. When I move recommendation menu, YCM ONLY complete function name. does not complete parenthesis. It is reasonable.
YCM complete function name
Finally, I pressed enter key(I chosed empty() function). However YCM did not complete parenthesis.
v.empty
So, I need to manually type left and right parenthesis.
I expected that when I pressed enter, YCM would complete parenthesis as well.
Is it possible to make YCM complete parenthesis?
below is my ~/.vimrc config.
let g:neocomplcache_enable_at_startup = 1
set completeopt-=preview
let g:ycm_add_preview_to_completeopt = 0
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')
Plugin 'delimitMate.vim'
Plugin 'VundleVim/Vundle.vim'
Plugin 'AutoComplPop'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tpope/vim-fugitive'
Plugin 'L9'
Plugin 'git://git.wincent.com/command-t.git'
call vundle#end() " required
filetype plugin indent on " required
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
"To avoid conflict snippets
let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_show_diagnostics_ui = 0
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_echo_current_diagnostic = 0
let g:ycm_collect_identifiers_from_tags_files = 1
set backspace=2
if has("syntax")
syntax on
endif
set nu
set nuw=9
set magic
set ls=2
set sc
set cursorline
"set autoindent
set ts=4
set shiftwidth=4
set laststatus=2
set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\
set hlsearch
set scrolloff=2
set showmatch
set showmode
set smarttab
set smartindent
set softtabstop=4
set tabstop=4
set ruler
set incsearch
set title
set wrap
set scrollbind
set background=dark
hi Comment term=bold cterm=bold ctermfg=green
syntax enable
" AutoComplPop customizing
function! InsertTabWrapper()
let col = col('.')-1
if !col||getline('.')[col-1]!~'\k'
return "\<TAB>"
else
if pumvisible()
return "\<C-N>"
else
return "\<C-N>\<C-P>"
end
endif
endfunction
" AutoComplPop end
inoremap <TAB> <c-r>=InsertTabWrapper()<cr>
hi Pmenu ctermbg=blue
hi PmenuSel ctermfg=yellow ctermbg=black
hi PmenuSbar ctermbg=red
"DelimitMate customizing
"BreakLine: Return TRUE if in the middle of {} or () in INSERT mode
fun BreakLine()
if (mode() == 'i')
return ((getline(".")[col(".")-2] == '{' && getline(".")[col(".")-1] == '}') ||
\(getline(".")[col(".")-2] == '(' && getline(".")[col(".")-1] == ')'))
else
return 0
endif
endfun
" Remap <Enter> to split the line and insert a new line in between if
" BreakLine return True
inoremap <expr> <CR> BreakLine() ? "<CR><ESC>O" : "<CR>"
"DelimitMate end

some vim airline themes doesn't work

I installed the vim-airlines and its themes with Vundle. I changed my .vimrc to the following format:
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('~/.vim/vundle_plugins')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" vim js plugin
Plugin 'pangloss/vim-javascript'
" auto complete
Plugin 'valloric/youcompleteme'
" file explorer
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-fugitive'
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Plugin 'vim-airline/vim-airline'
"
call vundle#end() " required
" nmap <F8> :TagbarToggle<CR>
let g:airline_theme= 'wombat'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
set laststatus=2
"set background=light
filetype plugin indent on " required
but nothing happens. I mean the following picture:
There is no theme change even after quitting the vim and reopening it. I installed both 'vim-airline' and vim-airline-theme today. So they are up to date.
Any comments is appreciated.
Update
I'm using 64bit Linux Mint 17
Vim version 7.4
Had the same problem.
Just add this line to your .bashrc/.zshrc file: export TERM=xterm-256color

Resources