diff --git a/README.md b/README.md index ab87613..8dc4462 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,7 @@ # Cài đặt theme dracula - Vô F:/Vim/plugged/dracula - Copy lần lượt **dracula.vim** trong autoload và colors của **F:/Vim/plugged/dracula** bỏ vào autoload và colors trong **F:/Vim** +# Markdown preview vim +- Nếu gõ lệnh `:MarkdownPreview` mà không thấy gì xảy ra thì vào *Vim* gõ `:call mkdp#util#install()` và chờ nó cài xong là được + # Goodluck 😋😋😋 diff --git a/_gvimrc b/_gvimrc index 0d796f9..123ec93 100644 --- a/_gvimrc +++ b/_gvimrc @@ -1 +1,2 @@ -set t_vb= +set vb t_vb= + diff --git a/_vimrc b/_vimrc index 811a809..82bfbe1 100644 --- a/_vimrc +++ b/_vimrc @@ -1,179 +1,264 @@ -"Basic Config{{{ +" Basic {{{ + syntax on -filetype indent on +filetype indent on set encoding=utf-8 set fileencoding=utf-8 set foldmethod=marker -set number +set number set relativenumber -set clipboard=unnamedplus +set clipboard=unnamed set backspace=2 set noswapfile set nobackup -set nowritebackup +set noundofile +set nowritebackup set noerrorbells set vb t_vb= set cursorline -set lines=35 columns=150 "set window size -highlight CursorLine gui=underline cterm=underline -au GUIEnter * simalt ~x +set hidden +set mouse=nvi +set expandtab +set smarttab +set shiftwidth=2 +set tabstop=2 +set hlsearch +set ignorecase +set smartcase +set scrolloff=5 +set nowrap +set fillchars+=vert:\ +set signcolumn=yes +set shortmess+=c +set updatetime=300 +set cmdheight=1 if has("gui_running") - set guioptions-=m - set guioptions-=T - "No scroll bar - set guioptions-=r - colorscheme dracula - set background=dark - set guifont=hack\ NF:h13 - " set guifont=Consolas:h13:b + set guioptions-=m + set guioptions-=T + set guioptions-=L + set guioptions-=r + set background=dark + set guifont=hack\ nfm:h11 + set termguicolors + autocmd GUIEnter * simalt ~x + autocmd BufEnter * lcd %:p:h endif +" }}} -"}}} - -"Key Binding{{{ -let mapleader=',' -inoremap jk -vnoremap jk -nnoremap sv :so% -nnoremap ev :e $MYRIMRC -"}}} - -"Plugin{{{ -call plug#begin('F:\Vim/plugged') -Plug 'morhetz/gruvbox' +" Plugin {{{ +call plug#begin('F:/Vim/plugged') +Plug 'junegunn/vim-plug' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'voldikss/vim-floaterm' +Plug 'altercation/vim-colors-solarized' Plug 'tpope/vim-commentary' -Plug 'dracula/vim', { 'as': 'dracula' } -Plug 'junegunn/goyo.vim' -Plug 'chrisbra/unicode.vim' +Plug 'Valloric/MatchTagAlways' +Plug 'tpope/vim-surround' +Plug 'AndrewRadev/tagalong.vim' +Plug 'jiangmiao/auto-pairs' Plug 'ryanoasis/vim-devicons' +Plug 'morhetz/gruvbox' +Plug 'nathanaelkane/vim-indent-guides' +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'dracula/vim', { 'name': 'dracula' } Plug 'preservim/nerdtree' -Plug 'mattn/vimtweak' -Plug 'tsuyoshicho/transparency.vim' -Plug 'Valloric/MatchTagAlways' -"This is for snippet +Plug 'tiagofumo/vim-nerdtree-syntax-highlight' +Plug 'ap/vim-css-color' +Plug 'arcticicestudio/nord-vim' +Plug 'ayu-theme/ayu-vim' +Plug 'Yggdroot/indentLine' call plug#end() "}}} -"CocInstall {{{ -let g:coc_global_extensions = [ - \ 'coc-html', - \ 'coc-css', - \ 'coc-git', - \ 'coc-pyright', - \ 'coc-emmet', - \ 'coc-prettier', - \ 'coc-pairs', - \ ] +"Mapping {{{ +let mapleader = " " +inoremap jk +vnoremap jk +nnoremap j +nnoremap k +nnoremap l +nnoremap h +nnoremap sv :source $MYVIMRC +nnoremap :w:w +inoremap :w:w +inoremap o +inoremap O +inoremap A +"moving code around +nnoremap :m .+1== +nnoremap :m .-2== +inoremap :m .+1==gi +inoremap :m .-2==gi +vnoremap :m '>+1gv=gv +vnoremap :m '<-2gv=gv +"toggle nerdtree +nnoremap t :NERDTreeToggle "}}} -"Coc Config{{{ -"" ctrl space to trigger completion -"inoremap coc#refresh() -"" Use to comfirm completion -"inoremap pumvisible() ? "\": "\u\" -"" Use to trigger completion and navigate -"inoremap pumvisible() ? "\" : check_back_space() ? "\" : coc#refresh() -"inoremap pumvisible() ? "\" : "\" -"" GoTo code navigation. -"nmap gd (coc-definition) -"nmap gy (coc-type-definition) -"nmap gi (coc-implementation) -"nmap gr (coc-references) - -"" Use K to show documentation in preview window. -"nnoremap K :call show_documentation() -"cài d?t cho tab, shift-tab -function! s:check_back_space() abort - let col = col('.')-1 - return !col || getline('.')[col-1] =~ '\s' -endfunction +" Airline {{{ +let g:airline#extensions#tabline#enabled=1 +let g:airline#extensions#tabline#left_sep = ' ' +let g:airline#extensions#tabline#left_alt_sep = '>' +" }}} + +" Coc {{{ inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : \ coc#refresh() -inoremap pumvisible() ? "\" : "\" +inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" -"make for confirm completion -inoremap pumvisible() ? coc#_select_confirm() : - \"\u\\=coc#on_enter()\" -"Ð?i tên hàm -nmap rn (coc-rename) +" Make to accept selected completion item or notify coc.nvim to format +" u breaks current undo, please make your own choice +inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + +function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion +if has('nvim') + inoremap coc#refresh() +else + inoremap coc#refresh() +endif -"" Map Ctrl + Space d? show list functions/bi?n autocomplete -inoremap coc#refresh() +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) -"" T? d?ng import file c?a bi?n/function khi ch?n và nh?n Tab -" inoremap pumvisible() ? "\" : "\u\" -"" Go to definition ? tab m?i -nmap gd :call CocAction('jumpDefinition', 'tab drop') +" GoTo code navigation +nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) -nnoremap K :call show_documentation() -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) +" Use K to show documentation in preview window +nnoremap K :call ShowDocumentation() + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') else - execute '!' . &keywordprg . " " . expand('') + call feedkeys('K', 'in') endif endfunction -""}}} -"Floaterm Config{{{ -let g:floaterm_keymap_new = 'ft' -let g:floaterm_keymap_toggle = '' -"}}} +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') -""Goyo configuration for presentation{{{ -"autocmd BufNewFile,BufRead *.md call SetVimPresentationMode() -"function SetVimPresentationMode() -" nnoremap :n -" nnoremap :N +" Symbol renaming +nmap rn (coc-rename) -" if !exists('#goyo') -" Goyo -" endif -"endfunction -""}}} +" Formatting selected code +xmap f (coc-format-selected) +nmap f (coc-format-selected) -"Airline Config{{{ -let g:airline#extensions#tabline#enabled=1 -let g:airline#extensions#tabline#formatter='unique_tail' -nnoremap -nnoremap -nnoremap :tabn -nnoremap :tabp -"}}} +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end -"Prettier Config{{{ -" :CocConfig -"Add "coc.preferences.formatOnSaveFiletypes": ["css", "markdown", "html", -""python"], -"}}} +" Applying code actions to the selected code block +" Example: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) -"Transparency config{{{ -let g:transparency_config = { - \ 'active':95, - \ 'inactive':70 - \ } -let g:transparency_ctermbg_none =1 -nmap (TransparencyOn) -nmap (TransparencyOff) -"}}} +" Remap keys for applying code actions at the cursor position +nmap ac (coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap as (coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap qf (coc-fix-current) + +" Remap keys for applying refactor code actions +nmap re (coc-codeaction-refactor) +xmap r (coc-codeaction-refactor-selected) +nmap r (coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap cl (coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if (coc-funcobj-i) +omap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap af (coc-funcobj-a) +xmap ic (coc-classobj-i) +omap ic (coc-classobj-i) +xmap ac (coc-classobj-a) +omap ac (coc-classobj-a) + +" Remap and to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap (coc-range-select) +xmap (coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings for CoCList +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item +nnoremap j :CocNext +" Do default action for previous item +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume + +" SCSS +autocmd FileType scss setl iskeyword+=@-@ +" }}} + +" Colorscheme {{{ +colorscheme ayu +" }}} + +" Prettier {{{ +command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument +" }}} + +" Indentline {{{ +let g:indentLine_char_list = ['|', '¦', '┆', '┊'] +let g:indentLine_concealcursor = 'inc' +let g:indentLine_conceallevel = 2 +let g:indentLine_enabled = 1 +" }}} -"Highlight tag{{{ -let g:mta_use_matchparen_group = 1 -let g:mta_filetype = { - \ 'html' : 1, - \'xhtml':1, - \'xml':1, - \'jinja':1, - \ } -"}}} diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..8f2102e --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,35 @@ +{ + "diagnostic.errorSign": "", + "diagnostic.warningSign": "", + "diagnostic.infoSign": "", + "diagnostic.hintSign": "", + "suggest.completionItemKindLabels": { + "variable": "\uf71b", + "constant": "\uf8ff", + "struct": "\ufb44", + "class": "\uf0e8", + "interface": "\ufa52", + "text": "\ue612", + "enum": "\uf435", + "enumMember": "\uf02b", + "color": "\ue22b", + "property": "\ufab6", + "field": "\uf93d", + "unit": "\uf475", + "file": "\uf471", + "value": "\uf8a3", + "event": "\ufacd", + "folder": "\uf115", + "keyword": "\uf893", + "snippet": "\uf64d", + "operator": "\uf915", + "reference": "\uf87a", + "typeParameter": "\uf278", + "default": "\uf29c" + }, + "prettier.printWidth": 80, + "coc.preferences.formatOnSaveFiletypes": ["css", "html"], + "bracketSpacing": "true", + "bracketSameLine": "true", + "proseWrap": "always" +}