How To Config Vim

Help to Config NeoVim on Linux

Install Part

Install NeoVim

first you need to try neovim, remember to install it’s newest version from github release (apt install is too old version)

https://github.com/neovim/neovim

Then you will need vim-plug to install plugins

https://github.com/junegunn/vim-plug

remember to reopen config file to finish your config

use the command line below to install what plugins you want:

1
:PlugInstall [plugname]

then add its’ github link to your config file, plz reference the github page of vim-plug above

Install coc.nvim to make your nvim like a real IDE

make sure you have updated your neovim to the newest version

https://github.com/neoclide/coc.nvim

use the command line below to install plugs of coc.nvim:

1
:CocInstall coc-json

You can install coc-marketplace first and use the command below to find plugs of coc.nvim:

1
2
3
:CocInstall Coc-marketplace

:CocList marketplace

also use the command line below to check what you have installed:

1
:CocList extensions

then you can press to get further action

what CocPlugs I’ve installed are above

Config Your Neovim

enter ~/.config and make /nvim/init.vim

here is my config:

image

https://github.com/ChouYuduki/NeovimSettings

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
set number     
set cursorline  
set showcmd " show what you did on the lower right corner
set wildmenu 
set hlsearch   
set incsearch
set ignorecase
set smartcase
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set autoindent
set cindent

noremap h i
noremap H I

noremap i k
noremap I 5k
noremap K 5j
noremap k j
noremap j h

" open file-tree explorer by typing tt
noremap tt :CocCommand explorer<CR>

map s <nop>
map S :w<CR>
map Q :q<CR>
map R :source $MYVIMRC<CR>

call plug#begin()

Plug 'vim-airline/vim-airline'
Plug 'connorholyday/vim-snazzy'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jiangmiao/auto-pairs'

call plug#end()

let g:SnazzyTransparent = 1
color snazzy

" initial coc.nvim plugins
let g:coc_global_extensions = [ 'coc-json', 'coc-vimlsp', 'coc-marketplace', 'coc-highlight' ]

" Use tab for trigger completion with characters ahead and navigate
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1) :
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <ctrl-space> to trigger completion
inoremap <silent><expr> <c-space> coc#refresh()

" Highlight the same thing and its references when holding the cursor
autocmd CursorHold * silent call CocActionAsync('highlight')
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy