質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Vim

VimとはUnix / Linux 系のOSに標準搭載されているターミナル上で動くテキストエディタです。

Q&A

解決済

1回答

4417閲覧

neovim,denite,highwayを使ってgrep検索し、結果一覧からヒット箇所に飛ばせるようにしたい

automaton

総合スコア12

Vim

VimとはUnix / Linux 系のOSに標準搭載されているターミナル上で動くテキストエディタです。

0グッド

1クリップ

投稿2017/05/09 13:43

下記のツールを使ってgrep検索したい

使っているツール

  • NVIM v0.2.0-dev
  • denite
  • dein
  • highway

ノーマルモードで ,ug の入力すると
Pattern: 検索文字 を入力すると
下記のような画面にになり、該当結果が検索されず、エスケープキーやQ
のキーなどを押しして反応しなくなる。

イメージ説明

nvimの設定ファイルは次のようにしています。

●~/config/nvim/init.vim の中身

let g:cache_home = empty($XDG_CACHE_HOME) ? expand('$HOME/.cache') : $XDG_CACHE_HOME let g:config_home = empty($XDG_CONFIG_HOME) ? expand('$HOME/.config') : $XDG_CONFIG_HOME let s:dein_cache_dir = g:cache_home . '/dein' if &compatible set nocompatible endif " reset augroup augroup MyAutoCmd autocmd! augroup END " dein.vim がなければ github から落としてくる if &runtimepath !~# '/dein.vim' let s:dein_repo_dir = s:dein_cache_dir . '/repos/github.com/Shougo/dein.vim' if !isdirectory(s:dein_repo_dir) execute '!git clone git@github.com:Shougo/dein.vim.git' s:dein_repo_dir endif execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p') endif " dein.vim settings let g:dein#install_max_processes = 16 let g:dein#install_progress_type = 'title' let g:dein#install_message_type = 'none' let g:dein#enable_notification = 1 if dein#load_state(s:dein_cache_dir) call dein#begin(s:dein_cache_dir) let s:toml_dir = g:config_home . '/dein' " TOML を読み込み、キャッシュしておく call dein#load_toml(s:toml_dir . '/dein.toml', {'lazy': 0}) call dein#load_toml(s:toml_dir . '/dein_lazy.toml', {'lazy': 1}) if has('nvim') call dein#load_toml(s:toml_dir . '/neovim.toml', {'lazy': 1}) endif call dein#end() call dein#save_state() endif if dein#check_install() call dein#install() endif filetype plugin indent on " エディタ基本設定 START colorscheme jellybeans syntax enable hi Comment ctermfg=2 "set encoding=utf-8 ""set fileencodings=iso-2022-jp,cp932,sjis,euc-jp,utf-8 "set fileformats=unix,dos,mac set number set tabstop=4 set shiftwidth=4 set expandtab set softtabstop=4 "set title ""set ambiwidth=double set list set listchars=tab:-=,eol:?,nbsp:%,extends:#",precedes:#' set laststatus=2 set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%{fugitive#statusline()}%=%l,%c%V%8P set modifiable set write highlight CursorLine ctermfg=LightBlue highlight LineNr ctermfg=246 " エディタ基本設定 END " タブの見出しに番号をを振る START " 1gt 2gt 数字gt でタブ移動ができる " 参考URL: http://iteba.hateblo.jp/entry/2014/05/16/171347 function! s:SID_PREFIX() return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$') endfunction function! s:my_tabline() "{{{ let s = '' for i in range(1, tabpagenr('$')) let bufnrs = tabpagebuflist(i) let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears let no = i " display 0-origin tabpagenr. let mod = getbufvar(bufnr, '&modified') ? '!' : ' ' let title = fnamemodify(bufname(bufnr), ':t') let title = '[' . title . ']' let s .= '%'.i.'T' let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#' let s .= no . ':' . title let s .= mod let s .= '%#TabLineFill# ' endfor let s .= '%#TabLineFill#%T%=%#TabLine#' return s endfunction "}}} let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()' set showtabline=2 nnoremap [Tag] <Nop> nmap t [Tag] map <silent> [Tag]c :tablast <bar> tabnew<CR> " タブの見出しに番号をを振る END " ctags を使った関数ジャンプ設定 START nnoremap <F1> :vsp<CR> :exe("tjump ".expand('<cword>'))<CR> nnoremap <F2> :split<CR> :exe("tjump ".expand('<cword>'))<CR> nnoremap <F3> :<C-u>tab stj <C-R>=expand('<cword>')<CR><CR> " ctags を使った関数ジャンプ 設定 END "拡張子とファイルシンタックスの関連付け設定 START "" HTML (.shtml and .stm for server side) au BufNewFile,BufRead *.ect set filetype=html "拡張子とファイルシンタックスの関連付け設定 END " 検索結果をquickfix-windowで自動的に開くようにする START " autocmd QuickFixCmdPost *grep* cwindow " 検索結果をquickfix-windowで自動的に開くようにする END

● ~/.config/dein/dein.toml の中身

[[plugins]] repo = 'Shougo/dein.vim' [[plugins]] repo = 'scrooloose/nerdtree' hook_add = ''' nnoremap <silent><C-e> :NERDTreeToggle<CR> ''' # ファイル保存時にシンタックスチェックする (php) # http://bashalog.c-brains.jp/13/02/27-102230.php [[plugins]] repo = 'scrooloose/syntastic' hook_add = ''' let g:syntastic_check_on_open = 1 let g:syntastic_enable_signs = 1 let g:syntastic_echo_current_error = 1 let g:syntastic_auto_loc_list = 2 let g:syntastic_enable_highlighting = 1 let g:syntastic_php_php_args = '-l' set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* ''' [[plugins]] repo = 'ctrlpvim/ctrlp.vim' [[plugins]] repo = 'tpope/vim-fugitive' hook_add = ''' set diffopt+=vertical ''' [[plugins]] repo = 't9md/vim-quickhl' hook_add = ''' nmap <Space>m <Plug>(quickhl-manual-this) xmap <Space>m <Plug>(quickhl-manual-this) nmap <Space>M <Plug>(quickhl-manual-reset) xmap <Space>M <Plug>(quickhl-manual-reset) ''' [[plugins]] repo = 'cohama/agit.vim' [[plugins]] repo = 'Shougo/deoplete.nvim' if = 'has("python3")' depends = ['context_filetype.vim'] on_event = 'InsertEnter' hook_source = ''' let g:deoplete#enable_at_startup = 1 let g:deoplete#enable_ignore_case = 1 let g:deoplete#enable_smart_case = 1 " <TAB>: completion. imap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : <SID>check_back_space() ? "\<TAB>" : deoplete#mappings#manual_complete() function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction " <S-TAB>: completion back. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" ''' [[plugins]] repo = 'Shougo/denite.nvim' if = 'has("python3")' #on_cmd = 'Denite' hook_add = ''' nnoremap <silent> ,uy :<C-u>Denite neoyank<CR> nnoremap <silent> ,uu :<C-u>Denite file_mru -mode=normal buffer<CR> nnoremap <silent> ,ub :<C-u>Denite buffer<CR> nnoremap <silent> ,ug :<C-u>Denite -auto_preview grep<CR> nnoremap <silent> ,ur :<C-u>Denite -resume -buffer-name=search-buffer-denite<CR> nnoremap <silent> ,un :<C-u>Denite -resume -buffer-name=search-buffer-denite -select=+1 -immediately<CR> nnoremap <silent> ,up :<C-u>Denite -resume -buffer-name=search-buffer-denite -select=-1 -immediately<CR> ''' hook_post_source = ''' call denite#custom#var('grep', 'command', ['hg']) call denite#custom#var('grep', 'recursive_opts', []) call denite#custom#var('grep', 'pattern_opt', []) call denite#custom#var('grep', 'default_opts', ['--follow', '--no-group', '--no-color']) ''' [[plugins]] repo = 'Shougo/neomru.vim' depends = 'denite.nvim' on_path = '.*' [[plugins]] repo = 'Shougo/neoyank.vim' depends = 'denite.nvim' on_event = 'TextYankPost'

vimは使っていましたが、nvimを習い始めた初心者です。
お手数おかけ致しますが、ご教授の程よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

作者です。

call denite#custom#var('grep', 'command', ['hw'])

call denite#custom#var('grep', 'default_opts', ['--follow-link', '--no-group', '--no-color'])

コマンド名とオプション名が間違っています。

さて、これで動作するかというと私が手元で試した限り動作しませんでした。
なぜか highway からの出力が出てこないようです。理由は不明です。
端末や unite.vim からだと動作しているので highway の独自の挙動が原因ではないかと考えています。今のところ highway をサポートできません。他の grep ツールを使ってください。

投稿2017/05/10 02:30

Shougo

総合スコア183

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

automaton

2017/05/11 14:35

Shougo様、お忙しいところご回答ありがとうございました。 highwayがサポートされていないこと承知いたしました。 grepツールとしてptをつかってみたところ、意図したことができるようになりました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問