Skip to content

Instantly share code, notes, and snippets.

@findstr
Created September 15, 2022 05:53
Show Gist options
  • Save findstr/6b62b432d0c97f3cf8442b2635f59e9a to your computer and use it in GitHub Desktop.
Save findstr/6b62b432d0c97f3cf8442b2635f59e9a to your computer and use it in GitHub Desktop.
set nu
set fenc=utf-8
set enc=utf-8
set nocompatible
set mouse=a
set backspace=indent,eol,start
set softtabstop=8
set shiftwidth=8
set noexpandtab
set linebreak
set hlsearch
set history=200
set foldenable
set foldcolumn=2
set foldlevel=8
set cindent
set smartindent
set incsearch
set autoindent
set cinoptions=:0
set showmatch
set autoread
set smarttab
set guioptions-=T
let &termencoding=&encoding
let g:mapleader = "\\"
set guifont=DejaVu\ Sans\ Mono\ 12
set fileencodings=utf-8,chinese,gb18030,gbk,gb2312,cp936
colo desert
nnoremap <esc>^[ <esc>^[
call plug#begin('~/.vim/plugged')
filetype on
Plug 'vim-scripts/a.vim'
Plug 'vim-scripts/taglist.vim'
Plug 'mhinz/vim-signify'
Plug 'ludovicchabant/vim-gutentags'
Plug 'w0rp/ale'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'romainl/vim-qf'
Plug 'skywind3000/vim-preview'
Plug 'Shougo/echodoc.vim'
Plug 'skywind3000/gutentags_plus'
Plug 'vim-scripts/taglist.vim'
call plug#end()
"----------gutentags
" pip install pygments
let $GTAGSLABEL = 'native-pygments'
let $GTAGSCONF = '/usr/local/share/gtags/gtags.conf'
let g:gutentags_project_root = ['.root', '.git', '.hg', '.project']
let g:gutentags_ctags_tagfile = '.tags'
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
let g:gutentags_modules = ['ctags', 'gtags_cscope']
let g:gutentags_plus_switch = 1
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
let g:gutentags_define_advanced_commands = 1
let g:gutentags_plus_nomap = 1
noremap <silent> <leader>s :GscopeFind s <C-R><C-W><cr>
noremap <silent> <leader>g :GscopeFind g <C-R><C-W><cr>
noremap <silent> <leader>d :GscopeFind d <C-R><C-W><cr>
noremap <silent> <leader>c :GscopeFind c <C-R><C-W><cr>
noremap <silent> <leader>t :GscopeFind t <C-R><C-W><cr>
noremap <silent> <leader>e :GscopeFind e <C-R><C-W><cr>
noremap <silent> <leader>f :GscopeFind f <C-R>=expand("<cfile>")<cr><cr>
noremap <silent> <leader>i :GscopeFind i <C-R>=expand("<cfile>")<cr><cr>
noremap <silent> <leader>a :GscopeFind a <C-R><C-W><cr>
"----------signify
" let g:signify_realtime = 1
let g:signify_vcs_list = ['git', 'svn']
let g:signify_sign_add = '+'
let g:signify_sign_delete = '_'
let g:signify_sign_delete_first_line = '‾'
let g:signify_sign_change = '~'
let g:signify_sign_changedelete = g:signify_sign_change
" git 仓库使用 histogram 算法进行 diff
let g:signify_vcs_cmds = {
\ 'git': 'git diff --no-color --diff-algorithm=histogram --no-ext-diff -U0 -- %f',
\}
"-----------ale
let g:ale_sign_column_always = 1
let g:ale_linters_explicit = 1
let g:ale_linters = {
\ 'csh': ['shell'],
\ 'zsh': ['shell'],
\ 'go': ['gofmt', 'golint'],
\ 'python': ['flake8', 'mypy', 'pylint'],
\ 'c': ['gcc'],
\ 'cpp': ['g++'],
\ 'text': [],
\}
let g:ale_completion_delay = 500
let g:ale_lint_on_save = 1
let g:ale_echo_delay = 20
let g:ale_lint_delay = 500
let g:ale_echo_msg_format = '[%linter%] %code: %%s'
let g:ale_lint_on_text_changed = 'normal'
let g:ale_lint_on_insert_leave = 1
let g:airline#extensions#ale#enabled = 1
let g:ale_c_gcc_options = '-Wall -O2 -std=c99'
let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14'
let g:ale_c_cppcheck_options = ''
let g:ale_cpp_cppcheck_options = ''
let g:ale_sign_error = "\ue009\ue009"
hi! clear SpellBad
hi! clear SpellCap
hi! clear SpellRare
hi! SpellBad gui=undercurl guisp=red
hi! SpellCap gui=undercurl guisp=blue
hi! SpellRare gui=undercurl guisp=magenta
"------------LeaderF
noremap M :LeaderfMru<cr>
noremap <leader>lf :LeaderfFunction!<cr>
noremap <leader>lb :LeaderfBuffer<cr>
noremap <leader>lt :LeaderfTag<cr>
let g:Lf_StlSeparator = { 'left': '', 'right': '', 'font': '' }
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.30
let g:Lf_CacheDirectory = expand('~/.vim/cache')
let g:Lf_ShowRelativePath = 0
let g:Lf_HideHelp = 1
let g:Lf_StlColorscheme = 'powerline'
let g:Lf_PreviewResult = {'Function':0, 'BufTag':0}
"-----------airline
let g:airline_theme="simple"
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_left_sep='>'
let g:airline_right_sep='<'
"------------echo doc
let g:echodoc#enable_at_startup = 1
set cmdheight=2
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
"------------Taglist
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
let Tlist_Auto_Open=1
let Tlist_Use_Right_Window = 1
let Tlist_Process_File_Always=1
"-----------basic config
"设置缩进
"绑定复制到系统剪贴板快捷键
syntax on
nnoremap F gd <C-O>
vmap <leader>c "+y
nmap <leader>c "+y
vmap <leader>v <ESC>"+p
nmap <leader>v "+p
nmap <ESC> :ccl<cr>
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
set cc=81
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
"读入python文件,设置缩进格式
autocmd BufNewFile,BufRead *.py set cinwords=if,elif,else,for,while,try,expect,finally,def,class
"读入其它文件,设置折叠方式为indent
autocmd BufNewFile,BufRead *.* set foldmethod=indent
autocmd BufWritePre * :call StripTailWhitespaces()
autocmd BufWritePost * :TlistUpdate
autocmd InsertLeave * write
"-----------all function
func StripTailWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment