* 준비
# 필수
> sudo yum -y install epel-release
> sudo yum -y groupinstall "Development Tools"
> sudo yum -y install kernel-devel kernel-headers
> sudo yum -y install cmake git
> sudo yum -y install python36-devel python36 python36-pip
# (옵션). vim 풀버전 설치(기본 lite 버전 설치되어있음)
> sudo yum -y install vim
# vim-plug neovim에 설치 ( https://github.com/junegunn/vim-plug )
> curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# python neovim 설치
> pip3 install --user pynvim
* neovim (nvim) 설치
yum 설치시 (현재 3.0 설치됨)
> sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
> sudo yum install -y neovim python3-neovim
> vi ~/.bashrc
alias vi='nvim'
> source ~/.bashrc
직접 설치시 (0.3.8)
릴리즈 : https://github.com/neovim/neovim/releases
> wget https://github.com/neovim/neovim/releases/download/v0.3.8/nvim-linux64.tar.gz
> tar xvfz nvim-linux64.tar.gz
> mkdir ~/prog
> mv nvim* ~/prog
> vi ~/.bashrc
export PATH=/home/user1/prog/nvim-linux64/bin:$PATH
alias vi='nvim'
> source ~/.bashrc
* neovim 설정
# 환경설정 파일 작성
> mkdir -p ~/.config/nvim
> cat > ~/.config/nvim/init.vim
"----------------------------------------------------------------------------------
"-- config
"----------------------------------------------------------------------------------
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
set hlsearch
set ignorecase
set nocompatible " disable vi compatibility (emulation of old bugs)
set autoindent " use indentation of previous line
set smartindent " use intelligent indentation for C
" configure tabwidth and insert spaces instead of tabs
set tabstop=4 " tab width is 4 spaces
set shiftwidth=4 " indent also with 4 spaces
set expandtab " expand tabs to spaces
" wrap lines at 120 chars. 80 is somewaht antiquated with nowadays displays.
set textwidth=120
" turn syntax highlighting on
set t_Co=256
syntax on
" colorscheme wombat256
set number " turn line numbers on
set showmatch " highlight matching braces
set comments=sl:/*,mb:\ *,elx:\ */ " intelligent comments
"----------------------------------------------------------------------------------
"-- keyboard mappings
"----------------------------------------------------------------------------------
" switch between header/source with F4
map <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
" goto definition with F12
map <F12> <C-]>
"----------------------------------------------------------------------------------
"-- plugins
"----------------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
"-------- c++ autocomplete : YCM
Plug 'valloric/youcompleteme'
let g:ycm_key_list_select_completion = ['<C-n>']
let g:ycm_key_list_previous_completion=['<C-p>']
let g:ycm_confirm_extra_conf = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_min_num_of_chars_for_completion = 1
"let g:ycm_server_python_interpreter = '/usr/bin/python3'
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings = 1
let g:ycm_complete_in_comments = 1
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_filetype_blacklist = {}
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
" 변수나 함수에서 \g, \gg, .. 로 사용 가능
" 자동완성은 CTRL + SPACE
" 점프 후 뒤돌아갈떈 CTRL + o
" 점프 후 뒤돌아간 후 다시 앞으로 갈땐 CTRL + i
nnoremap <leader>g :YcmCompleter GoTo<CR>
nnoremap <leader>gg :YcmCompleter GoToImprecise<CR>
nnoremap <leader>d :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>t :YcmCompleter GetType<CR>
nnoremap <leader>p :YcmCompleter GetParent<CR>
" nvim-gdb
Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh \| UpdateRemotePlugins' }
" nerdtree
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs' "Toggle nerd tree with one key
" auto complete
Plug 'jiangmiao/auto-pairs' "insert or delete brackets, parens, quotes in pair
" git
Plug 'airblade/vim-gitgutter' "Show git status in vim
Plug 'tpope/vim-fugitive' "syntax error
" find file
Plug 'ctrlpvim/ctrlp.vim' "Ctrl + P for search file
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
call plug#end()
"----------------------------------------------------------------------------------
"-- plugin config
"----------------------------------------------------------------------------------
"Python 3 executable file location
let g:python3_host_prog = "/usr/bin/python3"
" nerd tree
" nerd tree 왼쪽 생성(F7)
" nerd tree 현재 파일 위치를 tree에 표시(\r)
let NERDTreeWinPos = "left"
nmap <F7> :NERDTree<CR>
nnoremap <leader>r :NERDTreeFind<CR>
# nvim 실행 후 플러그인 설치
> nvim
: PlugInstall
: UpdateRemotePlugins
# YouCompleteMe 설치
> cd /home/user1/.vim/plugged/youcompleteme
> git submodule update --init --recursive
> python3 ./install.py --clang-completer
## 설치 확인 (정상: 0)
> echo $?
# YouCompleteMe 설정
## global 설정파일
> wget https://raw.githubusercontent.com/Valloric/ycmd/66030cd94299114ae316796f3cad181cac8a007c/.ycm_extra_conf.py -P ~/.vim/
## 작업할 디렉토리 설정 파일
## 다운받아둔 .ycm_extra_conf.py 파일
* ScreenShot
* 참고
neovim 상태 체크 명령
: CheckHealth
youcompleteme 가 동작하지 않는 경우
에러: The ycmd server SHUT DOWN (restart with ':YcmRestartServer')
에러: ModuleNotFoundError: No module named 'ycm_core'
https://github.com/ycm-core/YouCompleteMe/issues/2729
혹은 재설치 시도
~/.vim/plugged 로 이동 후 youcompleteme 삭제.
nvim 실행 후 :PlugClean, :PlugInstall 수행
~/.vim/plugged/youcompleteme 이동 후 python3 ./install.py --clang-completer 실행
'C++' 카테고리의 다른 글
값에 따라 원하는 확률로 선택되도록 하기 (0) | 2019.08.02 |
---|---|
libcurl call https post (0) | 2018.11.09 |
c++ make (0) | 2017.10.16 |
timer - timer_create(linux), SetTimer(windows), CreateTimerQueue(windows) (0) | 2017.09.24 |
c++ console project에서 console창을 띄우지 않고 프로그램 실행시키는 방법 (0) | 2017.08.29 |
cmake - 샘플 (0) | 2017.05.29 |
minidump (0) | 2017.04.25 |
[펌] Debugging Tips (1) - .map 파일과 .cod 파일 분석하기 (0) | 2017.04.24 |