user defined command should be sourced every time at startup - neovim - vim

I'm using Neovim and have the following line in my .init.vim:
command! FZF FloatermNew fzf
It only takes effect if I source $MYVIMRC file every time at startup with :so $MYVIMRC command otherwise it doesn't work.
.init.vim
call plug#begin('~/.config/nvim/plugged')
" Plugins will go here in the middle."
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf.vim'
Plug 'voldikss/vim-floaterm'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'arcticicestudio/nord-vim'
Plug 'scrooloose/nerdtree'
Plug 'itchyny/lightline.vim'
Plug 'fatih/vim-go'
"Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clangd-completer' }
Plug 'Raimondi/delimitMate'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
call plug#end()
source $HOME/.config/nvim/plug-config/floaterm.vim
command! FZF FloatermNew fzf
" now commands are not case-sensitive and write them and hit the tab for
" completion
set ignorecase
"theme
colorscheme nord
set termguicolors
let g:lightline = {'colorscheme': 'deus'}
syntax on
if !exists("g:syntax_on")
syntax enable
endif
" Plugins settings
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
"Golang
let g:go_auto_type_info = 1
let g:go_gocode_unimported_packages = 1
set updatetime=100
let g:go_gopls_complete_unimported = 1
"set completeopt-=preview
"let g:ycm_autoclose_preview_window_after_completion = 1
" ######### Coc Configs #########
" ######### Airline Configs #########
let g:airline_theme='deus'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" ######### FZF Configs #########
"line number
set number
"Auto-save before make command
set autowrite
"Custom key maps
map <F4> :w<CR>:!make<CR>
"without defining run target in Makefile
"map <F4> :w<CR>:!make && make run<CR>
"How can I open a NERDTree automatically when vim starts up?
"autocmd vimenter * NERDTree
"How can I close vim if the only window left open is a NERDTree?
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"focus on right window instead of nerdtree
au VimEnter * wincmd l
map <C-f> :NERDTreeFocus<CR>
"remove tilde for empty lines.
set fcs=eob:\
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
"show a vertical line in the right side of page to indicate a limit for total characters in a line.
"set colorcolumn=110
"highlight ColorColumn ctermbg=darkgray
"Auto-completion
"let g:ycm_global_ycm_extra_conf = '~/Users/admin/.config/nvim/plugged/YouCompleteMe/.ycm_extra_conf.py'
"to improve source code navigation, add something like this to your nvim configuration:
"au FileType c,cpp nnoremap <buffer> <c-]> :YcmCompleter GoTo<CR>
"let g:ycm_server_keep_logfiles = 1
"let g:ycm_server_log_level = 'debug'
Thanks in advance!

There's something called in vim after-directory which is helpful for this situation where you put .vim files and pass the path to :runtimepath command.
I'm using neovim so after-directory in my workflow in a macOS system is like below:
~/.config/nvim/after/plugin/commands.vim
so I command! FZF FloatermNew fzf in that file and then give file path to the :runtimepath so this file will be sourced after all other :scriptnames files sourced.

Related

VIM LanguageClient and ALE interop/overlap

I'm a VIM user and recently started using Reason for React dev. I use ALE and LanguageClient for different languages, i.e.:
autozimu/LanguageClient-neovim
rust
ocaml
reason
w0rp/ale
python
javascript
reason
Note the overlap with Reason.
I seem to be in this weird place where I'm using half of the functionality of each. Specifically, ALE is running refmt for formatting code, but it's not performing linting. The LanguageClient is performing linting. I've confirmed this by commenting out refmt in ALE (breaks formatting) and commenting out the LanguageClient line for reason (breaks linting). I prefer ALE's linting over LanguageClient due to its use of quickfix (:lopen to see all the issues) and async error checking on leaving insert mode. I also seem to have redundant capabilities across both plugins right now, which just bugs my internal perfectionist.
Questions:
Is there any point in having both of these plugins, or is the functionality entirely duplicated between ALE and LanguageClient?
Why isn't linting working in ALE? Works in every other language, and OLS shows as a valid option in my :ALEInfo.
.vimrc...
Thoughts?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General NVIM
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("nvim")
let g:python_host_prog = '/Users/nathan/.pyenv/versions/neovim2/bin/python'
let g:python3_host_prog = '/Users/nathan/.pyenv/versions/neovim3/bin/python'
endif
if has("nvim") || (v:version > 8)
set termguicolors
set guicursor=a:blinkon0
endif
colorscheme dark
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off
call plug#begin('~/.vim/plugged')
" Linting
Plug 'w0rp/ale'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" Completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neco-syntax'
Plug 'wokalski/autocomplete-flow', { 'for': 'javascript' }
Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern', 'for': 'javascript' }
Plug 'Shougo/neosnippet'
Plug 'zchee/deoplete-jedi'
Plug 'Shougo/neosnippet-snippets'
" General
Plug 'chriskempson/base16-vim' "Color Scheme
Plug 'ctrlpvim/ctrlp.vim' "Fuzzy Find
Plug 'dkprice/vim-easygrep' "Instant grep across files
Plug 'easymotion/vim-easymotion' "Fast movement
Plug 'jeetsukumaran/vim-buffergator' "Buffer management
Plug 'jiangmiao/auto-pairs' "Close pairs
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } "NerdTree
Plug 'tpope/vim-commentary' "File-specific commenting
Plug 'tpope/vim-surround' "Handle surrounds
Plug 'vim-airline/vim-airline' "Airline bar
Plug 'vim-airline/vim-airline-themes' "Make airline pretty
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' "Fuzzy finder
" Plug 'vim-scripts/paredit.vim', {'for': 'clojure'} "Lisp balance
" Javascript - need to be in order
Plug 'pangloss/vim-javascript', {'for': ['javascript', 'reason']}
Plug 'reasonml-editor/vim-reason-plus', {'for': ['reason']}
Plug 'mxw/vim-jsx', {'for': ['javascript', 'reason']}
Plug 'alvan/vim-closetag', {'for': ['html', 'vue', 'javascript', 'reason']}
" Filetype Plugins
Plug 'fatih/vim-go', {'for': 'go'}
Plug 'hdima/python-syntax', {'for': 'python'}
Plug 'jparise/vim-graphql', {'for': 'graphql'}
Plug 'neovimhaskell/haskell-vim', {'for': 'haskell'}
Plug 'rust-lang/rust.vim', {'for': 'rust'}
" Plug 'derekwyatt/vim-scala', {'for': 'scala'}
" Plug 'elixir-lang/vim-elixir', {'for': 'elixir'}
" Plug 'keith/swift.vim', {'for': 'swift'}
" Plug 'udalov/kotlin-vim', {'for': 'kotlin'}
" Plug 'guns/vim-clojure-static', {'for': 'clojure'}
call plug#end()
filetype plugin indent on
syntax on
" END Plug
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent "Enable automatic indentation
set backspace=indent,eol,start "Adaptive backspace
set cb=unnamed "Use global clipboard
set cc=0 "Color column (off by default, 80 for python, etc)
set copyindent "Copy indentation
set expandtab "Use spaces for tabs
set hlsearch "Highlight search
set ignorecase "Case insensitive search
set laststatus=2 "Always show airline
set mouse=a "Respond to mouse
set noerrorbells "Don't beep
set nostartofline "Keep cursor in place when switching buffers
set novisualbell "No annoying flashing
set ruler "Adds line numbers and distance to airline
set shiftround "Tab half-indented to the next tabstop
set shiftwidth=2 "Default indentation
set shortmess+=c "Avoid unnecessary messages
set sidescrolloff=0 "Don't scroll horizontally
set smartcase "Use case in search if caps is used
set smarttab "Use semantic tabs
set softtabstop=2 "Pretend spaces are tabs
set t_vb= "Disable visual bell
set tabstop=2 "Default tab width
set vb "Disable visual bell
set wildignore=.DS_Store,node_modules,bower_components "Ignore for CtrlP
set wrap "Wrap long lines
set backupcopy=yes " Fix for bucklescript
" Fix some shiftwidths
autocmd Filetype haskell set shiftwidth=4
autocmd Filetype go set shiftwidth=4
"Variables
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ale (linting and error checking)
let g:ale_javascript_eslint_executable = 'eslint_d' "Faster implementation
let g:ale_lint_on_text_changed="normal" "Lint on normal mode
let g:ale_reason_ols_executable = '/usr/local/bin/reason-language-server'
let g:ale_linters = {
\ 'javascript': ['flow', 'eslint'],
\ 'python': ['pyflakes'],
\ 'reason': ['ols'],
\}
let g:ale_fixers = {
\ 'javascript': ['eslint', 'prettier'],
\ 'reason': ['refmt'],
\ 'python': ['autopep8'],
\}
let g:ale_fix_on_save = 1
" Airline
let g:airline_theme='bubblegum'
let g:airline#extensions#ale#enabled = 1
" Buffergator
let g:buffergator_display_regime = "parentdir"
let g:buffergator_expand_on_split = 0
" vim-javascript conceal
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_null = "ø"
let g:javascript_conceal_this = "#"
let g:javascript_conceal_return = "⇚"
let g:javascript_conceal_arrow_function = "⇒"
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.jsx,*.re,*.xml,*.vue"
let g:haskell_indent_in = 0
let g:NERDTreeQuitOnOpen = 1
let g:jsx_ext_required = 0
let g:javascript_plugin_flow = 1
" Match Tag Always (close HTML tags)
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'javascript' : 1,
\ 'reason' : 1,
\ 'javascript.jsx' : 1,
\}
let g:LanguageClient_serverCommands = {
\ 'ocaml': ['ocaml-language-server', '--stdio'],
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'reason': ['/usr/local/bin/reason-language-server'],
\ }
"'python': ['/usr/local/bin/pyls'],
"'javascript': ['javascript-typescript-stdio'],
" Use Platinum Searcher Grep, CtrlP, etc
if executable('pt')
" Use pt over grep
set grepprg=pt\ --nogroup\ --nocolor
" Use pt in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'pt %s -l --nocolor -g ""'
" pt is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Keyboard mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = "\<Space>"
nnoremap <Leader>[ :BuffergatorMruCyclePrev<CR>
nnoremap <Leader>] :BuffergatorMruCycleNext<CR>
nnoremap <Leader>b :BuffergatorOpen<CR>
nnoremap <Leader>c :ALEToggle<CR>
nnoremap <Leader>d :NERDTreeToggle<CR>
nnoremap <Leader>f :Grep<space>
nnoremap <Leader>g :CtrlPBuffer<CR>
nnoremap <Leader>h :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1"<CR>
nnoremap <Leader>j :ALENextWrap<CR>
nnoremap <Leader>k :ALEPreviousWrap<CR>
nnoremap <Leader>o :CtrlP<CR>
"nnoremap <Leader>p "+p
nnoremap <Leader>q :q<CR>
nnoremap <Leader>r :ALEFix<CR>
nnoremap <Leader>s :w<CR>
nnoremap <Leader>w <C-W><C-W>
"vnoremap <Leader>y "+y
imap jk <Esc>
" Language Client
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" Autocomplete
let g:deoplete#enable_at_startup = 1
let g:neosnippet#enable_completed_snippet = 1
inoremap <expr><Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Fixes
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" https://github.com/jiangmiao/auto-pairs/issues/187
autocmd VimEnter,BufEnter,BufWinEnter * silent! iunmap <buffer> <M-">
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"GUI stuffs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("gui_vimr")
nnoremap <D-S-}> :tabnext<CR>
nnoremap <D-S-{> :tabprevious<CR>
endif
Figured it out.
This line in my .vimrc wasn't working:
let g:ale_reason_ols_executable = '/usr/local/bin/reason-language-server'
ALE tacks on the --stdio option, which ocaml-language-server requires. This isn't accepted by reason-language-server. It's not just ignored, but the language server doesn't run at all. I was able to get it working by creating a shell script to call reason-language-server that ignored the extra parameter. Essentially this:
#!/bin/bash
reason-language-server
With that change, ALE now lints properly, and I've removed the extra LanguageClient plugin. To the best of my knowledge ALE interacting with the reason-language-server (or ocaml-language-server) and LanguageClient provide the exact same information. They both provide whatever the language-server tells them. I don't mean to misrepresent either project, but the detail and capabilities on both plugins seems to be identical--they're just provided through a slightly different UI. Once I move rust over to ALE, I should have the same UI, hotkeys, etc, across all languages.
On the off chance either developer ever sees this SO, both projects are fantastic, and I appreciate the effort in making VIM an effective, full-featured IDE.

E492: Not an editor command: NERDTree

When I run vim . to open up a folder I get the following error:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree .
Press ENTER or type command to continue
I don't understand where this is coming from since everything was working fine. I then tried adding other plugins and then the error was thrown. However I have NERDTree in my ~/.vimrc file. Here is what the file looks like.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:plug_shallow = 0 " disable shallow cloning
call plug#begin()
Plug 'airblade/vim-gitgutter' " shows a git diff in the gutter
Plug 'altercation/vim-colors-solarized' " precision colorscheme
Plug 'godlygeek/tabular' " text filtering and alignment
Plug 'janko-m/vim-test' " test runner
Plug 'phallstrom/vim-sailfish'
Plug 'scrooloose/nerdtree' " tree explorer
Plug 'sjl/gundo.vim' " graph your vim undo tree
Plug 'tpope/vim-commentary' " comment stuff out
Plug 'tpope/vim-endwise' " wisely add 'end' in ruby, endfunction/endif/more in vim script, etc
Plug 'tpope/vim-fugitive' " git wrapper
Plug 'tpope/vim-rails', { 'for': ['ruby'] } " ruby on rails power tools
Plug 'vim-ruby/vim-ruby', { 'for': ['ruby'] } " vim/ruby configuration
Plug 'tpope/vim-projectionist' " project configuration (file jumping)
Plug 'kana/vim-textobj-user' " create your own text objects
Plug 'nelstrom/vim-textobj-rubyblock' " custom text object for selecting ruby blocks
Plug 'tpope/vim-surround' " quoting/parenthesizing made simple
Plug 'chriskempson/base16-vim' " color schemes, https://chriskempson.github.io/base16/
Plug 'w0rp/ale' " asynchronous lint engine
Plug 'editorconfig/editorconfig-vim' " editorConfig plugin
Plug 'vim-airline/vim-airline' " status/tabline
Plug 'vim-airline/vim-airline-themes' " status/tabline themes
Plug 'pangloss/vim-javascript' " Javascript syntax
Plug 'mxw/vim-jsx' " react jsx syntax
Plug 'posva/vim-vue', { 'for': ['vue'] } " Vue.js syntax
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' " A command-line fuzzy finder written in Go
Plug 'kien/rainbow_parentheses.vim', { 'for': ['clojure'] } " Better Rainbow Parentheses
Plug 'guns/vim-clojure-static', { 'for': ['clojure'] } " Meikel Brandmeyer's excellent Clojure runtime files
Plug 'tpope/vim-unimpaired' " pairs of handy bracket mappings
Plug 'tpope/vim-abolish' " easily search for, substitute, and abbreviate multiple variants of a word
Plug 'mechatroner/rainbow_csv' " highlighting columns in csv/tsv files
Plug 'slim-template/vim-slim' " slim syntax highlighting for vim
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256
set nocompatible " We're running Vim, not Vi!
set synmaxcol=500 " don't try to highlight long lines
compiler ruby " Enable compiler support for ruby
filetype plugin on
set background=dark
colorscheme default
set backspace=2
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set nowrap
set nrformats=
set backupdir=$HOME/.vimbackup,.
set directory=$HOME/.vimswap,.
au FocusLost * :wa
set ignorecase
set smartcase
set scrolloff=2
set ttyfast
set hidden
set wildmenu
set wildmode=list:longest
nnoremap <leader>nt :NERDTreeToggle<enter>
source $VIMRUNTIME/macros/matchit.vim
" fzf
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>b :Buffers<CR>
" https://github.com/tpope/vim-commentary/commit/4dcfc318e0b02fdbb0c2d9ff77cf3562b46eea25
xmap \\ <Plug>Commentary
nmap \\ <Plug>Commentary
set updatetime=250
nmap <silent> <leader>s :TestNearest<CR>
nmap <silent> <leader>t :TestFile<CR>
nmap <silent> <leader>T :TestSuite<CR>
set mouse=a
vnoremap <Leader>c "*y
noremap <Leader>v "*p
set nofixeol
set formatoptions+=j " Delete comment character when joining commented lines
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" | endif
let g:omni_sql_no_default_maps = 1 " disable SQL autocompletion entirely
" To ensure that EditorConfig plugin works well with Tim Pope's fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" ALE - Asynchronous Lint Engine
let g:ale_lint_on_enter = 0 " no checks on open
let g:ale_lint_on_save = 1 " check on save
let g:ale_lint_on_text_changed = 1 " check on text change
let g:ale_lint_delay = 300 " millisecond delay before checking
" Airline
let g:airline_theme = 'base16' " theme
set laststatus=2 " always show airline
set noshowmode " hide default mode indicator
let g:airline_powerline_fonts = 1 " use powerline font
let g:airline#extensions#wordcount#enabled = 0 " disable word counting
let g:airline#extensions#whitespace#enabled = 0 " disable detection of whitespace errors
" Rubocop
let g:vimrubocop_config = '/path/to/rubocop.yml'
if filereadable($HOME."/.vimrc_local")
source $HOME/.vimrc_local
endif
let g:jsx_ext_required = 0 " JSX syntax in .js files
" open file splits in vsplit by default
:nnoremap <C-W>f :vertical wincmd f<CR>
" https://github.com/posva/vim-vue#how-can-i-use-existing-configurationplugins-in-vue-files
" autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
au FileType clojure exe "RainbowParenthesesLoadRound" | RainbowParenthesesActivate
" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" https://github.com/slim-template/vim-slim/issues/38#issuecomment-23760100
autocmd BufNewFile,BufRead *.slim setlocal filetype=slim
I re-installed NERDTree but however I still that error.

.vimrc: line 4: syntax error near unexpected token `(' [duplicate]

This question already has answers here:
error while running "source .vimrc"
(2 answers)
Closed 4 years ago.
I'm trying to configured Vim. However when I try to source .vimrc after having edit the file I get the following error:
$ source ~/.vimrc
-bash: let g:plug_shallow = 0 : command not found
-bash: /Users/stevenaguilar/.vimrc: line 4: syntax error near unexpected token ('
-bash: /Users/stevenaguilar/.vimrc: line 4:call plug#begin()'
I don't understand where is this error coming from. It throws the error on line call plug#begin() which is closed. Here is the full .vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:plug_shallow = 0 " disable shallow cloning
call plug#begin()
Plug 'airblade/vim-gitgutter' " shows a git diff in the gutter
Plug 'altercation/vim-colors-solarized' " precision colorscheme
Plug 'godlygeek/tabular' " text filtering and alignment
Plug 'janko-m/vim-test' " test runner
Plug 'phallstrom/vim-sailfish'
Plug 'scrooloose/nerdtree' " tree explorer
Plug 'sjl/gundo.vim' " graph your vim undo tree
Plug 'tpope/vim-commentary' " comment stuff out
Plug 'tpope/vim-endwise' " wisely add 'end' in ruby, endfunction/endif/more in vim script, etc
Plug 'tpope/vim-fugitive' " git wrapper
Plug 'tpope/vim-rails', { 'for': ['ruby'] } " ruby on rails power tools
Plug 'vim-ruby/vim-ruby', { 'for': ['ruby'] } " vim/ruby configuration
Plug 'tpope/vim-projectionist' " project configuration (file jumping)
Plug 'kana/vim-textobj-user' " create your own text objects
Plug 'nelstrom/vim-textobj-rubyblock' " custom text object for selecting ruby blocks
Plug 'tpope/vim-surround' " quoting/parenthesizing made simple
Plug 'chriskempson/base16-vim' " color schemes, https://chriskempson.github.io/base16/
Plug 'w0rp/ale' " asynchronous lint engine
Plug 'editorconfig/editorconfig-vim' " editorConfig plugin
Plug 'vim-airline/vim-airline' " status/tabline
Plug 'vim-airline/vim-airline-themes' " status/tabline themes
Plug 'pangloss/vim-javascript' " Javascript syntax
Plug 'mxw/vim-jsx' " react jsx syntax
Plug 'posva/vim-vue', { 'for': ['vue'] } " Vue.js syntax
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' " A command-line fuzzy finder written in Go
Plug 'kien/rainbow_parentheses.vim', { 'for': ['clojure'] } " Better Rainbow Parentheses
Plug 'guns/vim-clojure-static', { 'for': ['clojure'] } " Meikel Brandmeyer's excellent Clojure runtime files
Plug 'tpope/vim-unimpaired' " pairs of handy bracket mappings
Plug 'tpope/vim-abolish' " easily search for, substitute, and abbreviate multiple variants of a word
Plug 'mechatroner/rainbow_csv' " highlighting columns in csv/tsv files
Plug 'slim-template/vim-slim' " slim syntax highlighting for vim
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256
set nocompatible " We're running Vim, not Vi!
set synmaxcol=500 " don't try to highlight long lines
compiler ruby " Enable compiler support for ruby
filetype plugin on
set background=dark
colorscheme base16-oceanicnext
set backspace=2
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set nowrap
set nrformats=
set backupdir=$HOME/.vimbackup,.
set directory=$HOME/.vimswap,.
au FocusLost * :wa
set ignorecase
set smartcase
set scrolloff=2
set ttyfast
set hidden
set wildmenu
set wildmode=list:longest
nnoremap <leader>nt :NERDTreeToggle<enter>
source $VIMRUNTIME/macros/matchit.vim
" fzf
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>b :Buffers<CR>
" https://github.com/tpope/vim-commentary/commit/4dcfc318e0b02fdbb0c2d9ff77cf3562b46eea25
xmap \\ <Plug>Commentary
nmap \\ <Plug>Commentary
set updatetime=250
nmap <silent> <leader>s :TestNearest<CR>
nmap <silent> <leader>t :TestFile<CR>
nmap <silent> <leader>T :TestSuite<CR>
set mouse=a
vnoremap <Leader>c "*y
noremap <Leader>v "*p
set nofixeol
set formatoptions+=j " Delete comment character when joining commented lines
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" | endif
let g:omni_sql_no_default_maps = 1 " disable SQL autocompletion entirely
" To ensure that EditorConfig plugin works well with Tim Pope's fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" ALE - Asynchronous Lint Engine
let g:ale_lint_on_enter = 0 " no checks on open
let g:ale_lint_on_save = 1 " check on save
let g:ale_lint_on_text_changed = 1 " check on text change
let g:ale_lint_delay = 300 " millisecond delay before checking
" Airline
let g:airline_theme = 'base16' " theme
set laststatus=2 " always show airline
set noshowmode " hide default mode indicator
let g:airline_powerline_fonts = 1 " use powerline font
let g:airline#extensions#wordcount#enabled = 0 " disable word counting
let g:airline#extensions#whitespace#enabled = 0 " disable detection of whitespace errors
if filereadable($HOME."/.vimrc_local")
source $HOME/.vimrc_local
endif
let g:jsx_ext_required = 0 " JSX syntax in .js files
" open file splits in vsplit by default
:nnoremap <C-W>f :vertical wincmd f<CR>
" https://github.com/posva/vim-vue#how-can-i-use-existing-configurationplugins-in-vue-files
" autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
au FileType clojure exe "RainbowParenthesesLoadRound" | RainbowParenthesesActivate
" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" https://github.com/slim-template/vim-slim/issues/38#issuecomment-23760100
autocmd BufNewFile,BufRead *.slim setlocal filetype=slim
It looks like you're sourcing your .vimrc from bash. It's not a bash script. Instead, you should source it from inside Vim:
:source ~/.vimrc
:source $MYVIMRC
Or just restart Vim.
It looks like you are trying to source your .vimrc from bash as you would your .bashrc, but this is a vim-specific settings file. vim will naturally source your .vimrc when you run it, if it is in the right place in your path (which it seems to be based on the error message).
If you are already in vim and have made some changes to the .vimrc or wish to load another one, you can source it from within vim by going into command mode and calling source
:source ~/.vimrc

Buffers not working in vim

My buffers are not working for some reason. When I click <leader>b it says
Not an editor command: Buffers
This is my .vimrc file:
set nocompatible " required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" required
Plugin 'VundleVim/Vundle.vim'
" General
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-commentary'
" User Interface
Plugin 'altercation/vim-colors-solarized'
Plugin 'JarrodCTaylor/vim-256-color-schemes'
Plugin 'JarrodCTaylor/vim-reflection'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'bling/vim-airline'
" Programming
Plugin 'mattn/emmet-vim'
Plugin 'tpope/vim-surround'
Plugin 'leafgarland/typescript-vim'
" Languages
Plugin 'pangloss/vim-javascript'
Plugin 'davidhalter/jedi-vim'
" all plugins must be above this line!!
call vundle#end() " required
filetype plugin indent on " required
" non-plugin stuff after this line!!
" Map leader to ,
let mapleader=','
set t_Co=256
syntax on
set nobackup " Don't constantly write backup files
set noswapfile " Ain't nobody got time for swap files
set noerrorbells " Don't beep
set nowrap " Do not wrap lines
set shiftwidth=4 " Number of spaces to use for each step of indent
set showcmd " Display incomplete commands in the bottom line of the screen
set tabstop=4 " Number of spaces that a <Tab> counts for
set undolevels=1000 " Never can be too careful when it comes to undoing
set hidden " Don't unload the buffer when we switch between them. Saves undo history
set visualbell " Visual bell instead of beeping
set wildmenu " Command-line completion in an enhanced mode
set shell=bash " Required to let zsh know how to run things on the command line
set ttimeoutlen=50 " Fix delay when escaping from insert with Esc
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
set showbreak=↪\
set synmaxcol=256
set scrolloff=3
set clipboard=unnamed
au BufNewFile,BufRead *.json set ft=javascript
" Status line / visual configuration
syntax enable
set t_Co=256
set t_ut=
hi clear
hi String ctermfg=81 ctermbg=NONE cterm=NONE guifg=#5fd7ff guibg=NONE gui=NONE
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
set laststatus=2 " Make the second to last line of vim our status line
let g:airline_theme='understated' " Use the custom theme I wrote
let g:airline_left_sep='' " No separator as they seem to look funky
let g:airline_right_sep='' " No separator as they seem to look funky
let g:airline#extensions#branch#enabled = 0 " Do not show the git branch in the status line
let g:airline#extensions#syntastic#enabled = 1 " Do show syntastic warnings in the status line
let g:airline#extensions#tabline#show_buffers = 0 " Do not list buffers in the status line
let g:airline_section_x = '' " Do not list the filetype or virtualenv in the status line
let g:airline_section_y = '[R%04l,C%04v] [LEN=%L]' " Replace file encoding and file format info with file position
let g:airline_section_z = '' " Do not show the default file position info
let g:airline#extensions#virtualenv#enabled = 0
autocmd BufReadPost quickfix nnoremap <buffer> <CR> :.cc<CR>
autocmd BufReadPost quickfix nnoremap <buffer> o :.cc<CR>
nnoremap <Leader>W :%s/\s\+$//<CR>:let #/=''<CR>
let g:syntastic_check_on_open=1 " check for errors when file is loaded
let g:syntastic_loc_list_height=5 " the height of the error list defaults to 10
let g:syntastic_python_checkers = ['flake8'] " sets flake8 as the default for checking python files
let g:syntastic_javascript_checkers = ['jshint'] " sets jshint as our javascript linter
let g:syntastic_filetype_map = { 'handlebars.html': 'handlebars' }
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html', 'handlebars'] }
set tags=./.ctags,.ctags;
let g:NERDTreeMapJumpNextSibling = ''
let g:NERDTreeMapJumpPrevSibling = ''
let g:gundo_preview_bottom = 1
let g:markdown_fold_style = 'nested'
let g:markdown_fenced_languages = ['python', 'sh', 'vim', 'javascript', 'html', 'css', 'c', 'sql']
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=238
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=249
function! s:DeleteBuffer()
let line = getline('.')
let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+'))
\ : fnamemodify(line[2:], ':p')
exec "bd" bufid
exec "norm \<F5>"
endfunction
" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nmap <F3> :NERDTreeToggle<CR>
" buffer configuration
nnoremap <silent> <leader>b :Buffers<CR>
" close buffer
nnoremap <leader>c :bd<CR>
Can someone tell me if I missed something? I will also accept tips on upgrading my vimrc file so feel free to give any tips :) But I mainly want to fix this problem. So please tell me what I should remove or add to get this working again. It was working before. This really appeared suddenly.
Maybe a typo, see :h buffers
Please change following line (lowercase the B in :Buffers)
nnoremap <silent> <leader>b :Buffers<CR>
to
nnoremap <silent> <leader>b :buffers<CR>

Vim: Delay after hitting gg

There is about a half second delay after I gg, which is extremely annoying. Other commands such as Shift-G work instantaneously, but with gg, I think there may be something in my .vimrc where vim is expecting another input.
My .vimrc is below if that helps. Thanks.
call plug#begin('~/.vim/plugged')
"Plug 'valloric/youcompleteme'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
"autocomplete
Plug 'honza/vim-snippets'
Plug 'garbas/vim-snipmate'
Plug 'ervandew/supertab'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-repeat'
"comments
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-commentary'
Plug 'kien/ctrlp.vim'
Plug 'wakatime/vim-wakatime'
Plug 'Yggdroot/indentLine'
Plug 'terryma/vim-multiple-cursors'
Plug 'itchyny/lightline.vim'
Plug 'matze/vim-move'
Plug 'jacoborus/tender'
Plug 'craigemery/vim-autotag'
Plug 'flazz/vim-colorschemes'
Plug 'jiangmiao/auto-pairs'
Plug 'justinmk/vim-syntax-extra'
Plug 'svermeulen/vim-easyclip'
call plug#end()
" toby vim
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set backspace=indent,eol,start
set mouse=a
set statusline+=%f
set number
set linebreak
set ruler
set showcmd
set smartcase
set laststatus=2
set incsearch " search as characters are entered
set foldenable " enable folding
nnoremap E ^
" Line Numbers
set number
set relativenumber
augroup lineNums
autocmd!
autocmd InsertEnter * set norelativenumber
autocmd InsertLeave * set relativenumber
augroup END
" Copy Paste to System Clipboard
set clipboard=unnamed
let mapleader="g" "for nerdcommenter
nnoremap gcc :call NERDComment(0,"toggle")<CR>
filetype plugin on
" If you have vim >=8.0 or Neovim >= 0.1.5
if (has("termguicolors"))
set termguicolors
endif
" Theme
syntax enable
set background=dark
colorscheme molokai
let t_Co=256
" set lighline theme inside lightline config
" let g:lightline = { 'colorscheme': 'wombat' }
"vim-move
let g:move_key_modifier = 'C'
" syntastic settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
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
" :ca off SyntasticToggleMode
:ca WQ wq
:ca Wq wq
:ca wQ wq
I don't think you need to look further than:
let mapleader="g" "for nerdcommenter
Since nerdcommenter defines a whole bunch of <leader> mappings, every time you press g Vim is going to wait a bit in order to decide if you wanted g or one of your many mappings starting with g.
g is a very bad <leader>, you should find an alternative.

Resources