Last active
November 23, 2021 06:16
-
-
Save NNBnh/a7b6c48d49f76e612fff5fb269d6d74b to your computer and use it in GitHub Desktop.
My last Neovim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
" █ █ ███ | |
" █ █ ███ | |
" █ █ ████ | |
" █ █ ████ | |
" | |
" File: init.vim | |
" Description: Vim config that SuperB | |
" Author: NNB | |
" └─ https://github.com/NNBnh | |
" Plugins {{{ | |
" Load plug-ins | |
call plug#begin('~/.local/share/nvim/plugged') | |
" Stander settings | |
Plug 'editorconfig/editorconfig-vim' "Editor-Config | |
Plug 'tpope/vim-sensible' "Defaults everyone can agree on | |
" UI | |
Plug 'srcery-colors/srcery-vim' "Color-scheme | |
Plug 'vim-airline/vim-airline' "Status-line | |
Plug 'RRethy/vim-hexokinase' "Color hex codes | |
Plug 'google/vim-searchindex' "Number in search | |
Plug 'iamcco/markdown-preview.nvim', | |
\ { 'do': { -> mkdp#util#install() } } "Markdown | |
Plug 'airblade/vim-gitgutter' "Git | |
" Functions | |
Plug 'justinmk/vim-sneak' "Add more motions | |
Plug 'preservim/nerdcommenter' "Comments | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} "Completion | |
Plug 'ryanoasis/vim-devicons' "Icon | |
call plug#end() | |
source $HOME/Datas/Documents/bkey-vim/plugin/bkey.vim | |
" }}} | |
" Simple {{{ | |
" Set color-scheme | |
set termguicolors | |
let g:srcery_transparent_background = 1 | |
let g:srcery_italic = 1 | |
"let g:srcery_inverse = 0 | |
colorscheme srcery | |
" Set the windows title | |
set title titlestring=%F\ -\ Vim | |
" Turn on the line numbers | |
set number relativenumber | |
" No line wrap | |
set nowrap | |
" When searching try to be smart about cases | |
set ignorecase smartcase | |
" Highlight current line | |
"set cursorline | |
" Status line | |
autocmd VimEnter * set laststatus=0 | |
set rulerformat=%l:%v\ \/\ %L | |
let g:airline#extensions#default#layout = [ | |
\ [ 'a', 'b', 'c' ], | |
\ [ 'x', 'error', 'warning', 'z' ] | |
\ ] | |
let g:airline_section_z = '%l:%v / %L' | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" Color hex codes | |
let g:Hexokinase_highlighters = ['backgroundfull'] | |
let g:Hexokinase_optInPatterns = [ | |
\ 'full_hex', | |
\ 'triple_hex', | |
\ 'rgb', | |
\ 'rgba', | |
\ 'hsl', | |
\ 'hsla' | |
\ ] | |
" Config-Editor | |
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] | |
" }}} | |
" Movements {{{ | |
" Quick jump | |
let g:sneak#label = 1 | |
let g:sneak#target_labels = "kdjfielsmcnvow;aurtbypq,x.z;KDJFIELSMCNVOW:AURTBYPQ<X>Z:9302841756(#)@*$!&%^" | |
map g<Space> <Plug>Sneak_s | |
map g<S-Space> <Plug>Sneak_S | |
map g<Insert> <Plug>Sneak_S | |
map g<CR> <Plug>Sneak_f | |
map g<S-CR> <Plug>Sneak_F | |
map g<C-Insert> <Plug>Sneak_F | |
map { <Plug>Sneak_, | |
map } <Plug>Sneak_; | |
" Comments | |
map " <plug>NERDCommenterToggle | |
" }}} | |
" Code {{{ | |
" Completion {{{ | |
" Setting {{{ | |
set hidden | |
set updatetime=300 | |
set shortmess+=c | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
augroup cocgroup | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
"python.jediEnabled": false | |
" }}} | |
" Command {{{ | |
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') | |
" }}} | |
" Function {{{ | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" }}} | |
" Key-binding {{{ | |
" Industry {{{ | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
inoremap <silent><expr> <c-space> coc#refresh() | |
if exists('*complete_info') | |
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
else | |
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
endif | |
" }}} | |
" Bkey {{{ | |
nnoremap <silent> <F1> :call <SID>show_documentation()<CR> | |
nmap <F2> <Plug>(coc-rename) | |
nmap <silent> <C-Space> <Plug>(coc-range-select) | |
xmap <silent> <C-Space> <Plug>(coc-range-select) | |
noremap / <Nop> | |
nmap // <Plug>(coc-fix-current) | |
xmap /d <Plug>(coc-codeaction-selected) | |
nmap /d <Plug>(coc-codeaction-selected) | |
nmap /D <Plug>(coc-codeaction) | |
xmap af <Plug>(coc-funcobj-i) | |
omap af <Plug>(coc-funcobj-i) | |
xmap Af <Plug>(coc-funcobj-a) | |
omap Af <Plug>(coc-funcobj-a) | |
nnoremap <silent> y; :<C-u>CocList<Space> | |
nmap <silent> g/d <Plug>(coc-definition) | |
nmap <silent> g/y <Plug>(coc-type-definition) | |
nmap <silent> g/i <Plug>(coc-implementation) | |
nmap <silent> g/r <Plug>(coc-references) | |
nmap <silent> [/ <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]/ <Plug>(coc-diagnostic-next) | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
" }}} | |
" }}} | |
" }}} | |
" Git {{{ | |
let g:gitgutter_enabled = 0 | |
" Key-binding {{{ | |
let g:gitgutter_map_keys = 0 | |
omap aw <Plug>(GitGutterTextObjectInnerPending) | |
omap Aw <Plug>(GitGutterTextObjectOuterPending) | |
xmap aw <Plug>(GitGutterTextObjectInnerVisual) | |
xmap Aw <Plug>(GitGutterTextObjectOuterVisual) | |
nmap [w <Plug>(GitGutterPrevHunk) | |
nmap ]w <Plug>(GitGutterNextHunk) | |
nmap /w <Plug>(GitGutterStageHunk) | |
nmap /z <Plug>(GitGutterUndoHunk) | |
noremap <Bslash>w :GitGutterBufferToggle<CR> | |
noremap <Bslash>W :GitGutterToggle<CR> | |
noremap 'w :GitGutterFold<CR> | |
noremap <Leader>w :GitGutterBufferToggle<CR> | |
noremap <Leader>W :GitGutterToggle<CR> | |
" }}} | |
" }}} | |
" Markdown {{{ | |
let g:mkdp_auto_start = 0 | |
let g:mkdp_auto_close = 0 | |
let g:mkdp_refresh_slow = 1 | |
let g:mkdp_command_for_global = 0 | |
let g:mkdp_open_to_the_world = 0 | |
let g:mkdp_open_ip = '' | |
let g:mkdp_browser = '' | |
let g:mkdp_echo_preview_url = 1 | |
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': {}, | |
\ 'flowchart_diagrams': {} | |
\ } | |
let g:mkdp_markdown_css = '' | |
let g:mkdp_highlight_css = '' | |
let g:mkdp_port = '' | |
let g:mkdp_page_title = '${name}' | |
" }}} | |
" }}} | |
" Application {{{ | |
" Set to auto read when a file is changed from the outside | |
au FocusGained,BufEnter * checktime | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" set fold method to manual | |
set foldmethod=manual | |
" Better splitting windows | |
set splitbelow splitright | |
" Turn backup off | |
set nobackup nowritebackup | |
" Display a confirmation dialog when closing an unsaved file | |
set confirm | |
" }}} | |
" vim: set fdm=marker : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment