This commit is contained in:
Lee Tang
2022-03-12 08:41:28 +08:00
commit 6fa77b0a86
37 changed files with 1944 additions and 0 deletions

148
.Brewfile.Darwin.mbp-arm64 Normal file
View File

@@ -0,0 +1,148 @@
tap "blendle/blendle"
tap "bufbuild/buf"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-drivers"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
tap "jesseduffield/lazygit"
tap "mongodb/brew"
tap "muesli/tap"
tap "universal-ctags/universal-ctags"
tap "wez/wezterm"
brew "autojump"
brew "automake"
brew "awscli"
brew "bat"
brew "bpytop"
brew "bzip2"
brew "llvm"
brew "ccls"
brew "cmake"
brew "coreutils"
brew "ctags", link: false
brew "dosbox"
brew "dpkg"
brew "fzf"
brew "gcc"
brew "gh"
brew "git"
brew "glib"
brew "unbound"
brew "gnutls"
brew "gnupg"
brew "go"
brew "grpcurl"
brew "hadoop"
brew "hbase"
brew "helm"
brew "htop"
brew "imagemagick"
brew "jmeter"
brew "jq"
brew "k9s"
brew "zookeeper"
brew "kafka"
brew "kind"
brew "kompose"
brew "kubernetes-cli"
brew "krew"
brew "kubectx"
brew "lazygit"
brew "lbzip2"
brew "qemu"
brew "lima"
brew "lrzsz"
brew "lsd"
brew "lua"
brew "luarocks"
brew "lzlib"
brew "maven"
brew "minikube"
brew "protobuf"
brew "mosh"
brew "mysql"
brew "neofetch"
brew "neovim"
brew "nghttp2"
brew "nload"
brew "nmap"
brew "node"
brew "openssl@3"
brew "podman"
brew "postgresql", restart_service: true
brew "pyenv"
brew "pyenv-virtualenv"
brew "python@3.8"
brew "rabbitmq"
brew "rclone"
brew "rebar3"
brew "redis", restart_service: true
brew "ripgrep"
brew "ruby"
brew "ruby@2.7"
brew "rust"
brew "rustup-init"
brew "socat"
brew "sshuttle"
brew "starship"
brew "stylua"
brew "telnet"
brew "the_silver_searcher"
brew "thrift"
brew "tmux"
brew "velero"
brew "wakeonlan"
brew "wget"
brew "zlib"
brew "zsh"
brew "bufbuild/buf/buf"
brew "mongodb/brew/mongodb-community"
brew "muesli/tap/duf"
brew "universal-ctags/universal-ctags/universal-ctags", args: ["HEAD"]
cask "adoptopenjdk"
cask "adoptopenjdk8"
cask "anki"
cask "balenaetcher"
cask "beyond-compare"
cask "brave-browser"
cask "calibre"
cask "charles"
cask "clashx"
cask "daisydisk"
cask "discord"
cask "font-jetbrains-mono-nerd-font"
cask "google-chrome"
cask "google-cloud-sdk"
cask "google-drive"
cask "hiddenbar"
cask "iina"
cask "iterm2"
cask "jetbrains-toolbox"
cask "lark"
cask "neteasemusic"
cask "netnewswire"
cask "notion"
cask "openemu"
cask "openvpn-connect"
cask "paw"
cask "postman"
cask "qq"
cask "qqmusic"
cask "racket"
cask "raycast"
cask "rectangle"
cask "sourcetree"
cask "spotify"
cask "stats"
cask "sunlogincontrol"
cask "surge"
cask "telegram"
cask "typora"
cask "visual-studio-code"
cask "wechat"
cask "wechatwork"
cask "wezterm-nightly"
cask "zerotier-one"

144
.Brewfile.Darwin.mbp-x86-64 Normal file
View File

@@ -0,0 +1,144 @@
tap "blendle/blendle"
tap "bufbuild/buf"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-drivers"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
tap "jesseduffield/lazygit"
tap "mongodb/brew"
tap "muesli/tap"
tap "universal-ctags/universal-ctags"
tap "wez/wezterm"
brew "readline"
brew "sqlite"
brew "xz"
brew "python@3.10"
brew "autojump"
brew "automake"
brew "awscli"
brew "bat"
brew "bpytop"
brew "llvm"
brew "ccls"
brew "cmake"
brew "coreutils"
brew "ctags", link: false
brew "dosbox"
brew "dpkg"
brew "fzf"
brew "gcc"
brew "gh"
brew "glib"
brew "unbound"
brew "gnutls"
brew "gnupg"
brew "go"
brew "grpcurl"
brew "hadoop"
brew "hbase"
brew "helm"
brew "htop"
brew "imagemagick"
brew "jmeter"
brew "jq"
brew "k9s"
brew "zookeeper"
brew "kafka"
brew "kind"
brew "kompose"
brew "kubernetes-cli"
brew "kubectx"
brew "lazygit"
brew "lima"
brew "lrzsz"
brew "lsd"
brew "lua"
brew "luarocks"
brew "maven"
brew "minikube"
brew "node@14"
brew "protobuf"
brew "mysql"
brew "neofetch"
brew "neovim"
brew "nghttp2"
brew "nload"
brew "nmap"
brew "node"
brew "openssl@3"
brew "podman"
brew "postgresql", restart_service: true
brew "pyenv"
brew "pyenv-virtualenv"
brew "python@3.8"
brew "rabbitmq"
brew "rclone"
brew "rebar3"
brew "redis", restart_service: true
brew "ripgrep"
brew "ruby"
brew "ruby@2.7"
brew "rustup-init"
brew "shfmt"
brew "socat"
brew "sshuttle"
brew "starship"
brew "stylua"
brew "telnet"
brew "the_silver_searcher"
brew "thrift"
brew "tmux"
brew "velero"
brew "wakeonlan"
brew "wget"
brew "zlib"
brew "zsh"
brew "bufbuild/buf/buf"
brew "mongodb/brew/mongodb-community"
brew "muesli/tap/duf"
brew "universal-ctags/universal-ctags/universal-ctags", args: ["HEAD"]
cask "adoptopenjdk"
cask "adoptopenjdk8"
cask "anki"
cask "balenaetcher"
cask "beyond-compare"
cask "brave-browser"
cask "calibre"
cask "charles"
cask "clashx"
cask "daisydisk"
cask "discord"
cask "font-jetbrains-mono-nerd-font"
cask "google-chrome"
cask "google-cloud-sdk"
cask "google-drive"
cask "iina"
cask "iterm2"
cask "jetbrains-toolbox"
cask "lark"
cask "logitech-options"
cask "monodraw"
cask "neteasemusic"
cask "netnewswire"
cask "notion"
cask "openemu"
cask "paw"
cask "postman"
cask "qbittorrent"
cask "qq"
cask "qqmusic"
cask "racket"
cask "raycast"
cask "sourcetree"
cask "spotify"
cask "stats"
cask "surge"
cask "telegram"
cask "typora"
cask "visual-studio-code"
cask "wechat"
cask "wechatwork"
cask "wezterm-nightly"

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
nvim/plugin/
nvim/.netrwhist
*.env
.git/
.DS_Store

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "tmux/plugins/tpm"]
path = tmux/plugins/tpm
url = https://github.com/tmux-plugins/tpm

55
.ideavimrc Normal file
View File

@@ -0,0 +1,55 @@
"" Source your .vimrc
"source ~/.vimrc
"" -- Suggested options --
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
" Do incremental searching.
set incsearch
set easymotion
let mapleader="\<Space>"
" Don't use Ex mode, use Q for formatting.
map Q gq
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
map <Leader>w <Plug>(easymotion-w)
map <Leader>b <Plug>(easymotion-b)
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
let g:EasyMotion_smartcase = 1
" ==== 系统剪切板复制粘贴 ====
" v 模式下复制内容到系统剪切板
vmap <Leader>c "+yy
" n 模式下复制一行到系统剪切板
nmap <Leader>c "+yy
" n 模式下粘贴系统剪切板的内容
nmap <Leader>v "+p
"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t
"" Map \r to the Reformat Code action
"map \r <Action>(ReformatCode)
"" Map <leader>d to start debug
"map <leader>d <Action>(Debug)
"" Map \b to toggle the breakpoint on the current line
"map \b <Action>(ToggleLineBreakpoint)
" Find more examples here: https://jb.gg/share-ideavimrc
map("i", "<c-b>", "<c-o>b")
map("i", "<c-f>", "<c-o>l")
map("i", "<c-j>", "<c-o>j")
map("i", "<c-k>", "<c-o>k")

118
.tmux.conf Normal file
View File

@@ -0,0 +1,118 @@
# ==== Common ====
# rebind PREFIX to C-a
set-option -g prefix C-a
# set title for terminal(using tmux sesion/window name)
set-option -g set-titles on
set-option -g set-titles-string "#S / #W"
# send interval to 1s to avoid conflicts with vim
set -sg escape-time 1
# set session starts with 1
set -g base-index 1
# set pane starts with 1
setw -g pane-base-index 1
# enable mouse
set -g mouse on
# set history limit
set -g history-limit 10000
# reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# send C-a to other apps
bind C-a send-prefix
# split window horizontally
bind | split-window -h -c "#{pane_current_path}"
# split window vertically
bind - split-window -v -c "#{pane_current_path}"
# create new window with current path
bind c new-window -c "#{pane_current_path}"
# reorder windows
bind R \
move-window -r\; \
display-message "Windows reordered..."
# move cursor between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# rename session/window
bind n command-prompt 'rename-window %%'
bind N command-prompt 'rename-session %%'
# switch window
bind-key , previous-window # <
bind-key . next-window # >
bind-key < swap-window -t :-
bind-key > swap-window -t :+
# move cursor between windows
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# ajdust pane size
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '30'
# Colors
set -g default-terminal "screen-256color"
set -g terminal-overrides ',xterm-256color:Tc'
# Dracula Color
white='#f8f8f2' # Foreground
dark_gray='#282a36' # Background
gray='#44475a' # Current Line / Selection
light_purple='#bd93f9' # Purple
dark_purple='#6272a4' # Comment
cyan='#8be9fd' # Cyan
green='#50fa7b' # Green
orange='#ffb86c' # Orange
red='#ff5555' # Red
pink='#ff79c6' # Pink
yellow='#f1fa8c' # Yellow
set -g status on
set -g status-fg $dark_purple
set -g status-bg $gray
set -g status-justify left
set -g status-interval 1
set -g status-left-length 100
set -g status-right-length 100
# Options -> ⧉ ❐
set -g status-left "#{?client_prefix,#[fg=$dark_gray bg=$green],#[fg=$dark_gray bg=$light_purple]} ⧉ #S "
set -g status-right "#[fg=$white] #{pane_current_path}"
set-window-option -g window-status-current-style "fg=$dark_purple bg=$white"
set-window-option -g window-status-current-format "#[bold italics] #I: #W #F "
# for some unknown reason this tmux section is being set to reverse from
# somewhere so we explictly remove it here
set-window-option -g window-status-style "fg=$dark_gray dim"
set-window-option -g window-status-format "#[none] #I: #{=20:window_name} "
set-window-option -g window-status-separator ""
# Set window notifications
set-option -g monitor-activity on
set-option -g visual-activity off

1
.zlogin Normal file
View File

@@ -0,0 +1 @@
workup

175
.zshrc Normal file
View File

@@ -0,0 +1,175 @@
export GOPATH=$HOME/.go
export GOPROXY=https://goproxy.cn,direct
export PYENV_ROOT="$HOME/.pyenv"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
export CARGO_PATH=$HOME/.cargo
export PATH="/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
export PATH="$CARGO_PATH/bin:$GOPATH/bin:$PYENV_ROOT/shims:$PATH"
export PATH="$HOME/.local/bin:${HOME}/.krew/bin:$PATH"
source $HOME/.antigen/antigen.zsh
antigen use oh-my-zsh
antigen bundle git
antigen bundle pip
antigen bundle kubectl
antigen bundle pyenv
antigen bundle vi-mode
antigen bundle autojump
antigen bundle Aloxaf/fzf-tab
antigen bundle wbingli/zsh-wakatime
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
#antigen theme spaceship-prompt/spaceship-prompt
antigen apply
eval "$(starship init zsh)"
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export MANPAGER="sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu' \
-c 'nnoremap i <nop>' \
-c 'nnoremap <Space> <C-f>' \
-c 'noremap q :quit<CR>' -\""
export KUBECONFIG=$(echo `ls ~/.kube/*config*` | sed 's/ /:/g')
export FZF_DEFAULT_OPTS="--height=50% --layout=reverse"
arch=$(uname -m)
if [ $arch = "x86_64" ]; then
brew_opt="/usr/local/opt"
elif [ $arch = "arm64" ]; then
brew_opt="/opt/homebrew/opt"
fi
LDFLAGS="-L$brew_opt/zlib/lib -L$brew_opt/openssl@3/lib"
CPPFLAGS="-I$brew_opt/zlib/include -I$brew_opt/openssl@3/include"
export LDFLAGS=$LDFLAGS
export CPPFLAGS=$CPPFLAGS
autoload -Uz compinit
compinit
source <(kubectl completion zsh)
source <(helm completion zsh)
alias ta='tmux a'
alias fixscreen='sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist && sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist'
alias urldecode='python3 -c "import sys, urllib.parse as ul; \
print(ul.unquote_plus(sys.argv[1]))"'
alias urlencode='python3 -c "import sys, urllib.parse as ul; \
print (ul.quote_plus(sys.argv[1]))"'
alias zerotier_reload='sudo launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist && sudo launchctl load /Library/LaunchDaemons/com.zerotier.one.plist'
alias git_branch="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'"
alias git_clean="git branch --merged | grep -v 'master' | grep -v 'main' | cat | xargs git branch -d"
#alias pyjson_decode='python3 -c "import sys, json; \
#print(json.dumps(eval(sys.argv[1])))"'
alias pyjson_decode_stdout='python3 -c "import sys, json, subprocess; \
print(json.dumps(eval(subprocess.check_output( \
\"pbpaste\", env={\"LANG\": \"en_US.UTF-8\"}).decode(\"utf-8\"))))"'
alias pyjson_decode='python3 -c "import json, subprocess; \
output=json.dumps(eval(subprocess.check_output(\
\"pbpaste\", env={\"LANG\": \"en_US.UTF-8\"}).decode(\"utf-8\"))).encode(\"utf-8\"); \
process=subprocess.Popen(\"pbcopy\", env={\"LANG\": \"en_US.UTF-8\"}, stdin=subprocess.PIPE); \
process.communicate(output)"'
alias ts_fmt='python3 -c "import datetime, subprocess; \
print(\"UTC+800:\", datetime.datetime.fromtimestamp(int(subprocess.check_output(\"pbpaste\", env={\"LANG\": \"en_US.UTF-8\"}).decode(\"utf-8\")))); \
print(\"UTC+000:\", datetime.datetime.fromtimestamp(int(subprocess.check_output(\"pbpaste\", env={\"LANG\": \"en_US.UTF-8\"}).decode(\"utf-8\"))-8*3600)); \
"'
alias leetcode_today='curl -sL "https://leetcode-cn.com/graphql" -H "content-type: application/json" -d '\''{"operationName":"questionOfToday","variables":{},"query":"query questionOfToday {\n todayRecord {\n question {\n questionFrontendId\n questionTitleSlug\n __typename\n }\n lastSubmission {\n id\n __typename\n }\n date\n userStatus\n __typename\n }\n}\n"}'\'' | jq '\''.data.todayRecord[0].question'\'''
alias clean_tmux_session='ls ~/.tmux/resurrect/* -1dtr | head -n 100 | xargs rm -v'
alias tl='tmux ls && read session && tmux attach -t ${session:-default} || tmux new -s ${session:-default}'
alias ls='lsd'
alias l='ls -l'
alias la='ls -a'
alias lla='ls -la'
alias lt='ls --tree'
alias kns='kubens'
alias kctx='kubectx'
alias kd='kubectl debug'
alias kk='kubectl krew'
alias vim='nvim'
alias vi='nvim'
alias jumper='ssh tangli@10.1.4.14 -p 32200'
alias wol_xps8940="host root.pi.d0zingcat.xyz | cut -d ' ' -f 4 | cat | xargs -I {} /usr/local/bin/wakeonlan -i {} -p 30009 'FC:44:82:13:BA:0F'"
alias nerdctl='lima nerdctl'
alias docker='lima docker'
function workup() {
if [[ -n "$TMUX" ]]; then
return 0
fi
tmux ls -F '#{session_name}' | fzf --bind=enter:replace-query+print-query |xargs echo | read session && tmux attach -t ${session:-default} || tmux new -s ${session:-default}
}
# kill porcess according to keyword
function s_kill() {
key=$1
if [ -z "$key" ]; then
echo "plz specify at least one keyword"
fi
ps -ef | grep $key | head -n 1 | awk '{print $2}' | xargs kill
}
macnst (){
netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
}
# proxy by clashx
function clashproxy() {
# shadowsocksx-r
local proxy=http://127.0.0.1:7890
export https_proxy=$proxy http_proxy=$proxy all_proxy=socks5://127.0.0.1:7891;
echo "proxy all set!"
}
# unset proxy
function clashproxy_unset() {
unset http_proxy
unset https_proxy
unset all_proxy
echo "proxy all unset!"
}
function flush-input() {
sudo killall -9 PAH_Extension TextInputMenuAgent TextInputSwitcher
}
function klogs() {
keyword=$1
k get pods --sort-by=.metadata.creationTimestamp | grep "$keyword" | head -n 1 | awk '{print $1}' | xargs kubectl logs -f
}
#export LESS_TERMCAP_so=$'\E[30;43m'
if [ $(uname -m) = 'arm64' ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
#neofetch
#export LDFLAGS="-L/usr/local/opt/llvm/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
#export CPPFLAGS="-I/usr/local/opt/llvm/include -I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"
#export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
[ -f /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc ] && . /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc
compdef __start_kubectl k

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# dotfiles
My dotfiles.

5
git/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
*.env
.git/
.DS_Store
.python-version
.mypy_cache/

200
nvim/init.lua Normal file
View File

@@ -0,0 +1,200 @@
local cmd = vim.cmd
local o_s = vim.o
local map_key = vim.api.nvim_set_keymap
local g = vim.g
local api = vim.api
local fn = vim.fn
local ncmd = vim.api.nvim_command
local o, wo, bo = vim.o, vim.wo, vim.bo
local buffer = { o, bo }
local window = { o, wo }
local utils = require('utils')
local map = utils.map
local set = utils.set
--vim.lsp.set_log_level('debug')
-- Preset
-- Prerequisites Must have neovim installed
if fn.has('nvim') == 0 then
return
end
-- Ensure packer installed
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
cmd('packadd packer.nvim')
end
-- reopen last position
-- cmd([[ autocmd BufReadPost * normal! g`" ]])
-- Shcemas and colors
set('termguicolors', true) -- 开启24bit的颜色开启这个颜色会更漂亮一些
--cmd [[ colorscheme onebuddy ]]
cmd([[ colorscheme tokyonight ]])
--set('background', 'dark') -- 主题背景 dark-深色; light-浅色
-- CMDs
-- cmd [[syntax enable]]
-- cmd [[syntax on]] -- 开启文件类型侦测
cmd('filetype plugin indent on')
cmd([[ autocmd FileType php setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120 ]])
cmd([[ autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 ]])
cmd([[ autocmd FileType json setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab ]])
cmd([[ autocmd FileType go setlocal tabstop=8 shiftwidth=8 softtabstop=8 textwidth=120 noexpandtab ]])
cmd([[ autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0 ]])
cmd([[ autocmd FileType yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0 expandtab ]])
cmd([[ autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120 ]])
cmd([[ autocmd FileType less,sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120 ]])
cmd(
[[ autocmd FileType javascript,javascript.jsx,javascriptreact,typescript,typescriptreact setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab ]]
)
cmd([[iabbrev pdb import pdb; pdb.set_trace()<ESC>]])
-- auto compile packer
cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
-- cmd [[command ShowBlank set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣]]
-- Settings
-- max timeout for common command
set('timeoutlen', 1000)
-- set number, cusor or line/column
set('nu', true, window)
set('rnu', true, window)
set('cul', true, window)
set('cuc', true, window)
-- tab 缩进
-- set("tabstop", 4) -- 设置Tab长度为4空格
-- set("shiftwidth", 4) -- 设置自动缩进长度为4空格
-- set("autoindent", true) -- 继承前一行的缩进方式,适用于多行注释
-- set("colorcolumn", "80") -- 设置长度提示79
-- set('noswapfile', true) -- 不设置swap文件
set('showmatch', true) -- 显示括号匹配
set('mouse', 'a') -- set scroll mode
set('langmenu', 'zh_CN.UTF-8')
set('helplang', 'cn')
set('encoding', 'utf-8')
set('fencs', 'utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936')
set('hidden', true)
set('wildmenu', true)
set('hlsearch', true)
set('matchtime', 1)
set('updatetime', 100)
set('smarttab', true)
set('expandtab', true)
set('laststatus', 2)
set('showcmd', true)
set('ruler', true)
set('history', 300)
set('backup', false)
set('swapfile', false)
set('foldenable', false)
set('autoread', true)
set('autowrite', true)
set('mouse', 'a')
set('incsearch', true) -- 开启实时搜索
set('ignorecase', true) -- 搜索时大小写不敏感
set('number', true, window)
-- set('relativenumber', true, window)
set('cursorline', true, window)
set('cursorcolumn', true, window)
set('signcolumn', 'auto:2')
-- set("textwidth", 120, buffer)
set('smartindent', true, buffer)
set('autoindent', true, buffer)
set('cindent', true, buffer)
set('shiftwidth', 4, buffer)
set('softtabstop', 4, buffer)
set('tabstop', 4, buffer)
-- set autowrite
-- set("backspace", "indent,eol,start")
-- Key mappings
-- map Leader key to <space>
g.mapleader = [[ ]]
-- v 模式下复制内容到系统剪切板
map('v', '<Leader>cp', '"+yy')
-- n 模式下复制一行到系统剪切板
map('n', '<Leader>cp', '"+yy')
-- n 模式下粘贴系统剪切板的内容
map('n', '<Leader>v', '"+p')
-- reload vimrc
map('n', '<leader>rv', ':source $MYVIMRC<CR>')
-- insert mode mapping
map('i', '<c-b>', '<c-o>b')
map('i', '<c-f>', '<c-o>l')
map('i', '<c-j>', '<c-o>j')
map('i', '<c-k>', '<c-o>k')
map('n', '<F1>', '<nop>')
map('i', '<F1>', '<nop>')
--map('i', '<c-k>', '<up>')
--map('i', '<c-j>', '<down>')
--map('i', '<c-h>', '<left>')
--map('i', '<c-l>', '<right>')
-- map('n', '<leader>e', '1<c-w>w')
-- map('n', '<leader>p', ':wincmd p<CR>')
--" Plug 'airblade/vim-gitgutter'
map('i', '<C-e>', 'copilot#Accept()', { expr = true })
vim.g.copilot_no_tab_map = 1
vim.g.copilot_no_maps = 1
vim.g.copilot_assume_mapped = 1
require('plugins')
-- Plug settings
-- map("n", "<space>e", ":NvimTreeToggle<CR>", {noremap = false})
-- map("n", "<space>R", ":NvimTreeRefresh<CR>", {noremap = false})
-- Neoformat
if not fn.executable('luafmt') then
cmd([[ :!npm install -g lua-fmt]])
end
-- todo-comments
-- require("todo-comments").setup {}
-- spaceline
g['spaceline_seperate_style'] = 'arrow'
g['spaceline_colorscheme'] = 'one'
-- barbar
local opts = { noremap = true, silent = true }
map('n', '=', ':BufferPick<CR>', opts)
-- choosewin
map('n', '-', '<Plug>(choosewin)', { noremap = false })
-- Some configurations not able to migrate
api.nvim_exec(
[[
" set nocompatible
"function! NearestMethodOrFunction() abort
" return get(b:, 'vista_nearest_method_or_function', '')
"endfunction
"
"set statusline+=%{NearestMethodOrFunction()}
]],
false
)

View File

View File

@@ -0,0 +1,33 @@
require('gitsigns').setup({
signs = {
add = { hl = 'GitSignsAdd', text = '', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
change = { hl = 'GitSignsChange', text = '', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
delete = { hl = 'GitSignsDelete', text = '', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
topdelete = { hl = 'GitSignsDelete', text = '', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
},
keymaps = {
-- Default keymap options
noremap = true,
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns.actions\".next_hunk()<CR>'" },
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns.actions\".prev_hunk()<CR>'" },
},
word_diff = false,
current_line_blame = true,
linehl = true,
numhl = true,
sign_priority = 6,
count_chars = {
[1] = '1', -- '₁',
[2] = '2', -- '₂',
[3] = '3', -- '₃',
[4] = '4', -- '₄',
[5] = '5', -- '₅',
[6] = '6', -- '₆',
[7] = '7', -- '₇',
[8] = '8', -- '₈',
[9] = '9', -- '₉',
['+'] = '', -- '₊',
},
})

View File

@@ -0,0 +1,11 @@
return {
filetypes = { 'yaml', 'yml' },
settings = {
yaml = {
schemas = {
['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*',
Kubernetes = '/*k8s.yaml',
},
},
},
}

View File

@@ -0,0 +1,125 @@
local lsp = vim.lsp
local api = vim.api
local cmd = vim.cmd
local lsp_installer = require('nvim-lsp-installer')
local lsp_installer_servers = require('nvim-lsp-installer.servers')
-- lspconfig && lspinstaller
local on_attach = function(client, bufnr)
local function buf_set_keymap(...)
api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
api.nvim_buf_set_option(bufnr, ...)
end
--require "lsp_signature".on_attach()
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap = true, silent = true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<C-y>', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>Telescope lsp_references<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>Telescope lsp_definitions<CR>', opts)
buf_set_keymap('n', 'go', '<cmd>Telescope lsp_document_symbols<CR>', opts)
buf_set_keymap('n', 'gO', '<cmd>Telescope lsp_workspace_symbols<CR>', opts)
--buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.cmd([[
augroup Format
au! * <buffer>
au BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
augroup END
]])
end
end
local capabilities = lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
-- Register a handler that will be called for all installed servers.
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = on_attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
}
if server.name == 'sumneko_lua' then
local luadev = require('lua-dev').setup({
lspconfig = {
settings = {
Lua = {
workspace = {
checkThirdParty = false,
},
},
},
},
})
opts = vim.tbl_deep_extend('force', opts, luadev)
end
if server.name == 'yamlls' then
--local yamlls_opts = {
--settings = {
--yaml = {
--filetypes = { 'yaml', 'yml' },
--schemaStore = {
--enable = true,
--url = 'https://www.schemastore.org/api/json/catalog.json',
--},
--validate = false,
--schemas = {
--['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*',
--kubernetes = '/*.k8s.yaml',
--},
--},
--},
--}
local conf = require(string.format('config.lsp_servers.%s', server.name))
opts = vim.tbl_deep_extend('force', opts, conf)
end
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)
local null_ls = require('null-ls')
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua.with({
extra_args = { '--config-path', vim.fn.expand('~/.config/stylua.toml') },
}),
null_ls.builtins.formatting.shfmt,
},
on_attach = on_attach,
})

106
nvim/lua/config/lualine.lua Normal file
View File

@@ -0,0 +1,106 @@
require('lualine').setup({
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename', 'lsp_progress' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})
local colors = {
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local config = {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = { '', '' },
section_separators = { '', '' },
disabled_filetypes = {},
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'filename' },
lualine_c = {},
lualine_x = {},
lualine_y = { 'encoding', 'fileformat', 'filetype' },
lualine_z = { 'branch' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x ot right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
--ins_left {
--'lsp_progress',
--display_components = { 'lsp_client_name', { 'title', 'percentage', 'message' }},
---- With spinner
---- display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' }},
--colors = {
--percentage = colors.cyan,
--title = colors.cyan,
--message = colors.cyan,
--spinner = colors.cyan,
--lsp_client_name = colors.magenta,
--use = true,
--},
--separators = {
--component = ' ',
--progress = ' | ',
--message = { pre = '(', post = ')'},
--percentage = { pre = '', post = '%% ' },
--title = { pre = '', post = ': ' },
--lsp_client_name = { pre = '[', post = ']' },
--spinner = { pre = '', post = '' },
--message = { commenced = 'In Progress', completed = 'Completed' },
--},
--display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } },
--timer = { progress_enddelay = 500, spinner = 1000, lsp_client_name_enddelay = 1000 },
--spinner_symbols = { '🌑 ', '🌒 ', '🌓 ', '🌔 ', '🌕 ', '🌖 ', '🌗 ', '🌘 ' },
--}

View File

@@ -0,0 +1,72 @@
local g = vim.g
local map = require('utils').map
g.nvim_tree_highlight_opened_files = 1
g.nvim_tree_icons = {
symlink = '',
git = {
untracked = '?',
},
folder = {
arrow_open = '',
arrow_closed = '',
default = '',
open = '',
},
}
g.nvim_tree_show_icons = {
git = 1,
folders = 1,
files = 1,
folder_arrows = 1,
}
local tree_cb = require('nvim-tree.config').nvim_tree_callback
require('nvim-tree').setup({
view = {
width = 35,
side = 'left',
mappings = {
list = {
{ key = '<C-v>', cb = tree_cb('vsplit') },
{ key = '<C-s>', cb = tree_cb('split') },
{ key = 'v', cb = tree_cb('vsplit') },
{ key = 's', cb = tree_cb('split') },
{ key = '-', cb = '<Plug>(choosewin)' },
{ key = '<C-t>', cb = ':ToggleTerm<cr>' },
},
},
},
diagnostics = {
enable = true,
icons = {
error = '',
warning = '',
info = '',
hint = '',
},
},
update_to_buf_dir = {
enable = true,
auto_update = true,
},
update_focused_file = {
enable = true,
},
filters = {
custom = { '.git' }, -- ignore .git
},
auto_close = true,
hijack_netrw = true,
update_cwd = true,
focus_tree = false,
open_on_setup = true,
})
map('n', '<leader>te', ':NvimTreeToggle<CR>')
vim.cmd([[
augroup nvimtree
autocmd VimEnter * lua require('nvim-tree').toggle(false, true)
augroup END
]])

View File

@@ -0,0 +1,18 @@
local cmd = vim.cmd
local g = vim.g
local map = require('utils').map
-- vim-bookmarks
require('telescope').load_extension('vim_bookmarks')
g['bookmark_sign'] = ''
g['bookmark_highlight_lines'] = 1
g['bookmark_no_default_key_mappings'] = 1
cmd([[highlight BookmarkSign ctermbg=NONE ctermfg=160]])
cmd([[highlight BookmarkLine ctermbg=194 ctermfg=NONE]])
map('n', 'mm', ':BookmarkToggle<CR>')
map('n', 'mA', ':Telescope vim_bookmarks all<CR>')
map('n', 'ma', ':Telescope vim_bookmarks current_file<CR>')
-- map("n", "ma", ":BookmarkShowAll<CR>")

View File

@@ -0,0 +1,42 @@
local fn = vim.fn
-- nvim-cmp
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
fn['vsnip#anonymous'](args.body)
end,
},
formatting = {
format = function(entry, vim_item)
-- set a name for each source
vim_item.menu = ({
buffer = '[Buf]',
nvim_lsp = '[LSP]',
luasnip = '[Snip]',
nvim_lua = '[Lua]',
latex_symbols = '[Latex]',
})[entry.source.name]
return vim_item
end,
},
mapping = {
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
--["<C-e>"] = cmp.mapping.close(),
['<C-e>'] = function(fallback)
fallback()
end,
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
},
})

View File

@@ -0,0 +1,14 @@
local g = vim.g
local map = require('utils').map
-- floaterm
g['floaterm_keymap_new'] = '<F7>'
g['floaterm_keymap_next'] = '<F8>'
g['floaterm_keymap_prev'] = '<F9>'
g['floaterm_keymap_toggle'] = '<F10>'
g['floaterm_position'] = 'bottomright'
map('t', '<Esc>', '<c-\\><c-n>')
map('n', '<leader>t', 'V:FloatermSend<CR>:FloatermToggle<CR>')
map('v', '<leader>t', ':FloatermSend<CR>:FloatermToggle<CR>')
map('n', '<leader>r', 'V:FloatermSend<CR>:FloatermToggle<CR>')
map('v', '<leader>r', ':FloatermSend<CR>:FloatermToggle<CR>')

View File

@@ -0,0 +1,16 @@
local map = require('utils').map
-- hopworld
require('hop').setup({ keys = 'etovxqpdygfblzhckisuran' })
map('n', '<leader>w', '<cmd>HopWordAC<cr>')
map('n', '<leader>fw', '<cmd>HopWord<cr>')
map('n', '<leader>s', '<cmd>HopChar1<cr>')
map('n', '<leader>k', '<cmd>HopLineStartBC<cr>')
map('n', '<leader>j', '<cmd>HopLineStartAC<cr>')
map('v', '<leader>k', '<cmd>HopLineStartBC<cr>')
map('v', '<leader>j', '<cmd>HopLineStartAC<cr>')
map('n', '<leader>h', '<cmd>HopWordBC<cr>')
map('n', '<leader>l', '<cmd>HopWordAC<cr>')
map('v', '<leader>h', '<cmd>HopWordBC<cr>')
map('v', '<leader>l', '<cmd>HopWordAC<cr>')

View File

@@ -0,0 +1,8 @@
local map = require('utils').map
local g = vim.g
-- nerdcommenter
map('', '<leader>cc', 'V}:call NERDComment("x", "toggle")<CR>')
map('', '<leader>cu', 'V{:call NERDComment("x", "toggle")<CR>')
g['NERDTrimTrailingWhitespace'] = 1
g['NERDSpaceDelims'] = 1

View File

@@ -0,0 +1,30 @@
local map = require('utils').map
-- telescope
local actions = require('telescope.actions')
require('telescope').setup({
defaults = {
layout_config = {
horizontal = {
width = 0.75,
height = 0.6,
},
},
mappings = {
i = {
['<esc>'] = actions.close,
['<C-j>'] = actions.move_selection_previous,
['<C-k>'] = actions.move_selection_next,
['<C-l>'] = { '<Right>', type = 'command' },
['<C-h>'] = { '<Left>', type = 'command' },
['<C-f>'] = actions.preview_scrolling_down,
['<C-b>'] = actions.preview_scrolling_up,
},
},
},
})
map('n', '<leader>ff', '<cmd>Telescope find_files<cr>')
map('n', '<leader>fg', '<cmd>Telescope live_grep<cr>')
map('n', '<leader>fb', '<cmd>Telescope buffers<cr>')
map('n', '<leader>;', '<cmd>Telescope commands<cr>')

View File

@@ -0,0 +1,14 @@
-- treesitter
require('nvim-treesitter.configs').setup({
ensure_installed = 'maintained', -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = { 'javascript' }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = {}, -- list of language that will be disabled
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
})

View File

@@ -0,0 +1,21 @@
local g = vim.g
-- vim-go
-- let g:go_code_completion_enabled = 1 -- Enable Autocompletion
--g['go_fmt_command'] = 'goimports' -- 格式化将默认的 gofmt 替换
g['go_autodetect_gopath'] = 1
g['go_list_type'] = 'quickfix'
g['go_version_warning'] = 1
g['go_highlight_types'] = 1
g['go_highlight_fields'] = 1
g['go_highlight_functions'] = 1
g['go_highlight_function_calls'] = 1
g['go_highlight_operators'] = 1
g['go_highlight_extra_types'] = 1
g['go_highlight_methods'] = 1
g['go_highlight_generate_tags'] = 1
g['godef_split'] = 2
--g['go_fmt_command'] = 'goimports' " Run goimports along gofmt on each save
g['go_imports_mode'] = 'goimports'
g['go_imports_autosave'] = 0 -- do not auto import
g['go_auto_type_info'] = 1 -- automatically get signature/type info for object under cursor

View File

View File

@@ -0,0 +1,46 @@
local g = vim.g
local map = require('utils').map
local Terminal = require('toggleterm.terminal').Terminal
local lazygit = Terminal:new({
cmd = 'lazygit',
dir = 'git_dir',
close_on_exit = true,
direction = 'float',
float_opts = {
border = 'double',
},
hidden = true,
-- function to run on opening the terminal
--on_open = function(term)
--vim.cmd("startinsert!")
--vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
--end,
-- function to run on closing the terminal
--on_close = function(term)
--vim.cmd("Closing terminal")
--end,
})
function _lazygit_toggle()
lazygit:toggle()
end
function _G.set_terminal_keymaps()
local opts = { noremap = true }
vim.api.nvim_buf_set_keymap(0, 't', '<C-o>', [[<C-\><C-n><C-w>]], opts)
--vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
--vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
--vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
--vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
--vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
end
vim.api.nvim_set_keymap('n', '<leader>g', '<cmd>lua _lazygit_toggle()<CR>', { noremap = true, silent = true })
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
map('n', '<leader>tm', ':ToggleTerm size=15 direction=horizontal<CR>')
require('toggleterm').setup({})

15
nvim/lua/config/vista.lua Normal file
View File

@@ -0,0 +1,15 @@
local api = vim.api
api.nvim_exec(
[[
" Ensure you have installed some decent font to show these pretty symbols, then you can enable icon for the kind.
let g:vista#renderer#enable_icon = 1
" The default icons can't be suitable for all the filetypes, you can extend it as you wish.
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
]],
false
)

241
nvim/lua/plugins.lua Normal file
View File

@@ -0,0 +1,241 @@
local fn = vim.fn
local g = vim.g
local cmd = vim.cmd
local lsp = vim.lsp
local api = vim.api
local map = require('utils').map
-- Ensure packer installed
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
cmd('packadd packer.nvim')
end
return require('packer').startup(function(use)
use('wbthomason/packer.nvim')
use('folke/lua-dev.nvim')
use('folke/tokyonight.nvim')
use('kyazdani42/nvim-web-devicons')
use('tpope/vim-fugitive') -- git fugitive
use({
'lewis6991/gitsigns.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('config.gitsigns')
end,
})
use({
'folke/which-key.nvim',
config = function()
require('which-key').setup({
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
})
end,
})
use({
'folke/trouble.nvim',
config = function()
require('trouble').setup({})
end,
})
--use({
--'TimUntersberger/neogit',
--requires = 'nvim-lua/plenary.nvim',
--config = function()
--local neogit = require('neogit')
--neogit.setup({
--integrations = {
--diffview = true,
--},
--})
--end,
--})
--use({
--'sindrets/diffview.nvim',
--requires = 'nvim-lua/plenary.nvim',
--config = function()
--require('diffview').setup({})
--end,
--})
use({
'MattesGroeger/vim-bookmarks',
requires = 'tom-anders/telescope-vim-bookmarks.nvim',
config = function()
require('config.nvim_bookmarks')
end,
})
use('junegunn/vim-easy-align') -- 可以快速对齐的插件
use({
't9md/vim-choosewin',
})
-- use "easymotion/vim-easymotion"
--use {
--"voldikss/vim-floaterm",
--config = function()
--require "config.nvim_floaterm"
--end
--}
use({
'akinsho/toggleterm.nvim',
config = function()
require('config.toggleterm')
end,
})
use('wakatime/vim-wakatime')
use('psf/black')
use({
'preservim/nerdcommenter',
config = function()
require('config.nvim_vimgo')
end,
})
use({
'windwp/nvim-autopairs',
config = function()
-- nvim-autopairs
require('nvim-autopairs').setup({})
end,
})
use({
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
require('config.nvim-tree')
end,
})
use({
'nvim-telescope/telescope.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function()
require('config.nvim_telescope')
end,
})
use({
'hrsh7th/nvim-cmp',
config = function()
require('config.nvim_cmp')
end,
requires = {
'hrsh7th/cmp-vsnip',
'hrsh7th/vim-vsnip',
'hrsh7th/vim-vsnip-integ',
},
})
use('hrsh7th/cmp-buffer')
use('hrsh7th/cmp-nvim-lsp')
use({
'github/copilot.vim',
setup = function() end,
config = function()
require('config.copilot')
end,
})
--use('sbdchd/neoformat')
use({
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
config = function()
require('config.nvim_treesitter')
end,
})
use({
'iamcco/markdown-preview.nvim',
run = 'cd app && yarn install',
cmd = { 'MarkdownPreview', 'MarkdownPreviewStop' },
})
--use {"glepnir/spaceline.vim", requires = "kyazdani42/nvim-web-devicons"}
use({
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
config = function()
require('config.lualine')
end,
})
use({
'j-hui/fidget.nvim',
config = function()
require('fidget').setup({})
end,
})
-- use 'arkav/lualine-lsp-progress'
use({
'romgrk/barbar.nvim',
requires = { 'kyazdani42/nvim-web-devicons' },
})
use({
'folke/todo-comments.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function()
require('todo-comments').setup({})
end,
})
use({
'phaazon/hop.nvim',
as = 'hop',
config = function()
-- you can configure Hop the way you like here; see :h hop-config
require('config.nvim_hop')
end,
})
--use {
--"ray-x/lsp_signature.nvim",
--config = function()
--require "lsp_signature".setup {
--transpancy = 10,
--hint_prefix = "😼",
---- zindex = 50,
--}
--end
--}
use({
'preservim/tagbar',
config = function()
require('config.tagbar')
end,
})
--use {
--"liuchengxu/vista.vim",
--config = function()
--require "config.vista"
--end
--}
-- LANGUAGES
use({
'neovim/nvim-lspconfig',
})
use({
'jose-elias-alvarez/null-ls.nvim',
})
use({
'williamboman/nvim-lsp-installer',
config = function()
require('config.lspconfig')
end,
})
use({
'fatih/vim-go',
run = ':GoUpdateBinaries',
config = function()
require('config.nvim_vimgo')
end,
})
-- erlang
use('vim-erlang/vim-erlang-tags')
-- markdown
use('iamcco/mathjax-support-for-mkdp')
use('iamcco/markdown-preview.vim')
--beancount
use('nathangrigg/vim-beancount')
-- python
use('Vimjas/vim-python-pep8-indent')
-- rust
use('rust-lang/rust.vim')
use('andrewstuart/vim-kubernetes')
end)
-- require("todo-comments").setup {}

54
nvim/lua/utils.lua Normal file
View File

@@ -0,0 +1,54 @@
local cmd = vim.cmd
local o_s = vim.o
local map_key = vim.api.nvim_set_keymap
local g = vim.g
local api = vim.api
local fn = vim.fn
local ncmd = vim.api.nvim_command
local lsp = vim.lsp
local o, wo, bo = vim.o, vim.wo, vim.bo
local buffer = { o, bo }
local window = { o, wo }
local function opt(o, v, scopes)
scopes = scopes or { o_s }
for _, s in ipairs(scopes) do
s[o] = v
end
end
local function autocmd(group, cmds, clear)
clear = clear == nil and false or clear
if type(cmds) == 'string' then
cmds = { cmds }
end
cmd('augroup ' .. group)
if clear then
cmd([[au!]])
end
for _, c in ipairs(cmds) do
cmd('autocmd ' .. c)
end
cmd([[augroup END]])
end
local function map(modes, lhs, rhs, opts)
opts = opts or {}
opts.noremap = opts.noremap == nil and true or opts.noremap
if type(modes) == 'string' then
modes = { modes }
end
for _, mode in ipairs(modes) do
map_key(mode, lhs, rhs, opts)
end
end
local function set(opt, v, scopes)
scopes = scopes or { o }
for _, s in ipairs(scopes) do
s[opt] = v
end
end
return { opt = opt, autocmd = autocmd, map = map, set = set, ncmd = ncmd }

2
pycodestyle Normal file
View File

@@ -0,0 +1,2 @@
[pycodestyle]
ignore=E501

146
setup.sh Executable file
View File

@@ -0,0 +1,146 @@
#!/usr/bin/env bash
# this is a script to setup dotfiles for myself.
set -x
FILES=(
.gitignore
.zshrc
.zlogin
.tmux.conf
.ideavimrc
)
CONFIG_FILES=(
nvim
git
tmux
raycast
wezterm
pycodestyle
starship.toml
stylua.toml
)
WORKING_DIR=$(pwd)
HOME_DIR="$HOME"
function init() {
sudo xcode-select --install
sudo xcodebuild -license accept
if [[ $(command -v brew) = "" ]]; then
echo "Installing brew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
brew update
brew install zsh
chsh -s /bin/zsh
ssh-keygen
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>"$HOME/.zshrc"
source "$HOME/.zshrc"
fi
}
function recover() {
OS="$(uname)"
# Homebrew
if [ ! $(which brew) ]; then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if [ "$OS" = 'Darwin' ]; then
export PATH=/usr/local/bin/:$PATH
elif [ "$OS" = 'Linux' ]; then
export PATH=/home/linuxbrew/.linuxbrew/bin/:$PATH
fi
# antigen
if [ ! -f $HOME/.antigen/antigen.zsh ]; then
mkdir -p $HOME/.antigen/
curl -L git.io/antigen >$HOME/.antigen/antigen.zsh
fi
mkdir -p $HOME/.kube/
# dotfiles
echo "Linking files..."
for i in ${FILES[@]}; do
ln -svfn $WORKING_DIR/$i $HOME_DIR/$i
done
echo "Linking config files..."
for i in ${CONFIG_FILES[@]}; do
ln -svfn $WORKING_DIR/$i $HOME_DIR/.config/$i
done
# submodules
echo 'Syncing Submodules...'
git submodule init
git submodule update --init --recursive
git submodule foreach --recursive git fetch
git submodule foreach git merge origin master
# brew bundle
echo "Installing by brew..."
suffix="$OS."$(echo $(hostname) | cut -d '.' -f 1)
mv .Brewfile.$suffix Brewfile
brew bundle -v
mv Brewfile .Brewfile.$suffix
# others
git config --global core.excludesfile ~/.config/git/.gitignore
git config --global init.defaultBranch main
$(brew --prefix)/opt/fzf/install
}
function manual_install() {
wget -qO- http://stevenygard.com/download/class-dump-3.5.tar.gz | tar xvz - -C /usr/local/bin && chmod u+x /usr/local/bin/class-dump
wget -O /usr/local/bin/class-dump https://github.com/AloneMonkey/MonkeyDev/raw/master/bin/class-dump && chmod u+x /usr/local/bin/class-dump
pip install --user frida-tools
}
function backup() {
# brew backup
brew tap Homebrew/bundle
brew bundle dump -f
mv Brewfile .Brewfile."$(uname)."$(echo $(hostname) | cut -d '.' -f 1)
}
function purge() {
uninstall_oh_my_zsh
brew remove $(brew list --formula)
for i in ${FILE_OR_DIRS[@]}; do
rm -rf $WORKING_DIR/$i $HOME_DIR/$i
done
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
}
function usage() {
echo "Try to backup/recover my dotfiles"
echo " "
echo "options:"
echo "-m mode, accept recover/backup/purge"
}
while getopts ":m:" opt; do
case ${opt} in
m)
echo $OPTARG
if [ "$OPTARG"x == "recover"x ]; then
recover
elif [ "$OPTARG"x == "backup"x ]; then
backup
else
echo "Invalid option: -$OPTARG" >&2
fi
exit 0
;;
\?)
usage
exit 0
;;
esac
done

20
starship.toml Normal file
View File

@@ -0,0 +1,20 @@
format = '$directory$git_branch$git_commit$git_state$git_status$golang$helm$java$nodejs$python$red$ruby$rust$kubernetes$custom$cmd_duration$lua$line_break$jobs$time$status$shell$character'
[git_commit]
tag_disabled = true
only_detached = false
disabled = false
commit_hash_length = 8
[kubernetes]
disabled = false
symbol = '⎈ '
format = '[$symbol$context \($namespace\)]($style) '
[python]
pyenv_version_name = false
[golang]
symbol = 'ʕ◔ϖ◔ʔ '
[rust]

2
stylua.toml Normal file
View File

@@ -0,0 +1,2 @@
indent_type = "Spaces"
quote_style = "AutoPreferSingle"

1
tmux/plugins/tpm Submodule

Submodule tmux/plugins/tpm added at b699a7e01c

View File

@@ -0,0 +1,11 @@
[colors]
foreground = "#c0caf5"
background = "#24283b"
cursor_bg = "#c0caf5"
cursor_border = "#c0caf5"
cursor_fg = "#24283b"
selection_bg = "#364A82"
selection_fg = "#c0caf5"
ansi = ["#1D202F", "#f7768e", "#9ece6a", "#e0af68", "#7aa2f7", "#bb9af7", "#7dcfff", "#a9b1d6"]
brights = ["#414868", "#f7768e", "#9ece6a", "#e0af68", "#7aa2f7", "#bb9af7", "#7dcfff", "#c0caf5"]

40
wezterm/wezterm.lua Normal file
View File

@@ -0,0 +1,40 @@
local wezterm = require('wezterm')
return {
font_size = 14,
font = wezterm.font_with_fallback({
'JetBrains Mono',
'JetBrainsMono Nerd Font Mono',
}),
colors = {
tab_bar = {
active_tab = {
bg_color = '#24283b',
fg_color = '#c0caf5',
},
},
},
color_scheme = 'tokyonight',
window_frame = {
font_size = 14.0,
},
window_padding = {
left = 5,
right = 5,
top = 0,
bottom = 0,
},
foreground_text_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.2,
},
use_ime = true, -- fix Chinese
skip_close_confirmation_for_processes_named = {
'fzf',
'zsh',
'fzf',
},
keys = {
{ key = 'w', mods = 'CMD', action = wezterm.action({ CloseCurrentTab = { confirm = false } }) },
},
}