Add '.vimrc'
parent
a3674eec84
commit
b7741c48b8
|
@ -0,0 +1,222 @@
|
|||
set cursorline
|
||||
set wildmenu
|
||||
set incsearch
|
||||
set hlsearch
|
||||
set nu rnu
|
||||
set tabstop=4
|
||||
set softtabstop=4
|
||||
set shiftwidth=4
|
||||
set autoindent
|
||||
set textwidth=80
|
||||
set noshowmode
|
||||
set expandtab
|
||||
syntax on
|
||||
set nocompatible
|
||||
let mapleader=" "
|
||||
filetype off
|
||||
|
||||
set path+=/usr/include/nodejs/src/
|
||||
|
||||
if isdirectory('/usr/local/lib/node_modules/node-addon-api')
|
||||
set path+=/usr/local/lib/node_modules/node-addon-api
|
||||
endif
|
||||
if isdirectory('~/.cache/node-gyp/17.0.1/include/node')
|
||||
set path+=~/.cache/node-gyp/17.0.1/include/node
|
||||
endif
|
||||
|
||||
set rtp+=~/.vim/bundle/Vundle.vim
|
||||
call vundle#begin()
|
||||
|
||||
Plugin 'VundleVim/Vundle.vim'
|
||||
Plugin 'preservim/nerdtree'
|
||||
Plugin 'joshdick/onedark.vim'
|
||||
Plugin 'w0rp/ale'
|
||||
Plugin 'neoclide/coc.nvim'
|
||||
Plugin 'tiagofumo/vim-nerdtree-syntax-highlight'
|
||||
Plugin 'ryanoasis/vim-devicons'
|
||||
Plugin 'airblade/vim-gitgutter'
|
||||
Plugin 'ctrlpvim/ctrlp.vim'
|
||||
Plugin 'preservim/nerdcommenter'
|
||||
Plugin 'HerringtonDarkholme/yats.vim'
|
||||
Plugin 'mhinz/vim-startify'
|
||||
Plugin 'Valloric/YouCompleteMe'
|
||||
Plugin 'sbdchd/neoformat'
|
||||
Plugin 'Raimondi/delimitMate'
|
||||
Plugin 'itchyny/lightline.vim'
|
||||
Plugin 'github/copilot.vim'
|
||||
" Plugin 'vim-syntastic/syntastic'
|
||||
|
||||
call vundle#end()
|
||||
|
||||
filetype plugin indent on
|
||||
|
||||
" Opens NERDTree when a directory is opened
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
|
||||
|
||||
" Exit NERDTree if all files have closed
|
||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||
|
||||
" Check if NERDTree is open or active
|
||||
function! IsNERDTreeOpen()
|
||||
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
|
||||
endfunction
|
||||
|
||||
" Call NERDTreeFind if NERDTree is active, current window contains a modifiable
|
||||
" file and we're not in vimdiff
|
||||
function! SyncTree()
|
||||
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
|
||||
NERDTreeFind
|
||||
wincmd p
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let g:coc_global_extensions = [
|
||||
\ 'coc-snippets',
|
||||
\ 'coc-pairs',
|
||||
\ 'coc-tsserver',
|
||||
\ 'coc-eslint',
|
||||
\ 'coc-prettier',
|
||||
\ 'coc-json',
|
||||
\ ]
|
||||
|
||||
set hidden
|
||||
set updatetime=300
|
||||
set signcolumn=yes
|
||||
|
||||
let g:NERDTreeGitStatusWithFlags = 1
|
||||
let g:NERDTreeIgnore = ['^node_modules$']
|
||||
" Create default mappings
|
||||
let g:NERDCreateDefaultMappings = 1
|
||||
|
||||
" Add spaces after comment delimiters by default
|
||||
let g:NERDSpaceDelims = 1
|
||||
|
||||
" Use compact syntax for prettified multi-line comments
|
||||
let g:NERDCompactSexyComs = 1
|
||||
|
||||
" Align line-wise comment delimiters flush left instead of following code indentation
|
||||
let g:NERDDefaultAlign = 'left'
|
||||
|
||||
" Set a language to use its alternate delimiters by default
|
||||
let g:NERDAltDelims_java = 1
|
||||
|
||||
" Add your own custom formats or override the defaults
|
||||
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
|
||||
|
||||
" Allow commenting and inverting empty lines (useful when commenting a region)
|
||||
let g:NERDCommentEmptyLines = 1
|
||||
|
||||
" Enable trimming of trailing whitespace when uncommenting
|
||||
let g:NERDTrimTrailingWhitespace = 1
|
||||
|
||||
" Enable NERDCommenterToggle to check all selected lines is commented or not
|
||||
let g:NERDToggleCheckAllLines = 1
|
||||
|
||||
command! -nargs=0 Prettier :CocCommand prettier.formatFile
|
||||
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
|
||||
|
||||
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
|
||||
|
||||
" Autoformat with clang-format
|
||||
function! FormatOnSave()
|
||||
let l:formatdiff = 1
|
||||
pyf ~/.local/bin/clang-format.py
|
||||
endfunction
|
||||
autocmd BufWritePre *.h,*.cc,*.cpp,*.c call FormatOnSave()
|
||||
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
autocmd BufWritePre,InsertLeave *.js Neoformat
|
||||
augroup mygroup
|
||||
autocmd!
|
||||
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
||||
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
augroup end
|
||||
|
||||
au BufNewFile,BufRead *.ejs set filetype=html
|
||||
|
||||
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')
|
||||
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
||||
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||
xmap <leader>f <Plug>(coc-format-selected)
|
||||
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
xmap if <Plug>(coc-funcobj-i)
|
||||
xmap af <Plug>(coc-funcobj-o)
|
||||
xmap <silent> <C-d> <Plug>(coc-range-select)
|
||||
omap if <Plug>(coc-funcobj-i)
|
||||
omap af <Plug>(coc-funcobj-o)
|
||||
nmap <silent> <C-d> <Plug>(coc-range-select)
|
||||
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
nmap <leader>f <Plug>(coc-format-selected)
|
||||
nmap <F2> <Plug>(coc-rename)
|
||||
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 <leader>ac <Plug>(coc-codeaction)
|
||||
nmap <leader>qf <Plug>(coc-fix-current)
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
|
||||
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
|
||||
map <C-n> :NERDTreeToggle<CR>
|
||||
inoremap jk <ESC>
|
||||
vmap <C-m> <Plug>NERDCommenterToggle
|
||||
nmap <C-m> <Plug>NERDCommenterToggle
|
||||
nnoremap <C-h> <C-w><C-h>
|
||||
nnoremap <C-j> <C-w><C-j>
|
||||
nnoremap <C-k> <C-w><C-k>
|
||||
nnoremap <C-l> <C-w><C-l>
|
||||
nnoremap ,<space> :nohlsearch<CR>
|
||||
|
||||
if (has("nvim"))
|
||||
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
|
||||
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
||||
endif
|
||||
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
|
||||
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
|
||||
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
|
||||
if (has("termguicolors"))
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
let g:onedark_hide_endofbuffer = 1
|
||||
let g:onedark_termcolors = 256
|
||||
let g:onedark_terminal_italics = 1
|
||||
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'onedark',
|
||||
\ }
|
||||
|
||||
" Python tab fix
|
||||
function! s:fixtab()
|
||||
set expandtab
|
||||
set tabstop=4
|
||||
retab
|
||||
endfunction
|
||||
|
||||
command FixTab :call s:fixtab()
|
||||
|
||||
syntax on
|
||||
colorscheme onedark
|
Loading…
Reference in New Issue