This commit is contained in:
Young Xu 2023-03-16 23:12:27 +08:00
parent 857bf86ef3
commit 4d28773598
Signed by: xuthus5
GPG Key ID: A23CF9620CBB55F9
8 changed files with 79 additions and 0 deletions

19
ftplugin/go.vim Normal file
View File

@ -0,0 +1,19 @@
augroup golang
au!
autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.organizeImport')
autocmd BufWritePre *.go :call CocAction('format')
augroup END
vnoremap <silent><buffer> F :<c-u>call <SID>gfor()<cr>jo
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>
func s:gfor()
let tag = getline(line("."))[col("'<") - 1 : col("'>") - 2 + (&selection != 'exclusive' ? 1 : 0)]
let l = line('.')
let space = substitute(getline(l), '\v(^\s*).*', '\1', '')
call appendbufline('%', line('.'), printf(space . 'for idx := range %s {', tag))
call appendbufline('%', line('.') + 1, printf(space . ' %s := %s[idx]', tag[:-2], tag))
call appendbufline('%', line('.') + 2, space . '}')
execute 'norm! j'
endf

1
ftplugin/javascript.vim Normal file
View File

@ -0,0 +1 @@
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>

51
ftplugin/markdown.vim Normal file
View File

@ -0,0 +1,51 @@
hi MDTask ctermfg=1
hi MDDoneText ctermfg=37 cterm=italic,strikethrough
hi MDTodoText cterm=NONE
hi MDDoneDate cterm=strikethrough ctermfg=71
hi MDTodoDate ctermfg=71
hi Deadline ctermfg=162 cterm=bold,underline
hi NearDeadline ctermfg=178 cterm=bold
au FileType markdown syn match markdownError "\w\@<=\w\@="
au FileType markdown syn match MDDoneDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained
au FileType markdown syn match MDTodoDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained
au FileType markdown syn match MDDoneText /- \[x\] \zs.*/ contains=MDDoneDate contained
au FileType markdown syn match MDTodoText /- \[ \] \zs.*/ contains=MDTodoDate contained
au FileType markdown syn match MDTask /- \[\(x\| \)\] .*/ contains=MDDoneText,MDTodoText
au FileType markdown call matchadd('Deadline', 'D:'.strftime("%Y-%m-%d"))
au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 24))
au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 48))
let b:md_block = '```'
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=2
nnoremap <silent><buffer> <CR> :call <SID>toggleTodoStatus()<CR><CR>
nnoremap <silent><buffer> <2-LeftMouse> :call <SID>toggleTodoStatus()<CR>:w<CR><2-LeftMouse>
vnoremap <silent><buffer> B :<c-u>call SurroundVaddPairs("**", "**")<cr>
vnoremap <silent><buffer> I :<c-u>call SurroundVaddPairs("*", "*")<cr>
vnoremap <silent><buffer> T :<c-u>call SurroundVaddPairs("- [ ] ", "")<cr>
vnoremap <silent><buffer> ` :<c-u>call SurroundVaddPairs("`", "`")<cr>
vnoremap <silent><buffer> C :<c-u>call SurroundVaddPairs("```plaintext", "```")<cr>
fun! s:toggleTodoStatus()
let line = getline('.')
if line =~ glob2regpat('*- \[ \]*')
call setline('.', substitute(line, '\[ \]', '[x]', ''))
elseif line =~ glob2regpat('*- \[x\]*')
call setline('.', substitute(line, '\[x\]', '[ ]', ''))
endif
endf
nnoremap <silent><buffer> <F6> :call <SID>toggleMPTheme()<CR>
inoremap <silent><buffer> <F6> <ESC>:call <SID>toggleMPTheme()<CR>
fun! s:toggleMPTheme()
if g:mkdp_theme == 'dark'
let g:mkdp_theme = 'light'
else
let g:mkdp_theme = 'dark'
endif
exec 'MarkdownPreviewStop'
sleep 1
exec 'MarkdownPreview'
endf

1
ftplugin/mysql.vim Normal file
View File

@ -0,0 +1 @@
let g:omni_sql_no_default_maps = 1

1
ftplugin/python.vim Normal file
View File

@ -0,0 +1 @@
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>

1
ftplugin/sql.vim Normal file
View File

@ -0,0 +1 @@
let g:omni_sql_no_default_maps = 1

1
ftplugin/typescript.vim Normal file
View File

@ -0,0 +1 @@
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>

4
ftplugin/vue.vim Normal file
View File

@ -0,0 +1,4 @@
augroup vue
au!
autocmd BufWritePre *.vue :call CocAction('format')
augroup END