Update readme, add some key bindings for vim tabs

This commit is contained in:
ducnn 2022-10-09 10:04:29 +07:00
parent 2088c5e6be
commit 3b13afa8a2
2 changed files with 49 additions and 34 deletions

View File

@ -1,2 +1,27 @@
# vim
My Vim configuration
## vim-plug
#### Vim
###### Unix
```sh
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
#### Neovim
###### Linux
```sh
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
```
## Conquer of Completion
Run commands in NeoVim/Vim:
```
:CocInstall coc-json coc-tsserver
:CocInstall coc-snippets
:CocInstall coc-vimtex
:CocInstall coc-pairs
```

58
init.vim Normal file → Executable file
View File

@ -1,8 +1,8 @@
syntax on
set number
set cursorline
set expandtab smarttab tabstop=4 shiftwidth=4 softtabstop=4
set autoindent smartindent
set expandtab tabstop=4 shiftwidth=4 softtabstop=4
set autoindent
" Fold
@ -30,33 +30,20 @@ Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'cocopon/iceberg.vim'
Plug 'kevinhwang91/nvim-bqf'
Plug 'morhetz/gruvbox'
call plug#end()
"Color scheme
colorscheme iceberg
"colorscheme iceberg
colorscheme gruvbox
set background=light
let g:gruvbox_contrast_light = 'hard'
"Open NERDTree
:nnoremap <silent> <expr> <F2> g:NERDTree.IsOpen() ? "\:NERDTreeClose<CR>" : bufexists(expand('%')) ? "\:NERDTreeFind<CR>" : "\:NERDTree<CR>"
"Coc.nvim
:set completeopt=longest,menuone
:inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" open omni completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
" open user completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
"Autocomplete with the first option if pop up menu is open.
"inoremap <silent><expr> <TAB> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<TAB>"
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<cr>"
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
@ -70,7 +57,7 @@ function! s:check_back_space() abort
endfunction
let g:coc_snippet_next = '<tab>'
nnoremap <leader>s :CocCommand snippets.editSnippets<CR>
nnoremap <leader>e :CocCommand snippets.editSnippets<CR>
" Comments
let mapleader = ","
@ -87,9 +74,23 @@ nnoremap <C-Left> <C-W>h
nnoremap <C-Down> <C-W>j
nnoremap <C-Up> <C-W>k
nnoremap <C-Right> <C-W>l
nnoremap <leader>o :tabonly<CR>
nnoremap <leader>to :tabonly<CR>
nnoremap <leader>o :only<CR>
nnoremap <tab> :tabn<CR>
nnoremap <S-tab> :tabp<CR>
nnoremap <BS> <C-O>
"set clipboard+=unnamedplus
" " Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" " Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
set clipboard+=unnamedplus
" FZF key mapping
nnoremap <silent> <Leader>b :Buffers<CR>
@ -102,17 +103,6 @@ filetype plugin on
set splitright
set splitbelow
" " Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" " Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
function! IBusOff()
" Lưu engine hiện tại
@ -154,7 +144,7 @@ silent call IBusOff()
"Language tool
let b:ale_linter_aliases = ['tex', 'text', 'html']
let g:ale_languagetool_executable = "java"
let g:ale_languagetool_options = "-jar /data/runtimes/languagetool/languagetool-commandline.jar --languagemodel /data/runtimes/languagemodel/ --word2vecmodel /data/runtimes/word2vec/ --disable WHITESPACE_RULE,COMMA_PARENTHESIS_WHITESPACE,CURRENCY[1]"
let g:ale_languagetool_options = "-jar /data/runtimes/languagetool/languagetool-commandline.jar --languagemodel /data/runtimes/languagemodel/ --word2vecmodel /data/runtimes/word2vec/ --disable WHITESPACE_RULE,COMMA_PARENTHESIS_WHITESPACE"
let g:ale_disable_lsp = 1
map <F3> :ALEToggle<CR>