[go: nahoru, domu]

Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
邵博 committed Sep 7, 2022
0 parents commit dab0769
Show file tree
Hide file tree
Showing 25 changed files with 4,137 additions and 0 deletions.
2,804 changes: 2,804 additions & 0 deletions autoload/plug.vim

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions coc-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"languageserver": {
"golang": {
"command": "gopls",
"rootPatterns": ["go.mod", ".vim/", ".git/", ".bg"],
"filetypes": ["go"]
},
"lua": {
"command": "lua-lsp",
"filetypes": ["lua"]
},
"clangd": {
"command": "ccls",
"rootPatterns": ["compile_flags.txt", "compile_commands.json"],
"filetypes": ["c", "cpp", "objc", "objcpp"]
},
"rust": {
"command": "rust-analyzer",
"filetypes": ["rust"],
"rootPatterns": ["Cargo.toml"]
}
}
}
337 changes: 337 additions & 0 deletions init.bk
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
" 显示行号
set number
" 语法

" 高亮搜索
set hlsearch
set incsearch
" 设置折叠方式

" 设置删除模式
set backspace=2

" 设置缩进
set autoindent
set cindent

" 检测文件类型
filetype on
" 针对不同的文件类型采用不同的缩进格式
filetype indent on
" 允许插件
filetype plugin on
" 启动自动补全
filetype plugin indent on

" 设置tab
set tabstop=4
set expandtab
set shiftwidth=4
set softtabstop=4

set ruler
set showcmd

set encoding=UTF-8

" 主题
" require('github-theme').setup()
" colorscheme github_dark_colorblind

" scolloff
set scrolloff=5

" 设置 退出vim后,内容显示在终端屏幕, 可以用于查看和复制
" 好处:误删什么的,如果以前屏幕打开,可以找回
set t_ti= t_te=

" 设置行、列高亮
set cursorcolumn
set cursorline
highlight CursorLine cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
highlight CursorColumn cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE


" 代码折叠
set foldenable
set foldmethod=indent "设置根据缩进折叠代码
set foldcolumn=0 "设置折叠区域的宽度
setlocal foldlevel=1 "设置折叠层数
set foldlevelstart=99 "打开文件默认不折叠代码
" set foldclose=all 设置为自动关闭折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>


" map
inoremap jj <Esc>`^

let mapleader = ','
let g:mapleader = ','



" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
" + 插件管理 +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
call plug#begin('~/.vim/plugged')

" vim 开始界面
Plug 'mhinz/vim-startify'
" 状态栏
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" 侧边导航
Plug 'scrooloose/nerdtree' " 用来提供一个导航目录的侧边栏
Plug 'jistr/vim-nerdtree-tabs' " 可以使 nerdtree Tab 标签的名称更友好些
" git
Plug 'airblade/vim-gitgutter' " 可以在文档中显示 git 信息
Plug 'Xuyuanp/nerdtree-git-plugin' " 可以在导航目录中看到 git 版本信息

Plug 'ryanoasis/vim-devicons'

" golang plugin
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }

" 自动补全插件
Plug 'neoclide/coc.nvim', {'branch': 'release'}

" tag 索引插件
Plug 'majutsushi/tagbar'

" 代码注释
Plug 'tpope/vim-commentary'
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-surround'
" 对齐插件
Plug 'junegunn/vim-easy-align'
" Plug 'tenfyzhong/tagbar-rust.vim'
"
" 主题插件
Plug 'projekt0n/github-nvim-theme'

call plug#end()


" use ctrl+h/j/k/l switch window
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" use ctrl+c close window
noremap <C-c> <C-w>c

" TagBar
nmap <F2> :TagbarToggle<CR>

" easymotion
nmap ss <Plug>(easymotion-s2)

" 自动对齐插件
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)

" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
" + coc 自动补全 +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
let g:coc_global_extensions = [ 'coc-snippets']

autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')


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()

inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

function! s:check_back_space() abort
let col = col('.') - 1
return ! col || getline('.')[col - 1] =~? '\s'
endfunction

augroup user_plugin_coc
autocmd!
autocmd CompleteDone * if pumvisible() == 0 | pclose | endif
augroup END

" use <c-space>for trigger completion
inoremap <silent><expr> <C-space> coc#refresh()

" Movement within 'ins-completion-menu'
imap <expr><C-j> pumvisible() ? "\<Down>" : "\<C-j>"
imap <expr><C-k> pumvisible() ? "\<Up>" : "\<C-k>"

" Scroll pages in menu
inoremap <expr><C-f> pumvisible() ? "\<PageDown>" : "\<Right>"
inoremap <expr><C-b> pumvisible() ? "\<PageUp>" : "\<Left>"
imap <expr><C-d> pumvisible() ? "\<PageDown>" : "\<C-d>"
imap <expr><C-u> pumvisible() ? "\<PageUp>" : "\<C-u>"

" 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)

nmap gs <Plug>(coc-git-chunkinfo)
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
" show commit contains current position
nmap gC <Plug>(coc-git-commit)

" 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
let l:found = CocAction('doHover')
endif
endfunction

" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
" + vim-go plugin +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
let g:go_fmt_command = "goimports" " 格式化将默认的 gofmt 替换
let g:go_autodetect_gopath = 1
let g:go_list_type = "quickfix"
let g:go_version_warning = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_methods = 1
let g:go_highlight_generate_tags = 1
let g:godef_split=2
let g:go_auto_type_info = 1

" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
" + NERDTree +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nmap <F1> :NERDTreeToggle<CR>
" 通过gm来在NERDTree窗口中标记当前光标所在目录
" nmap gm :Bookmark<CR>
" 在启动NERDTree时显示标签
" let NERDTreeShowBookmarks = 1
" 当NERDTree窗口是最后一个窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" let NERDChristmasTree=0
" let NERDTreeWinSize=20
" let NERDTreeChDirMode=2
" let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
" let NERDTreeShowHidden=1
" let NERDTreeShowBookmarks=1
" let let NERDTreeWinPos="left"
" let g:NERDTreeHighlightCursorline = 0
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }

" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
" + 配对自动补全 +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
" inoremap { {<CR>}<Esc>O
autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
" inoremap } <c-r>=CloseBracket()<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
" inoremap ' <c-r>=QuoteDelim("'")<CR>

function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf

function CloseBracket()
if match(getline(line('.') + 1), '\s*}') < 0
return "\<CR>}"
else
return "\<Esc>j0f}a"
endif
endf

function QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
return a:char.a:char."\<Esc>i"
endif
endf

" tab 操作
" http://vim.wikia.com/wiki/Alternative_tab_navigation
" http://stackoverflow.com/questions/2005214/switching-to-a-particular-tab-in-vim

" tab切换
map <leader>th :tabfirst<cr>
map <leader>tl :tablast<cr>

map <leader>tj :tabnext<cr>
map <leader>tk :tabprev<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprev<cr>

map <leader>te :tabedit<cr>
map <leader>td :tabclose<cr>
map <leader>tm :tabm<cr>

" normal模式下切换到确切的tab
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>

" Toggles between the active and last active tab "
" The first tab is always 1 "
let g:last_active_tab = 1
" nnoremap <leader>gt :execute 'tabnext ' . g:last_active_tab<cr>
" nnoremap <silent> <c-o> :execute 'tabnext ' . g:last_active_tab<cr>
" vnoremap <silent> <c-o> :execute 'tabnext ' . g:last_active_tab<cr>
nnoremap <silent> <leader>tt :execute 'tabnext ' . g:last_active_tab<cr>
autocmd TabLeave * let g:last_active_tab = tabpagenr()

" 新建tab Ctrl+t
nnoremap <C-t> :tabnew<CR>
inoremap <C-t> <Esc>:tabnew<CR>

14 changes: 14 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require('basic')
require("keybindings")
require("plugins")
require("colorscheme")
require("plugin-config.nvim-tree")
require("plugin-config.bufferline")
require("plugin-config.lualine")
require("plugin-config.dashboard")
require("plugin-config.project")
require("plugin-config.nvim-treesitter")
require("plugin-config.autopairs")
require("plugin-config.comment")
require("lsp.setup")
require("lsp.null")
Loading

0 comments on commit dab0769

Please sign in to comment.