Skip to content

Instantly share code, notes, and snippets.

@y9c
Last active March 22, 2018 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y9c/1c70261f92a5cac0545e0f6e8ad99c26 to your computer and use it in GitHub Desktop.
Save y9c/1c70261f92a5cac0545e0f6e8ad99c26 to your computer and use it in GitHub Desktop.
"=============================================================================
" Configuration for SpaceVim ( URL: https://spacevim.org )
" Edited by yech
"=============================================================================
" SpaceVim Wraped Options: {{{
let g:spacevim_enable_debug = 1
let g:spacevim_realtime_leader_guide = 1
let g:spacevim_enable_tabline_filetype_icon = 1
let g:spacevim_enable_statusline_display_mode = 0
let g:spacevim_enable_os_fileformat_icon = 1
let g:spacevim_buffer_index_type = 1
let g:spacevim_enable_vimfiler_welcome = 1
let g:spacevim_enable_debug = 1
" }}}
" SpaceVim Layers: {{{
call SpaceVim#layers#load('lang#c')
call SpaceVim#layers#load('lang#go')
call SpaceVim#layers#load('lang#java')
call SpaceVim#layers#load('lang#rust')
call SpaceVim#layers#load('lang#lua')
call SpaceVim#layers#load('lang#swig')
call SpaceVim#layers#load('lang#perl')
call SpaceVim#layers#load('lang#python')
call SpaceVim#layers#load('lang#javascript')
call SpaceVim#layers#load('lang#typescript')
call SpaceVim#layers#load('lang#tmux')
call SpaceVim#layers#load('lang#vim')
call SpaceVim#layers#load('lang#xml')
call SpaceVim#layers#load('lang#markdown')
call SpaceVim#layers#load('colorscheme')
call SpaceVim#layers#load('incsearch')
call SpaceVim#layers#load('lsp')
call SpaceVim#layers#load('shell')
call SpaceVim#layers#load('VersionControl')
call SpaceVim#layers#load('tools#screensaver')
" }}}
" Global Env: {{{
" fix python lints for python3
" let g:pymode_python = 'python3'
" let g:python2_host_prog = "/usr/bin/python2"
" let g:python3_host_prog = "/usr/bin/python3"
" default conceallevel is 2, which is suitable for editing symbol and can't
" be editted in SpaceVim
let g:tex_conceal = "" "default is abdgm
let g:neotex_pdflatex_alternative = "xelatex"
" seems not work
" let g:neotex_latexdiff = 1
" autoHeader
let g:autoHEADER_default_author = 'yech'
let g:autoHEADER_fill_char_repeat = 60
" enable markdown file folding
let g:markdown_folding = 1
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh']
" }}}
" Theme: {{{
set termguicolors
let g:one_allow_italics = 1 " italic for comments
let g:spacevim_colorscheme = 'one'
" let g:spacevim_colorscheme_bg = 'light' " can switch to a light theme
let g:spacevim_colorscheme_bg = 'dark'
" highlight pythoon
let g:python_highlight_all = 1
autocmd ColorScheme * hi Typing gui=italic guifg=#5c6370 guibg=#2c323c cterm=italic ctermfg=59 ctermbg=236
" highlight typescript
autocmd ColorScheme * hi typescriptType gui=italic guifg=#5c6370 guibg=#2c323c cterm=italic ctermfg=59 ctermbg=236
" more clear match paren
hi MatchParen cterm=bold ctermbg=none ctermfg=magenta
" }}}
" Keymapping: {{{
noremap U <C-R>
" Fn keys shortcut mapping
" F1: disabled -- may conflict with system default
noremap <F1> <Esc>"
" F2: tag list -- DEFAULT SETTING
" F3: dir tree -- DEFAULT SETTING
" F7: version control -- DEFAULT SETTING
" F8: tag list -- DEFAULT SETTING
" WTF! another tag list?
" }}}
" Plugin Setting: {{{
" If there is a particular plugin you don't like, you can define this variable to disable them entirely:
" let g:spacevim_disabled_plugins=[
" \ ['othree/es.next.syntax.vim'],
" \ ]
" If you want to add some custom plugins, use these options:
let g:spacevim_custom_plugins = [
\ ['yech1990/vim_enhanced_syntax', {'on_ft' : 'python'}],
\ ['donRaphaco/neotex', { 'for': 'tex' }]
\ ]
" }}}
" File and Characters: {{{
"set encoding
set encoding=utf-8
set fileencoding=utf-8
"show CRLF
set ffs=unix
"show mark special symbol
" set listchars=eol:⏎,tab:␉·,trail:␠,nbsp:⎵
" }}}
" Custom Functions {{{
" Fx: format code -- changed for neovim
" noremap <Fx> :NeoFormat<CR>
" Fx: spell check
" set nospell
" nnoremap <Fx> :set spell! spell?<CR>
" Fx: paste mode -- both normal and insert mode works
" set pastetoggle=<Fx>
" disbale paste mode when leaving insert mode
" au InsertLeave * set nopaste
" nnoremap <Fx> :exec exists('syntax_on') ? 'syn off' : 'syn on'<CR>
" Fx: wrap line
" nnoremap <Fx> :set wrap! wrap?<CR>
" Fx: list
nnoremap <F4> :set list! list?<CR>
" Fx: toggle linenumber -- useful for mouse selection
function! ToggleLineNumber()
if(&relativenumber == &number)
set relativenumber! number!
elseif(&number)
set number!
else
set relativenumber!
endif
set number?
endfunc
" nnoremap <Fx> :call ToggleLineNumber()<CR>
" Fx: quick insert datetime -- both normal and insert mode
" nmap <Fx> i<C-R>=system('date --iso-8601=second')<CR><Esc>
" imap <Fx> <C-R>=system('date --iso-8601=second')<CR>
" self define task list
function! Toggle_Task_List()
if getline('.') =~ '^- \[ \]\ '
s/^- \[ \]/- [x]/
elseif getline('.') =~ '^- \[x\]\ '
s/^- \[x\]/- [ ]/
else
echo "Not a item of task list!"
endif
endfunction
" task list toggle
map <leader>tt :call Toggle_Task_List()<cr>
function! New_Task_List()
if getline('.') =~ '^- \[ \]\ '
call append(line('.'), "- [ ] ")
call cursor(line('.')+1, 0)
startinsert!
elseif getline('.') =~ '^- \[x\]\ '
call append(line('.'), "- [x] ")
call cursor(line('.')+1, 0)
startinsert!
else
echo "Not a item of task list!"
endif
endfunction
" task list new
map <leader>tn :call New_Task_List()<cr>
function! New_Task_List()
if getline('.') =~ '^- \[ \]\ '
call append(line('.'), "- [ ] ")
call cursor(line('.')+1, 0)
startinsert!
elseif getline('.') =~ '^- \[x\]\ '
call append(line('.'), "- [x] ")
call cursor(line('.')+1, 0)
startinsert!
else
echo "Not a item of task list!"
endif
endfunction
" task list fold
map <leader>tf :call Fold_Task_List()<cr>
function! Fold_Task_List()
if &foldlevel
echo "file is unfold"
set foldmethod=expr
set foldexpr=getline(v:lnum)=~'^-\ [x\\]\ '
set fml=0
set foldlevel=0
else
echo "file is fold"
set foldmethod=manual
set foldexpr=0
set fml=1
set foldlevel=1
endif
endfunction
" async run method, alternation in SpaceVim
augroup SPACEVIM_ASYNCRUN
autocmd!
" Automatically open the quickfix window
autocmd User AsyncRunStart call asyncrun#quickfix_toggle(15, 1)
augroup END
function! s:compile_and_run()
exec 'w'
if &filetype == 'c'
exec "AsyncRun! gcc % -o %<; time ./%<"
elseif &filetype == 'cpp'
exec "AsyncRun! g++ -std=c++11 % -o %<; time ./%<"
elseif &filetype == 'java'
exec "AsyncRun! javac %; time java %<"
elseif &filetype == 'sh'
exec "AsyncRun! time bash %"
elseif &filetype == 'python'
exec "AsyncRun! time python3 %"
endif
endfunction
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment