diff --git a/nvim_init.vim b/nvim_init.vim new file mode 100644 index 0000000..2d2ddc2 --- /dev/null +++ b/nvim_init.vim @@ -0,0 +1,133 @@ + +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 + + + +"""""""""" Plugins """""""""" + +set nocp +filetype plugin on + +call plug#begin('~/.local/share/plugged') +let g:plug_url_format='git@github.com:%s.git' + +Plug 'tpope/vim-repeat' +Plug 'tpope/vim-surround' +Plug 'elkowar/yuck.vim' +Plug 'skywind3000/asyncrun.vim' + +call plug#end() + + + +"""""""""" Remaps """""""""" + +command W w +map Q ZZ + +func Semicolon() + let line = getline('.') + if match(line, "for") == -1 && match(line, "if") == -1 + return "\;" + 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 ; Semicolon() +autocmd FileType vim,c,cpp,go,rust,python,typescript,tex inoremap ( () +autocmd FileType vim,c,cpp,go,rust,python,typescript,tex inoremap [ [] +autocmd FileType vim,c,cpp,go,rust,python,typescript inoremap " "" +autocmd FileType vim,c,cpp,go,rust,python,typescript inoremap ' '' + +autocmd FileType c,cpp,go,rust,typescript inoremap { {} +autocmd FileType c,cpp,go,rust,typescript inoremap {} +autocmd FileType vim,tex,python inoremap { {} +autocmd FileType vim,tex,python inoremap {} + +augroup END + + + +" Guess what? Despite Neovim being smart enough to distinguish +" from , it treats as anyways if +" you have a normal mode mapping for . Screw me I guess. +" Edit: My bad - Please refer to :h 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 + + +" Use Meta-HJKL for Left/Down/Up/Right. +imap +imap +imap +imap + + + +"""""""""" 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 + diff --git a/setup.minimal.sh b/setup.minimal.sh index bc72046..52e2eeb 100755 --- a/setup.minimal.sh +++ b/setup.minimal.sh @@ -9,7 +9,7 @@ mkdir -pv ../.config/nvim ln -sriv vimrc ../.vimrc -ln -sriv vimrc ../.config/nvim/init.vim +ln -sriv nvim_init.vim ../.config/nvim/init.vim ln -sriv zshrc.minimal ../.zshrc ln -sriv coc-settings.json ../.config/nvim/coc-settings.json ln -sriv _clang-format ../.clang-format diff --git a/setup.sh b/setup.sh index e58c7d6..97ddc0f 100755 --- a/setup.sh +++ b/setup.sh @@ -10,7 +10,7 @@ mkdir -pv ../.oh-my-zsh/themes ln -sriv vimrc ../.vimrc -ln -sriv vimrc ../.config/nvim/init.vim +ln -sriv nvim_init.vim ../.config/nvim/init.vim ln -sriv oh.my.zshrc ../.zshrc ln -sriv coc-settings.json ../.config/nvim/coc-settings.json ln -sriv _clang-format ../.clang-format