C++のソースコードの入力時、vim-lsp、aleでエラー表示を行い、補間にはclangをvim-lsp経由で使用しています。あまり思い当たる設定変更をした記憶がないのですが、昨日から補間の候補をtabで選択し、C-pやEnterで確定した場合やEscでインサートモードを抜けた際に、補完した文字列の後ろに続く文字が削除されてしまうようになりました。
たとえば、std::vector<std::vector<std::pair<int, in>>>
と入力し、nの後ろを補間すると、>>
が消えて、std::vector<std::vector<std::pair<int, int>
になってしまいます。
ターミナルエミュレータにはlilytermを使用していますが、alacrittyでも同様の状態になります。vim hoge.cpp -u NONE
で起動すると補間は出来ませんが、問題も再現出来ませんでした。OSはantergosを使用しています。この問題についてどなたかご教授いただけますでしょうか。以下はinit.vimをそのまま貼り付けました。どうぞよろしくお願いいたします。
"-------------------------
" GENERAL SETTINGS
"-------------------------
set history=10000
" disable motion by mouse
set mouse=
" set clipboard^=unnamed,unnamedplus
set noswapfile
"-------------------------
" PLUGINS
"-------------------------
" automatic installation of vim-plug itself
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.config/nvim/plugged')
" :PlugInstall -> install plugins
" :PlugUpdate -> update plugins
" :PlugUpdate! -> force update plugins
" :PlugUpgrade -> update vim-plug itself
" appearance
Plug 'nathanaelkane/vim-indent-guides'
Plug 'freeo/vim-kalisi'
Plug 'cocopon/lightline-hybrid.vim'
Plug 'itchyny/lightline.vim'
" Plug 'w0ng/vim-hybrid'
" Plug 'tomasr/molokai'
" Plug 'lifepillar/vim-solarized8'
" utilities
Plug 'https://github.com/vim-scripts/fcitx.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'bronson/vim-trailing-whitespace'
Plug 'cohama/lexima.vim'
Plug 'tyru/caw.vim'
Plug 'tpope/vim-surround'
" dependency for language plugins
" Plug 'thinca/vim-quickrun'
" Plug 'Shougo/vimproc'
" Plug 'Shougo/unite.vim'
" Plug 'osyo-manga/shabadou.vim'
" Plug 'osyo-manga/vim-watchdogs'
" Plug 'scrooloose/nerdtree'
" Plug 'jistr/vim-nerdtree-tabs'
" C++
" Python
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'w0rp/ale'
" R
" Documentation
" Plug 'rhysd/devdocs.vim'
Plug 'KabbAmine/zeavim.vim', {'on': [
\ 'Zeavim', 'Docset',
\ '<Plug>Zeavim',
\ '<Plug>ZVVisSelection',
\ '<Plug>ZVKeyDocset',
\ '<Plug>ZVMotion'
\ ]}
call plug#end()
"-------------------------
" PLUGIN SETTINGS
"-------------------------
""""" vim-trailing-whitespace
" erase white space at the end of the line
augroup space
autocmd!
autocmd BufWritePre * :FixWhitespace
augroup END
""""" lexima.vim
" parentheses
let g:lexima_enable_basic_rules = 1
let g:lexima_enable_newline_rules = 1
"""""" vim-lsp
let g:lsp_diagnostics_enabled = 1 " enable diagnostics support
let g:lsp_signs_enabled = 1 " enable signs
let g:lsp_diagnostics_echo_cursor = 1 " enable echo under cursor when in normal mode
let g:lsp_virtual_text_enabled = 0 " disable in-place error notification
let g:lsp_highlights_enabled = 1
let g:lsp_textprop_enabled = 1
nnoremap <Space>ld :LspDefinition<CR>
" back to the original place by typing Ctrl-o
nnoremap <Space>lf :LspDocumentFormat<CR>
nnoremap <Space>lh :LspHover<CR>
nnoremap <Space>lr :LspReferences<CR>
" completion by C-p, selection by C-n, C-p, choosing by C-y, Enter
if executable('clangd')
augroup lsp_clangd
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],
\ })
autocmd FileType c setlocal omnifunc=lsp#complete
autocmd FileType cpp setlocal omnifunc=lsp#complete
autocmd FileType objc setlocal omnifunc=lsp#complete
autocmd FileType objcpp setlocal omnifunc=lsp#complete
augroup end
endif
if executable('pyls')
augroup lsp_pyls
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'whitelist': ['python'],
\ })
autocmd FileType python setlocal omnifunc=lsp#complete
augroup end
endif
""""" asyncomplete.vim
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
imap <c-space> <Plug>(asyncomplete_force_refresh)
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
""""" ale
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_insert_leave = 0
" let g:ale_sign_column_always = 1
" let g:ale_sign_error = '>>'
" let g:ale_sign_warning = '--'
augroup compileflag-text
autocmd!
autocmd BufNewFile,BufReadPost * call s:compileflag_text(expand('<afile>:p:h'))
augroup END
function! s:compileflag_text(loc)
let files = findfile('compile_flags.txt', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
let g:ale_cpp_clang_options = system("cat " . i . "| tr '\\n' ' '")
let g:ale_cpp_gcc_options = system("cat " . i . "| tr '\\n' ' '")
endfor
endfunction
""""" cppman
augroup cppmanref
autocmd VimEnter * call system("cppman -s cppreference.com")
autocmd VimLeave * call system("cppman -s cplusplus.com")
augroup END
autocmd FileType cpp set keywordprg=:term\ cppman
"-------------------------
" KEY MAPPINGS
"-------------------------
let mapleader = "\<Space>"
inoremap <silent> jj <ESC>
inoremap <silent> っj <ESC>
inoremap <silent> kk <ESC>
inoremap <silent> hh <ESC>
nnoremap ; :
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap $ g$
nnoremap gj j
nnoremap gk k
nnoremap g0 0
nnoremap g$ $
vnoremap j gj
vnoremap k gk
vnoremap 0 g0
vnoremap $ g$
vnoremap gj j
vnoremap gk k
vnoremap g0 0
vnoremap g$ $
nnoremap <C-h> <Nop>
" copy / cut to system clipboard
nnoremap <Space>y "+y
nnoremap <Space>d "+d
nnoremap <Space>p "+p
nnoremap <Space>P "+P
vnoremap <Space>y "+y
vnoremap <Space>d "+d
vnoremap <Space>p "+p
vnoremap <Space>P "+P
vnoremap <Space>x "+x
" comment / uncomment
nmap ,c <Plug>(caw:hatpos:toggle)
vmap ,c <Plug>(caw:hatpos:toggle)
" reset search highlight
nnoremap <Esc><Esc> :noh<CR>
" do not use ex mode
nnoremap Q <Nop>
""""" vim-tmux-navigator
" seamless pane moving between vim and tmux
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <M-j> :TmuxNavigateDown<CR>
nnoremap <silent> <M-k> :TmuxNavigateUp<CR>
nnoremap <silent> <M-h> :TmuxNavigateLeft<CR>
nnoremap <silent> <M-l> :TmuxNavigateRight<CR>
inoremap <silent> <M-j> <Esc>:TmuxNavigateDown<CR>
inoremap <silent> <M-k> <Esc>:TmuxNavigateUp<CR>
inoremap <silent> <M-h> <Esc>:TmuxNavigateLeft<CR>
inoremap <silent> <M-l> <Esc>:TmuxNavigateRight<CR>
""""" caw.vim
" comment out lines by typing ,c
""""" vim-surround
" surround selected text by typing S", S', S{, S<b>, etc.
" unsurround text by typing ds', etc.
" change surrounding by typing cs'" (' --> "), etc.
""""" cppman
" search by typing shift-k
" http://ja.stackoverflow.com/questions/33212
command! -nargs=+ Cppman silent! call system("/home/tak0kada/dotfiles/neovim/plugins/cppman/tmux-cppman" . expand(<q-args>))
autocmd FileType cpp nnoremap <silent><buffer> K <Esc>:Cppman <cword><CR>
autocmd FileType cpp vnoremap <silent><buffer> K <Esc>:Cppman <cword><CR>
""""" zeavim.vim
" search for document out side of vim, in the stand alone application zeal
nmap gz <Plug>Zeavim " <leader>z (NORMAL mode)
vmap gz <Plug>ZVVisSelection " <leader>z (VISUAL mode)
" nmap gzz <Plug>ZVMotion " gz{motion} (NORMAL mode)
" nmap gZ <Plug>ZVKeyDocset " <leader><leader>z
""""" devdocs.vim
" search for document onside of vim, in the webbrowser
" autocmd Filetype nmap K <Plug>(devdocs-under-cursor)
"-------------------------
" SEARCH
"-------------------------
set incsearch
set hlsearch
set smartcase
set ignorecase
set showmatch
"-------------------------
" APPEARANCE
"-------------------------
syntax on
set number
set guicursor=
autocmd OptionSet guicursor noautocmd set guicursor=
set background=dark
colorscheme kalisi
" colorscheme hybrid
" colorscheme molokai
" colorscheme solarized8_dark_low
" color the line which the cursor is on
set cursorline
highlight LineNr ctermfg=241
highlight CursorLineNr ctermfg=233 ctermbg=0 cterm=NONE
set tabstop=8 shiftwidth=4 expandtab smartindent
" print line at 80th caracter from left
set colorcolumn=80
" config used by vim-indent-guides
" draw line to visualize indent
let g:indent_guides_enable_on_vim_startup = 1
" draw guide at 1st character
let g:indent_guides_start_level = 1
" guide width
let g:indent_guides_guide_size = 1
" turn off default color setting
let g:indent_guides_auto_colors = 0
if g:colors_name == 'kalisi'
hi IndentGuidesOdd ctermbg=236
hi IndentGuidesEven ctermbg=237
hi ColorColumn ctermbg=235
" make background transprant
if !has('gui_running')
augroup seiya
autocmd!
autocmd VimEnter,ColorScheme * highlight Normal ctermbg=none
autocmd VimEnter,ColorScheme * highlight LineNr ctermbg=none
autocmd VimEnter,ColorScheme * highlight SignColumn ctermbg=none
autocmd VimEnter,ColorScheme * highlight VertSplit ctermbg=none
autocmd VimEnter,ColorScheme * highlight NonText ctermbg=none
augroup END
endif
" elseif g:colors_name == 'hybrid'
" hi IndentGuidesOdd ctermbg=236
" hi IndentGuidesEven ctermbg=237
endif
"cursor position does not shift even if there are characters such as "□" or "○"
" if exists('&ambiwidth')
" set ambiwidth=double
" endif
" lightline print information at the bottom low
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ Regular
set laststatus=2
set noshowmode
let g:lightline = {
\'colorscheme': 'solarized',
\'component': {
\'readonly': '%{&readonly?"":""}',
\},
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\}
追記 (2019/07/26): pythonのファイル編集時は後ろの文字列は消えませんでした。vimの問題ではなくclangdの設定の問題かも知れません。