diff --git a/.gitignore b/.gitignore index efaaeb9..07cddbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ config/mpv/watch_later/ config/fish/fishd.* +config/fish/fish_variables config/ranger/bookmarks config/ranger/history config/ranger/tagged config/ranger/plugins config/Thunar/accels.scm +config/nvim/autoload +config/nvim/plugged +config/nvim/.* diff --git a/bin/02-install-base-pkgs.fish b/bin/02-install-base-pkgs.fish index a8f29a8..55e2c43 100755 --- a/bin/02-install-base-pkgs.fish +++ b/bin/02-install-base-pkgs.fish @@ -5,7 +5,7 @@ set DIR (dirname (dirname (readlink -f (status --current-filename)))) # cli basic tooling pacman -S \ base-devel \ - vim \ + vim neovim \ tmux bc \ unzip p7zip \ openssh \ diff --git a/bin/06-config-user.fish b/bin/06-config-user.fish index 3644539..983bb1a 100755 --- a/bin/06-config-user.fish +++ b/bin/06-config-user.fish @@ -40,26 +40,35 @@ function link-dotfile run-cmd "ln -sf $DIR/$argv ~/.$argv" end +set -l argv +argparse 'c/cli-only' -- $argv + + link-dotfolder config link-dotfolder pip link-dotfile tmux.conf -link-dotfile vimrc -link-dotfile xinitrc -link-dotfile Xresources -link-dotfile Xmodmap - - +#link-dotfile vimrc +rm -rf ~/.vimrc ~/.vim/coc-settings.json +ln -s $DIR/config/nvim/init.vim ~/.vimrc +mkdir -p ~/.vim +ln -s $DIR/config/nvim/coc-settings.json ~/.vim/coc-settings.json # install tpm git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm -# set zathura as default pdf viewer -xdg-mime default org.pwmt.zathura.desktop application/pdf +if [ -n "$_flag_c" ] + link-dotfile xinitrc + link-dotfile Xresources + link-dotfile Xmodmap + # set zathura as default pdf viewer + xdg-mime default org.pwmt.zathura.desktop application/pdf -# setup mpd -mkdir -p ~/.mpd/playlists -systemctl --user enable mpd -systemctl --user start mpd -# install ranger plugin -yay -S ttf-nerd-fonts-symbols -git clone https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons + # setup mpd + mkdir -p ~/.mpd/playlists + systemctl --user enable mpd + systemctl --user start mpd + + # install ranger plugin + yay -S ttf-nerd-fonts-symbols + git clone https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons +end diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..3a56a22 --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,3 @@ +{ + "npm.binPath": "yarn" +} diff --git a/config/fish/config.fish b/config/fish/config.fish index f3f0de4..504511d 100644 --- a/config/fish/config.fish +++ b/config/fish/config.fish @@ -25,6 +25,7 @@ end source-file-if-exists /usr/share/autojump/autojump.fish source-file-if-exists /usr/local/share/autojump/autojump.fish append-path-if-exists ~/.local/bin +append-path-if-exists ~/Programs/bin append-path-if-exists ~/.yarn/bin source-file-if-exists ~/.cargo/env append-path-if-exists /usr/local/bin diff --git a/config/fish/fish_variables b/config/fish/fish_variables deleted file mode 100644 index cc50299..0000000 --- a/config/fish/fish_variables +++ /dev/null @@ -1,36 +0,0 @@ -# This file contains fish universal variable definitions. -# VERSION: 3.0 -SETUVAR __fish_init_2_39_8:\x1d -SETUVAR __fish_init_2_3_0:\x1d -SETUVAR __fish_init_3_x:\x1d -SETUVAR __fish_initialized:3100 -SETUVAR fish_color_autosuggestion:555\x1ebrblack -SETUVAR fish_color_cancel:\x2dr -SETUVAR fish_color_command:005fd7 -SETUVAR fish_color_comment:990000 -SETUVAR fish_color_cwd:green -SETUVAR fish_color_cwd_root:red -SETUVAR fish_color_end:009900 -SETUVAR fish_color_error:ff0000 -SETUVAR fish_color_escape:00a6b2 -SETUVAR fish_color_history_current:\x2d\x2dbold -SETUVAR fish_color_host:normal -SETUVAR fish_color_host_remote:yellow -SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue -SETUVAR fish_color_normal:normal -SETUVAR fish_color_operator:00a6b2 -SETUVAR fish_color_param:00afff -SETUVAR fish_color_quote:999900 -SETUVAR fish_color_redirection:00afff -SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_status:red -SETUVAR fish_color_user:brgreen -SETUVAR fish_color_valid_path:\x2d\x2dunderline -SETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell -SETUVAR fish_key_bindings:fish_default_key_bindings -SETUVAR fish_pager_color_completion:\x1d -SETUVAR fish_pager_color_description:B3A06D\x1eyellow -SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline -SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan -SETUVAR fish_user_paths:/home/klesh/\x2econfig/nvm/10\x2e20\x2e1/bin diff --git a/config/fish/functions/nvm.fish b/config/fish/functions/nvm.fish index d0d40d7..0eda488 100644 --- a/config/fish/functions/nvm.fish +++ b/config/fish/functions/nvm.fish @@ -169,7 +169,7 @@ function _nvm_use set arch armv6l case armv7 armv7l set arch armv7l - case armv8 armv8l + case armv8 armv8l aarch64 set arch arm64 case \* set arch x86 diff --git a/config/nvim/coc-settings.json b/config/nvim/coc-settings.json new file mode 100644 index 0000000..48e1fa0 --- /dev/null +++ b/config/nvim/coc-settings.json @@ -0,0 +1,7 @@ +{ + "npm.binPath": "yarn", + "python.linting.enable": true, + "python.linting.flake8Enabled": true, + "explorer.icon.enableNerdfont": true, + "explorer.width": 30 +} diff --git a/config/nvim/init.vim b/config/nvim/init.vim new file mode 100644 index 0000000..a6772bd --- /dev/null +++ b/config/nvim/init.vim @@ -0,0 +1,138 @@ +" basic settings +set ts=4 +set sw=4 +set cc=120 +set expandtab +set nu +set hidden +set list +set autoindent +set confirm +set noundofile +set nobackup +set nowritebackup +set hlsearch +set noswapfile +set ignorecase +set smarttab +set smartindent +set cursorline +set incsearch +set signcolumn=yes +set laststatus=2 +set fillchars=vert:\ ,fold:- +set clipboard+=unnamedplus +filetype plugin indent on +syntax on +au! BufWritePost $MYVIMRC source % + +cnoremap +cnoremap +cnoremap +cnoremap +cnoremap +cnoremap +cnoremap + +inoremap +inoremap +inoremap +inoremap +inoremap +inoremap +inoremap + +noremap +noremap +noremap +noremap + +vnoremap p "_dP +nnoremap q :qall + +nnoremap 1 :b1 +nnoremap 2 :b2 +nnoremap 3 :b3 +nnoremap 4 :b4 +nnoremap 5 :b5 +nnoremap w :w +nnoremap :noh + +inoremap + + +" trailing spaces +highlight ExtraWhitespace ctermbg=red guibg=red +au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red +au Syntax * match ExtraWhitespace /\s\+$/ +nnoremap es :%s/\s\+$//g + +" auto install vim-plug +if has('nvim') + let vim_plug_path = expand("~/.config/nvim/autoload/plug.vim") +else + let vim_plug_path = expand("~/.vim/autoload/plug.vim") +endif +let vim_plug_just_installed = 0 +if !filereadable(vim_plug_path) + echo "Installing vim-plug..." + :exe "!curl -fLo " . vim_plug_path . " --create-dirs https://gitee.com/klesh/vim-plug/raw/master/plug.vim" + let vim_plug_just_installed = 1 + echo "vim-plug installed" +endif + +call plug#begin() +Plug 'editorconfig/editorconfig-vim' +Plug 'tpope/vim-surround' +Plug 'jiangmiao/auto-pairs' +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} +Plug 'iamcco/coc-vimlsp', {'do': 'yarn install --frozen-lockfile'} +Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} +Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'} +Plug 'liuchengxu/eleline.vim' +Plug 'tpope/vim-fugitive' " git 功能 +Plug 'scrooloose/nerdcommenter' +Plug 'ctrlpvim/ctrlp.vim' +Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '(GrepperOperator)'] } +Plug 'morhetz/gruvbox' +call plug#end() + + +" ==== coc configuration ==== +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +xmap fs (coc-format-selected) +nmap fs (coc-format-selected) +nmap fb (coc-format) +nmap rn (coc-rename) +nmap ne (coc-diagnostic-next-error) +nmap pe (coc-diagnostic-prev-error) +nmap fe :CocCommand explorer --toggle +nmap if :CocInfo +nmap cl :CocList +nmap sd :call CocAction('doHover') +nmap ss :syntax sync fromstart +nmap ol (coc-openlink) +nnoremap sg :Grepper -tool git +nnoremap sc :Grepper -tool grep + + +" ==== fugitive configuration ==== +nnoremap gs :Gstatus +nnoremap gc :Gcommit +nnoremap gp :Gpush +nnoremap gg :Gpull +nnoremap gd :Gdiff + +" ==== ctrlp configuration ==== +let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard'] + + +" ==== gruvbox configuration ==== +color gruvbox +set background=dark +highlight Normal ctermbg=None diff --git a/config/zathura/zathurarc b/config/zathura/zathurarc index 53e572e..4c56c8a 100644 --- a/config/zathura/zathurarc +++ b/config/zathura/zathurarc @@ -2,3 +2,5 @@ unmap q set recolor true set recolor-darkcolor "#dcdccc" set recolor-lightcolor "#1f1f1f" +map i set recolor false +map I set recolor true diff --git a/tex.vimrc b/tex.vimrc new file mode 100644 index 0000000..ef37679 --- /dev/null +++ b/tex.vimrc @@ -0,0 +1,102 @@ +function! MathAndLiquid() + "" Define certain regions + " Block math. Look for "$$[anything]$$" + syn region math start=/\$\$/ end=/\$\$/ + " inline math. Look for "$[not $][anything]$" + syn match math_block '\$[^$].\{-}\$' + + " Liquid single line. Look for "{%[anything]%}" + syn match liquid '{%.*%}' + " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}" + syn region highlight_block start='{% highlight .*%}' end='{%.*%}' + " Fenced code blocks, used in GitHub Flavored Markdown (GFM) + syn region highlight_block start='```' end='```' + + "" Actually highlight those regions. + hi link math Statement + hi link liquid Statement + hi link highlight_block Function + hi link math_block Function +endfunction + +" Call everytime we open a Markdown file +"autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid() + +" \vm 2 4\ +" \begin{vmatrix} +" <++> & <++> & <++> & <++> \\ +" <++> & <++> & <++> & <++ > \\ +" \end{vmatrix}<++> +" +function! Tex() + let mark = '\' + let sepr = ' ' + let tags = {'vm': 'vmatrix', 'bm': 'bmatrix', 'mt': 'matrix', 'cs': 'cases', 'ad': 'aligned', 'al': 'align', 'ar': 'array'} + let text = getline('.') + let end = col('.') + let start = strridx(text, mark, end) + if start > -1 + let params = strpart(text, start+1, end - start - 1) + let params = split(params, sepr) + let abbr = params[0] + if strlen(abbr) == 0 || !has_key(tags, abbr) + return + endif + let rc = params[1] + if !(rc>0) + return + endif + if len(params)>2 + let cc = params[2] + if !(cc>0) + return + endif + else + let cc = 1 + end + + let prefix = repeat(' ', start) + + let thecols = [] + let i = 0 + while i < cc + call add(thecols, '<++>') + let i += 1 + endwhile + let columnsText = prefix . ' '. join(thecols, ' & ') . ' \\' + + let lines = [] + let i = 0 + while i < rc + call add(lines, columnsText) + let i += 1 + endwhile + call add(lines, prefix . '\end{' . tags[abbr] . '}<++>') + + let leftPart = strpart(text, 0, start) + let rightPart = strpart(text, end) + if strlen(rightPart) > 0 + call add(lines, prefix . rightPart) + endif + call setline(line('.'), leftPart . '\begin{' . tags[abbr] . '}') + call append(line('.'), lines) + "call append(line('.'), lines) + endif +endfunction + +" autocmd FileType markdown +inoremap :call Tex()a +" Navigating with guides +inoremap /<++>"_c4l +vnoremap /<++>"_c4l +map /<++>"_c4l +nmap NERDCommenterToggle +vmap NERDCommenterTogglegv + +" Markdown setup +autocmd FileType markdown inoremap \cs \begin{cases}\end{cases}<++>F\i +autocmd FileType markdown inoremap \fr \frac{<++>}{<++>}<++>F\i +autocmd FileType markdown inoremap ` `$$`<++>F$i +autocmd FileType markdown inoremap $ $$$$<++>kO +autocmd FileType markdown inoremap \{ \{\}<++>F{a +autocmd FileType markdown vnoremap b c__"__ diff --git a/tmux.conf b/tmux.conf index b4671bf..ca70a2c 100644 --- a/tmux.conf +++ b/tmux.conf @@ -1,6 +1,7 @@ ############################ # general ############################ +set -g set-clipboard on set -g default-terminal "xterm-256color" set -s escape-time 0 set -g base-index 1 @@ -65,7 +66,7 @@ set -g @yank_action 'copy-pipe' # tmux source ~/.tmux.conf # prefix + I # plugins dir: ~/.tmux/plugins/ -set -g @plugin 'tmux-plugins/tmux-yank' +#set -g @plugin 'tmux-plugins/tmux-yank' set -g @plugin 'kristijanhusak/tmux-simple-git-status' set -g @plugin 'klesh/tmux-open' set -g @plugin 'tmux-plugins/tmux-copycat' diff --git a/ubuntu/install-base.sh b/ubuntu/install-base.sh index c3fc17a..1d22c43 100755 --- a/ubuntu/install-base.sh +++ b/ubuntu/install-base.sh @@ -1,5 +1,6 @@ #!/bin/bash +set -e sudo apt update -sudo apt upgrade --fix-missing -sudo apt install build-essential automake pkg-config software-properties-common curl -y +sudo apt upgrade --fix-missing -y -q +sudo apt install build-essential automake pkg-config software-properties-common curl -y -q diff --git a/ubuntu/install-fish.sh b/ubuntu/install-fish.sh index 5375321..9a89a87 100755 --- a/ubuntu/install-fish.sh +++ b/ubuntu/install-fish.sh @@ -1,3 +1,6 @@ +#!/bin/bash + +set -e sudo add-apt-repository ppa:fish-shell/release-3 -y sudo apt update sudo apt install fish -y diff --git a/ubuntu/install-sources.sh b/ubuntu/install-sources.sh index 3c40b89..30235e9 100755 --- a/ubuntu/install-sources.sh +++ b/ubuntu/install-sources.sh @@ -1,13 +1,13 @@ #!/bin/bash +set -e + +DIR=$(dirname "${BASH_SOURCE[0]}") +ARCH=$(lscpu | head -n 1 | awk '{print $2}') if [ ! -e /etc/apt/sources.bak ]; then sudo mv /etc/apt/sources.list /etc/apt/sources.bak CURRENT_CODENAME=$(lsb_release -c | cut -f2) - SOURCE_CODENAME=$(head -n 1 $DIR/sources.list | cut -d' ' -f3) - if [ "$CURRENT_CODENAME" != "$SOURCE_CODENAME" ]; then - sudo bash -c "cat $DIR/sources.list | sed s/$SOURCE_CODENAME/$CURRENT_CODENAME/g > /etc/apt/sources.list" - else - sudo cp $DIR/sources.list /etc/apt/ - fi + SOURCE_CODENAME=$(head -n 1 $DIR/sources.$ARCH.list | cut -d' ' -f3) + sudo bash -c "sed s/$SOURCE_CODENAME/$CURRENT_CODENAME/g $DIR/sources.$ARCH.list > /etc/apt/sources.list" fi diff --git a/ubuntu/install-tmux.sh b/ubuntu/install-tmux.sh index d34215a..e576ceb 100755 --- a/ubuntu/install-tmux.sh +++ b/ubuntu/install-tmux.sh @@ -1,14 +1,18 @@ #!/bin/bash +set -e + sudo apt install libevent-dev libncurses5-dev -y TMUX_VER=3.1b -curl -L https://github.com/tmux/tmux/releases/download/$TMUX_VER/tmux-$TMUX_VER.tar.gz -o /tmp/tmux.tar.gz -cd /tmp/ -tar zxvf tmux.tar.gz -cd tmux-$TMUX_VER +#curl -L https://github.com/tmux/tmux/releases/download/$TMUX_VER/tmux-$TMUX_VER.tar.gz -o /tmp/tmux.tar.gz +[ ! -f /tmp/tmux.tar.gz ] && curl -L https://gitee.com/klesh/tmux/repository/archive/$TMUX_VER?format=tar.gz -o /tmp/tmux.tar.gz +rm -rf /tmp/tmux +mkdir -p /tmp/tmux +tar zxvf /tmp/tmux.tar.gz -C /tmp/tmux --strip 1 +pushd /tmp/tmux +[ -f autogen.sh ] && sh autogen.sh ./configure && make sudo make install -cd -rm -rf /tmp/tmux-$TMUX_VER -rm -rf /tmp/tmux.tar.gz +popd +rm -rf /tmp/tmux* diff --git a/ubuntu/install-vim.sh b/ubuntu/install-vim.sh index 916b530..e891025 100755 --- a/ubuntu/install-vim.sh +++ b/ubuntu/install-vim.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -e + sudo add-apt-repository ppa:jonathonf/vim -y -sudo apt update +sudo add-apt-repository ppa:neovim-ppa/stable -y +#sudo apt update sudo apt install -y vim +sudo apt install -y neovim diff --git a/ubuntu/setup.sh b/ubuntu/setup.sh index b42f40f..f8bf637 100755 --- a/ubuntu/setup.sh +++ b/ubuntu/setup.sh @@ -1,9 +1,16 @@ #!/bin/bash +set -e + DIR=$(dirname "${BASH_SOURCE[0]}") +echo '=================== Replace sources.list ====================' $DIR/install-sources.sh +echo '=================== Installing basic packages ====================' $DIR/install-base.sh +echo '=================== Installing fish shell ====================' $DIR/install-fish.sh +echo '=================== Installing vim ====================' $DIR/install-vim.sh +echo '=================== Installing tmux ====================' $DIR/install-tmux.sh diff --git a/ubuntu/sources.aarch64.list b/ubuntu/sources.aarch64.list new file mode 100644 index 0000000..a6d71b8 --- /dev/null +++ b/ubuntu/sources.aarch64.list @@ -0,0 +1,16 @@ + +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial main +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial main + +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main + +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial universe +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial universe +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universe +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universe + +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security main +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security main +deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universe +deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universe diff --git a/ubuntu/sources.list b/ubuntu/sources.x86_64.list similarity index 100% rename from ubuntu/sources.list rename to ubuntu/sources.x86_64.list diff --git a/vimrc b/vimrc index 2417cfd..484607a 100644 --- a/vimrc +++ b/vimrc @@ -37,129 +37,140 @@ else source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim endif -Plug 'terryma/vim-multiple-cursors' -Plug 'jiangmiao/auto-pairs' -"Plug 'scrooloose/syntastic' -"Plug 'w0rp/ale' -Plug 'scrooloose/nerdtree' -Plug 'alvan/vim-closetag' -"Plug 'AndrewRadev/tagalong.vim' -Plug 'tpope/vim-repeat' -Plug 'tpope/vim-fugitive' " git 功能 -Plug 'tpope/vim-surround' -"Plug 'vim-airline/vim-airline' -"Plug 'vim-airline/vim-airline-themes' -Plug 'scrooloose/nerdcommenter' -Plug 'editorconfig/editorconfig-vim' + +" searching and formatting Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '(GrepperOperator)'] } Plug 'ctrlpvim/ctrlp.vim' +Plug 'godlygeek/tabular' " align text by specified pattern :Tabularize / +Plug 'editorconfig/editorconfig-vim' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-repeat' +Plug 'alvan/vim-closetag' +Plug 'jiangmiao/auto-pairs' + +" ide like +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} +Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} +Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'} +Plug 'scrooloose/nerdcommenter' +Plug 'tpope/vim-fugitive' " git 功能 +"Plug 'scrooloose/nerdtree' +"Plug 'mgedmin/coverage-highlight.vim' +"Plug 'klesh/vim-fakeclip' + +" color themes +Plug 'morhetz/gruvbox' + +" syntax +Plug 'peitalin/vim-jsx-typescript' +Plug 'pangloss/vim-javascript' Plug 'lunaru/vim-less' Plug 'posva/vim-vue' Plug 'othree/html5.vim' -Plug 'mtscout6/syntastic-local-eslint.vim' -Plug 'pangloss/vim-javascript' -Plug 'klesh/vim-fakeclip' Plug 'dag/vim-fish' -Plug 'digitaltoad/vim-pug' -"Plug 'ludovicchabant/vim-gutentags' -Plug 'godlygeek/tabular' +"Plug 'vim-python/python-syntax' Plug 'plasticboy/vim-markdown' -Plug 'triglav/vim-visual-increment' -Plug 'jvirtanen/vim-octave' -Plug 'vim-python/python-syntax' -Plug 'mgedmin/coverage-highlight.vim' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} -Plug 'morhetz/gruvbox' -Plug 'peitalin/vim-jsx-typescript' +"Plug 'digitaltoad/vim-pug' + +" statusline +Plug 'liuchengxu/eleline.vim' call plug#end() -" coc configuration, may need to run `yarn` in ~/.vim/coc-python folder -" $ pip install --user python-language-server jedi rope - - - -" Remap keys for gotos +" ==== coc configuration ==== nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) +xmap fs (coc-format-selected) +nmap fs (coc-format-selected) +nmap fb (coc-format) +nmap rn (coc-rename) +nmap ne (coc-diagnostic-next-error) +nmap pe (coc-diagnostic-prev-error) +nmap fe :CocCommand explorer --toggle +nmap if :CocInfo +nmap cl :CocList +nmap ol (coc-openlink) + " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') + + " Use K to show documentation in preview window -nnoremap K :call show_documentation() - -" Remap for rename current word -nmap rn (coc-rename) - -" Remap for format selected region -xmap f (coc-format-selected) -nmap f (coc-format-selected) - function! s:show_documentation() + " s:f makes function f local, use f() to call it, ! replaces existing + " function quitely if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction +nnoremap K :call show_documentation() -" markdown +" ==== markdown configuration ==== let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_math = 1 -" nerdtree + +" ==== nerdtree configuration ==== let NERDTreeDirArrowExpandable = "+" let NERDTreeDirArrowCollapsible = "-" +let NERDTreeIgnore = ['\.pyc$', '__pycache__'] -" python + +" ==== python configuration ==== let g:python_highlight_all = 1 -" airline -let g:airline_theme='bubblegum' -let g:airline_left_sep = '' -let g:airline_right_sep = '' -"let g:airline_left_sep = ' ' -"let g:airline_right_sep = ' ' -let g:airline_symbols#crypt = '🔒' -let g:airline_symbols#linenr = '¶' -let g:airline_symbols#maxlinenr = '☰' -let g:airline_symbols#branch = '' -"let g:airline_symbols#paste = 'ρ' -let g:airline_symbols#paste = 'Þ' -"let g:airline_symbols#paste = '∥' -"let g:airline_symbols#spell = 'Ꞩ' -"let g:airline_symbols#notexists = '∄' -"let g:airline_symbols#whitespace = 'Ξ' -" -"let g:airline_theme='luna' -" CtrlP +" ==== ctrlp configuration ==== let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard'] -"let g:ctrlp_map = '' -" NERDTree -let NERDTreeIgnore = ['\.pyc$', '__pycache__'] -" syntastic -" let g:syntastic_javascript_checkers = ['eslint'] -"let g:ale_python_pylint_change_directory = 0 -let g:ale_linters = { - \ 'python': ['flake8'] - \} - -" vue-vim -" 解决跳到尾部时语法高亮不正常的问题 +" ==== vue configuration ==== +" syntax highlighting not working correctly occasionally for vue autocmd FileType vue syntax sync fromstart -" 利用现有的插件对语法进行高亮 -"autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html5.javascript.less autocmd BufRead,BufNewFile *.vue setlocal filetype=vue -" vim + +" ==== closetag configuration ==== +" Disables auto-close if not in a "valid" region (based on filetype) +let g:closetag_regions = { + \ 'typescript.tsx': 'jsxRegion,tsxRegion', + \ 'javascript.jsx': 'jsxRegion', + \ } +let g:closetag_shortcut = '>' +let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.vue,*.tsx" + + +" ==== nerdcommenter configuration ==== +" fixing vue commenting problem +fu! NERDCommenter_before() + if &ft == 'vue' + let b:isvue = 1 + let stack = synstack(line('.'), col('.')) + if len(stack) > 0 + let syn = synIDattr((stack)[0], 'name') + if len(syn) > 0 + let syn = tolower(syn) + exe 'setf '.syn + endif + endif + endif +endfu +fu! NERDCommenter_after() + if exists('b:isvue') && b:isvue + setf vue + let b:isvue = 0 + endif +endfu + + +" ==== general configuration ==== set ts=4 set sw=4 set listchars=eol:$,tab:->,extends:>,precedes:<,space:., @@ -179,77 +190,52 @@ set noshowmatch set laststatus=2 let html_no_rendering=1 set fillchars=vert:\ ,fold:- -"highlight VertSplit guibg=Orange guifg=Black ctermbg=None ctermfg=033 +set showcmd hi StatusLine cterm=NONE -" keybindings -" 从系统剪贴板复制/粘贴 -"inoremap "+pa -"nnoremap "+p -"vnoremap "+p -"vnoremap "+y -vmap (fakeclip-y) -inoremap ::wa -nnoremap ::w - -"nnoremap :CtrlP -nnoremap n :NERDTreeToggle -nnoremap g :Grepper -tool git - -nnoremap :noh -nnoremap o :only -nnoremap w -nnoremap q :qall -vnoremap p "_dP -nnoremap e :%s/\s\+$//g -nnoremap s :syntax sync fromstart -nnoremap c ::set cursorcolumn! - -nnoremap h h -nnoremap j j -nnoremap k k -nnoremap l l -nnoremap m :vertical resize +5 -nnoremap , :vertical resize -5 -nnoremap . :resize +5 -nnoremap / :resize -5 -nnoremap d :vs -nnoremap [ :lprev -nnoremap ] :lnext - -vnoremap m c=trim(@") . '=' . trim(system('math ' . shellescape(@"))) - " 行尾空格高亮 highlight ExtraWhitespace ctermbg=red guibg=red au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red au Syntax * match ExtraWhitespace /\s\+$/ -" iterm2 插入模式时backspace不works -set backspace=indent,eol,start +" theme +try + color gruvbox +catch + color delek +endtry +set background=dark +highlight Normal ctermbg=None -function! ReadClipboardWsl() - let text = system('powershell.exe -Command Get-Clipboard') - let text = substitute(text, "\r\n", '', 'g') - return text -endfunction +" ==== keybinding configuration ==== +"vmap (fakeclip-y) +inoremap ::wa +nnoremap ::w -function! TabNewFromClipboard() - exec ':tabnew ' . ReadClipboardWsl() -endfunction - -function! Jsonpp() - "exec ':%!python -m json.tool' - exec ':%!json_pp' -endfunction - -function! DecodeHtml() - exec ':%s/
/```\r/g'
-  exec ':%s/<\/pre>/\r```/g'
-  exec ':%s/<//g'
-  exec ':%s/&/\&/g'
-endfunction
+vnoremap p "_dP
+nnoremap  :noh
+nnoremap nt :NERDTreeToggle
+nnoremap fs :Grepper -tool git
+nnoremap o :only
+nnoremap q :qall
+nnoremap e :%s/\s\+$//g
+nnoremap s :syntax sync fromstart
+nnoremap c ::set cursorcolumn!
+nnoremap gs ::Gstatus
+nnoremap gc ::Gcommit
+nnoremap gp ::Gpush
+nnoremap gg ::Gpull
+nnoremap gd ::Gdiff
+autocmd FileType json nnoremap f %!json_pp
 
+"nnoremap m :vertical resize +5
+"nnoremap , :vertical resize -5
+"nnoremap . :resize +5
+"nnoremap / :resize -5
+"nnoremap d :vs
+"nnoremap [ :lprev
+"nnoremap ] :lnext
+"vnoremap  m c=trim(@") . '=' . trim(system('math ' . shellescape(@")))
 cnoremap  
 cnoremap  
 cnoremap  
@@ -270,113 +256,19 @@ noremap  
 noremap  
 noremap  
 noremap  
-noremap  
-noremap  
 
-function! MathAndLiquid()
-  "" Define certain regions
-  " Block math. Look for "$$[anything]$$"
-  syn region math start=/\$\$/ end=/\$\$/
-  " inline math. Look for "$[not $][anything]$"
-  syn match math_block '\$[^$].\{-}\$'
+" iterm2 插入模式时backspace不works
+set backspace=indent,eol,start
 
-  " Liquid single line. Look for "{%[anything]%}"
-  syn match liquid '{%.*%}'
-  " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
-  syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
-  " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
-  syn region highlight_block start='```' end='```'
 
-  "" Actually highlight those regions.
-  hi link math Statement
-  hi link liquid Statement
-  hi link highlight_block Function
-  hi link math_block Function
+function! DecodeHtml()
+  exec ':%s/
/```\r/g'
+  exec ':%s/<\/pre>/\r```/g'
+  exec ':%s/<//g'
+  exec ':%s/&/\&/g'
 endfunction
 
-" Call everytime we open a Markdown file
-"autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
-
-" \vm 2 4\
-" \begin{vmatrix}
-" <++> & <++> & <++> & <++> \\
-" <++> & <++> & <++> & <++ > \\
-" \end{vmatrix}<++>
-"
-function! Tex()
-  let mark = '\'
-  let sepr = ' '
-  let tags = {'vm': 'vmatrix', 'bm': 'bmatrix', 'mt': 'matrix', 'cs': 'cases', 'ad': 'aligned', 'al': 'align', 'ar': 'array'}
-  let text = getline('.')
-  let end = col('.')
-  let start = strridx(text, mark, end)
-  if start > -1
-    let params = strpart(text, start+1, end - start - 1)
-    let params = split(params, sepr)
-    let abbr = params[0]
-    if strlen(abbr) == 0 || !has_key(tags, abbr)
-      return
-    endif
-    let rc = params[1]
-    if !(rc>0)
-      return
-    endif
-    if len(params)>2
-      let cc = params[2]
-      if !(cc>0)
-        return
-      endif
-    else
-      let cc = 1
-    end
-
-    let prefix = repeat(' ', start)
-
-    let thecols = []
-    let i = 0
-    while i < cc
-      call add(thecols, '<++>')
-      let i += 1
-    endwhile
-    let columnsText = prefix . '  '. join(thecols, ' & ') . ' \\'
-
-    let lines = []
-    let i = 0
-    while i < rc
-      call add(lines, columnsText)
-      let i += 1
-    endwhile
-    call add(lines, prefix . '\end{' . tags[abbr] . '}<++>')
-
-    let leftPart = strpart(text, 0, start)
-    let rightPart = strpart(text, end)
-    if strlen(rightPart) > 0
-      call add(lines, prefix . rightPart)
-    endif
-    call setline(line('.'), leftPart . '\begin{' . tags[abbr] . '}')
-    call append(line('.'), lines)
-    "call append(line('.'), lines)
-  endif
-endfunction
-
-" autocmd FileType markdown
-inoremap  :call Tex()a
-" Navigating with guides
-inoremap  /<++>"_c4l
-vnoremap  /<++>"_c4l
-map  /<++>"_c4l
-nmap    NERDCommenterToggle
-vmap    NERDCommenterTogglegv
-
-" Markdown setup
-autocmd FileType markdown inoremap \cs \begin{cases}\end{cases}<++>F\i
-autocmd FileType markdown inoremap \fr \frac{<++>}{<++>}<++>F\i
-autocmd FileType markdown inoremap ` `$$`<++>F$i
-autocmd FileType markdown inoremap $ $$$$<++>kO
-autocmd FileType markdown inoremap \{ \{\}<++>F{a
-autocmd FileType markdown vnoremap b c__"__
-autocmd FileType json nnoremap f %!json_pp
-
 function! HTML5()
   let html = []
   call setline(1, '')
@@ -391,49 +283,3 @@ function! HTML5()
   call add(html, '')
   call append(1, html)
 endfunction
-
-color gruvbox
-set background=dark
-highlight Normal ctermbg=None
-
-" closetag
-" dict
-" Disables auto-close if not in a "valid" region (based on filetype)
-let g:closetag_regions = {
-    \ 'typescript.tsx': 'jsxRegion,tsxRegion',
-    \ 'javascript.jsx': 'jsxRegion',
-    \ }
-let g:closetag_shortcut = '>'
-let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.vue,*.tsx"
-"
-"let g:tagalong_additional_filetypes = ['typescript.tsx']
-
-fu! NERDCommenter_before()
-  if &ft == 'vue'
-    let b:isvue = 1
-    let stack = synstack(line('.'), col('.'))
-    if len(stack) > 0
-      let syn = synIDattr((stack)[0], 'name')
-      if len(syn) > 0
-        let syn = tolower(syn)
-        exe 'setf '.syn
-      endif
-    endif
-  endif
-endfu
-fu! NERDCommenter_after()
-  if exists('b:isvue') && b:isvue
-    setf vue
-    let b:isvue = 0
-  endif
-endfu
-"
-
-"fu! NERDCommenter_before()
-  "setf javascript
-"endfu
-
-
-"fu! NERDCommenter_after()
-  "setf vue
-"endfu