set encoding=utf-8
set autochdir
"末尾空格显示为点
set listchars=trail:.
set list
"不与vi兼容
set nocompatible
"更改字号
let s:fontsize = 24
function! AdjustFontSize(amount)
let s:fontsize = s:fontsize+a:amount
:execute "GuiFont! Consolas:h" . s:fontsize
endfunction
noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
inoremap <C-ScrollWheelUp> <Esc>:call AdjustFontSize(1)<CR>a
inoremap <C-ScrollWheelDown> <Esc>:call AdjustFontSize(-1)<CR>a
set rnu
"a文Swp件
set nobackup " no backup files
set noswapfile " no swap files
set nowritebackup " only in case you don't want a backup file while editing
set noundofile " no undo files
"折叠功能
"折叠
set nofoldenable
"语法高亮
syntax on
filetype on
filetype plugin on
set ignorecase
set mouse=a
"搜索高亮
set hlsearch
set wildmenu
" 显示行号
set number"
let mapleader=","
set pastetoggle=<F10>
set backspace=indent,eol,start
" 基本缩进效果
set noautoindent
set tabstop=4
set shiftwidth=4
set expandtab
noremap J 5j
noremap K 5k
noremap L 7l
noremap H 7h
map S <nop>
noremap S :w<CR>
noremap Q :q<CR>
map R :source $MYVIMRC<CR>
source C:/Editor/neovim/snippits.vim
"分页跳转
noremap <M-H> <C-w>h
noremap <M-J> <C-w>j
noremap <M-K> <C-w>k
noremap <M-L> <C-w>l
"noremap E :vsplit C:/Users/lenovo/AppData/Local/nvim/init.vim<CR>
noremap E :tabnew $MYVIMRC<CR>
"分页
"noremap <C-up> <C-w>s
"noremap <C-down> <C-w>s<C-w>j
"noremap <C-left> <C-w>v
"noremap <C-right> <C-w>v<C-w>l
"分页大小调整
map <C-Up> :res +5<CR>
map <C-down> :res -5<CR>
map <C-left> :vertical resize-5<CR>
map <C-right> :vertical resize+5<CR>
"快捷键
map <C-z> <Esc>ui
inoremap <C-a> <ESc>
inoremap <C-f> <Esc>/
map e $
map b 0
"复制粘贴
inoremap <C-S-v> <Esc>"*pa
call plug#begin('~/.vim/plugged')
" ===
" === wildfire
" ===
Plug 'gcmt/wildfire.vim'
Plug 'tpope/vim-surround'
" ===
" === colorscheme
" ===
Plug 'rakr/vim-one'
Plug 'morhetz/gruvbox'
colorscheme gruvbox
set background=dark
highlight Normal guibg=NONE ctermbg=None
" ===
" === 代码补全coc
" ===
Plug 'https://gitee.com/from1999/coc.nvim.git',{'do': 'yarn install --frozen-lockfile'}
inoremap <silent><expr> <TAB>
\ pumvisible() ? "<C-n>" :
\ <SID>check_back_space() ? "<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "<C-p>" : "<C-h>"
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "<C-y>" : "<C-g>u<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <c-space> coc#refresh()
inoremap <silent><expr> <c-o> coc#refresh()
function! Show_documentation()
call CocActionAsync('highlight')
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
nnoremap <LEADER>h :call Show_documentation()<CR>
" set runtimepath^=~/.config/nvim/coc-extensions/coc-flutter-tools/
" let g:coc_node_args = ['--nolazy', '--inspect-brk=6045']
" let NVIM_COC_LOG_FILE = '/Users/david/Desktop/log.txt'
nnoremap <silent><nowait> <LEADER>d :CocList diagnostics<cr>
nmap <silent> <LEADER>- <Plug>(coc-diagnostic-prev)
nmap <silent> <LEADER>= <Plug>(coc-diagnostic-next)
nnoremap <c-c> :CocCommand<CR>
" Text Objects
xmap kf <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap kf <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
xmap kc <Plug>(coc-classobj-i)
omap kc <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Useful commands
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
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)
nmap <leader>rn <Plug>(coc-rename)
nmap tt :CocCommand explorer<CR>
" coc-translator
nmap ts <Plug>(coc-translator-p)
" Remap for do codeAction of selected region
function! s:cocActionsOpenFromSelected(type) abort
execute 'CocCommand actions.open ' . a:type
endfunction
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>aw <Plug>(coc-codeaction-selected)w
" coctodolist
nnoremap <leader>tn :CocCommand todolist.create<CR>
nnoremap <leader>tl :CocList todolist<CR>
nnoremap <leader>tu :CocCommand todolist.download<CR>:CocCommand todolist.upload<CR>
" coc-tasks
noremap <silent> <leader>ts :CocList tasks<CR>
" coc-snippets
imap <C-l> <Plug>(coc-snippets-expand)
vmap <C-e> <Plug>(coc-snippets-select)
let g:coc_snippet_next = '<c-e>'
let g:coc_snippet_prev = '<c-n>'
imap <C-e> <Plug>(coc-snippets-expand-jump)
let g:snips_author = 'Haozhe Wang'
autocmd BufRead,BufNewFile tsconfig.json set filetype=jsonc
" ===
" === tagbar
" ===
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'majutsushi/tagbar'
nmap <F8> :TagbarToggle<CR>
"不显示文档总字数
"let g:airline#extensions#wordcount#enabled = 0
""不显示文件编码(Windows系统)
let g:airline#parts#ffenc#skip_expected_string='utf-8[dos]'
"设置tagber对于markdown的支持
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Chapter',
\ 'i:Section',
\ 'k:Paragraph',
\ 'j:Subparagraph'
\ ]
\ }
let g:asyncrun_status = ''
"取消显示warning部分
let g:airline_section_warning = ''
"激活tagbar扩展
let g:airline#extensions#tagbar#enabled = 1"
" ===
" === vim-toc
" ===
Plug 'mzlogin/vim-markdown-toc'
let g:vim_auto_upgdate_on_save = 1
let g:vmt_cycle_list_item_markers = 1
"===
" === tab
" ===
noremap <M-k> :tabnext<CR>
noremap <M-j> :tabprevious<CR>
"括号匹配
Plug 'jiangmiao/auto-pairs'
" ===
" === airline
" ===
"airline
""安装字体后必须设置
"let g:airline_powerline_fonts = 1
""关闭tabline
let g:airline#extensions#tabline#enabled = 0
let g:airline#extensions#tabline#buffer_nr_show = 1
" ===
" === nerdtree
" ===
Plug 'preservim/nerdtree'
let NERDTreeShowHidden=1
map tt :NERDTree<CR>
map tc :NERDTreeClose<CR>
" ===
" === markdown
" ===
" Create markmap from the whole file
nmap <Leader>m <Plug>(coc-markmap-create)
" " Create markmap from the selected lines
vmap <Leader>m <Plug>(coc-markmap-create-v)"
Plug 'godlygeek/tabular' "必要插件,安装在vim-markdown前面
Plug 'plasticboy/vim-markdown'
Plug 'dkarter/bullets.vim'
" Bullets.vim
let g:bullets_enabled_file_types = [
\ 'markdown',
\ 'text',
\ 'gitcommit',
\ 'scratch',
\ 'md'
]
let g:vim_markdown_new_list_item_indent = 2
set concealcursor=""
let g:indentLine_concealcursor = 'Q'
let g:vmt_auto_update_on_save = 0
function RToc()
exe "/-toc .* -->"
let lstart=line('.')
exe "/-toc -->"
let lnum=line('.')
execute lstart.",".lnum."g/ /d"
endfunction
"数学公式
let g:vim_markdown_math = 1
"Plug 'suan/vim-instant-markdown'
Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'https://gitee.com/yaozhijin/markdown-preview.nvim.git', { 'do': 'cd app && yarn install'}
" "
" ===
" === ulitsnips
" ===
Plug 'https://gitee.com/zgpio/ultisnips.git'
""设置tab键为触发键
let g:UltiSnipsExpandTrigger = '<C-j>'
"设置向后跳转键
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
"设置向前跳转键
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
"设置文件目录
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips'
let g:UltiSnipsSnippetDirectories = ['UltiSnips']
"设置打开配置文件时为垂直打开
let g:UltiSnipsEditSplit="vertical"
"________________代码片段 over _________________
Plug 'honza/vim-snippets'
" ===
" === 参考线
" ===
Plug 'Yggdroot/indentLine'
let g:indent_guides_guide_size = 1 " 指定对齐线的尺寸
let g:indent_guides_start_level = 2 " 从第二层开始可视化显示缩进
" ===
" === 多光标
" ===
Plug 'mg979/vim-visual-multi'
call plug#end()
" ===
" === markdown shortcuts
" ===
map <F5> :MarkdownPreview<CR>
autocmd BufRead,BufNewFile *.{mdkdarkdown$dwn} set noimdisable
noremap W :vsplit C:/Editor/neovim/snippits.vim<CR>
function CheckPythonSyntax()
let mp = &makeprg
let ef = &errorformat
let exeFile = expand("%:t")
setlocal makeprg=python\ -u
set efm=%C\ %.%#,%A\ \ File\ "%f"\,\ line\ %l%.%#,%Z%[%^\ ]%\@=%m
silent make %
copen
" set efm 是设置quickfix的errorformat,以便vim识别
" makeprg 是vim内置的编译命令,可以通过更改来实现编译对应类型文件。具体可参考vim官方说明文件。
" copen是打开quickfix,n用来设置quichfix窗口大小,如 cope5。在错误描述上回车,可以直接跳转到错误行。
let &makeprg = mp
let &errorformat = ef
endfunction
"一个是普通模式下,一个是插入模式下
au filetype python map <F6> :w <cr> :call CheckPythonSyntax() <cr>
au filetype python imap <F6> <esc> :w <cr> :call CheckPythonSyntax() <cr></cr></cr></esc></F6></cr></cr></F6>