Created
October 29, 2020 14:27
-
-
Save wsntxxn/5bbe7856a472985d82f62e1b0895ce60 to your computer and use it in GitHub Desktop.
neovim initialization file
This file contains hidden or 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
" Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
call plug#begin('~/.vim/plugged') | |
set clipboard=unnamedplus " Use system clipboard | |
set cursorline " Highlight the cursor line | |
set hlsearch | |
set incsearch | |
set ignorecase " Required for proper smartcase functionality | |
set smartcase " Case insensitive unless typing with caps | |
set cursorcolumn | |
set showcmd | |
set linebreak | |
set pastetoggle=<F2> " Toggle paste mode with F2<Paste> | |
" See N lines above | |
set scrolloff=14 | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set fileencodings=utf-8 | |
set tabstop =4 | |
set softtabstop =4 | |
set shiftwidth =4 | |
set expandtab | |
set number | |
"set completeopt=menu,preview,longest,menuone,noselect | |
set completeopt+=preview,longest | |
"set completeopt=menu,noinsert,menuone,noselect,preview | |
"autocmd CompleteDone * silent! pclose! | |
"Echodoc | |
set cmdheight=2 | |
Plug 'numirias/semshi', {'do': ':UpdateRemotePlugins'} | |
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} | |
Plug 'honza/vim-snippets' | |
Plug 'roxma/nvim-yarp' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'dhruvasagar/vim-table-mode' | |
Plug 'szymonmaszke/vimpyter' | |
Plug 'w0rp/ale' | |
Plug 'terryma/vim-multiple-cursors' | |
Plug 'vim-pandoc/vim-pandoc' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'vim-pandoc/vim-pandoc-syntax' | |
Plug 'gabrielelana/vim-markdown' | |
Plug 'scrooloose/nerdtree' | |
Plug 'junegunn/vim-easy-align' | |
Plug 'tpope/vim-fugitive' | |
Plug 'heavenshell/vim-pydocstring' | |
Plug 'lervag/vimtex' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'blueyed/vim-qf_resize' | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'ryanoasis/vim-devicons' | |
" Color viewer | |
Plug 'ap/vim-css-color' | |
" COLORS | |
Plug 'morhetz/gruvbox' | |
Plug 'dracula/vim' | |
Plug 'kaicataldo/material.vim' | |
Plug 'ayu-theme/ayu-vim' | |
Plug 'sonph/onehalf', {'rtp': 'vim/'} | |
Plug 'rakr/vim-one' | |
call plug#end() | |
let g:echodoc_enable_at_startup = 1 | |
let g:ale_completion_enabled = 1 | |
" For conceal markers. | |
setlocal conceallevel=2 | |
" " Enable true color 启用终端24位色 | |
if exists('+termguicolors') | |
" Tmux hacks | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
set t_ZH=^[[3m | |
set t_ZR=^[[23m | |
set termguicolors | |
endif | |
set background=dark | |
colorscheme dracula | |
" Select all | |
nmap <C-o> :NERDTreeToggle<CR> | |
map ; :Buffers<CR> | |
map <C-p> :Files<CR> | |
map <C-f> :Lines<CR> | |
nnoremap <C-Left> :tabprevious<CR> | |
nnoremap <C-Right> :tabnext<CR> | |
nnoremap <C-t> :tabnew<CR> | |
map <Bar> <C-W>v<C-W><Right> | |
map - <C-W>s<C-W><Down> | |
" Delte all whitespaces with F5 | |
nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR> | |
" Ale specific | |
let g:ale_fixers = ['autopep8'] | |
autocmd FileType python nmap <leader>= <Plug>(ale_fix) | |
let g:ale_sign_column_always = 1 | |
" Set this. Airline will handle the rest. | |
"let g:airline#extensions#ale#enabled = 1 | |
" Only check linting on save | |
let g:ale_lint_on_text_changed = 'normal' | |
let g:ale_lint_on_enter = 0 | |
" Start at previous closed line | |
if has("autocmd") | |
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | |
\| exe "normal! g'\"" | endif | |
endif | |
" markdown compatible table mode | |
let g:table_mode_corner='|' | |
" And pandoc/markdown , rremove conceal | |
let g:pandoc#syntax#conceal#use =1 | |
" Disable folding | |
let g:pandoc#modules#disabled = ["folding"] | |
let g:pandoc#syntax#codeblocks#embeds#langs = ["c", "python", "ruby", "bash"] | |
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/plugged/vim-snippets/UltiSnips', $HOME.'/.vim/plugged/ultisnips/'] | |
let g:ultisnips_python_style= 'google' | |
"let g:SuperTabDefaultCompletionType = '<C-n>' | |
" better key bindings for UltiSnipsExpandTrigger | |
"let g:UltiSnipsExpandTrigger="<tab>" | |
"let g:UltiSnipsJumpForwardTrigger="<tab>" | |
"let g:UltiSnipsJumpBackwardTrigger="<s-tab>" | |
" Pydocstring | |
nmap <silent> <C-_> <Plug>(pydocstring) | |
" vimtex related | |
let g:tex_flavor = 'latex' | |
" Do not show quickfix on warning | |
let g:vimtex_quickfix_open_on_warning = 0 | |
" open omni completion menu closing previous if open and opening new menu without changing the text | |
"inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') . | |
"\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>' | |
" open user completion menu closing previous if open and opening new menu without changing the text | |
"inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') . | |
"\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>' | |
nnoremap <expr> k (v:count == 0 ? 'gk' : 'k') | |
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j') | |
"Vimtex compilation | |
"let g:vimtex_view_general_viewer = 'okular' | |
let g:vimtex_compiler_latexmk = { | |
\ 'options' : [ | |
\ '-pdf', | |
\ '-bibtex', | |
\ '-pdflatex="xelatex --shell-escape %O %S"', | |
\ '-verbose', | |
\ '-file-line-error', | |
\ '-synctex=1', | |
\ '-interaction=nonstopmode', | |
\ ], | |
\ 'build_dir': 'build', | |
\} | |
let g:airline_theme='dracula' | |
let g:airline_powerline_fonts = 1 | |
" Terminal VIM | |
" ESC | |
tnoremap <Esc> <C-\><C-n> | |
" Navigate windows with alt | |
tnoremap <A-h> <C-\><C-N><C-w>h | |
tnoremap <A-j> <C-\><C-N><C-w>j | |
tnoremap <A-k> <C-\><C-N><C-w>k | |
tnoremap <A-l> <C-\><C-N><C-w>l | |
inoremap <A-h> <C-\><C-N><C-w>h | |
inoremap <A-j> <C-\><C-N><C-w>j | |
inoremap <A-k> <C-\><C-N><C-w>k | |
inoremap <A-l> <C-\><C-N><C-w>l | |
nnoremap <A-h> <C-w>h | |
nnoremap <A-j> <C-w>j | |
nnoremap <A-k> <C-w>k | |
nnoremap <A-l> <C-w>l | |
" Autoinsert on terminal mode | |
autocmd BufEnter term://* startinsert | |
" Mapping selecting mappings | |
nmap <leader><tab> <plug>(fzf-maps-n) | |
xmap <leader><tab> <plug>(fzf-maps-x) | |
omap <leader><tab> <plug>(fzf-maps-o) | |
" Insert mode completion | |
imap <c-x><c-k> <plug>(fzf-complete-word) | |
imap <c-x><c-f> <plug>(fzf-complete-path) | |
imap <c-x><c-j> <plug>(fzf-complete-file-ag) | |
imap <c-x><c-l> <plug>(fzf-complete-line) | |
" Advanced customization using autoload functions | |
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'}) | |
" COC | |
" | |
" if hidden is not set, TextEdit might fail. | |
set hidden | |
" | |
" " Some servers have issues with backup files, see #649 | |
set nobackup | |
set nowritebackup | |
" " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python | |
nmap <silent> <TAB> <Plug>(coc-range-select) | |
xmap <silent> <TAB> <Plug>(coc-range-select) | |
xmap <silent> <S-TAB> <Plug>(coc-range-select-backword) | |
" always show signcolumns | |
set signcolumn=yes | |
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : | |
"\"\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? coc#_select_confirm() : | |
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
let g:coc_snippet_next = '<tab>' | |
" Use tab for trigger completion with characters ahead and navigate. | |
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. | |
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 <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[c` and `]c` to navigate diagnostics | |
nmap <silent> [c <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]c <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
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 | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Remap for rename current word | |
nmap <leader>rn <Plug>(coc-rename) | |
" Remap for format selected region | |
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 | |
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap for do codeAction of current line | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Fix autofix problem of current line | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Enable mouse | |
set mouse=a | |
" Fold settings | |
set foldmethod=indent | |
set foldlevel=99 | |
nnoremap <space> za | |
" nerdcommenter settings | |
let mapleader="," | |
set timeout timeoutlen=1500 | |
" when the cursor stay stationery for a while, disable search highlighting | |
autocmd cursorhold * set nohlsearch | |
" when searching again, enable highlighting | |
nnoremap n :set hlsearch<cr>n | |
nnoremap N :set hlsearch<cr>N | |
nnoremap / :set hlsearch<cr>/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment