Skip to content

Instantly share code, notes, and snippets.

@viclm
Last active July 3, 2024 05:55
Show Gist options
  • Save viclm/7a7e7a3b8895fae36b9c1f64acd60a09 to your computer and use it in GitHub Desktop.
Save viclm/7a7e7a3b8895fae36b9c1f64acd60a09 to your computer and use it in GitHub Desktop.
" vim-plug
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" :PlugInstall :PlugUpdate :PlugClean :PlugUpgrade
let &pythonthreedll = '/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib'
call plug#begin()
Plug 'joshdick/onedark.vim'
Plug 'scrooloose/nerdtree'
Plug 'ap/vim-buftabline'
Plug 'itchyny/lightline.vim'
Plug 'itchyny/vim-gitbranch'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-commentary'
Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'chemzqm/wxapp.vim'
Plug 'leafOfTree/vim-vue-plugin'
call plug#end()
" onedark.vim
syntax enable
colorscheme onedark
" buftabline
nnoremap <S-Left> :bprev<CR>
nnoremap <S-Right> :bnext<CR>
nnoremap <S-Backspace> :bdelete<CR>
" lightline with gitbranch
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name'
\ },
\ }
" nerdtree
let NERDTreeShowHidden=1
let NERDTreeIgnore=['\.swp$', '\~$']
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | wincmd w | endif
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
nnoremap <S-N> :NERDTree<CR>
" LeaderF
let g:Lf_CommandMap = {'<C-K>': ['<Up>'], '<C-J>': ['<Down>'], '<Up>': ['<Left>'], '<Down>': ['<Right>']}
"nnoremap <S-P> :LeaderfFile<CR>
nnoremap <S-P> :call OpenFileAndExpandNERDTree()<CR>
function! OpenFileAndExpandNERDTree()
" 执行 LeaderfFile 命令
execute 'LeaderfFile'
" 切换到 Leaderf buffer
for buf in filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype", "") ==# "leaderf"')
execute 'b ' . buf
break
endfor
" 获取 Leaderf 中选定的路径
let selected_path = getbufvar(bufnr('%'), 'lf_selection_path', '')
" 切换到 NERDTree buffer,并展开选定的路径
execute 'NERDTreeFind ' . selected_path
endfunction
" prettier
let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
" coc
let g:coc_global_extensions = ['coc-tabnine', 'coc-tsserver'] "
" Use tab for trigger completion with characters ahead and navigate
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
nnoremap <S-C> :CocCommand<CR>
nnoremap <S-T> :CocCommand tsserver.restart<CR>
set nobackup
set tags=tags;/
set hidden
set number
set nowrap
set smarttab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
autocmd FileType typescript setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
autocmd FileType vue setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
set list
set listchars=tab:>-,trail:-
set ic
set hls is
set nobomb
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set termencoding=utf-8
set fileformats=unix,dos
set macligatures
set guifont=Fira\ Code:h14
set guioptions-=l
set guioptions-=r
set guioptions-=L
set guioptions-=R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment