114 lines
2.5 KiB
VimL
114 lines
2.5 KiB
VimL
|
|
if exists('g:vscode')
|
|
" VSCode extension.
|
|
" This is all the config for VSCode-Neovim.
|
|
" normal Nvim uses ~/.vimrc.
|
|
|
|
set backspace=2
|
|
set showmatch
|
|
set ruler
|
|
|
|
set mouse=a
|
|
set ts=4
|
|
set sw=4
|
|
set cindent
|
|
set cinoptions=:0,l1,g0
|
|
set nohlsearch
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
set autochdir
|
|
set timeout timeoutlen=1000 ttimeoutlen=15
|
|
|
|
set title
|
|
|
|
set guicursor=a:blinkon0-Cursor
|
|
let g:netrw_mousemaps=0
|
|
|
|
set nu
|
|
set signcolumn=no
|
|
|
|
set updatetime=1000
|
|
|
|
|
|
command W w
|
|
map Q ZZ
|
|
|
|
func Semicolon()
|
|
let line = getline('.')
|
|
if match(line, "for") == -1 && match(line, "if") == -1
|
|
return "\<End>;"
|
|
else
|
|
return ';'
|
|
endif
|
|
endfunc
|
|
|
|
au BufNewFile,BufRead *.frag,*.vert,*.geom,*.fp,*.vp,*.glsl setf glsl
|
|
|
|
augroup vimrc_cmaps
|
|
autocmd FileType c,cpp,rust,typescript inoremap <buffer><expr> ; Semicolon()
|
|
autocmd FileType vim,c,cpp,go,rust,python,typescript,tex inoremap <buffer> ( ()<Left>
|
|
autocmd FileType vim,c,cpp,go,rust,python,typescript,tex inoremap <buffer> [ []<Left>
|
|
autocmd FileType vim,c,cpp,go,rust,python,typescript inoremap <buffer> " ""<Left>
|
|
autocmd FileType vim,c,cpp,go,rust,python,typescript inoremap <buffer> ' ''<Left>
|
|
|
|
autocmd FileType c,cpp,go,rust,typescript inoremap <buffer> { <End>{<CR>}<Up><End><CR>
|
|
autocmd FileType c,cpp,go,rust,typescript inoremap <buffer> <C-]> {}<Left>
|
|
autocmd FileType vim,tex,python inoremap <buffer> { {}<Left>
|
|
autocmd FileType vim,tex,python inoremap <buffer> <C-]> <End>{<CR>}<Up><End><CR>
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
" Guess what? Despite Neovim being smart enough to distinguish
|
|
" <Ctrl-I> from <Tab>, it treats <Ctrl-I> as <Tab> anyways if
|
|
" you have a normal mode mapping for <Tab>. Screw me I guess.
|
|
" Edit: My bad - Please refer to :h <Tab> or :h CTRL-I. Maybe
|
|
" learn to read sometime this century.
|
|
"
|
|
" https://vi.stackexchange.com/a/46704
|
|
" https://github.com/neovim/neovim/pull/17932
|
|
"
|
|
" This magical line tricks Nvim into being smart again.
|
|
nnoremap <C-I> <C-I>
|
|
|
|
|
|
" Use Meta-HJKL for Left/Down/Up/Right.
|
|
imap <M-H> <Left>
|
|
imap <M-J> <Down>
|
|
imap <M-K> <Up>
|
|
imap <M-L> <Right>
|
|
|
|
|
|
|
|
"""""""""" AsyncRun """"""""""
|
|
|
|
let g:asyncrun_open = 1
|
|
|
|
" Deactivate IME when leaving Insert mode.
|
|
au InsertLeavePre * AsyncRun -silent which fcitx5-remote >/dev/null && fcitx5-remote -c
|
|
|
|
|
|
"""""""""" Misc """"""""""
|
|
|
|
set tags+=~/.cache/ctags
|
|
|
|
lang zh_CN.UTF-8
|
|
|
|
" Uncomment the following to have Vim jump to the last position when
|
|
" reopening a file
|
|
au BufReadPost * exe "normal! g'\""
|
|
|
|
set showmode
|
|
|
|
|
|
|
|
else
|
|
" ordinary Neovim
|
|
set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
|
let &packpath = &runtimepath
|
|
source ~/.vimrc
|
|
endif
|
|
|