2 Star 8 Fork 3

SpringHan / nvim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
init.vim 25.62 KB
一键复制 编辑 原始数据 按行查看 历史
SpringHan 提交于 2020-07-26 23:32 . Added a keybinding
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
" __ __ _ _ _
" | \/ |_ _ | \ | | ___ _____ _(_)_ __ ___ _ __ ___
" | |\/| | | | | | \| |/ _ \/ _ \ \ / / | '_ ` _ \| '__/ __|
" | | | | |_| | | |\ | __/ (_) \ V /| | | | | | | | | (__
" |_| |_|\__, | |_| \_|\___|\___/ \_/ |_|_| |_| |_|_| \___|
" |___/
" @Author: SpringHan (https://github.com/SpringHan)
" @Date: 2020.7.26
" -- ------
" -- ------ Install all the plugins when opening it for the first time
" -- ------
if empty(glob('~/.config/nvim/plugged/'))
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" -- ------
" -- ------ The Path
" -- ------
let g:python_host_skip_check = 1
let g:python_host_prog = '/usr/bin/python'
let g:python3_host_skip_check = 1
let g:python3_host_prog = '/usr/bin/python3'
" -- ------
" -- ------ Important Settings
" -- ------
let &t_ul=''
set autochdir
" -- ------
" -- ------ Basic Setting
" -- ------
syntax enable
syntax on
filetype indent on
set termguicolors
set smartindent
set termencoding=utf-8
set fileformats=unix
set encoding=utf-8
set mouse=nv
set number
set tabstop=2
set shiftwidth=2
set showcmd
set noswapfile
set noexpandtab
set showmatch
set ruler
set wrap
set noshowmode
set showtabline=1
set smartcase
set notimeout
set ttimeoutlen=0
set lazyredraw
set visualbell
set history=800
set scrolloff=5
set hlsearch
set incsearch
set cursorline
set list
set listchars=tab:\┆\ ,trail:-
hi CursorLine ctermbg=darkred ctermfg=white guibg=darkred guifg=white
set viewoptions=cursor,folds,slash,unix
set wildmenu
set wildmode=full
set wildchar=<Tab>
set guicursor=n:block,i:ver1,v:block,r:block,c:block,ci:block,cr:block
set relativenumber
set autoindent
set path=.,/usr/include,/usr/local/include/
set foldmethod=marker
set foldlevelstart=99
set colorcolumn=80
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
let g:mapleader = "\<Space>"
" -- ------
" -- ------ Key Mappings
" -- ------
" Important Mappings
noremap e j
noremap i l
noremap u k
noremap U 5k
noremap E 5j
noremap N 5h
noremap I 5l
noremap l u
noremap h i
noremap k n
noremap K N
noremap H I
noremap n h
nnoremap cB cb
noremap L e
nnoremap <C-q> <nop>
" Insert bindings
inoremap .* /* */<ESC>hi
inoremap ;; <ESC>A;
inoremap ,; ;
inoremap ., <ESC>A
inoremap .. .
inoremap .fl {{{
inoremap .fn }}}
inoremap ,, ,
inoremap ?A <ESC>la
inoremap ?O <ESC>O
inoremap ?o <ESC>o
inoremap ?I <ESC>I
inoremap ?H <ESC>i
inoremap ?? ?
inoremap ?< <ESC><<a
inoremap ?> <ESC>>>a
inoremap ,x <ESC>xa
inoremap ,X <ESC>xi
inoremap .x <ESC>lxi
inoremap <C-x> <C-x><C-s>
inoremap .z <ESC>zza
inoremap \\ \
" Normal Bindings
nnoremap ; :
nnoremap > >>
nnoremap < <<
nnoremap s <nop>
nnoremap cq Q
nnoremap <silent> cl :bp<CR>
nnoremap <silent> cn :bn<CR>
nnoremap <silent> S :w<CR>
nnoremap <silent> Q :q<CR>
nnoremap <silent> sq :wq<CR>
nnoremap <silent> sa :qa!<CR>
nnoremap <silent> se :q!<CR>
nnoremap cet :edit<Space>
nnoremap va <C-w>+
nnoremap vx <C-w>-
nnoremap vj <C-w>=
nnoremap ve <C-w>j
nnoremap vu <C-w>k
nnoremap vn <C-w>h
nnoremap vi <C-w>l
nnoremap vE <C-w>J
nnoremap vU <C-w>K
nnoremap vN <C-w>H
nnoremap vI <C-w>L
nnoremap vr <C-w>r
nnoremap vR <C-w>R
nnoremap vy vy
nnoremap <silent> cb :call BDeleteBuf()<CR>
nnoremap <silent> cd :nohlsearch<CR>
nnoremap sr :r<Space>
nnoremap sh :!
nnoremap <leader><Return> gf
nnoremap <silent><leader>nrc :e ~/.config/nvim/init.vim<CR>
nnoremap <silent> vw :source ~/.config/nvim/init.vim<CR>:call ReloadHighlight(2)<CR>:nohlsearch<CR>
nnoremap css :set spell!<CR>
nnoremap sc z=
nnoremap vv v
nnoremap spt :set nosplitbelow<CR>:split<Space>
nnoremap spb :set splitbelow<CR>:split<Space>
nnoremap vsr :set splitright<CR>:vsplit<Space>
nnoremap vsl :set nosplitright<CR>:vsplit<Space>
nnoremap csc :%s/\r//<CR>
nnoremap cmit :r ~/.config/nvim/CopyRight/MIT<CR>
nnoremap gG ggG
" Command bindings
cnoremap <C-a> <HOME>
cnoremap <C-e> <END>
cnoremap <C-b> <LEFT>
cnoremap <C-k> <RIGHT>
" Other mode bingdings
xmap ; :
" PlaceHolder
nnoremap <silent> <leader><leader> /<+++><CR>:nohlsearch<CR>c5l
inoremap <silent> ,p <ESC>/<+++><CR>:nohlsearch<CR>c5l
inoremap <silent> ?p <ESC>/<+++><CR>N:nohlsearch<CR>c5l
inoremap .p <+++>
" Notes
nnoremap <silent> <leader>la :call BackgroudColor(1)<CR>
nnoremap <silent> <leader>te :exec "!touch ./".expand("<cWORD>")<CR>
nnoremap <silent> <leader>ww :e ~/Github/StudyNotes/index.md<CR>
" Snippets
autocmd filetype markdown source ~/.config/nvim/md-snippets.vim
" Tab's
nnoremap tn :tabnew<CR>
nnoremap te :tabedit<Space>
nnoremap ctn :tabnext<CR>
nnoremap ctp :tabprevious<CR>
nnoremap ctf :tabfirst<CR>
nnoremap ctl :tablast<CR>
nnoremap cta :+tabmove<CR>
nnoremap ctx :-tabmove<CR>
nnoremap ctb :tabclose<CR>
nnoremap cto :tabonly<CR>
" -- ------
" -- ------ Terminal Settings
" -- ------
autocmd TermOpen term://* startinsert
tnoremap <silent> <C-\> <C-\><C-n>
" Dracula's terminal theme
let g:terminal_color_0 = '#000000'
let g:terminal_color_1 = '#FF5555'
let g:terminal_color_2 = '#50FA7B'
let g:terminal_color_3 = '#F1FA8C'
let g:terminal_color_4 = '#BD93F9'
let g:terminal_color_5 = '#FF79C6'
let g:terminal_color_6 = '#8BE9FD'
let g:terminal_color_7 = '#BFBFBF'
let g:terminal_color_8 = '#4D4D4D'
let g:terminal_color_9 = '#FF6E67'
let g:terminal_color_10 = '#5AF78E'
let g:terminal_color_11 = '#F4F99D'
let g:terminal_color_12 = '#CAA9FA'
let g:terminal_color_13 = '#FF92D0'
let g:terminal_color_14 = '#9AEDFE'
" -- ------
" -- ------ Plugins
" -- ------
call plug#begin('~/.config/nvim/plugged')
" The Begining
Plug 'mhinz/vim-startify'
" StatusLine
Plug 'Styadev/HicusLine'
Plug 'airblade/vim-gitgutter'
" vim-style
Plug 'SpringHan/vim-deus'
Plug 'RRethy/vim-illuminate'
" Autosuggestion
Plug 'neoclide/coc.nvim' , { 'branch': 'release' }
Plug 'mattn/emmet-vim', { 'for': [ 'html', 'vim-plug' ] }
" Markdown
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle' }
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & npm install', 'for': [ 'markdown', 'vim-plug' ] }
" Finder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': 'FZF' }
Plug 'brooth/far.vim', { 'on': 'Far' }
" Highlight
Plug 'pangloss/vim-javascript', { 'for': [ 'javascript', 'vim-plug' ] }
" Tagbar
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
" Todo
Plug 'SpringHan/NoToC.vim' " Control the notes and todos
" Useful plugin
Plug 'junegunn/vim-easy-align'
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'tpope/vim-surround'
Plug 'MattesGroeger/vim-bookmarks'
Plug 'lambdalisue/suda.vim' " Use sudo in neovim
Plug 'SpringHan/vim-capslock'
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'RRethy/vim-hexokinase', { 'do': 'make hexokinase', 'for': [ 'html', 'css', 'javascript', 'vim-plug' ] }
Plug 'itchyny/calendar.vim', { 'on': 'Calendar' }
Plug 'terryma/vim-multiple-cursors' " Multi-lines edition
" Translation
" Plug 'denstiny/Terslation'
Plug 'SpringHan/Terslation.vim', { 'on': [ 'TerslationToggle', 'TerslationWordTrans', 'TerslationSelectTrans' ] }
" Comment
Plug 'preservim/nerdcommenter'
" Others
Plug 'makerj/vim-pdf'
Plug 'SpringHan/vim-focus'
call plug#end()
" -- ------
" -- ------ Plugins Settings
" -- ------
" NeoVim Styles
colorscheme deus
" Startify
let g:startify_custom_header = [
\ ' _____ _ _ __ _ ___ ',
\ ' / ___/____ _____(_)___ ____ _ / | / /__ ____| | / (_)___ ___ ',
\ ' \__ \/ __ \/ ___/ / __ \/ __ `/ / |/ / _ \/ __ \ | / / / __ `__ \ ',
\ ' ___/ / /_/ / / / / / / / /_/ / / /| / __/ /_/ / |/ / / / / / / / ',
\ ' /____/ .___/_/ /_/_/ /_/\__, / /_/ |_/\___/\____/|___/_/_/ /_/ /_/ ',
\ ' /_/ /____/ ',
\ ]
" Coc.nvim
let g:coc_start_at_startup = 0
function! CocTimerStart(timer)
exec "CocStart"
echohl MoreMsg | echo "[Spring]: Coc.nvim loaded." | echohl None
endfunction
call timer_start(300, 'CocTimerStart', {'repeat': 1})
set hidden
set updatetime=50
" Plugins
let g:coc_global_extensions = [ 'coc-python', 'coc-vimlsp', 'coc-html', 'coc-css',
\ 'coc-phpls', 'coc-json', 'coc-tsserver', 'coc-lists', 'coc-gitignore',
\ 'coc-vimlsp', 'coc-tailwindcss', 'coc-stylelint', 'coc-tslint',
\ 'coc-lists', 'coc-git', 'coc-explorer', 'coc-sourcekit', 'coc-kite',
\ 'coc-yank', 'coc-snippets', 'coc-pairs' ]
" Basic
inoremap <silent><expr> <c-space> coc#refresh()
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
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
" coc-snippets
let g:coc_snippets_next = '<C-n>'
let g:coc_snippets_prev = '<C-e>'
imap <silent> <C-s> <Plug>(coc-snippets-expand)
vmap <silent> <C-j> <Plug>(coc=snippets-select)
" Others
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
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 <silent> gk :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
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
nmap <leader>crn <Plug>(coc-rename)
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xnoremap <leader>a <Plug>(coc-codeaction-selected)
nnoremap <leader>a <Plug>(coc-codeaction-selected)
nnoremap <leader>ac <Plug>(coc-codeaction)
nnoremap <leader>qf <Plug>(coc-fix-current)
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Using CocList
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>co :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>ss :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
nnoremap <silent> tt :CocCommand explorer<CR>
nnoremap <silent> <leader>cfg :CocConfig<CR>
nnoremap <silent> <leader>yy :<C-u>CocList -A --normal yank<CR>
nnoremap <silent> <leader>yc :CocCommand yank.clean<CR>
nnoremap <silent> <leader>es :CocCommand snippets.editSnippets<CR>
" VimTableMode
nnoremap <leader>tm :TableModeToggle<CR>
let g:table_mode_corner = '|'
let g:table_mode_delimiter = ''
let g:table_mode_cell_text_object_i_map = 'k<Bar>'
" Undotree
nnoremap <leader>ut :UndotreeToggle<CR>
function g:Undotree_CustomMap()
nmap <buffer> U <plug>UndotreeNextState
nmap <buffer> E <plug>UndotreePreviousState
endfunc
if has("persistent_undo")
set undofile
set undodir=~/.config/nvim/do_history
endif
" Fuzzy Finder
nmap <leader>FZ :FZF<CR>
nmap <leader>ff :FZF<Space>
" Markdown Preview
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 0
let g:mkdp_open_to_the_world = 0
let g:mkdp_open_ip = ''
let g:mkdp_browser = 'google-chrome-stable'
let g:mkdp_echo_preview_url = 0
let g:mkdp_browserfunc = ''
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {}
\ }
let g:mkdp_markdown_css = ''
let g:mkdp_highlight_css = ''
let g:mkdp_port = ''
let g:mkdp_page_title = '「${name}」'
" vim-javascript
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_null = "ø"
let g:javascript_conceal_this = "@"
let g:javascript_conceal_return = "⇚"
let g:javascript_conceal_undefined = "¿"
let g:javascript_conceal_NaN = "ℕ"
let g:javascript_conceal_prototype = "¶"
let g:javascript_conceal_static = "•"
let g:javascript_conceal_super = "Ω"
let g:javascript_conceal_arrow_function = "⇒"
let g:javascript_conceal_noarg_arrow_function = "🞅"
let g:javascript_conceal_underscore_arrow_function = "🞅"
" Tagbar
nnoremap <leader>T :TagbarToggle<CR>
let g:tagbar_ctags_bin = '/usr/bin/ctags'
" Far.vim
nnoremap <leader>FA :Far %<Left><Left><Space>
" Vim-easy-align
xmap ga <Plug>(EasyAlign)
" Vim-peekaboo
xnoremap Y "+y
nnoremap P "+p
" HicusLine
highlight GitStatusAdd ctermfg=142 ctermbg=239 guifg=#98C379 guibg=#44475A
highlight GitStatusMod ctermfg=214 ctermbg=239 guifg=#FABD2F guibg=#44475A
highlight GitStatusDel ctermfg=167 ctermbg=239 guifg=#FB4934 guibg=#44475A
set laststatus=2
let g:HicusLineEnabled = 1
let g:HicusColorSetWay = 1
let g:HicusLine = {
\ 'active': {
\ 'left': [ 'modehighlight', 'space', 'filename', 'truncate', 'space',
\ 'spell', '%#infos#', 'gitinfo', 0, 'modified', 'readonly',
\ 'space', '%#ErrorStatus#', 'errorstatus', 'space',
\ '%#WarningStatus#', 'warningstatus', 'bufferline', 'truncate',
\ 'gitmodified' ],
\ 'right': [ 'filetype3', 'space', '%#infos#', 'space', 'fileencoding',
\ 'space', "%{exists('*CapsLockStatusline')".
\ "?CapsLockStatusline():''}" , 'space', 'fileformat',
\ 'truncate', 'space', 'modehighlight', 'space', 'linenumber',
\ ':', 'bufferlinesnumber', 'space', 'windowpercentage',
\ 'space' ],
\ },
\ 'basic_option': {
\ 'ErrorSign': '●',
\ 'WarningSign': '●'
\ }
\}
let g:HicusLineMode = {
\ 'n': [ '', 'normalmode', { 'infos': 'normalinfos', }, ],
\ 'i': [ '', 'insertmode', { 'infos': 'otherinfos', }, ],
\ 'R': [ '', 'replacemode', { 'infos': 'otherinfos', }, ],
\ 'v': [ '', 'visualmode', { 'infos': 'otherinfos', }, ],
\ 'V': [ '', 'visualmode', { 'infos': 'otherinfos', }, ],
\ "\<C-v>": [ '', 'visualmode', { 'infos': 'otherinfos', }, ],
\ 'c': [ '', 'commandmode', { 'infos': 'otherinfos', }, ],
\ 's': [ '', 'normalmode', { 'infos': 'normalinfos', }, ],
\ 'S': [ '', 'normalmode', { 'infos': 'normalinfos', }, ],
\ "\<C-s>": [ '', 'normalmode', { 'infos': 'normalinfos', }, ],
\ 't': [ '', 'normalmode', { 'infos': 'normalinfos', }, ]
\}
let g:HicusColor = {
\ 'StatusLine': [ 'none', '#8BE9FD', '#44475A', ],
\ 'normalmode': [ 'bold', '#282A36', '#BD93F9', ],
\ 'insertmode': [ 'bold', '#282A36', '#50FA7B', ],
\ 'visualmode': [ 'bold', '#282A36', '#FFB86C', ],
\ 'replacemode': [ 'bold', '#282A36', '#FF5555', ],
\ 'commandmode': [ 'bold', '#C6C6C6', '#3A81C3', ],
\ 'normalinfos': [ 'none', '#FFFFFF', '#6272A4', ],
\ 'otherinfos': [ 'none', '#44475A', '#8BE9FD', ],
\ 'ErrorStatus': [ 'none', '#FF0033', '#44475A', ],
\ 'WarningStatus': [ 'none', '#FFCC00', '#44475A', ],
\ 'HicusBuffer': [ 'none', '#FFFFFF', '#44475A', ],
\ 'HicusCurrentBuffer': [ 'bold', '#FFFFFF', 'none', ]
\}
" vim-multiple-cursors
let g:multi_cursor_use_default_mapping = 0
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<A-n>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
" emmet
let g:user_emmet_mode = 'i'
let g:user_emmet_leader_key = '<C-r>'
" Rnvimr
nnoremap <silent> <leader>Rt :RnvimrToggle<CR>
let g:rnvimr_layout = { 'relative': 'editor',
\ 'width': float2nr(round(0.95 * &columns)),
\ 'height': float2nr(round(0.95 * &lines)),
\ 'col': float2nr(round(0.03 * &columns)),
\ 'row': float2nr(round(0.03 * &lines)),
\ 'style': 'minimal', }
" vim-bookmarks
let g:bookmark_no_default_key_mappings = 1
let g:bookmark_no_default_key_mappings = 1
let g:bookmark_sign = '>>'
let g:bookmark_annotation_sign = '##'
let g:bookmark_save_per_working_dir = 0
let g:bookmark_auto_save_file = $HOME.'/.config/nvim/.vim-bookmarks'
nmap <leader>mm <Plug>BookmarkToggle
nmap <leader>mi <Plug>BookmarkAnnotate
nmap <leader>ma <Plug>BookmarkShowAll
nmap <leader>mn <Plug>BookmarkNext
nmap <leader>mp <Plug>BookmarkPrev
nmap <leader>mc <Plug>BookmarkClear
nmap <leader>mx <Plug>BookmarkClearAll
nmap <Leader>mP <Plug>BookmarkMoveUp
nmap <Leader>mN <Plug>BookmarkMoveDown
nmap <Leader>mt <Plug>BookmarkMoveToLine
" Illuminate
let g:Illuminate_delay = 750
hi illuminatedWord cterm=undercurl gui=undercurl
" Terslation.vim
let g:TerslationFloatWin = 1
nnoremap <silent><leader>tp "tp
nnoremap <silent><leader>ts :TerslationToggle<CR>
nnoremap <silent><leader>tws :TerslationWordTrans<CR>
vnoremap <silent><leader>tws :TerslationSelectTrans<CR>
" suda.vim
nnoremap sw :w sudo://%<CR>
let g:suda#prefix = 'sudo://'
" NerdCommenter
let g:NERDSpaceDelims = 1
" Goyo
nnoremap <silent> <leader>gy :Goyo 93%x95%<CR>
nnoremap <silent> <leader>go :Goyo!<CR>:call ReloadHighlight(2)<CR>
" vim-hexokinase
nnoremap <silent> <leader>ht :HexokinaseToggle<CR>
let g:Hexokinase_highlighters = [ 'virtual' ]
let g:Hexokinase_ftEnabled = [ 'css', 'html', 'javascript' ]
" vim-calendar
nnoremap <silent> <leader>vc :Calendar<CR>
augroup calendar-mappings
autocmd!
autocmd FileType calendar nmap <buffer> u <Plug>(calendar_up)
autocmd FileType calendar nmap <buffer> n <Plug>(calendar_left)
autocmd FileType calendar nmap <buffer> e <Plug>(calendar_down)
autocmd FileType calendar nmap <buffer> i <Plug>(calendar_right)
autocmd FileType calendar nmap <buffer> <c-u> <Plug>(calendar_move_up)
autocmd FileType calendar nmap <buffer> <c-n> <Plug>(calendar_move_left)
autocmd FileType calendar nmap <buffer> <c-e> <Plug>(calendar_move_down)
autocmd FileType calendar nmap <buffer> <c-i> <Plug>(calendar_move_right)
autocmd FileType calendar nmap <buffer> h <Plug>(calendar_start_insert)
autocmd FileType calendar nmap <buffer> H <Plug>(calendar_start_insert_head)
augroup END
" vim-gitgutter
nnoremap <silent> g- :GitGutterPrevHunk<CR>
nnoremap <silent> g= :GitGutterNextHunk<CR>
let g:gitgutter_signs = 0
let g:gitgutter_map_keys = 0
let g:gitgutter_override_sign_column_highlight = 0
" vim-focus
vnoremap <silent> <leader>vf :FocusStart<CR>
nnoremap <silent> <leader>vs :FocusConvert<CR>
nnoremap <silent> <leader>vS :FocusSave<CR>
let g:VimFocusOpenWay = 'buffer'
" -- ------
" -- ------ Extension funcitons
" -- ------
function! TermSet()
setlocal splitbelow
split
endfunction
function! TestCodes(type) " By the filetype to run the code.
exec "w"
if &filetype == 'html'
exec "!google-chrome-stable ./% &"
elseif &filetype == 'php'
exec a:type == 0 ? "!php -S 127.0.0.1:8080 -t ./ &" : "killall php"
exec a:type == 0 ? "!google-chrome-stable 127.0.0.1:8080 &" : ""
elseif &filetype == 'sh'
call TermSet()
terminal sh ./%
elseif &filetype == 'python'
call TermSet()
terminal python3 ./%
elseif &filetype == 'c'
call TermSet()
terminal gcc -std=c11 % -o /tmp/%<.o; /tmp/%<.o
elseif &filetype == 'markdown'
exec a:type == 0 ? "MarkdownPreview" : "MarkdownPreviewStop"
elseif &filetype == 'go'
call TermSet()
terminal go run ./%
elseif &filetype == 'javascript'
call TermSet()
terminal node ./%
endif
endfunction
function! BackgroudColor(option) " Get the .backColor to set backgroud color
execute a:option != 1 && a:option != 2 ? "return" : ""
if empty(glob($HOME.'/.config/nvim/.backColor'))
call system('touch '.$HOME.'/.config/nvim/.backColor')
call writefile([ '1' ], $HOME.'/.config/nvim/.backColor')
endif
if a:option == 2
if readfile($HOME.'/.config/nvim/.backColor')[0] == '1'
hi Normal ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#2C323B
else
hi Normal ctermfg=223 ctermbg=None guifg=#ebdbb2 guibg=None
endif
else
let l:currentColor = str2nr(readfile($HOME.'/.config/nvim/.backColor')[0])
execute l:currentColor == 1 ?
\ "hi Normal ctermfg=223 ctermbg=None guifg=#ebdbb2 guibg=None"
\ : l:currentColor == 0 ?
\ "hi Normal ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#2C323B" : ""
call writefile(
\ l:currentColor == 0 ? [ '1' ] : [ '0' ],
\ $HOME.'/.config/nvim/.backColor')
unlet l:currentColor
endif
endfunction
function! ReloadHighlight(type)
exec a:type != 0 ? "HicusSyntaxReload" : ""
exec a:type != 0 && &filetype == 'ntc' ? "NtcHighlightReload" : ""
endfunction
function! FloatTerm(type, ...) " Float Terminal
execute exists('g:FloatTermBuf') && a:type == 0 ? "silent bd! ".g:FloatBorder.
\ " " . g:FloatTermBuf. " | unlet g:FloatTermBuf g:EditingBuf".
\ " g:FloatWindowNum g:FloatBorder g:FloatBorderWin | return" : ""
execute a:type == 2 ? g:EditingBuf . "wincmd w | return" : a:type == 3 ?
\ g:FloatTermBuf . "wincmd w | return" : ""
let g:FloatTermBuf = nvim_create_buf(v:false, v:true)
let g:FloatBorder = nvim_create_buf(v:false, v:true)
let g:EditingBuf = bufnr('%')
let l:opt = { 'relative': 'win', 'width': float2nr(round(
\ a:type == 1 ? 0.45 * &columns : 0.95 * &columns)),
\ 'height': float2nr(round(a:type == 1 ? 0.45 * &lines : 0.95 * &lines)),
\ 'col': float2nr(round(a:type == 1 ? &columns : 0.02 * &columns)),
\ 'row': float2nr(round(a:type == 1 ? 0.01 * &lines : 0.02 * &lines)),
\ 'anchor': 'NW',
\ 'style': 'minimal'
\ }
let l:top = "┌" . repeat("─", l:opt.width - 2) . "┐"
let l:mid = "│" . repeat(" ", l:opt.width - 2) . "│"
let l:bot = "└" . repeat("─", l:opt.width - 2) . "┘"
let l:lines = [ l:top ] + repeat([ l:mid ], l:opt.height - 2 ) + [ l:bot ]
unlet l:top l:mid l:bot
let g:FloatBorderWin = nvim_open_win(g:FloatBorder, v:true, l:opt)
call nvim_win_set_option(g:FloatBorderWin, 'winhl', 'Normal:Normal')
call nvim_buf_set_lines(g:FloatBorder, 0, -1, v:true, l:lines)
let l:opt.row += 1
let l:opt.col = a:type == 1 ? float2nr(round(0.56 * &columns)) : l:opt.col + 1
let l:opt.height -= 2
let l:opt.width -= 2
let g:FloatWindowNum = nvim_open_win(g:FloatTermBuf, v:true, l:opt)
call nvim_win_set_option(g:FloatWindowNum, 'number', v:false)
call nvim_win_set_option(g:FloatWindowNum, 'relativenumber', v:false)
call nvim_win_set_option(g:FloatWindowNum, 'winhl', 'Normal:Normal')
call nvim_buf_set_option(g:FloatTermBuf, 'buftype', 'nofile')
execute empty(a:000) ? "terminal" : "terminal " . a:1
unlet l:lines l:opt
endfunction
function! TermConvert() " Convert the FloatTerminal's window
let l:currentStatus = get(nvim_win_get_config(g:FloatBorderWin), 'row', 1)
let l:opt = { 'relative': 'win', 'width': float2nr(round(
\ l:currentStatus != 0.0 ? 0.45 * &columns : 0.95 * &columns)),
\ 'height': float2nr(round(l:currentStatus != 0.0 ?
\ 0.45 * &lines : 0.95 * &lines)),
\ 'col': float2nr(round(l:currentStatus != 0.0 ?
\ &columns : 0.02 * &columns)),
\ 'row': float2nr(round(l:currentStatus != 0.0 ?
\ 0.01 * &lines : 0.02 * &lines)),
\ 'anchor': 'NW',
\ 'style': 'minimal'
\ }
let l:top = "┌" . repeat("─", l:opt.width - 2) . "┐"
let l:mid = "│" . repeat(" ", l:opt.width - 2) . "│"
let l:bot = "└" . repeat("─", l:opt.width - 2) . "┘"
let l:lines = [ l:top ] + repeat([ l:mid ], l:opt.height - 2 ) + [ l:bot ]
unlet l:top l:mid l:bot
call nvim_buf_set_lines(g:FloatBorder, 0, -1, v:true, l:lines)
call nvim_win_set_config(g:FloatBorderWin, l:opt)
let l:opt.row += 1
let l:opt.col = l:currentStatus == 0.0 ? l:opt.col + 1 :
\ float2nr(round(0.56 * &columns))
let l:opt.height -= 2
let l:opt.width -= 2
call nvim_win_set_config(g:FloatWindowNum, l:opt)
unlet l:currentStatus l:opt l:lines
endfunction
function! BDeleteBuf() " BDelete the current buffer
if &modified == 1
let l:result = input('Now the buffer is modified, do you want to continue?')
if l:result == 'y' || l:result == ''
execute "bd!"
endif
unlet l:result
else
execute "bd"
endif
endfunction
" Run codes
nnoremap <silent> <leader>r :call TestCodes(0)<CR>
nnoremap <silent> <leader>sr :call TestCodes(1)<CR>
" Float Terminal
nnoremap <silent> <leader>Ft :call FloatTerm(0)<CR>
nnoremap <silent> <leader>Fs :call FloatTerm(1)<CR>
nnoremap <silent> <leader>FB :call FloatTerm(3)<CR>:startinsert<CR>
tnoremap <silent> <M-b> <C-\><C-n>:call FloatTerm(2)<CR>
tnoremap <silent> <C-q> <C-\><C-n>:call FloatTerm(0)<CR>
tnoremap <silent> <M-a> <C-\><C-n>:call TermConvert()<CR>:startinsert<CR>
" Float Ranger
nnoremap <silent> <leader>Rt :call FloatTerm(0, "ranger")<CR>
" Clear the buffers without the current buffer
nnoremap <silent> co :only<CR>
" Open the lazygit
nnoremap <silent> <C-l> :tabe<CR>:-tabmove<CR>:setlocal nonumber norelativenumber<CR>:term lazygit<CR>
" Set the background color
call BackgroudColor(2)
" Debug
" set runtimepath+=~/Github/HicusLine
" set runtimepath+=~/Github/Terslation.vim
" set runtimepath+=~/Github/NoToC.vim
" set runtimepath+=~/Github/vim-focus
" let g:NoToCCache = $HOME.'/.cache/NoToC.vim/'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
VimL
1
https://gitee.com/springhan/nvim.git
git@gitee.com:springhan/nvim.git
springhan
nvim
nvim
master

搜索帮助