Merge branch 'master' of gitee.com:klesh/dotfiles

This commit is contained in:
Klesh Wong 2020-06-20 12:38:39 +08:00
commit cd1df46ba4
21 changed files with 472 additions and 360 deletions

4
.gitignore vendored
View File

@ -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/.*

View File

@ -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 \

View File

@ -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

3
coc-settings.json Normal file
View File

@ -0,0 +1,3 @@
{
"npm.binPath": "yarn"
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,7 @@
{
"npm.binPath": "yarn",
"python.linting.enable": true,
"python.linting.flake8Enabled": true,
"explorer.icon.enableNerdfont": true,
"explorer.width": 30
}

138
config/nvim/init.vim Normal file
View File

@ -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 <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
cnoremap <C-d> <Delete>
cnoremap <C-n> <Down>
cnoremap <C-p> <Up>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-d> <Delete>
inoremap <C-n> <Down>
inoremap <C-p> <Up>
noremap <C-a> <Home>
noremap <C-e> <End>
noremap <C-f> <Right>
noremap <C-b> <Left>
vnoremap <leader>p "_dP
nnoremap <leader>q :qall<CR>
nnoremap <leader>1 :b1<CR>
nnoremap <leader>2 :b2<CR>
nnoremap <leader>3 :b3<CR>
nnoremap <leader>4 :b4<CR>
nnoremap <leader>5 :b5<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader><Esc> :noh<return><esc>
inoremap <C-w> <esc><C-w>
" trailing spaces
highlight ExtraWhitespace ctermbg=red guibg=red
au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
au Syntax * match ExtraWhitespace /\s\+$/
nnoremap <leader>es :%s/\s\+$//g<CR>
" 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', '<plug>(GrepperOperator)'] }
Plug 'morhetz/gruvbox'
call plug#end()
" ==== coc configuration ====
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
xmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fb <Plug>(coc-format)
nmap <silent> <leader>rn <Plug>(coc-rename)
nmap <silent> <leader>ne <Plug>(coc-diagnostic-next-error)
nmap <silent> <leader>pe <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>fe :CocCommand explorer --toggle<CR>
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>sd :call CocAction('doHover')<CR>
nmap <silent> <leader>ss :syntax sync fromstart<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
nnoremap <leader>sg :Grepper -tool git<CR>
nnoremap <leader>sc :Grepper -tool grep<CR>
" ==== fugitive configuration ====
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gc :Gcommit<CR>
nnoremap <leader>gp :Gpush<CR>
nnoremap <leader>gg :Gpull<CR>
nnoremap <leader>gd :Gdiff<CR>
" ==== 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

View File

@ -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

102
tex.vimrc Normal file
View File

@ -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\<Tab>
" \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 <Bslash><Tab> <Esc>:call Tex()<Esc>a
" Navigating with guides
inoremap <leader><Tab> <Esc>/<++><Enter>"_c4l
vnoremap <leader><Tab> <Esc>/<++><Enter>"_c4l
map <leader><Tab> <Esc>/<++><Enter>"_c4l
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle<CR>gv
" Markdown setup
autocmd FileType markdown inoremap \cs<Tab> \begin{cases}\end{cases}<++><Esc>F\i
autocmd FileType markdown inoremap \fr<Tab> \frac{<++>}{<++>}<++><Esc>F\i
autocmd FileType markdown inoremap `<Tab> `$$`<++><Esc>F$i
autocmd FileType markdown inoremap $<Tab> $$<Enter>$$<Enter><++><Esc>kO
autocmd FileType markdown inoremap \{ \{\}<++><Esc>F{a
autocmd FileType markdown vnoremap <leader>b c__<C-r>"__<Esc>

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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*

View File

@ -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

View File

@ -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

View File

@ -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

426
vimrc
View File

@ -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', '<plug>(GrepperOperator)'] }
Plug 'ctrlpvim/ctrlp.vim'
Plug 'godlygeek/tabular' " align text by specified pattern :Tabularize /<pattern>
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 <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
xmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fb <Plug>(coc-format)
nmap <silent> <leader>rn <Plug>(coc-rename)
nmap <silent> <leader>ne <Plug>(coc-diagnostic-next-error)
nmap <silent> <leader>pe <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>fe :CocCommand explorer --toggle<CR>
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
function! s:show_documentation()
" s:f makes function f local, use <SID>f() to call it, ! replaces existing
" function quitely
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
nnoremap <silent> K :call <SID>show_documentation()<CR>
" 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 = '<Space><Space>'
" 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 <C-p> <ESC>"+pa
"nnoremap <C-p> "+p
"vnoremap <C-p> "+p
"vnoremap <C-y> "+y
vmap <C-y> <Plug>(fakeclip-y)
inoremap <C-S-s> <ESC>:<C-u>:w<CR>a
nnoremap <C-S-s> :<C-u>:w<CR>
"nnoremap <Space><Space> :CtrlP<CR>
nnoremap <Space>n :NERDTreeToggle<CR>
nnoremap <Space>g :Grepper -tool git<CR>
nnoremap <Esc><Esc> :noh<return><esc>
nnoremap <Space>o :only<CR>
nnoremap <Space>w <C-w><C-w>
nnoremap <Space>q :<C-u>qall<CR>
vnoremap <Space>p "_dP
nnoremap <Space>e :<C-u>%s/\s\+$//g<CR>
nnoremap <Space>s :<C-u>syntax sync fromstart<CR>
nnoremap <Space>c :<C-u>:set cursorcolumn!<CR>
nnoremap <Space>h <C-w>h
nnoremap <Space>j <C-w>j
nnoremap <Space>k <C-w>k
nnoremap <Space>l <C-w>l
nnoremap <Space>m :vertical resize +5<CR>
nnoremap <Space>, :vertical resize -5<CR>
nnoremap <Space>. :resize +5<CR>
nnoremap <Space>/ :resize -5<CR>
nnoremap <Space>d :vs<CR>
nnoremap <Space>[ :lprev<CR>
nnoremap <Space>] :lnext<CR>
vnoremap <silent> <leader>m c<c-r>=trim(@") . '=' . trim(system('math ' . shellescape(@")))<cr><esc>
" 行尾空格高亮
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 <C-y> <Plug>(fakeclip-y)
inoremap <C-S-s> <ESC>:<C-u>:w<CR>a
nnoremap <C-S-s> :<C-u>:w<CR>
function! TabNewFromClipboard()
exec ':tabnew ' . ReadClipboardWsl()
endfunction
function! Jsonpp()
"exec ':%!python -m json.tool'
exec ':%!json_pp'
endfunction
function! DecodeHtml()
exec ':%s/<pre>/```\r/g'
exec ':%s/<\/pre>/\r```/g'
exec ':%s/&lt;/</g'
exec ':%s/&gt;/>/g'
exec ':%s/&amp;/\&/g'
endfunction
vnoremap <leader>p "_dP
nnoremap <leader><Esc> :noh<return><esc>
nnoremap <leader>nt :NERDTreeToggle<CR>
nnoremap <leader>fs :Grepper -tool git<CR>
nnoremap <leader>o :only<CR>
nnoremap <leader>q :<C-u>qall<CR>
nnoremap <leader>e :<C-u>%s/\s\+$//g<CR>
nnoremap <leader>s :<C-u>syntax sync fromstart<CR>
nnoremap <leader>c :<C-u>:set cursorcolumn!<CR>
nnoremap <leader>gs :<C-u>:Gstatus<CR>
nnoremap <leader>gc :<C-u>:Gcommit<CR>
nnoremap <leader>gp :<C-u>:Gpush<CR>
nnoremap <leader>gg :<C-u>:Gpull<CR>
nnoremap <leader>gd :<C-u>:Gdiff<CR>
autocmd FileType json nnoremap <leader>f %!json_pp<Cr>
"nnoremap <leader>m :vertical resize +5<CR>
"nnoremap <leader>, :vertical resize -5<CR>
"nnoremap <leader>. :resize +5<CR>
"nnoremap <leader>/ :resize -5<CR>
"nnoremap <leader>d :vs<CR>
"nnoremap <leader>[ :lprev<CR>
"nnoremap <leader>] :lnext<CR>
"vnoremap <silent> <leader>m c<c-r>=trim(@") . '=' . trim(system('math ' . shellescape(@")))<cr><esc>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
@ -270,113 +256,19 @@ noremap <C-a> <Home>
noremap <C-e> <End>
noremap <C-f> <Right>
noremap <C-b> <Left>
noremap <C-n> <Down>
noremap <C-p> <Up>
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/<pre>/```\r/g'
exec ':%s/<\/pre>/\r```/g'
exec ':%s/&lt;/</g'
exec ':%s/&gt;/>/g'
exec ':%s/&amp;/\&/g'
endfunction
" Call everytime we open a Markdown file
"autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
" \vm 2 4\<Tab>
" \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 <Bslash><Tab> <Esc>:call Tex()<Esc>a
" Navigating with guides
inoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
map <Space><Tab> <Esc>/<++><Enter>"_c4l
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle<CR>gv
" Markdown setup
autocmd FileType markdown inoremap \cs<Tab> \begin{cases}\end{cases}<++><Esc>F\i
autocmd FileType markdown inoremap \fr<Tab> \frac{<++>}{<++>}<++><Esc>F\i
autocmd FileType markdown inoremap `<Tab> `$$`<++><Esc>F$i
autocmd FileType markdown inoremap $<Tab> $$<Enter>$$<Enter><++><Esc>kO
autocmd FileType markdown inoremap \{ \{\}<++><Esc>F{a
autocmd FileType markdown vnoremap <Space>b c__<C-r>"__<Esc>
autocmd FileType json nnoremap <Space>f %!json_pp<Cr>
function! HTML5()
let html = []
call setline(1, '<!DOCTYPE html>')
@ -391,49 +283,3 @@ function! HTML5()
call add(html, '</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