码迷,mamicode.com
首页 > 系统相关 > 详细

vim配置

时间:2020-09-17 12:54:28      阅读:28      评论:0      收藏:0      [点我收藏+]

标签:signature   dcom   comm   ack   indent   buffer   other   column   editor   

Vim 配置

if has("autocmd")
  autocmd BufReadPost *
        \ if line("‘\"") > 1 && line("‘\"") <= line("$") | exe "normal! g‘\"" | endif
endif

set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set noerrorbells
set mouse=a
set autochdir
let mapleader=‘ ‘
let &t_ut=‘‘

" ======== indent settings ========
set expandtab
set smarttab
set smartindent
set autoindent

autocmd Filetype c,cpp,java,python,javascript,css,json
      \ setlocal tabstop=4 softtabstop=4 shiftwidth=4 cindent
autocmd Filetype vim,sh,html,xml,yaml
      \ setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd Filetype markdown setlocal tabstop=3 softtabstop=3 shiftwidth=3
autocmd Filetype go
      \ setlocal tabstop=4 softtabstop=4 shiftwidth=4 cindent noexpandtab

set shiftround

"set foldmethod=indent
set laststatus=2
set foldlevel=99
set scrolloff=4
set clipboard=unnamedplus

set number
"set list
set relativenumber

set cursorline
"autocmd ColorScheme * highlight! Cursorline cterm=bold ctermbg=236 guibg=Gray90
"highlight! Cursorline cterm=none ctermbg=236 guibg=Gray90
"highlight! CursorlineNr cterm=none ctermfg=159 ctermbg=236 guibg=Gray90

"set cursorcolumn
set ruler
set wrap
set showcmd
set wildmenu

set hlsearch
"highlight! Search cterm=bold

exec ‘nohlsearch‘
set incsearch
set ignorecase
set smartcase

" ========== key board map =========
map <up> :resize -5<cr>
map <down> :resize +5<cr>
map <left> :vertical resize -5<cr>
map <right> :vertical resize +5<cr>

"map te :tabedit<cr>
map = :tabnext<cr>
map - :-tabnext<cr>

map <A-t> :vsplit<cr><C-w>l:terminal<cr>i

noremap <leader><cr> :nohlsearch<cr>
noremap <leader><leader> <esc>/<++><cr>:nohlsearch<cr>c4l
noremap <leader>b ciw**<esc>pa**<esc>

call plug#begin(‘C:\Users\Zero Sharp\AppData\Local\nvim\plugged‘)
Plug ‘dracula/vim‘
Plug ‘connorholyday/vim-snazzy‘
Plug ‘vim-airline/vim-airline‘
Plug ‘vim-airline/vim-airline-themes‘
Plug ‘rafalbromirski/vim-airlineish‘
Plug ‘mhinz/vim-startify‘
Plug ‘ryanoasis/vim-devicons‘

Plug ‘preservim/nerdtree‘
"Plug ‘Xuyuanp/nerdtree-git-plugin‘
Plug ‘mbbill/undotree‘ 
Plug ‘majutsushi/tagbar‘, { ‘on‘: ‘TagbarOpenAutoClose‘ }
Plug ‘airblade/vim-gitgutter‘
Plug ‘tpope/vim-fugitive‘
Plug ‘skywind3000/asyncrun.vim‘
Plug ‘Chiel92/vim-autoformat‘
Plug ‘tpope/vim-surround‘
Plug ‘jiangmiao/auto-pairs‘
Plug ‘preservim/nerdcommenter‘
Plug ‘Yggdroot/indentLine‘, { ‘for‘: [‘c‘, ‘cpp‘, ‘java‘, ‘python‘, ‘javascript‘, ‘css‘, ‘html‘, ‘go‘] }
Plug ‘mattn/emmet-vim‘, { ‘for‘: ‘html‘ }
Plug ‘suan/vim-instant-markdown‘, {‘fot‘: ‘markdown‘}
Plug ‘mzlogin/vim-markdown-toc‘, { ‘for‘: ‘markdown‘ }
Plug ‘dhruvasagar/vim-table-mode‘, { ‘for‘: ‘markdown‘ }
Plug ‘neoclide/coc.nvim‘, {‘branch‘: ‘release‘}
call plug#end()

colorscheme dracula
"colorscheme snazzy
"let g:airline_theme = ‘airlineish‘

let g:startify_bookmarks = [
      \  { ‘a‘: ‘D:\Zero Sharp\codes\acwing‘ },
      \  { ‘i‘: ‘D:\Zero Sharp\codes\IntroductionToAlgorithms‘ },
      \]


" TextEdit might fail if hidden is not set.
set hidden

" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Use tab for trigger completion with characters ahead and navigate.
" 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>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

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

" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists(‘*complete_info‘)
  inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
  inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index([‘vim‘,‘help‘], &filetype) >= 0)
    execute ‘h ‘.expand(‘<cword>‘)
  else
    call CocAction(‘doHover‘)
  endif
endfunction

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

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

" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction(‘format‘)

" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call     CocAction(‘fold‘, <f-args>)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocAction(‘runCommand‘, ‘editor.action.organizeImport‘)

" popup
nmap <leader>t <Plug>(coc-translator-p)
vmap <leader>t <Plug>(coc-translator-pv)
" echo
nmap <leader>e <Plug>(coc-translator-e)
vmap <leader>e <Plug>(coc-translator-ev)
" replace
nmap <leader>r <Plug>(coc-translator-r)
vmap <leader>r <Plug>(coc-translator-rv)

vim配置

标签:signature   dcom   comm   ack   indent   buffer   other   column   editor   

原文地址:https://www.cnblogs.com/idlezero/p/vim-config.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!