Низкая производительность в Vim с Ag (Серебряный Искатель)

Я пытался реализовать Ag с помощью Vundle, но заметил очень медленное время поиска как в Vim, так и в MacVim. Скорость поиска в 3-4 раза больше, чем в этом видео от MinuteVimTricks.

Я потерпел неудачу в попытках найти проблему, и я не нашел других, сталкивающихся с той же самой проблемой. Я переустановил все плагины в моем каталоге.vim / bundles и попробовал Ag с очищенным.vimrc, который, казалось, помог. Затем я повторно применил свои предпочтительные настройки в.vimrc, и Ag все еще работал быстро. Однако через полдня я начал замечать то же старое вялое поведение, когда поиск по каталогу занимал до 3 секунд.

Я с подозрением отношусь к моим настройкам конфигурации и надеюсь, что у кого-то здесь будет дополнительная информация для меня. По общему признанию плохо советованный для новичка, такого как я, я был вынужден добавить различную конфигурацию, чтобы соответствовать стандартам на моем рабочем месте, поэтому у меня мало знаний о некоторых из настроек ниже. Вот мой текущий.vimrc

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

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-commentary' "Commenting plugin
Plugin 'bling/vim-airline' "Status bar customization
Plugin 'ctrlpvim/ctrlp.vim' " Fuzzy search plugin
Plugin 'rking/ag.vim' "Ag search utility
Plugin 'https://github.com/scrooloose/nerdtree.git' " NERDTree file explorer plugin
"Plugin 'thoughtbot/vim-rspec' "Rspec for VIM, https://robots.thoughtbot.com/running-specs-from-vim

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required


" Remap leader key
let mapleader = ","

"timeout length for leader key
:set timeoutlen=2000

"opens .vimrc in new tab
nmap <leader>v :tabedit $MYVIMRC<CR>

" opens NERDTree w/ Ctrl+n
map <C-n> :NERDTreeToggle<CR>

" Get to NORMAL mode with 'jj'
:imap jj <Esc>

" shortcut to save
nmap <leader>, :w<cr> 

"Open new tab and search for something
nmap <leader>a :tab split<CR>:Ag ""<Left>

"Immediately search for the word under the cursor in a new tab
nmap <leader>A :tab split<CR>:Ag <C-r><C-w><CR>   
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => CONFIG
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
  " Use Ag over Grep
  set grepprg=ag\ --nogroup\ --nocolor

  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'

  " ag is fast enough that CtrlP doesn't need to cache
  let g:ctrlp_use_caching = 0
endif

set lines=40 columns=160

set gdefault " assume the /g flag on :s substitutions to replace all matches in a line


filetype indent on "activates indenting for files
set autoindent " auto indenting
set number " line numbers
set relativenumber "shows relative line numbers 
set nobackup " get rid of anoying ~file
set nocompatible
set clipboard=unnamed " Use the OS clipboard by default (on versions compiled with `+clipboard`) 

set wildmenu " Enhance command-line completion

" Allow cursor keys in insert mode
set esckeys
" Allow backspace in insert mode
set backspace=indent,eol,start
" Optimize for fast terminal connections
set ttyfast
" Add the g flag to search/replace by default
set gdefault
" Use UTF-8 without BOM
set encoding=utf-8 nobomb
" Don’t add empty newlines at the end of files
set binary
set noeol
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif

" config from PCR.

" Sets how many lines of history VIM has to remember
set history=700

" Enable filetype plugins
filetype plugin on
filetype indent on

" Set to auto read when a file is changed from the outside
set autoread

" => VIM user interface
" Set 7 lines to the cursor - when moving vertically using j/k
" set so=7
set so=7

" New splits always to right or below active window
set splitright
set splitbelow

" Turn on the WiLd menu
set wildmenu

" Ignore compiled files
set wildignore=*.o,*~,*.pyc
"
"Always show current position
set ruler

" Height of the command bar
set cmdheight=1
set hid " A buffer becomes hidden when it is abandoned

" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l

" Ignore case when searching
set ignorecase

" When searching try to be smart about cases 
set smartcase

" Highlight search results
set hlsearch

" Makes search act like search in modern browsers
set incsearch

" Don't redraw while executing macros (good performance config)
set lazyredraw

" For regular expressions turn magic on
set magic

" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2

" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => COLORS AND FONTS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

syntax enable
set background=dark

"Colorscheme conditional: MacVim or Vim
if has('gui_running')
   colorscheme tomorrow-night-eighties
else
   colorscheme lapis256
endif

hi clear CursorLineNR "clears highlighting of cursor line number
set encoding=utf8 " Set utf8 as standard encoding and en_US as the standard language
set ffs=unix,dos,mac " Use Unix as the standard file type

" => Files, backups and undo
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile

" => Text, tab and indent related
" Use spaces instead of tabs
" DISABLING IT PER JEFF'S REQUEST
set expandtab
" set noexpandtab
set copyindent
set preserveindent
set softtabstop=0

" Be smart when using tabs ;)
set smarttab

" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2

" Linebreak on 500 characters
set lbr
set tw=500

set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines as break lines (useful when moving around in them)
map j gj
map k gk

" Specify the behavior when switching between buffers 
try
  set switchbuf=useopen,usetab,newtab
  set stal=2
catch
endtry

" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
     \ if line("'\"") > 0 && line("'\"") <= line("$") |
     \   exe "normal! g`\"" |
     \ endif
" Remember info about open buffers on close
set viminfo^=%

" => Status line

" Always show the status line
set laststatus=2

" Format the status line
"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ Col:\ %c

" Returns true if paste mode is enabled
function! HasPaste()
  if &paste
    return 'PASTE MODE  '
  endif
  return ''
endfunction

" show all characters that aren't whitespace by using :set list
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<

0 ответов

Другие вопросы по тегам