215 Commits

Author SHA1 Message Date
laily c95a1d70b1 fix: docker-install skip installed packages and suspend needrestart
Avoid upgrading already-installed packages and restarting unrelated
services on Ubuntu 24.04, where apt-pinvoke -m u overrides NEEDRESTART_MODE.
2026-08-29 14:37:36 +08:00
laily d6eee6465b feat: update mise 2026-08-28 14:49:34 +08:00
laily 2aba5d7162 feat: modify skiff to pouch 2026-08-25 15:32:09 +08:00
laily a0ea27099b feat: add upstream gitea 2026-08-10 12:22:52 +08:00
laily 8072e344ac feat: add ssh2 2026-08-04 14:59:54 +08:00
laily 4382de9ddc feat: improve scan-ip device identification 2026-07-28 15:47:24 +08:00
laily 8f2ebfc3de feat: add skiff to path 2026-07-27 17:48:01 +08:00
laily 6a92e31a90 feat: sudo by default 2026-07-25 22:16:38 +08:00
laily 045242e2c2 feat: sudo by default 2026-07-25 22:12:11 +08:00
laily 6e57abcec6 feat: sudo by default 2026-07-25 22:04:59 +08:00
laily 7654790973 feat: add ssh-harden 2026-07-25 21:57:16 +08:00
laily c974d858be feat: add ssh-harden 2026-07-25 21:49:20 +08:00
laily 5598ad5b3f feat: add ssh-harden 2026-07-25 21:33:52 +08:00
laily 9617bbbd27 feat: add ssh-harden 2026-07-25 21:27:49 +08:00
laily 1e12ae5c6e feat: add ssh-harden 2026-07-25 21:21:09 +08:00
laily b804e42ef1 feat: add ssh-harden 2026-07-25 21:13:15 +08:00
laily c5d99958d4 feat: add init.sh 2026-07-25 21:02:07 +08:00
laily db8a531b92 feat: add ssh-key-only 2026-07-25 20:58:38 +08:00
laily dc58f0c253 feat: modify scan-ip 2026-07-21 23:35:28 +08:00
laily a376995947 feat: update ghostty ssh term 2026-07-14 21:45:02 +08:00
laily ca88abbfc9 feat: add modify docker config 2026-07-02 12:33:40 +08:00
laily b08868cf16 feat: add sudo write 2026-06-27 14:28:18 +08:00
laily 8dcd6e3ac9 fix: add alias for script 2026-06-27 12:00:04 +08:00
laily a43e8bc885 feat: add git-setup 2026-06-27 11:55:41 +08:00
laily c12b212091 fix: init docker 2026-06-27 11:29:07 +08:00
laily 0548056ca4 fix: toggle-resion 2026-06-27 11:20:47 +08:00
laily acac6c3650 feat: update git credential 2026-06-26 11:18:08 +08:00
laily 783965d826 fix: make help.autocorrect compatible with old Git versions
Use numeric 0 in main config so legacy Git does not fail on parse; keep prompt in platform includes for Git 2.36+.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:15:24 +08:00
laily 9551225ee9 feat: update git credential 2026-06-26 11:10:23 +08:00
laily 84c7f37c53 docs: add AGENTS.md as shared dotfile maintenance conventions
Point Cursor and Claude rules at AGENTS.md for cross-tool agent guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 15:19:25 +08:00
laily 67291a9a50 feat: add script catalog and -h help for all dotfile scripts
Introduce ff script -h with auto descriptions, shared help.sh, and usage flags across script/*.sh.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 15:09:35 +08:00
laily 1f6b042b26 feat: split git credential config by OS on Linux and macOS
Use includeIf so Linux prefers libsecret with cache fallback, while macOS keeps osxkeychain.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 11:04:15 +08:00
laily e8aae9738b feat: add nosudo 2026-06-25 10:46:07 +08:00
laily 0e7fe55474 fix: support ubuntu 2026-06-10 10:26:05 +08:00
laily ff420521ac feat: add script to change debian source 2026-06-04 15:32:13 +08:00
laily 77c9259ade fix: update docker mirror to tsinghua source 2026-06-04 15:26:12 +08:00
laily 81bebadff8 fix: init fish 2026-06-01 00:41:46 +08:00
laily 058c2e58af fix: <C-p> for sidekick 2026-06-01 00:26:19 +08:00
laily e63107f6ff fix: ff update 2026-06-01 00:23:39 +08:00
laily ec19670ebc feat: modify dirsize 2026-05-30 14:30:46 +08:00
laily d2f1ca33a0 feat: add dirsize 2026-05-30 14:21:17 +08:00
laily 21b12675e9 fix: dirsize 2026-05-30 13:42:51 +08:00
laily 609536a15c feat: add move window of tmux 2026-05-27 10:15:53 +08:00
laily cccf5fd750 feat: move windows 2026-05-27 09:50:02 +08:00
laily 64a059b8ec fix: modify sidekick width 2026-05-27 09:43:32 +08:00
laily 082781b4d2 feat: add tags 2026-05-26 17:51:15 +08:00
laily 4e8e3b7073 feat: add notify command, modify sidekick with tmux 2026-05-26 16:54:53 +08:00
laily c32e8b4015 feat: add mise config 2026-05-26 13:07:40 +08:00
laily 137e67503a feat: scan-ip support port 2026-05-25 21:36:14 +08:00
laily d82c9af650 feat: add ghostty 2026-05-24 14:14:38 +08:00
laily a53a3e0030 fix: unzip nvim package 2026-05-21 17:45:49 +08:00
laily 01998497e3 fix: scan-ip 2026-05-17 14:03:17 +08:00
laily 6abd1b7185 fix: neovim install support aarch64 2026-05-14 17:22:24 +08:00
laily b938a04538 fix: neovim install support aarch64 2026-05-14 17:17:37 +08:00
laily 27e5c11ea9 feat: add dirsize 2026-05-13 22:44:10 +08:00
laily 68e6780238 feat: add ghostty 2026-05-12 11:12:14 +08:00
laily e6bff850c3 feat: add lazygit install 2026-05-11 18:01:05 +08:00
laily c2439bfe72 feat: disable some features of snacks 2026-05-10 14:50:09 +08:00
laily fd0d59a7df fix: set zsh as default shell when init it 2026-05-10 14:13:37 +08:00
laily 9edcf1ffb4 fix: load telescopt fail 2026-05-10 14:04:01 +08:00
laily f8635b0969 feat: add zsh 2026-05-10 13:55:06 +08:00
laily 8e32f5c533 feat: update sidekick toggle 2026-05-10 13:44:39 +08:00
laily 34273ee6d5 feat: update toggle sidekick 2026-05-10 12:43:14 +08:00
laily 34f619c172 feat: update toggle region 2026-05-09 19:17:31 +08:00
laily 1101796d39 feat: update toggle region 2026-05-09 19:11:29 +08:00
laily 6be4389e2e feat: update toggle region 2026-05-09 19:08:35 +08:00
laily 89d808a864 feat: update toggle region 2026-05-09 19:02:21 +08:00
laily 67c5128840 feat: update toggle region 2026-05-09 18:32:47 +08:00
laily 2950f6b442 feat: update nvim config 2026-04-01 02:50:48 +08:00
laily 524dd75eb3 feat: update nvim config 2026-04-01 02:28:02 +08:00
laily 9fd296a777 feat: modify sidekick 2026-04-01 00:47:22 +08:00
laily 4ec54aeff7 feat: update nvim config 2026-03-31 16:26:32 +08:00
laily 3bc05c5abb feat: add glow 2026-03-30 12:13:18 +08:00
laily 61c1f088c7 feat: add journalctl --user 2026-03-24 11:35:15 +08:00
laily e4296ed34d feat: update fish 2026-03-24 11:02:45 +08:00
laily 478449d3a8 feat: update 2026-03-18 17:35:07 +08:00
laily df359c6e07 feat: add vim function 2026-03-18 17:34:47 +08:00
laily 96c923d6cc feat: update bigfiles search 2026-03-02 15:38:33 +08:00
laily 9587780c13 feat: add mise env 2026-02-12 10:53:38 +08:00
laily d58bfd63f4 fix: ctrl+p in neovim 2026-01-17 22:24:19 +08:00
laily ff4b73d8ac feat: add mise 2026-01-17 22:04:21 +08:00
laily fba3be8fd8 fix: nvim 2026-01-17 21:52:18 +08:00
laily 72fb4fc412 feat: update nvom 2026-01-17 14:45:11 +08:00
laily 108a8420f9 feat: update nvim and add gemini cli 2026-01-17 14:00:12 +08:00
laily 5e3ed80e39 feat: update nvim script 2026-01-17 13:38:17 +08:00
laily ddc76e7695 feat: update gitconfig 2025-12-26 11:50:12 +08:00
laily 9d15bcc3c4 feat: add scan-port script 2025-12-16 20:59:34 +08:00
laily f3064c2370 feat: support scanip 2025-12-16 15:33:54 +08:00
laily e4e6281742 fix: dc alias 2025-12-13 19:09:30 +08:00
laily 17b983ffb4 feat: support set debian apt source 2025-12-13 15:29:20 +08:00
laily 7f087b9e5f fix: cursor config 2025-12-02 16:23:42 +08:00
laily 5a78b07c51 feat: update 2025-12-01 19:55:54 +08:00
laily 8de370bdf5 feat: update readme 2025-11-29 19:22:45 +08:00
laily ab0812037d feat: add install mihomo 2025-11-29 19:18:33 +08:00
laily 1fe69f6c95 feat: support nvm(fnm) 2025-11-28 16:16:36 +08:00
laily 9bd43f9f9c feat: update git alias 2025-11-18 14:25:09 +08:00
laily d9bce3b9ee feat: modify golangci-lint config 2025-11-11 20:18:34 +08:00
laily 8de75b7faf feat: update golangci-lint config 2025-11-11 20:10:47 +08:00
laily 78b6f9e6c5 feat: add build_script 2025-10-22 11:40:12 +08:00
laily d80f88dbb4 feat: add ff update 2025-10-19 18:13:44 +08:00
laily 01029777d5 feat: update ff command 2025-10-19 18:06:50 +08:00
laily 03b384b819 feat: add command 2025-10-19 18:02:14 +08:00
laily 2bd26fc9ef feat: 增强用户密码设置功能,支持交互式和非交互式环境 2025-07-17 12:23:23 +08:00
laily 246f230b7f feat: 更新代理设置并添加用户初始化脚本 2025-07-17 12:18:01 +08:00
laily 4bf69165e0 feat: modify filename 2025-07-10 11:08:16 +08:00
laily 239640a996 feat: update git and vscode config 2025-07-09 11:21:21 +08:00
laily 2b04c95e48 feat: add vscode keybinding 2025-06-20 21:14:53 +08:00
laily aab4f145ce feat: add pnpm 2025-06-19 16:25:40 +08:00
laily 1189ac8fd1 fix: install golang 2025-02-26 17:24:45 +08:00
laily bbb57da4b5 feat: modify github git config 2025-02-26 17:20:21 +08:00
laily 7df9df1801 feat: modify github git config 2025-02-26 17:10:44 +08:00
laily a55e3ca1e2 feat: add gvm 2025-02-19 17:21:00 +08:00
laily 6c0d9c3d1d feat: add docker compose alias 2025-01-15 17:37:43 +08:00
laily 21058acac5 feat: add docker compose alias 2025-01-15 17:32:26 +08:00
laily 490e9eff3a feat: add docker compose alias 2025-01-15 17:29:00 +08:00
laily ffc4fcd91f fix: add shortcut for tmux mouse on 2025-01-08 11:24:52 +08:00
laily 0bcae45cd9 fix: script function 2024-11-27 11:41:10 +08:00
laily d72b02118c Merge branch 'main' of github.com:hilaily/.dotfile 2024-11-27 11:30:06 +08:00
laily bb752943a5 fix: update fish script 2024-11-27 11:29:56 +08:00
laily d3f12850bd fix: merge 2024-11-22 11:20:48 +00:00
laily 878d67c8e4 Merge branch 'main' of github.com:hilaily/.dotfile 2024-11-18 16:47:35 +08:00
laily 3f7fabc88a chore: update plugin 2024-11-18 16:47:14 +08:00
laily 5dca7835bf fix: iterm mouse scroll 2024-11-18 16:40:30 +08:00
laily cad5e667f8 fix: docker install 2024-11-18 16:32:16 +08:00
laily 11aeacdc88 fix: nvim install 2024-11-18 16:30:29 +08:00
laily d6135e1ac5 feat: add docker-install.sh 2024-11-17 20:11:55 +08:00
laily 8f4ebb0071 fix: fish 2024-11-11 15:58:55 +08:00
laily 5517cd4186 fix: fish 2024-11-11 15:56:56 +08:00
laily f2da334604 fix: mason 2024-11-11 00:27:45 +08:00
laily 0ceb4dc061 fix: modify font 2024-11-10 23:50:11 +08:00
laily eddda52c71 Merge branch 'main' of github.com:hilaily/.dotfile 2024-11-10 23:49:57 +08:00
laily 3c370d80cc fix: 2024-11-10 23:49:52 +08:00
laily 4f10716dcd fix: merge 2024-11-07 11:14:04 +08:00
laily 25871a335b fix: nvim config 2024-11-06 23:23:01 +08:00
laily 80d0449402 fix: install python 2024-11-06 23:09:01 +08:00
laily 041f993017 fix: add command reset-proxy 2024-11-06 23:01:01 +08:00
laily aec3961983 feat: add font 2024-11-06 22:57:50 +08:00
laily efdbffa489 fix: modify font 2024-11-06 18:01:38 +08:00
laily 6ac8de0999 feat: add install firacode 2024-11-06 12:50:59 +08:00
laily dfa04656dd feat: add nvim init 2024-11-05 12:07:29 +08:00
laily 89b7a7c969 Merge branch 'main' of github.com:hilaily/.dotfile 2024-11-04 14:11:51 +08:00
laily 12af360c37 fix: node path 2024-11-01 17:44:30 +08:00
laily 66a781c5d0 feat: modify git remote 2024-10-25 18:14:23 +08:00
laily eaa9c6d924 feat: add iterm2 2024-10-25 18:13:08 +08:00
laily ff4629cafe feat: modify install nvim 2024-10-25 18:02:02 +08:00
laily 8b609eb959 feat: add croncheck.sh 2024-10-15 11:08:30 +08:00
laily b6dc6b839e feat: add sudoo 2024-09-26 11:11:03 +08:00
laily ddb09fb2cf fix: modify gitignore 2024-08-12 14:29:32 +08:00
laily eeb97adf94 feat: add neotest 2024-08-07 15:14:42 +08:00
laily 67c9d89f41 fix: add alias 2024-08-05 17:25:38 +08:00
laily 30dfd1a02d Merge branch 'main' of github.com:hilaily/.dotfile 2024-08-03 17:56:33 +08:00
laily 9d0b63a2e9 Merge branch 'main' of https://github.com/hilaily/.dotfile into main 2024-08-03 08:05:55 +00:00
laily f139016c25 fix 2024-08-03 16:03:23 +08:00
laily a159a4179e fix 2024-08-03 16:02:45 +08:00
laily 8991b192ea temp 2024-08-03 15:42:13 +08:00
laily 8241518dd2 fix: add resurrect for tmux 2024-07-29 11:43:39 +08:00
laily 4812514474 fix: outline width 2024-07-22 17:06:30 +08:00
laily 3ba2f0b62c fix: git editor 2024-07-22 08:54:47 +00:00
laily c22f3b28b0 fix: merge 2024-07-22 08:54:04 +00:00
laily 8433ab381e fix: modify per 2024-07-22 08:53:49 +00:00
laily 5a9193eb38 fix: modify useless plugin 2024-07-19 17:04:44 +08:00
laily dc376f31e3 fix: remove useless code 2024-06-28 15:33:38 +08:00
laily 0247a4c2a0 merge 2024-06-22 00:09:57 +08:00
laily a64b47a65f feat: add shortcut of swith pane 2024-06-20 15:33:12 +08:00
laily 785d8bde8c feat: add tpm for tmux 2024-06-19 12:22:18 +08:00
laily d97fb14d1f fix: modify mason server 2024-06-12 17:49:36 +08:00
laily 8c5df554ed chrore: update fish script 2024-06-11 23:06:19 +08:00
laily a9f48d2d59 fix: add git alias 2024-06-11 17:53:43 +08:00
laily 7bb20c64e2 fix: modify add to path 2024-06-08 17:16:53 +08:00
laily fd96710321 fix: modify fish/git init script 2024-06-08 16:24:22 +08:00
laily f0186eaefb feat: add script 2024-06-05 19:37:18 +08:00
laily 6283ab3cfb feat: support dap 2024-05-21 14:22:14 +08:00
laily 22b880e642 fix: modify gopls for completion 2024-05-08 20:20:43 +08:00
laily 2a68d143a8 fix: modify lsp 2024-05-04 15:47:07 +08:00
laily 05053a87b7 fix: disable auto format 2024-04-30 17:43:53 +08:00
laily 27dff38b7c fix: new lsp 2024-04-29 19:06:42 +08:00
laily cabec5bd63 fix: rm unused files 2024-03-22 15:48:03 +08:00
laily e430d2a721 fix: add env 2024-03-22 11:06:57 +08:00
laily a48619031d fix: modify nvim config 2024-03-22 11:05:02 +08:00
laily 7ef3a2f073 fix: jump 2024-02-29 14:52:44 +08:00
laily ddda0a2a02 fix: save lazy-lock 2024-02-29 10:54:55 +08:00
laily 685b477e1b fix: plugin 2024-02-28 22:01:26 +08:00
laily dc01c402c8 fix: modify plugin directory 2024-02-28 16:38:02 +08:00
laily b1698fb7cf fix: update telegraf 2024-02-22 20:26:43 +08:00
laily fad2c5fed9 fix: update telegraf 2024-02-22 20:17:41 +08:00
laily 23c83906b5 feat: add prettier 2024-02-21 20:54:58 +08:00
laily 820d501911 fix: c-p to search file 2024-02-21 17:41:48 +08:00
laily 0b7374d42a feat: add new plugin 2024-02-20 21:52:06 +08:00
laily b49026c12e feat: new config 2024-02-20 21:19:43 +08:00
laily 3fad1b11f4 feat: update gitcofig 2024-02-20 19:24:22 +08:00
laily b63fb4494c feat: add fish 2024-02-05 15:28:56 +08:00
laily a103031734 fix: modify nvim-tree 2023-11-06 14:58:22 +08:00
laily f12a4caccb fix: update autocommands 2023-09-15 14:10:38 +08:00
laily fa8b291b1d feat: modify some script 2023-09-13 14:21:52 +08:00
laily 47f16510b2 feat: modify for v0.9.2 2023-09-13 12:29:12 +08:00
laily d2aa7bad86 feat: modify git config 2023-09-07 18:03:21 +08:00
laily 9b9a929281 fix(ci): modify err check 2023-07-31 19:50:17 +08:00
laily e10a850527 feat: add plugin nvim lint 2023-04-27 11:43:55 +08:00
laily 7d83cc0d6e feat: add comment ci 2023-04-26 17:35:00 +08:00
laily d42ae1bb29 fix: linter 2023-04-21 12:24:49 +08:00
laily 96f4181e5f fix: linter 2023-04-21 12:05:30 +08:00
laily 53ab00c196 fix: workrepo 2023-04-19 11:32:29 +08:00
laily 1def7fc888 fix: add alias 2023-04-19 10:57:07 +08:00
laily c20d5f6024 fix: add a command 2023-03-21 15:13:21 +08:00
laily 6c36082c4f merge: master 2023-03-21 14:58:18 +08:00
laily 2072b48df7 fix: modify sub gitconfig 2023-03-21 14:53:18 +08:00
laily 83dbf07703 fix: modify sub gitconfig 2023-03-21 14:48:19 +08:00
laily 1fd0cdaf63 fix: update linux brew 2023-03-14 15:37:04 +08:00
laily 06cf9bae2c fix: add lock file 2023-01-03 11:53:59 +08:00
laily 77d16ce217 fix: modify nvim colorscheme 2022-12-30 14:10:56 +08:00
laily 8bc810fd39 fix: modify nvim plugin 2022-12-30 12:02:36 +08:00
laily 3180d287e7 Merge branch 'master' of github.com:hilaily/.dotfile 2022-12-30 11:35:23 +08:00
laily 46a920d574 fix: modify alias 2022-12-30 11:35:17 +08:00
laily 9a61a98643 fix: modify client.resolved_capabilities to client.server_capabilities 2022-12-01 21:12:05 +08:00
laily c92d815b3f 1. update nvim config of version 0.8.1
2. modify brew environment
2022-12-01 21:06:07 +08:00
196 changed files with 11538 additions and 4899 deletions
+46
View File
@@ -0,0 +1,46 @@
.PHONY: image tag version
# 默认架构
GOOS ?= linux
GOARCH ?= $(shell go env GOARCH)
# 常用架构组合
PLATFORMS ?= linux/amd64,linux/arm64
# Docker 构建
docker-local:
$(MAKE) check-image-name
GOOS=$(GOOS) GOARCH=$(GOARCH) .build_scripts/build_go.sh
GOOS=$(GOOS) GOARCH=$(GOARCH) .build_scripts/build_image.sh $(IMAGE_NAME) Dockerfile.local
docker-local-amd64:
$(MAKE) check-image-name
GOOS=linux GOARCH=amd64 .build_scripts/build_go.sh
GOOS=linux GOARCH=amd64 .build_scripts/build_image.sh $(IMAGE_NAME) Dockerfile.local
docker-local-arm64:
$(MAKE) check-image-name
GOOS=linux GOARCH=arm64 .build_scripts/build_go.sh
GOOS=linux GOARCH=arm64 .build_scripts/build_image.sh $(IMAGE_NAME) Dockerfile.local
docker-local-multiarch:
$(MAKE) check-image-name
make build-all-multiarch
PLATFORM=$(PLATFORMS) .build_scripts/build_image.sh $(IMAGE_NAME) Dockerfile.local
check-image-name:
@if [ -z "$(IMAGE_NAME)" ]; then \
echo "IMAGE_NAME is not set"; \
exit 1; \
fi; \
tag:
@VERSION=$$(cat VERSION); \
echo "Creating tag: $$VERSION"; \
git tag $$VERSION; \
git push origin $$VERSION; \
echo "Tag $$VERSION created and pushed successfully"
version: .build_scripts/version.sh
@.build_scripts/version.sh "$(filter-out version,$(MAKECMDGOALS))" "$(VERSION)"
+250
View File
@@ -0,0 +1,250 @@
# Scripts 使用说明
这个目录包含项目的构建和版本管理脚本。
## 文件说明
- `Makefile`: 构建、推送 Docker 镜像和版本管理的自动化脚本
- `version.sh`: 版本号管理脚本
## Makefile 使用
### 可配置的环境变量
- `IMAGE_NAME`: Docker 镜像名称
### 独立使用
#### 1. 使用默认镜像名
```bash
cd scripts
make image
```
#### 2. 使用自定义镜像名
```bash
cd scripts
IMAGE_NAME=myregistry/myimage make image
```
或者:
```bash
export IMAGE_NAME=myregistry/myimage
cd scripts
make image
```
### 在其他 Makefile 中引用
有多种方式可以在其他 Makefile 中引用这个 Makefile:
#### 方式一:使用 `$(MAKE) -C` 调用子目录(推荐)
在项目根目录创建主 Makefile:
```makefile
.PHONY: build-image
# 定义镜像名称
IMAGE_NAME = myregistry/myproject
# 调用 scripts 目录下的 Makefile
build-image:
IMAGE_NAME=$(IMAGE_NAME) $(MAKE) -C scripts image
# 或者使用 export 导出环境变量
build-image-export:
export IMAGE_NAME=$(IMAGE_NAME) && $(MAKE) -C scripts image
```
使用:
```bash
make build-image
```
#### 方式二:使用 `include` 包含
在项目根目录的 Makefile 中:
```makefile
# 设置变量(会覆盖被包含文件中的默认值)
IMAGE_NAME = myregistry/myproject
# 包含 scripts 目录的 Makefile
include scripts/Makefile
# 现在可以直接调用 image 目标
.PHONY: build
build: image
```
使用:
```bash
make build
```
**注意**: 使用 `include` 时,相对路径会基于主 Makefile 的位置,可能需要调整路径。
#### 方式三:环境变量传递(跨多层 Makefile)
根目录 `Makefile`:
```makefile
.PHONY: all
# 设置并导出环境变量,使所有子 make 都能访问
export IMAGE_NAME = myregistry/myproject
export VERSION = v1.0.0
all:
@echo "Building with IMAGE_NAME=$(IMAGE_NAME)"
$(MAKE) -C scripts image
```
#### 方式四:通过命令行传递多个变量
```bash
IMAGE_NAME=myregistry/myimage VERSION=v2.0.0 make -C scripts image
```
### 完整示例
假设项目结构:
```
/project-root
├── Makefile # 主 Makefile
├── scripts/
│ ├── Makefile # 本文件
│ └── version.sh
└── ...
```
主 `Makefile` 内容示例:
```makefile
.PHONY: help build-backend build-frontend build-all
# 项目配置
PROJECT_NAME = myproject
REGISTRY = docker.io/myorg
BACKEND_IMAGE = $(REGISTRY)/$(PROJECT_NAME)-backend
FRONTEND_IMAGE = $(REGISTRY)/$(PROJECT_NAME)-frontend
help:
@echo "Available targets:"
@echo " build-backend - Build and push backend image"
@echo " build-frontend - Build and push frontend image"
@echo " build-all - Build and push all images"
build-backend:
@echo "Building backend image..."
IMAGE_NAME=$(BACKEND_IMAGE) $(MAKE) -C scripts image
build-frontend:
@echo "Building frontend image..."
IMAGE_NAME=$(FRONTEND_IMAGE) $(MAKE) -C scripts image
build-all: build-backend build-frontend
@echo "All images built successfully!"
# 也可以创建版本管理的快捷方式
version:
$(MAKE) -C scripts version $(filter-out $@,$(MAKECMDGOALS))
# 允许传递额外参数
%:
@:
```
使用示例:
```bash
# 构建后端镜像
make build-backend
# 构建前端镜像
make build-frontend
# 构建所有镜像
make build-all
# 版本管理
make version patch
make version v1.2.3
```
## 版本管理
### 基本用法
```bash
# 查看当前版本和帮助
make version
# 设置特定版本
make version v1.0.0
# 或者
make version VERSION=v1.0.0
# 递增版本
make version patch # v1.0.0 -> v1.0.1
make version minor # v1.0.0 -> v1.1.0
make version major # v1.0.0 -> v2.0.0
# 预发布版本
make version pre # v1.0.0 -> v1.0.0-rc.1
make version pre alpha # v1.0.0 -> v1.0.0-alpha.1
make version pre beta # v1.0.0 -> v1.0.0-beta.1
make version pre rc 2 # v1.0.0 -> v1.0.0-rc.2
```
## 创建标签
```bash
# 基于 VERSION 文件创建并推送 Git 标签
make tag
```
## 注意事项
1. **环境变量优先级**:
- 命令行传递 > 父 Makefile export > 本 Makefile 默认值
2. **工作目录**:
- 使用 `$(MAKE) -C scripts` 会切换到 scripts 目录执行
- 注意脚本中的相对路径问题
3. **变量传递**:
- `IMAGE_NAME=xxx $(MAKE)`: 只对当前 make 有效
- `export IMAGE_NAME=xxx; $(MAKE)`: 对所有子 make 有效
- `export IMAGE_NAME=xxx` 后再调用: 对整个 shell 会话有效
4. **调试技巧**:
```bash
# 查看实际使用的变量值
make -C scripts image -n # 干运行,只显示命令不执行
```
## 扩展建议
如果需要更复杂的配置,可以创建配置文件:
```makefile
# config.mk
PROJECT_NAME = myproject
REGISTRY = docker.io/myorg
VERSION = v1.0.0
# 在主 Makefile 中
include config.mk
export IMAGE_NAME = $(REGISTRY)/$(PROJECT_NAME)
```
这样可以将配置集中管理,便于维护。
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Build Go binary
# Args:
# 1. OUTPUT_DIR: output directory, default is ./output, the full output directory is $OUTPUT_DIR/$GOOS-$GOARCH
set -e
if [ -z $GOOS ]; then
echo "GOOS is not set"
exit 1
fi
if [ -z $GOARCH ]; then
echo "GOARCH is not set"
exit 1
fi
OUTPUT_DIR=${1:-./output/$GOOS-$GOARCH}
mkdir -p $OUTPUT_DIR/
go build -o $OUTPUT_DIR/server ./cmd/
if [ -d ./conf ]; then
mkdir -p $OUTPUT_DIR/conf/
cp -r ./conf/* $OUTPUT_DIR/conf/
fi
if [ -d ./scripts ]; then
mkdir -p $OUTPUT_DIR/scripts/
cp -r ./scripts/* $OUTPUT_DIR/scripts/
fi
if [ -f ./scripts/Makefile ]; then
cp ./scripts/Makefile $OUTPUT_DIR/
fi
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# Build Docker image
# Args:
# 1. IMAGE_NAME: image name, required
# 2. DOCKER_FILE: docker file, default is Dockerfile
set -e
IMAGE_NAME=$1
DOCKER_FILE=${2:-Dockerfile}
if [ -z "$IMAGE_NAME" ]; then
echo "IMAGE_NAME is not set";
exit 1;
fi;
VERSION=$(cat VERSION);
echo "Building image: $IMAGE_NAME:$VERSION with Dockerfile: $DOCKER_FILE";
docker build -t $IMAGE_NAME:$VERSION -f $DOCKER_FILE .;
docker push $IMAGE_NAME:$VERSION;
if [[ "$VERSION" != *"-"* ]]; then
echo "This is a stable release, also tagging as latest";
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest;
docker push $IMAGE_NAME:latest;
echo "Latest tag pushed successfully";
else
echo "This is a pre-release version, skipping latest tag";
fi;
echo "Image built and pushed successfully: $IMAGE_NAME:$VERSION"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# Build Web
set -e
if [ -z $GOOS ]; then
echo "GOOS is not set"
exit 1
fi
if [ -z $GOARCH ]; then
echo "GOARCH is not set"
exit 1
fi
OUTPUT_DIR=${1:-./output/$GOOS-$GOARCH}
cd web
pnpm install
pnpm build
cd ..
mkdir -p $OUTPUT_DIR/
rm -rf $OUTPUT_DIR/web/*
mkdir -p $OUTPUT_DIR/web/
cp -r web/out/* $OUTPUT_DIR/web/
+152
View File
@@ -0,0 +1,152 @@
#!/bin/bash
# Version management script
# Args:
# 1. ARGS: arguments, optional
# 2. VERSION_VAR: version variable, optional
set -e
ARGS="$1"
VERSION_VAR="$2"
CURRENT_VERSION=$(cat VERSION)
show_usage() {
echo "Current version: $CURRENT_VERSION"
echo "Usage:"
echo " make version VERSION=v1.0.0 # Set specific version"
echo " make version v1.0.0 # Set specific version"
echo " make version patch # Increment patch version"
echo " make version minor # Increment minor version"
echo " make version major # Increment major version"
echo " make version pre # Add/increment pre-release (default: rc)"
echo " make version pre alpha # Add alpha pre-release"
echo " make version pre beta # Add beta pre-release"
echo " make version pre rc # Add rc pre-release"
echo " make version pre alpha 2 # Add specific alpha version"
}
parse_version() {
local version="$1"
# Remove 'v' prefix and split by '-'
local clean_version="${version#v}"
local base_version="${clean_version%-*}"
local pre_release=""
if [[ "$clean_version" == *"-"* ]]; then
pre_release="${clean_version#*-}"
fi
# Split base version
IFS='.' read -r major minor patch <<< "$base_version"
echo "$major $minor $patch $pre_release"
}
increment_version() {
local type="$1"
local version_parts
read -r major minor patch pre_release <<< "$(parse_version "$CURRENT_VERSION")"
case "$type" in
"patch")
patch=$((patch + 1))
echo "v$major.$minor.$patch"
;;
"minor")
minor=$((minor + 1))
patch=0
echo "v$major.$minor.$patch"
;;
"major")
major=$((major + 1))
minor=0
patch=0
echo "v$major.$minor.$patch"
;;
esac
}
handle_prerelease() {
local args=($1)
local version_parts
read -r major minor patch pre_release <<< "$(parse_version "$CURRENT_VERSION")"
local base_version="$major.$minor.$patch"
local pre_type="rc"
local pre_num="1"
# Parse arguments
if [[ ${#args[@]} -ge 3 ]]; then
# make version pre alpha 2 (明确指定版本号)
pre_type="${args[1]}"
pre_num="${args[2]}"
elif [[ ${#args[@]} -ge 2 ]]; then
# make version pre alpha (指定类型,智能处理版本号)
pre_type="${args[1]}"
if [[ -n "$pre_release" ]]; then
# 当前已经是 pre-release
IFS='.' read -r current_type current_num <<< "$pre_release"
if [[ "$current_type" == "$pre_type" ]]; then
# 相同类型,递增版本号
pre_num=$((current_num + 1))
else
# 不同类型,重置为 1
pre_num="1"
fi
else
# 当前是正式版本,从 1 开始
pre_num="1"
fi
else
# make version pre (智能处理)
if [[ -n "$pre_release" ]]; then
# 当前已经是 pre-release,递增版本号
IFS='.' read -r current_type current_num <<< "$pre_release"
pre_type="$current_type"
pre_num=$((current_num + 1))
else
# 当前是正式版本,添加默认 pre-release
pre_type="rc"
pre_num="1"
fi
fi
echo "v$base_version-$pre_type.$pre_num"
}
update_version() {
local new_version="$1"
echo "Updating version from $CURRENT_VERSION to $new_version"
echo "$new_version" > VERSION
git add .
git commit -m "update version to $new_version"
git push origin HEAD
echo "[$new_version] Version file updated and pushed successfully"
}
main() {
if [[ -n "$ARGS" ]]; then
local first_arg="${ARGS%% *}"
case "$first_arg" in
"patch"|"minor"|"major")
new_version=$(increment_version "$first_arg")
;;
"pre")
new_version=$(handle_prerelease "$ARGS")
;;
*)
new_version="$first_arg"
;;
esac
update_version "$new_version"
elif [[ -n "$VERSION_VAR" ]]; then
update_version "$VERSION_VAR"
else
show_usage
fi
}
main "$@"
+10
View File
@@ -0,0 +1,10 @@
---
description: dotfile 维护约定(详见 AGENTS.md)
alwaysApply: true
---
# dotfile 项目
修改本仓库前请先阅读并遵循根目录 **[AGENTS.md](../AGENTS.md)** 中的维护约定(目录结构、`*-install` / `*-init`、脚本 `-h`、`ff` 入口、软链 init 等)。
AGENTS.md 为跨工具单一事实来源(Cursor、Claude Code、Codex 等均可使用)。
+8
View File
@@ -2,3 +2,11 @@
.SpaceVim.d/init.vim .SpaceVim.d/init.vim
.DS_Store .DS_Store
nvim/plugin nvim/plugin
_set_env_*.sh
_set_env.sh
log
cn.sh
__pycache__
Makefile
.claude/
script/clash.sh
-356
View File
@@ -1,356 +0,0 @@
run:
tests: false
timeout: 1m
linters:
enable:
- govet
- staticcheck
- unused
- ineffassign
- typecheck
- exportloopref
- bodyclose
- gofmt
- stylecheck
- revive
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
disable-all: true
linters-settings:
staticcheck:
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
checks: ["all"]
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
max-open-files: 2048
# When set to false, ignores files with "GENERATED" header, similar to golint.
# See https://github.com/mgechev/revive#available-rules for details.
# Default: false
ignore-generated-header: true
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity: error
# Enable all available rules.
# Default: false
enable-all-rules: true
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
# Default: 0.8
confidence: 0.1
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant
- name: add-constant
severity: warning
disabled: false
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: "0,1,2"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit
- name: argument-limit
severity: warning
disabled: false
arguments: [4]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic
- name: atomic
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters
- name: banned-characters
severity: warning
disabled: false
arguments: ["Ω", "Σ", "σ", "7"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
- name: blank-imports
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc
- name: call-to-gc
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity
- name: cognitive-complexity
severity: warning
disabled: false
arguments: [7]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming
- name: confusing-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results
- name: confusing-results
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
- name: constant-logical-expr
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
- name: context-as-argument
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
- name: context-keys-type
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic
- name: cyclomatic
severity: warning
disabled: false
arguments: [3]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace
- name: datarace
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
- name: deep-exit
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
- name: defer
severity: warning
disabled: false
arguments:
- ["call-chain", "loop"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
- name: dot-imports
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
- name: duplicated-imports
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
- name: empty-block
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
- name: error-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
- name: error-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
- name: error-strings
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
- name: errorf
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
- name: exported
severity: warning
disabled: false
arguments:
- "checkPrivateReceivers"
- "sayRepetitiveInsteadOfStutters"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header
- name: file-header
severity: warning
disabled: false
arguments:
- This is the text that must appear at the top of source files.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
- name: flag-parameter
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit
- name: function-result-limit
severity: warning
disabled: false
arguments: [2]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length
- name: function-length
severity: warning
disabled: false
arguments: [10, 0]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return
- name: get-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
- name: identical-branches
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
- name: if-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
- name: increment-decrement
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
- name: indent-error-flow
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist
- name: imports-blacklist
severity: warning
disabled: false
arguments:
- "crypto/md5"
- "crypto/sha1"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit
- name: line-length-limit
severity: warning
disabled: false
arguments: [80]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs
- name: max-public-structs
severity: warning
disabled: false
arguments: [3]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter
- name: modifies-parameter
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver
- name: modifies-value-receiver
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs
- name: nested-structs
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order
- name: optimize-operands-order
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
- name: package-comments
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
- name: range
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
- name: range-val-in-closure
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
- name: range-val-address
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming
- name: receiver-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
- name: redefines-builtin-id
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int
- name: string-of-int
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
severity: warning
disabled: false
arguments:
- - 'core.WriteError[1].Message'
- '/^([^A-Z]|$)/'
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
- name: superfluous-else
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
- name: time-equal
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming
- name: time-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
severity: warning
disabled: false
arguments:
- ["ID"] # AllowList
- ["VM"] # DenyList
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
- name: var-declaration
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
- name: unconditional-recursion
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
- name: unexported-return
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
severity: warning
disabled: false
arguments:
- "fmt.Printf"
- "myFunction"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code
- name: unreachable-code
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
- name: waitgroup-by-value
severity: warning
disabled: false
-45
View File
@@ -1,45 +0,0 @@
setw -g mode-keys vi
#unbind ^b
#set -g prefix 'C-a'
#set -g prefix `
#bind-key ` send-prefix
bind r source-file ~/.tmux.conf \; display-message "Config reloaded"
# 切分面板
# unbind '"'
bind - splitw -v -c '#{pane_current_path}'
# unbind %
bind | splitw -h -c '#{pane_current_path}'
# 开启 24bit 真彩色,tmux > 2.2 开始支持
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",*256col*:Tc"
set-option -g mouse on
# 绑定hjkl键为面板切换的上下左右键
bind k select-pane -U # 绑定k为↑
bind j select-pane -D # 绑定j为↓
bind h select-pane -L # 绑定h为←
bind l select-pane -R # 绑定l为→
# 绑定Ctrl+hjkl键为面板上下左右调整边缘的快捷指令
bind -r K resizep -U 10 # 绑定Ctrl+k为往↑调整面板边缘10个单元格
bind -r J resizep -D 10 # 绑定Ctrl+j为往↓调整面板边缘10个单元格
bind -r H resizep -L 10 # 绑定Ctrl+h为往←调整面板边缘10个单元格
bind -r L resizep -R 10 # 绑定Ctrl+l为往→调整面板边缘10个单元格
# 设置tmux的延迟,文档说当有干扰的时候可以设置这个参数,比如影响vim编辑的时候
set -s escape-time 1
# 设置窗口名为当前目录名
set-option -g status-interval 10
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'
set-option -g set-titles on
#set-option -g set-titles-string "#{session_name} - #{host}"
set-option -g set-titles-string "#{session_name}"
# tmux resurrect
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
-145
View File
@@ -1,145 +0,0 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="laily"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
extract
docker
docker-compose
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Ctrl+b/f 向后/前移动一个词
bindkey "^b" backward-word
bindkey "^f" forward-word
# Turn off all beeps
unsetopt BEEP
# Turn off autocomplete beeps
# unsetopt LIST_BEEP
# brew
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_NO_AUTO_UPDATE=true # 禁止 brew 每次安装软件都 upate
# git
export REVIEW_BASE="master"
# go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export GOPROXY=goproxy.cn
export GOSUMDB="sum.golang.google.cn"
[ -f ~/.zprofile ] && source ~/.zprofile
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# add z
eval "$(lua /usr/local/z.lua/z.lua --init zsh)"
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
# add nvim
export PATH=$PATH:/usr/local/nvim/bin:/usr/local/osx-64/nvim/bin
# for terminal notify
# https://github.com/julienXX/terminal-notifier
alias alert='terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal
# git
alias gitb="git branch --show-current | tr -d '\n' | pbcopy"
alias ct="go test -gcflags=all=-l -cover ./..."
alias ci="golangci-lint -c=~/.dotfile/.golangci.yml run ./..."
alias gmt="go mod tidy"
alias gt="go test -gcflags=all=-l "
alias swg="swag init -o docs -g "
alias sws="swagger serve -F=swagger"
+97
View File
@@ -0,0 +1,97 @@
# dotfile 维护约定
个人 dotfiles 仓库(`~/.dotfile`)。本文件供 AI coding agent 与维护者共用:新增或改造配置/脚本时请遵循以下规则。
## 常用命令
```bash
ff script -h # 列出 script/ 下所有脚本及说明
ff script <name> # 运行脚本
make -f Makefile.scripts <name> # 同上(make 入口)
ff region # 切换 CN_REGION(国内/国外镜像)
ff reload # 重载 fish 配置
```
## 目录职责
| 路径 | 用途 |
|------|------|
| `script/` | 可执行脚本(安装、初始化、工具);已加入 fish `PATH` |
| `script/common/` | 脚本共享片段(`help.sh`、`os-arch.sh`) |
| `fish/default.fish` | 共享 fish 配置(进 git) |
| `~/.config/fish/config.fish` | 本机 wrapper,仅 `source` default.fish + 可选 `custom.fish` |
| `fish/functions/`、`fish/completions/` | fish 函数与补全;`fish-init` 会软链到 `~/.config/fish/` |
| `git/`、`nvim/`、`tmux/`、`zsh/`、`cursor/`、`ghostty/`、`mise/` 等 | 各工具**真实配置**,由对应 `*-init` 软链到系统路径 |
| `Makefile.scripts` | `make <script-name>` 运行 `script/<name>.sh` |
## 脚本命名
- **`*-install.sh`**:安装软件/运行时(如 `docker-install`、`nvim-install`、`mise-install`)
- **`*-init.sh`**:把 dotfile 配置**软链接**到系统默认路径(如 `git-init`、`fish-init`、`nvim-init`)
- **工具脚本**:动词或名词(`dns-clean`、`scan-ip`、`nosudo`、`docker-group`、`dirsize`)
- 文件名与 `make` / `ff script` 子命令一致(无扩展名调用)
## 新增脚本 checklist
1. 放在 `script/`,shebang + **一行 `#` 功能描述**(供 `ff script -h` 自动展示)
2. `source "$SCRIPT_DIR/common/help.sh"`,实现 `usage()`,支持 **`-h` / `--help`**
3. 需要平台判断时用 `script/common/os-arch.sh`
4. 依赖国内镜像的安装脚本读取 **`CN_REGION=1`**(`toggle-region` / `ff region`)
5. 若需 fish 补全,更新 `fish/completions/ff.fish`(描述从脚本头注释提取)
## init 脚本模式
- 目标路径已有文件:**先备份**(`*.bak` 或 `*.backup.<timestamp>`),再 `ln -sf` 指向 `~/.dotfile/...`
- 已存在且指向正确的软链:**幂等跳过**
- 示例:`git-init` → `~/.gitconfig`;`nvim-init` → `~/.config/nvim`;`ghostty-init` → 各平台 Ghostty 配置目录
- **fish-init** 特殊:不链整个 `config.fish`,只在顶部插入 `source ~/.dotfile/fish/default.fish`,并链 `functions/`、`completions/`
## install 脚本模式
- 优先用系统包管理器(brew/apt),其次官方安装脚本或 Release 二进制到 `~/.local/bin`
- Debian/Ubuntu 安装类脚本应支持 `CN_REGION` 切换镜像(参考 `docker-install.sh`)
- 需要 root 的脚本在 usage 里写 `sudo`,不要静默假设
## Fish / `ff` 入口
- 跑脚本:`ff script <name>` 或 `ff s <name>`(走 `execute-script.fish`)
- 列脚本:`ff script -h`
- 新增 `ff` 子命令时:改 `fish/functions/ff.fish` + `fish/completions/ff.fish`
## Git 配置
- 公共配置在 `git/.gitconfig`
- **凭据**(所有 Git 版本):`git/git-credential.sh` 写在主配置里,使用 `!$HOME/.dotfile/...`(Git 不展开 `~`)
- macOS:`osxkeychain` → 回退 `store`(`~/.git-credentials`)
- Linux:`libsecret` → 回退 `store`
- 平台扩展(可选):`git/.gitconfig.darwin` / `.gitconfig.linux` 仅在高版本 Git 下通过 includeIf 加载
- `help.autocorrect`:主配置为 `0`(兼容旧 Git);Git ≥ 2.36 的平台文件里为 `prompt`
## 边界(不要做的事)
- 不要把密钥、webhook、本机专用路径写进 git(`script/clash.sh` 等已在 `.gitignore`)
- 不要改 `~/.config/fish/config.fish` 进仓库;本机差异放 `custom.fish`
- 不要为 init 复制整份配置到 `$HOME`;**优先软链接**到 dotfile
- 脚本改动保持最小 diff,风格与相邻脚本一致(bash、`set -euo pipefail` 视情况)
- 未经明确要求不要 `git commit` / `git push`
## 参考模板(新 bash 脚本)
```bash
#!/bin/bash
# 一行功能描述
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/common/help.sh"
usage() {
cat <<'EOF'
用法: ...
选项:
-h, --help 显示此帮助
EOF
}
dotfile_help_requested "${1:-}" && dotfile_show_help
# ... 正文
```
+3
View File
@@ -0,0 +1,3 @@
# Claude Code
本仓库的 AI / 维护约定见 **[AGENTS.md](./AGENTS.md)**。修改 dotfile、脚本或 init 配置时请遵循该文件。
+47
View File
@@ -0,0 +1,47 @@
.PHONY: help all list
# 脚本目录
SCRIPT_DIR := script
# 默认目标:显示帮助信息
help:
@echo "Dotfile Management"
@echo ""
@echo "Usage: make <script-name>"
@echo " Example: make brew-install"
@echo " make fish-init"
@echo " make zsh-init"
@echo " make docker-clean"
@echo ""
@echo "Available scripts:"
@ls -1 $(SCRIPT_DIR)/*.sh $(SCRIPT_DIR)/*.py 2>/dev/null | xargs -n1 basename | sed 's/\.[^.]*$$//' | sort | sed 's/^/ make /'
@echo ""
@echo "Quick commands:"
@echo " make list List all available scripts"
@echo " make help Show this help message"
# 列出所有可用脚本
list:
@echo "Available scripts in $(SCRIPT_DIR)/"
@ls -1 $(SCRIPT_DIR)/*.sh $(SCRIPT_DIR)/*.py 2>/dev/null | xargs -n1 basename
#################################################################
# 通用规则:自动映射命令到脚本文件
#################################################################
# 匹配所有命令,自动执行对应的脚本文件
%:
@if [ -f "$(SCRIPT_DIR)/$@.sh" ]; then \
echo "Running $(SCRIPT_DIR)/$@.sh..."; \
bash $(SCRIPT_DIR)/$@.sh; \
elif [ -f "$(SCRIPT_DIR)/$@.py" ]; then \
echo "Running $(SCRIPT_DIR)/$@.py..."; \
python3 $(SCRIPT_DIR)/$@.py; \
elif [ "$@" = "init-default-user" ]; then \
echo "Running $(SCRIPT_DIR)/init-default-user.sh (requires sudo)..."; \
sudo bash $(SCRIPT_DIR)/init-default-user.sh; \
else \
echo "Error: No script found for '$@'"; \
echo "Run 'make list' to see available scripts"; \
exit 1; \
fi
+10 -30
View File
@@ -1,35 +1,15 @@
### 使用 ### 使用
```shell ```shell
git clone https://github.com/Laily123/.dotfile.git ~/.dotfile git clone https://github.com/hilaily/.dotfile.git ~/.dotfile
```
### zsh 安装
安装 zsh
```shell
https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH
# macOS
brew install zsh zsh-completions
# CentOS
sudo yum -y install zsh
# Ubuntu
apt install zsh
``` ```
安装 oh-my-zsh 首先安装 fish
```shell
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" `brew install fish` 或者 `apt install fish`
然后初始化 fish
```bash
bash ~/.dotfile/script/fish-install.sh
``` ```
初始化配置
```shell
ln -sf ~/.dotfile/.zshrc ~/
ln -sf ~/.dotfile/laily.zsh-theme ~/.oh-my-zsh/themes/
ln -sf ~/.dotfile/.tmux.conf ~/
ln -sf ~/.dotfile/.gitconfig ~/.gitconfig
```
### spacevim 安装
安装
`curl -sLf https://spacevim.org/install.sh | bash`
初始化配置
`ln -sf ~/.dotfile/.SpaceVim.d ~/`
+291
View File
@@ -0,0 +1,291 @@
// 将键绑定放入此文件中以覆盖默认值
[
{
"key": "alt+cmd+left",
"command": "workbench.action.navigateBack",
},
{
"key": "alt+cmd+right",
"command": "workbench.action.navigateForward",
},
{
"key": "alt+cmd+l",
"command": "editor.action.formatSelection",
"when": "editorHasDocumentFormattingProvider && editorHasSelection && editorTextFocus && !editorReadonly",
},
{
"key": "cmd+k m",
"command": "-workbench.action.editor.changeLanguageMode",
"when": "!notebookEditorFocused",
},
{
"key": "ctrl+j",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion",
},
{
"key": "ctrl+n",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion",
},
{
"key": "ctrl+k",
"command": "-deleteAllRight",
"when": "textInputFocus && !editorReadonly",
},
{
"key": "ctrl+k",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion",
},
{
"key": "ctrl+p",
"command": "-selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion",
},
{
"key": "cmd+i",
"command": "composerMode.agent",
},
{
"key": "space",
"command": "vspacecode.space",
"when": "activeEditorGroupEmpty && focusedView == '' && !whichkeyActive && !inputFocus",
},
{
"key": "space",
"command": "vspacecode.space",
"when": "sideBarFocus && !inputFocus && !whichkeyActive",
},
// {
// "key": "tab",
// "command": "extension.vim_tab",
// "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'"
// },
// {
// "key": "tab",
// "command": "-extension.vim_tab",
// "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
// },
{
"key": "x",
"command": "magit.discard-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "k",
"command": "-magit.discard-at-point",
},
{
"key": "-",
"command": "magit.reverse-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "v",
"command": "-magit.reverse-at-point",
},
{
"key": "shift+-",
"command": "magit.reverting",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "shift+v",
"command": "-magit.reverting",
},
{
"key": "shift+o",
"command": "magit.resetting",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "shift+x",
"command": "-magit.resetting",
},
{
"key": "x",
"command": "-magit.reset-mixed",
},
{
"key": "ctrl+u x",
"command": "-magit.reset-hard",
},
{
"key": "y",
"command": "-magit.show-refs",
},
{
"key": "y",
"command": "vspacecode.showMagitRefMenu",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode == 'Normal'",
},
{
"key": "g",
"command": "-magit.refresh",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "g",
"command": "vspacecode.showMagitRefreshMenu",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/",
},
{
"key": "ctrl+j",
"command": "workbench.action.quickOpenSelectNext",
"when": "inQuickOpen",
},
{
"key": "ctrl+k",
"command": "workbench.action.quickOpenSelectPrevious",
"when": "inQuickOpen",
},
{
"key": "ctrl+j",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus",
},
{
"key": "ctrl+k",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus",
},
{
"key": "ctrl+l",
"command": "acceptSelectedSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus",
},
{
"key": "ctrl+j",
"command": "showNextParameterHint",
"when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible",
},
{
"key": "ctrl+k",
"command": "showPrevParameterHint",
"when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible",
},
{
"key": "ctrl+j",
"command": "selectNextCodeAction",
"when": "codeActionMenuVisible",
},
{
"key": "ctrl+k",
"command": "selectPrevCodeAction",
"when": "codeActionMenuVisible",
},
{
"key": "ctrl+l",
"command": "acceptSelectedCodeAction",
"when": "codeActionMenuVisible",
},
// Quick Navigation for file browser
{
"key": "ctrl+h",
"command": "file-browser.stepOut",
"when": "inFileBrowser",
},
{
"key": "ctrl+l",
"command": "file-browser.stepIn",
"when": "inFileBrowser",
},
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft",
"when": "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible && !isInDiffEditor",
},
{
"key": "ctrl+j",
"command": "workbench.action.navigateDown",
"when": "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible",
},
{
"key": "ctrl+k",
"command": "workbench.action.navigateUp",
"when": "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible",
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight",
"when": "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible && !isInDiffEditor",
},
// Quick Navigation for diff view
{
"key": "ctrl+h",
"command": "workbench.action.compareEditor.focusSecondarySide",
"when": "isInDiffEditor && !isInDiffLeftEditor",
},
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft",
"when": "isInDiffEditor && isInDiffLeftEditor",
},
{
"key": "ctrl+l",
"command": "workbench.action.compareEditor.focusPrimarySide",
"when": "isInDiffEditor && isInDiffLeftEditor",
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight",
"when": "isInDiffEditor && !isInDiffLeftEditor",
},
{
"key": "ctrl+l",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated && !accessibilityModeEnabled || terminalFocus && terminalProcessSupported && !accessibilityModeEnabled || accessibilityModeEnabled && accessibleViewIsShown && terminalHasBeenCreated && accessibleViewCurrentProviderId == 'terminal' || accessibilityModeEnabled && accessibleViewIsShown && terminalProcessSupported && accessibleViewCurrentProviderId == 'terminal'",
},
{
"key": "cmd+k",
"command": "-workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated && !accessibilityModeEnabled || terminalFocus && terminalProcessSupported && !accessibilityModeEnabled || accessibilityModeEnabled && accessibleViewIsShown && terminalHasBeenCreated && accessibleViewCurrentProviderId == 'terminal' || accessibilityModeEnabled && accessibleViewIsShown && terminalProcessSupported && accessibleViewCurrentProviderId == 'terminal'",
},
{
"key": "space",
"command": "vspacecode.space",
"when": "terminalFocus && terminalHasBeenCreated && !accessibilityModeEnabled || terminalFocus && terminalProcessSupported && !accessibilityModeEnabled || accessibilityModeEnabled && accessibleViewIsShown && terminalHasBeenCreated && accessibleViewCurrentProviderId == 'terminal' || accessibilityModeEnabled && accessibleViewIsShown && terminalProcessSupported && accessibleViewCurrentProviderId == 'terminal'",
},
{
"key": "ctrl+o",
"command": "workbench.action.navigateBack",
"when": "canNavigateBack",
},
{
"key": "ctrl+-",
"command": "-workbench.action.navigateBack",
"when": "canNavigateBack",
},
{
"key": "ctrl+o",
"command": "-lineBreakInsert",
"when": "textInputFocus && !editorReadonly",
},
{
"key": "ctrl+\\",
"command": "-glass.openActionMenu",
"when": "isGlassAgentWorkspace && glassActiveTabKind == 'diff'",
},
{
"key": "ctrl+\\",
"command": "-glass.openPlanBuildMenu",
"when": "isGlassAgentWorkspace && glassActiveTabKind == 'plan'",
},
{
"key": "ctrl+cmd+i",
"command": "-workbench.panel.chat",
"when": "workbench.panel.chat.view.copilot.active",
},
{
"key": "ctrl+\\",
"command": "workbench.action.toggleAgentsFromKeyboard",
"when": "!isAuxiliaryWindowFocusedContext && !isGlass",
},
{
"key": "alt+cmd+j",
"command": "-workbench.action.toggleAgentsFromKeyboard",
"when": "!isAuxiliaryWindowFocusedContext && !isGlass",
},
]
+291
View File
@@ -0,0 +1,291 @@
{
"editor.fontLigatures": true,
"editor.fontSize": 16,
"editor.renderControlCharacters": true,
"workbench.iconTheme": "Monokai Classic Icons",
"workbench.welcome.enabled": false,
"workbench.colorTheme": "Dracula Theme Soft",
"vim.overrideCopy": false,
"vim.enableNeovim": true,
"vim.neovimPath": "/usr/local/bin/nvim",
"vim.disableAnnoyingNeovimMessage": true,
// Vim easymotion is required for Jump menu - <SPC> j
"vim.easymotion": true,
// Use system clipboard for vim
"vim.useSystemClipboard": true,
// Trigger the main which key menu with in the active editor with vim
// This cannot be put into keybindings.json because it will
// create conflict with Vim.
// https://github.com/stevenguh/spacecode/issues/3
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<space>"],
"commands": ["vspacecode.space"]
},
{
"before": [","],
"commands": [
"vspacecode.space",
{
"command": "whichkey.triggerKey",
"args": "m"
}
]
}
],
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": ["<space>"],
"commands": ["vspacecode.space"]
},
{
"before": [","],
"commands": [
"vspacecode.space",
{
"command": "whichkey.triggerKey",
"args": "m"
}
]
},
{
"before": [">"],
"commands": ["editor.action.indentLines"]
},
{
"before": ["<"],
"commands": ["editor.action.outdentLines"]
}
],
"workbench.panel.location": "right",
"gitHistory.hideCommitViewExplorer": true,
"python.linting.pylintEnabled": false,
"python.pythonPath": "/usr/local/bin/python3",
"editor.wordWrap": "on",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"sync.gist": "3c4e02a02a0d110622006b8c8b058fa5",
"go.languageServerFlags": ["-rpc.trace"],
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"files.associations": {
"*.html": "html",
"*.json": "jsonc",
"NOTES.txt": "helm",
"Dockerfile": "dockerfile"
},
"[helm]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
// "editor.formatOnSave": false // alternatively, force it to leave you alone
},
"gitlens.codeLens.recentChange.enabled": false,
"gitlens.codeLens.authors.enabled": false,
"sync.forceUpload": true,
"gitlens.currentLine.enabled": false,
"emmet.triggerExpansionOnTab": true,
// "terminal.integrated.shell.osx": "/bin/zsh",
"editor.fontFamily": "Fira Code, Sarasa Fixed SC Nerd Font, Menlo, Monaco, 'Courier New', monospace",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"search.followSymlinks": false,
"go.autocompleteUnimportedPackages": true,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"vscode-neovim.mouseSelectionStartVisualMode": true,
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--config=~/.dotfile/golang/golangci.yml"],
"go.liveErrors": {
"enabled": false,
"delay": 500
},
"python.languageServer": "Pylance",
"go.overwriteGoplsMiddleware": {},
"go.useLanguageServer": true,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.snippetSuggestions": "none",
"editor.defaultFormatter": "golang.go"
},
"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"gopls": {
"usePlaceholders": true,
"staticcheck": false
},
"go.testFlags": ["-v"],
"vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim",
"go.buildOnSave": "off",
"vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/im-select",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}",
"vim.autoSwitchInputMethod.enable": true,
"editor.cursorStyle": "line",
"editor.insertSpaces": false,
"editor.lineNumbers": "on",
"editor.wordSeparators": "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-",
"security.workspace.trust.untrustedFiles": "open",
"workbench.tree.indent": 4,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"python.defaultInterpreterPath": "/usr/local/bin/python3",
"[python]": {
"editor.formatOnType": true,
"editor.defaultFormatter": "ms-python.python"
},
"[go][go.mod]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"update.showReleaseNotes": false,
"terminal.integrated.defaultProfile.osx": "fish",
"extensions.experimental.affinity": {
"asvetliakov.vscode-neovim": 1
},
"makefile.configureOnOpen": false,
"python.terminal.activateEnvInCurrentTerminal": true,
"remote.SSH.enableAgentForwarding": false,
"remote.SSH.defaultForwardedPorts": [],
"remote.SSH.useLocalServer": false,
"remote.SSH.connectTimeout": 30,
"remote.SSH.localServerDownload": "always",
"remote.SSH.remotePlatform": {
"box1": "linux",
"hx80": "linux",
"hx20": "linux",
"pc30": "linux"
},
"editor.formatOnSave": true,
"pylint.enabled": false,
"python.analysis.typeCheckingMode": "standard",
"python.analysis.packageIndexDepths": [
{
"name": "sklearn",
"depth": 2
},
{
"name": "matplotlib",
"depth": 2
},
{
"name": "scipy",
"depth": 2
},
{
"name": "django",
"depth": 2
},
{
"name": "flask",
"depth": 2
},
{
"name": "fastapi",
"depth": 2
}
],
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
// "[dockerfile]": {
// "editor.defaultFormatter": "foxundermoon.shell-format"
// },
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[properties]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"editor.codeActionsOnSave": {
// "source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},
"[proto3]": {
"editor.defaultFormatter": "zxh404.vscode-proto3"
},
"[dotenv]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"typescript.preferences.quoteStyle": "single",
"javascript.preferences.quoteStyle": "single",
"go.toolsManagement.autoUpdate": true,
"pretty-formatter.quoteConvert": "single",
"html.completion.attributeDefaultValue": "singlequotes",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.jsxSingleQuote": true,
"go.buildFlags": ["-tags=wireinject"],
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced",
"diffEditor.ignoreTrimWhitespace": false,
"editor.defaultColorDecorators": "never"
},
"html.format.unformatted": "",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"notebook.defaultFormatter": "esbenp.prettier-vscode",
"workbench.activityBar.orientation": "vertical", // cursor test
"vspacecode.bindingOverrides": [
{
"keys": ["space"],
"name": "Space (Global Leader)",
"type": "bind",
"command": "vspacecode.space",
"when": "editorTextFocus || explorerViewletVisible || terminalFocus"
},
{
"keys": "w.t",
"name": "Toggle Terminal",
"type": "command",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"keys": "w.w",
"name": "Toggle AI Sidebar",
"type": "command",
"command": "workbench.action.toggleAuxiliaryBar"
},
{
"keys": "w.e",
"name": "Focus First Editor Group",
"type": "command",
"command": "workbench.action.focusFirstEditorGroup"
}
],
"[java]": {
"editor.suggest.snippetsPreventQuickSuggestions": false
},
"git.confirmSync": false,
"editor.dropIntoEditor.preferences": [],
"whichkey.bindingOverrides": [],
"workbench.colorCustomizations": {},
"javascript.format.enable": false,
"typescript.format.enable": false,
"terminal.integrated.env.linux": {
"ANTHROPIC_AUTH_TOKEN": "sk-cp-QvKTjyX6D0bf5u0f9mB-mpaYcyCwdXq3nubxEzTFFtiGuYmLmC_nyxGOsK3jzmJSCMix2rXJ90iSFb6Xva0R30ZY1ilwMLf44npGnAzTWgtwUIqoGwHmQsc",
"ANTHROPIC_BASE_URL": "https://api.minimaxi.com/anthropic",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "MiniMax-M2.1",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "MiniMax-M2.1",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "MiniMax-M2.1",
"ANTHROPIC_MODEL": "MiniMax-M2.1",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
},
"claudeCode.preferredLocation": "panel",
"window.autoDetectColorScheme": false,
"vim.disableExtension": true
}
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
set -x
# 设置环境变量
export CURSOR_VERSION=
export CURSOR_COMMIT=
export REMOTE_ARCH="x64" # or arm64
export REMOTE_OS="linux"
# 创建目录结构
mkdir -p ${HOME}/.cursor-server/cli/servers/Stable-${CURSOR_COMMIT}/server/
# 下载并解压第一个压缩包 (cli-alpine)
CLI_URL="https://cursor.blob.core.windows.net/remote-releases/${CURSOR_COMMIT}/cli-alpine-${REMOTE_ARCH}.tar.gz"
curl -L "${CLI_URL}" -o ${HOME}/.cursor-server/cursor-cli.tar.gz
tar -xzf ${HOME}/.cursor-server/cursor-cli.tar.gz -C ${HOME}/.cursor-server/
mv ${HOME}/.cursor-server/cursor ${HOME}/.cursor-server/cursor-$CURSOR_COMMIT
# 下载并解压第二个压缩包 (vscode-reh)
VSCODE_URL="https://cursor.blob.core.windows.net/remote-releases/${CURSOR_VERSION}-${CURSOR_COMMIT}/vscode-reh-${REMOTE_OS}-${REMOTE_ARCH}.tar.gz"
curl -L "${VSCODE_URL}" -o ${HOME}/.cursor-server/cursor-vscode-server.tar.gz
tar -xzf ${HOME}/.cursor-server/cursor-vscode-server.tar.gz -C ${HOME}/.cursor-server/cli/servers/Stable-${CURSOR_COMMIT}/server/ --strip-components=1
echo "Cursor server installation completed!"
+7
View File
@@ -0,0 +1,7 @@
{
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3"
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"registry-mirrors": [
"https://docker.1ms.run"
]
}
+89
View File
@@ -0,0 +1,89 @@
# Completions for ff command
complete -c ff -f
set -l ff_subcommands reload edit fish dotfile pon poff pst make script s update help region ssh init copy dirsize help region
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "reload" -d "Reload fish configuration"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "edit" -d "Edit custom fish configuration"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "fish" -d "Change to fish config directory"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "dotfile" -d "Change to dotfile directory"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pon" -d "Enable proxy (proxy on)"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "poff" -d "Disable proxy (proxy off)"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pst" -d "Show proxy status"
# complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "make" -d "Run dotfile Makefile commands"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "script" -d "Run script from script directory"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "s" -d "Run script (alias for script)"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "help" -d "Show this help message"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "region" -d "Toggle or set CN_REGION (mirror/proxy region)"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "ssh" -d "SSH init (keys + config.d) or copy config to remote"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "dirsize" -d "Show directory sizes"
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s a -l all -d "Recursively show all subdirectories"
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s d -l depth -d "Recursion depth (default 1)" -r
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s n -l top -d "Show top N only" -r
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s r -l reverse -d "Sort smallest first"
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s h -l help -d "Show help"
complete -c ff -n "__fish_seen_subcommand_from dirsize" -a "(__fish_complete_directories)" -d "Directory"
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a init -d "Ensure SSH key and config.d Include"
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a copy -d "Copy specified SSH config file(s) to remote"
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a help -d "Show ssh subcommand help"
function __ff_ssh_config_d_files
for d in $HOME/.ssh/config.d $HOME/.dotfile/ssh/config.d
if test -d $d
for f in $d/*
if test -f $f
basename $f
end
end
end
end
end
complete -c ff -n "__fish_seen_subcommand_from ssh copy; and test (count (commandline -opc)) -eq 2" -a "(__fish_ssh_hosts 2>/dev/null; or __fish_print_hostnames)" -d "SSH host"
complete -c ff -n "__fish_seen_subcommand_from ssh copy; and test (count (commandline -opc)) -ge 3" -a "(__ff_ssh_config_d_files)" -d "Config file"
# # make 子命令的补全 - 直接使用脚本文件名
# complete -c ff -n "__fish_seen_subcommand_from make" -a "help" -d "Show all make targets"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "list" -d "List all available scripts"
# Install scripts
# complete -c ff -n "__fish_seen_subcommand_from make" -a "brew-install" -d "Install Homebrew"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "docker-install" -d "Install Docker"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-install" -d "Install Neovim"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "python-install" -d "Install Python"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "gvm-install" -d "Install Go Version Manager"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "firacode-install" -d "Install FiraCode font"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "font-install" -d "Install fonts"
# # Init scripts
# complete -c ff -n "__fish_seen_subcommand_from make" -a "fish-init" -d "Initialize Fish shell"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "git-init" -d "Initialize Git config"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-init" -d "Initialize Neovim config"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "tmux-init" -d "Initialize Tmux config"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "cursor-init" -d "Initialize Cursor config"
# complete -c ff -n "__fish_seen_subcommand_from make" -a "init-default-user" -d "Initialize default user (sudo)"
# script 子命令的补全 - 动态列出 script 目录下的脚本
function __ff_list_scripts
if not functions -q script-list-names
source ~/.dotfile/fish/functions/script-catalog.fish
end
script-list-names
end
function __ff_complete_scripts
if not functions -q script-extract-description
source ~/.dotfile/fish/functions/script-catalog.fish
end
for name in (script-list-names)
set -l path (script-resolve-path $name)
set -l desc (script-extract-description $path)
printf "%s\t%s\n" $name $desc
end
end
complete -c ff -n "__fish_seen_subcommand_from script s; and test (count (commandline -opc)) -eq 2" -s h -l help -d "List all scripts and descriptions"
complete -c ff -n "__fish_seen_subcommand_from script s; and test (count (commandline -opc)) -eq 2" -a help -d "List all scripts and descriptions"
complete -c ff -n "__fish_seen_subcommand_from script s; and not __fish_seen_subcommand_from help -h --help (__ff_list_scripts)" -a '(__ff_complete_scripts)' -d "Script name"
+51
View File
@@ -0,0 +1,51 @@
# ----- Git worktree native completions -----
# 列出分支
function __git_branches
git branch --format="%(refname:short)" 2>/dev/null
end
# 列出 worktree 路径
function __git_worktree_paths
git worktree list --porcelain 2>/dev/null \
| awk '/worktree/ {print $2}'
end
# -----------------------
# Worktree 别名补全
# -----------------------
# git wtl → worktree list
complete -f -c git -n '__fish_seen_subcommand_from wtl' -a ''
# git wtp → worktree prune
complete -f -c git -n '__fish_seen_subcommand_from wtp' -a ''
# git wta → worktree add <path> <branch>
complete -c git -n '__fish_seen_subcommand_from wta' \
-a '(__git_branches)' \
-d "Branch to add worktree for"
# git wtb → worktree add -b <newbranch> <path> <base>
complete -c git -n '__fish_seen_subcommand_from wtb' \
-a '(__git_branches)' \
-d "Base branch to create new branch from"
# git wtr → worktree remove <path>
complete -c git -n '__fish_seen_subcommand_from wtr' \
-a '(__git_worktree_paths)' \
-d "Existing worktree paths"
# ------------------------------
# 原生 git worktree 补全增强
# ------------------------------
# git worktree add <path> <branch>
complete -c git -n '__fish_seen_subcommand_from worktree; and __fish_seen_subcommand_from add' \
-a '(__git_branches)' \
-d "Branch to checkout"
# git worktree remove <path>
complete -c git -n '__fish_seen_subcommand_from worktree; and __fish_seen_subcommand_from remove' \
-a '(__git_worktree_paths)' \
-d "Worktree path"
+2
View File
@@ -0,0 +1,2 @@
# Inherit ssh-copy-id options and host completions
complete -c ssh2 -w ssh-copy-id
+247
View File
@@ -0,0 +1,247 @@
#################################################################
# option
fish_vi_key_bindings
# Vi 模式下:Ctrl+A / Ctrl+E 行首、行尾(readline 习惯)
bind --mode insert \ca beginning-of-line
bind --mode insert \ce end-of-line
bind --mode default \ca beginning-of-line
bind --mode default \ce end-of-line
#################################################################
# basic
# 定义一个函数来检查并添加路径到 PATH
function add_to_path
# 遍历传递给函数的所有参数
for path in $argv
# 检查路径是否存在
if test -d $path
# 如果路径存在且不在 PATH 中,则添加到 PATH
if not contains $path $PATH
#echo "Adding $path to PATH"
set -gx PATH $PATH $path
else
#echo "$path is already in PATH"
end
else
#echo "$path does not exist"
end
end
end
function is_command_exists
if command -v $argv[1] >/dev/null 2>&1
return 0
else
return 1
end
end
# set environment
set paths_to_check /usr/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/bin /opt/sbin /usr/syno/sbin /usr/syno/bin /usr/local/sbin $HOME/.local/bin $HOME/.pouch/bin
for path in $paths_to_check do
add_to_path $path
end
function sudoo
eval sudo $history[1]
end
# add my script
add_to_path $HOME/.dotfile/script $HOME/.app00/script
if test -f ~/.config/fish/custom.fish
source ~/.config/fish/custom.fish
end
#################################################################
# brew
set -gx HOMEBREW_BREW_GIT_REMOTE "https://mirrors.ustc.edu.cn/brew.git"
set -gx HOMEBREW_CORE_GIT_REMOTE "https://mirrors.ustc.edu.cn/homebrew-core.git"
set -gx HOMEBREW_BOTTLE_DOMAIN "https://mirrors.ustc.edu.cn/homebrew-bottles"
#################################################################
# java 17 + android sdk (local debug builds; no Android Studio)
if test -d /usr/local/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
set -gx JAVA_HOME /usr/local/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
else if test -d /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
set -gx JAVA_HOME /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
else if test -d /home/linuxbrew/.linuxbrew/opt/openjdk@17
set -gx JAVA_HOME /home/linuxbrew/.linuxbrew/opt/openjdk@17
end
if set -q JAVA_HOME
if not contains $JAVA_HOME/bin $PATH
set -gx PATH $JAVA_HOME/bin $PATH
end
end
if test -d $HOME/Library/Android/sdk
set -gx ANDROID_HOME $HOME/Library/Android/sdk
else if test -d $HOME/Android/Sdk
set -gx ANDROID_HOME $HOME/Android/Sdk
end
if set -q ANDROID_HOME
set -gx ANDROID_SDK_ROOT $ANDROID_HOME
add_to_path $ANDROID_HOME/cmdline-tools/latest/bin $ANDROID_HOME/platform-tools
end
#################################################################
# go
set -gx GOPATH $HOME/go:$HOME/workrepo/go
set -gx GOPROXY "goproxy.cn,direct"
set -gx GOSUMDB "sum.golang.google.cn"
set -gx EDITOR vim
add_to_path $HOME/go/bin
add_to_path $HOME/.yarn/bin $HOME/.config/yarn/global/node_modules/.bin
function gtr
go test -gcflags=all=-l -v -run=$argv
end
#################################################################
# python
set -gx PYENV_ROOT $HOME/.pyenv
# Pyenv initialization
if command -v pyenv 1>/dev/null 2>&1
pyenv init - | source
end
add_to_path $PYENV_ROOT/bin
# pnpm
set -gx PNPM_HOME $HOME/.pnpm
if not string match -q -- $PNPM_HOME $PATH
set -gx PATH "$PNPM_HOME" $PATH
end
#################################################################
# git
# alias
alias gitb="git branch --show-current | tr -d '\n' | clip-copy.sh"
alias gci="golangci-lint run -c=~/.dotfile/golang/golangci.yml ./..."
alias gmt="go mod tidy"
alias gtc="go test -gcflags=all=-l -cover ./..."
alias swg="swag init -o docs -g "
alias sws="swagger serve -F=swagger"
alias sourceit="source ~/.config/fish/config.fish"
#################################################################
# docker
function dc
# 检查第一个参数是否是 is_sudo
set use_sudo false
set args $argv
if test (count $argv) -gt 0; and test "$argv[1]" = is_sudo
set use_sudo true
set args $argv[2..-1]
end
# 检查 docker-compose 是否可用
if command -v docker-compose >/dev/null
set compose_cmd docker-compose
else
set compose_cmd docker compose
end
# 构建执行命令(如果需要 sudo,添加 sudo 前缀)
if test $use_sudo = true
set exec_cmd command sudo $compose_cmd
else
set exec_cmd $compose_cmd
end
switch $args[1]
case lf
$exec_cmd logs -f $args[2..-1]
case upd
$exec_cmd up -d $args[2..-1] && $exec_cmd logs -f $args[2..-1]
case reupd
$exec_cmd up -d --force-recreate $args[2..-1] && $exec_cmd logs -f $args[2..-1]
case '*'
$exec_cmd $args
end
end
#################################################################
# systemctl
function sc
systemctl $argv
end
function scu
systemctl --user $argv
end
function jc
journalctl $argv
end
function jcu
journalctl --user $argv
end
# 智能 sudo 包装,支持展开函数别名
function sudo --wraps sudo
if test (count $argv) -gt 0
set cmd $argv[1]
switch $cmd
case sc
command sudo systemctl $argv[2..-1]
case jc
command sudo journalctl $argv[2..-1]
case dc
# 调用 dc 函数并传递 is_sudo 参数
dc is_sudo $argv[2..-1]
case '*'
command sudo $argv
end
else
command sudo $argv
end
end
#################################################################
# other
function ctl
systemctl $argv
end
if status is-interactive
# Commands to run in interactive sessions can go here
end
# source env
function source_env
for line in (cat $argv | grep -v '^#' | grep -v '^\s*$')
set item (string split -m 1 '=' $line)
set -gx $item[1] (eval echo $item[2])
end
end
function make2
make -f Makefile.local $argv
end
# Added by OrbStack: command-line tools and integration
# This won't be added again if you remove it.
source ~/.orbstack/shell/init2.fish 2>/dev/null || :
# mise (formerly rtx)
if command -v mise >/dev/null
add_to_path $HOME/.local/bin
add_to_path $HOME/.local/share/mise/shims
mise activate fish | source
end
function vim
if command -q nvim
command nvim $argv
else if command -q vim
command vim $argv
else
command vi $argv
end
end
# bun
set --export BUN_INSTALL "$HOME/.bun"
set --export PATH $BUN_INSTALL/bin $PATH
+7
View File
@@ -0,0 +1,7 @@
function _notify_emit --argument-names title body
if set -q TMUX
printf '\ePtmux;\e\e]777;notify;%s;%s\a\e\\' "$title" "$body"
else
printf '\e]777;notify;%s;%s\a' "$title" "$body"
end
end
@@ -0,0 +1,13 @@
function _notify_human_duration --argument-names ms
test -z "$ms"; and set ms 0
set -l s (math --scale=0 $ms / 1000)
if test $s -lt 1
echo {$ms}ms
else if test $s -lt 60
echo {$s}s
else if test $s -lt 3600
echo (math --scale=0 $s / 60)m(math $s % 60)s
else
echo (math --scale=0 $s / 3600)h(math --scale=0 ($s % 3600) / 60)m
end
end
+52
View File
@@ -0,0 +1,52 @@
# Execute script from script directory
function execute-script
if not functions -q script-show-catalog
source ~/.dotfile/fish/functions/script-catalog.fish
end
set -l dotfile_dir ~/.dotfile
set -l script_dir $dotfile_dir/script
set -l script_name $argv[1]
# ff script|s -h / --help / help
if test -z "$script_name"; or contains -- $script_name -h --help help
if test -z "$script_name"; or test (count $argv) -eq 1
script-show-catalog
return 0
end
end
if test -z "$script_name"
script-show-catalog
return 1
end
set -l script_path (script-resolve-path $script_name 2>/dev/null; or echo "")
if test -n "$script_path" -a -f "$script_path"
echo "Running: $script_path"
set -l run_status 0
if test -x $script_path
$script_path $argv[2..-1]
set run_status $status
else if string match -q "*.py" $script_path
python3 $script_path $argv[2..-1]
set run_status $status
else
bash $script_path $argv[2..-1]
set run_status $status
end
if test "$script_name" = toggle-region
if not functions -q region_apply_from_custom
source ~/.dotfile/fish/functions/region.fish
end
region_apply_from_custom
end
return $run_status
end
echo "Error: Script not found: $script_name"
echo ""
script-show-catalog
return 1
end
+181
View File
@@ -0,0 +1,181 @@
# ff ssh: local init (keys + config.d) and copy config to remote
function __ff_ssh_has_key
for f in $HOME/.ssh/id_*
if test -f $f; and not string match -q '*.pub' -- $f
return 0
end
end
return 1
end
function __ff_ssh_ensure_keys
if __ff_ssh_has_key
echo "SSH key exists, skip generation"
return 0
end
set -l key_path "$HOME/.ssh/id_ed25519"
set -l comment "$USER@"(hostname -s 2>/dev/null; or echo localhost)
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
echo "No SSH key found, generating ed25519: $key_path"
if test -t 0
ssh-keygen -t ed25519 -f $key_path -C $comment
else
ssh-keygen -t ed25519 -f $key_path -C $comment -N ""
echo "Non-interactive mode: created with empty passphrase"
end
end
function __ff_ssh_ensure_config_d
set -l ssh_config "$HOME/.ssh/config"
set -l include_line "Include ~/.ssh/config.d/*"
mkdir -p "$HOME/.ssh/config.d"
chmod 700 "$HOME/.ssh"
if not test -f $ssh_config
printf '%s\n' $include_line > $ssh_config
chmod 600 $ssh_config
echo "Created $ssh_config with $include_line"
else if grep -qE 'Include[[:space:]]+.*config\.d' $ssh_config
echo "config.d Include already in $ssh_config"
else
printf '\n# config.d\n%s\n' $include_line >> $ssh_config
echo "Appended to $ssh_config: $include_line"
end
end
function __ff_ssh_resolve_path --argument path
if test -L $path
set path (readlink $path)
if not string match -q '/*' -- $path
set path "$HOME/.ssh/$path"
end
end
echo $path
end
function __ff_ssh_remote_has_include --argument host
ssh -q $host 'test -f ~/.ssh/config && grep -qE "Include[[:space:]]+.*config\.d" ~/.ssh/config'
end
function __ff_ssh_remote_ensure_include --argument host
ssh $host 'mkdir -p ~/.ssh/config.d && chmod 700 ~/.ssh
if [ -f ~/.ssh/config ] && grep -qE "Include[[:space:]]+.*config\.d" ~/.ssh/config; then
echo "Remote config.d Include already exists"
elif [ -f ~/.ssh/config ]; then
printf "\n# config.d\nInclude ~/.ssh/config.d/*\n" >> ~/.ssh/config
chmod 600 ~/.ssh/config
echo "Appended config.d Include on remote"
else
printf "%s\n" "Include ~/.ssh/config.d/*" > ~/.ssh/config
chmod 600 ~/.ssh/config
echo "Created remote config with config.d Include"
fi'
end
function __ff_ssh_resolve_copy_src --argument file
set -l src $file
if test -f $src
echo $src
return 0
end
set -l in_config_d "$HOME/.ssh/config.d/$file"
if test -f $in_config_d
echo $in_config_d
return 0
end
set -l dotfile_src "$HOME/.dotfile/ssh/config.d/$file"
if test -f $dotfile_src
echo $dotfile_src
return 0
end
return 1
end
function __ff_ssh_copy_remote --argument-names argv
set -l host $argv[1]
set -l files $argv[2..-1]
set -l ssh_dir "$HOME/.ssh"
set -l main_config "$ssh_dir/config"
if test -z "$host"
echo "Usage: ff ssh copy <host> <config-file>..."
echo " host: SSH alias or user@hostname"
echo " file: path, or name under ~/.ssh/config.d/"
return 1
end
if test (count $files) -eq 0
echo "Usage: ff ssh copy <host> <config-file>..."
echo ""
echo "Examples:"
echo " ff ssh copy mynas 30-hanxi.conf"
echo " ff ssh copy mynas ~/.dotfile/ssh/config.d/20-personal.conf"
if test -d "$ssh_dir/config.d"
echo ""
echo "Available in ~/.ssh/config.d/:"
ls -1 "$ssh_dir/config.d/"
end
return 1
end
echo "Checking remote Include on $host ..."
ssh -q $host "mkdir -p ~/.ssh/config.d && chmod 700 ~/.ssh"
if __ff_ssh_remote_has_include $host
echo "Remote config.d Include: OK"
else
echo "Remote missing config.d Include, adding ..."
__ff_ssh_remote_ensure_include $host
end
for f in $files
set -l src (__ff_ssh_resolve_copy_src $f 2>/dev/null)
if test $status -ne 0 -o -z "$src"
echo "Error: file not found: $f"
return 1
end
set -l resolved_main (__ff_ssh_resolve_path $main_config)
set -l name (basename $src)
if test "$src" = "$resolved_main"; or test "$name" = config
set -l ts (date +%Y%m%d%H%M%S)
ssh -q $host "test -f ~/.ssh/config && cp ~/.ssh/config ~/.ssh/config.bak.$ts || true"
scp -q $src "$host:.ssh/config"
ssh -q $host "chmod 600 ~/.ssh/config"
echo "Copied $src -> $host:~/.ssh/config"
else
scp -q $src "$host:.ssh/config.d/$name"
ssh -q $host "chmod 600 ~/.ssh/config.d/$name"
echo "Copied $src -> $host:~/.ssh/config.d/$name"
end
end
echo "Done."
end
function ff_ssh --argument-names argv
set -l sub (test (count $argv) -ge 1; and echo $argv[1]; or echo init)
switch $sub
case init ''
__ff_ssh_ensure_keys
__ff_ssh_ensure_config_d
case copy
__ff_ssh_copy_remote $argv[2..-1]
case help -h
echo "Usage: ff ssh [init|copy <host> <file>...|help]"
echo ""
echo " init Ensure SSH key and config.d Include (default)"
echo " copy <host> <file> Check remote Include, then scp specified config file(s)"
echo " help Show this help"
case '*'
echo "Unknown subcommand: $sub"
echo "Run 'ff ssh help' for usage"
return 1
end
end
+133
View File
@@ -0,0 +1,133 @@
# Fast commands management
function ff
# 定义命令和描述(格式:命令|描述)
set -l commands \
"reload|Reload fish configuration" \
"edit|Edit custom fish configuration" \
"fish|Change to fish config directory" \
"dotfile|Change to dotfile directory" \
"pon|Enable proxy (proxy on)" \
"poff|Disable proxy (proxy off)" \
"pst|Show proxy status" \
"make|Run dotfile Makefile commands" \
"script|Run script from script directory" \
"s|Alias for script" \
"update|Update dotfile" \
"region|Toggle or set CN_REGION (mirror/proxy region)" \
"ssh|SSH init (keys + config.d) or copy config to remote" \
"dirsize|Show directory sizes (du wrapper)" \
"help|Show this help message"
# 确保 execute-script 可用(在 fish 自动加载前手动引入一次)
if not functions -q execute-script
set -l execute_script_path ~/.dotfile/fish/functions/execute-script.fish
if test -f $execute_script_path
source $execute_script_path
end
end
switch $argv[1]
case reload
source ~/.config/fish/config.fish
echo "Fish configuration reloaded!"
case edit
vim ~/.config/fish/custom.fish
case fish
cd ~/.config/fish/
case dotfile
cd ~/.dotfile
case pon
set -gx https_proxy http://127.0.0.1:7890
set -gx http_proxy http://127.0.0.1:7890
set -gx all_proxy socks5://127.0.0.1:7890
echo "✓ Proxy enabled"
export | grep -i proxy
case poff
set -e http_proxy
set -e https_proxy
set -e ftp_proxy
set -e all_proxy
set -e HTTP_PROXY
set -e HTTPS_PROXY
set -e FTP_PROXY
set -e ALL_PROXY
echo "✓ Proxy disabled"
export | grep -i proxy
case pst
export | grep -i proxy
case make
# 切换到 dotfile 目录执行脚本管理 makefile
set -l dotfile_dir ~/.dotfile
if test -d $dotfile_dir
make -f $dotfile_dir/Makefile.scripts -C $dotfile_dir $argv[2..-1]
else
echo "Error: Dotfile directory not found at $dotfile_dir"
end
case script s
if not functions -q execute-script
source ~/.dotfile/fish/functions/execute-script.fish
end
execute-script $argv[2..-1]
case help
echo "Usage: ff <command>"
echo ""
echo "Commands:"
# 自动生成帮助信息
for cmd in $commands
set -l parts (string split '|' $cmd)
printf " %-10s %s\n" $parts[1] $parts[2]
end
case update
set -l dotfile_dir ~/.dotfile
if not test -d $dotfile_dir
echo "Error: Dotfile directory not found at $dotfile_dir"
return 1
end
set -l prev_dir (pwd)
cd $dotfile_dir
if git pull origin main
cd $prev_dir
echo "Reloading fish configuration..."
ff reload
else
cd $prev_dir
echo "Error: git pull failed, skip reload"
return 1
end
case ssh
if not functions -q ff_ssh
source ~/.dotfile/fish/functions/ff-ssh.fish
end
ff_ssh $argv[2..-1]
case dirsize
set -l script_path ~/.dotfile/script/dirsize.sh
if test -f $script_path
bash $script_path $argv[2..-1]
else
echo "Error: dirsize script not found at $script_path"
return 1
end
case region
if not functions -q region_toggle
source ~/.dotfile/fish/functions/region.fish
end
set -l sub toggle
if test (count $argv) -ge 2
set sub $argv[2]
end
switch $sub
case toggle
region_toggle
case '*'
echo "Usage: ff region [toggle]"
echo "Unknown subcommand: $sub"
end
case '*'
if test -z "$argv[1]"
echo "Error: No command specified"
else
echo "Error: Unknown command '$argv[1]'"
end
echo "Run 'ff help' for usage information"
end
end
+24
View File
@@ -0,0 +1,24 @@
function notify-done --description '前置包装:运行命令并在完成时发送 OSC 777 通知'
if test (count $argv) -eq 0
echo "Usage: notify-done <command> [args...]" >&2
return 2
end
set -l start (date +%s)
$argv
set -l rc $status
set -l elapsed (math (date +%s) - $start)
set -l human (_notify_human_duration (math $elapsed \* 1000))
set -l label
if test $rc -eq 0
set label "完成: $argv[1]"
else
set label "失败 exit=$rc: $argv[1]"
end
set -l body "$human · "(hostname -s)" · "(string join ' ' $argv)
_notify_emit "$label" "$body"
return $rc
end
+18
View File
@@ -0,0 +1,18 @@
function notify --description '发送 OSC 777 通知;无参时复用上一条命令的状态与耗时'
set -l rc $status
set -l dur $CMD_DURATION
set -l label
if test (count $argv) -gt 0
set label (string join ' ' $argv)
else if test $rc -eq 0
set label "完成"
else
set label "失败 exit=$rc"
end
set -l body (_notify_human_duration $dur)" · "(hostname -s)" · "(pwd | string replace $HOME '~')
_notify_emit "$label" "$body"
return $rc
end
+7
View File
@@ -0,0 +1,7 @@
function pwdc --description 'Copy current directory path to clipboard'
set -l dir (pwd -P)
if not printf '%s' $dir | clip-copy.sh
return 1
end
echo "Copied: "(string replace $HOME '~' $dir)
end
+58
View File
@@ -0,0 +1,58 @@
# CN_REGION 读写 ~/.config/fish/custom.fish(与 script/common/region.sh 约定一致)
function region_custom_path
echo ~/.config/fish/custom.fish
end
function region_read
set -l path (region_custom_path)
if test -f $path
set -l matches (grep -E '^\s*set\s+-gx\s+CN_REGION\s+' $path 2>/dev/null)
if test (count $matches) -gt 0
set -l line $matches[-1]
echo (string trim (string replace -r '.*\s' '' $line))
return
end
end
if set -q CN_REGION
echo $CN_REGION
else
echo 0
end
end
function region_write
set -l new $argv[1]
set -l path (region_custom_path)
mkdir -p (dirname $path)
set -l tmp (mktemp)
if test -f $path
grep -Ev '^\s*# dotfile: CN_REGION|^\s*set\s+-gx\s+CN_REGION\s+' $path >$tmp 2>/dev/null; or true
else
touch $tmp
end
echo "# dotfile: CN_REGION (managed by ff region / toggle-region)" >>$tmp
echo "set -gx CN_REGION $new" >>$tmp
mv $tmp $path
set -gx CN_REGION $new
end
function region_toggle
set -l current (region_read)
set -l new
if test "$current" = "1"
set new 0
echo "Switched to: 0 (国外)"
else
set new 1
echo "Switched to: 1 (国内)"
end
region_write $new
echo "Persisted to ~/.config/fish/custom.fish"
end
function region_apply_from_custom
set -gx CN_REGION (region_read)
end
+126
View File
@@ -0,0 +1,126 @@
# 列举 ~/.dotfile/script 下脚本及从文件头注释提取的简短说明
function script-extract-description --argument filepath
if not test -f "$filepath"
echo "(无描述)"
return
end
set -l past_shebang 0
set -l candidates
for line in (cat "$filepath")
if string match -qr '^#!/' -- $line
set past_shebang 1
continue
end
if test $past_shebang -eq 0
continue
end
set line (string trim $line)
if test -z "$line"
if test (count $candidates) -gt 0
break
end
continue
end
if not string match -qr '^#' -- $line
break
end
set line (string replace -r '^#\s*' '' $line)
if string match -qr '^---' -- $line
continue
end
if string match -qr '^(用法|Usage|示例|Example)' -- $line
continue
end
if string match -qr '^\./' -- $line
continue
end
if string match -qr '^https?://' -- $line
continue
end
# 行内 “# 用法” 类注释
if string match -qr '#\s*(用法|Usage)' -- $line
continue
end
set candidates $candidates $line
if test (count $candidates) -ge 8
break
end
end
if test (count $candidates) -eq 0
echo "(无描述)"
return
end
for c in $candidates
if string match -qr '(脚本|安装|初始化|清理|扫描|切换|配置|用于|镜像|凭据|用户组|免密|Install|Init|Clean|Toggle)' -- $c
echo $c
return
end
end
for c in $candidates
if test (string length $c) -ge 10
echo $c
return
end
end
echo $candidates[1]
end
function script-list-names
set -l script_dir ~/.dotfile/script
set -l names
if not test -d $script_dir
return
end
for script in $script_dir/*.sh $script_dir/*.py
if test -f $script
set -l name (basename $script)
set name (string replace -r '\.(sh|py)$' '' $name)
set names $names $name
end
end
string join \n $names | sort
end
function script-resolve-path --argument name
set -l script_dir ~/.dotfile/script
for ext in sh py
set -l path "$script_dir/$name.$ext"
if test -f $path
echo $path
return 0
end
end
if test -f "$script_dir/$name"
echo "$script_dir/$name"
return 0
end
return 1
end
function script-show-catalog
set -l script_dir ~/.dotfile/script
echo "Usage: ff script <name> [args...] (alias: ff s)"
echo ""
echo "Scripts in $script_dir:"
echo ""
for name in (script-list-names)
set -l path (script-resolve-path $name)
set -l desc (script-extract-description $path)
printf " %-22s %s\n" $name $desc
end
echo ""
echo "提示: ff s <name> -h 查看单个脚本内的详细帮助"
end
+10
View File
@@ -0,0 +1,10 @@
# ssh-copy-id 后交互保存 SSH Host 别名
function ssh2 --wraps ssh-copy-id --description "Copy SSH key and save host alias"
set -l script_path ~/.dotfile/script/ssh2.sh
if not test -f $script_path
echo "Error: ssh2 script not found at $script_path" >&2
return 1
end
bash $script_path $argv
end
+51
View File
@@ -0,0 +1,51 @@
# 主题推荐:Catppuccin, Tokyo Night, 或 Gruvbox
theme = Atom One Dark
# 字体设置 (建议安装带 Nerd Font 图标的字体)
font-family = "FiraCode Nerd Font"
font-size = 16
font-feature = -calt # 如果你不喜欢连字(Ligatures)可以禁用
# 窗口样式:隐藏标题栏,让视觉更纯粹
#window-decoration = true
#macos-titlebar-style = transparent
macos-titlebar-style = tabs
window-title-font-family = "FiraCode Nerd Font"
#fullscreen=non-native
# 背景透明度与模糊 (适合 2017 MBP 的精致感)
background-opacity = 0.95
background-blur-radius = 20
# 将 Option 键映射为 Alt/Meta 键 (对 Neovim/Tmux 极其重要)
macos-option-as-alt = true
# 自动定位到当前 Shell 所在的目录
working-directory = home
# 选中文本时自动复制到剪贴板
copy-on-select = true
# 确认退出(防止误触 Command+Q 关掉正在运行的任务)
confirm-close-surface = true
# 光标样式:块状且闪烁
cursor-style = block
cursor-style-blink = true
# 滚动条设置:通常建议隐藏,通过 Tmux 控制滚动
mouse-scroll-multiplier = 1
scrollback-limit = 10000
# Ghostty 配置
desktop-notifications = true
term = xterm-256color
scrollbar = system
mouse-shift-capture = true
shell-integration-features = ssh-env
# 开启所有 shell 集成特性,包含 ssh-terminfo 自动注入
shell-integration = fish
+97 -8
View File
@@ -1,28 +1,78 @@
[user] [user]
name = Laily name = laily
email = i@laily.net email = i@laily.net
[core] [core]
autocrlf = input autocrlf = input
quotepath = false quotepath = false
editor = /usr/local/bin/nvim editor = vim
excludesfile = ~/.dotfile/git/.gitignore excludesfile = ~/.dotfile/git/.gitignore
[init]
defaultBranch = main
[tag]
sort = version:refname
[column]
ui = auto
[color]
status = auto
diff = auto
branch = auto
interactive = auto
grep = auto
ui = auto
[push] [push]
default = current #default = current
default = simple
autoSetupRemote = true
followTags = true
[fetch]
prune = true
pruneTags = true
all = true
[pull]
rebase = false
[diff]
algorithm = histogram
colorMoved = plain
mnemonicPrefix = true
renames = true
[difftool "nvimdiff"]
cmd = nvim -d \"$LOCAL\" \"$REMOTE\"
[merge] [merge]
tool = vimdiff tool = nvimdiff
[include] [mergetool "nvimdiff"]
path = ~/.subgitconfig cmd = nvim -d \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[includeIf "gitdir:~/workrepo/"]
path = ~/.workgitconfig
[rebase]
autoSquash = true
autoStash = true
updateRefs = true
[commit]
verbose = true
[rerere]
enabled = true
autoupdate = true
[help]
# 旧版 Git 仅支持数字(0=仅提示不执行)。Git 2.36+ 见 .gitconfig.darwin / .gitconfig.linux 可改为 prompt
autocorrect = 0
[branch] [branch]
autoSetupMerge = always autoSetupMerge = always
sort = -committerdate
[alias] [alias]
au = add -u au = add -u
co = checkout co = checkout
cm = commit -m cm = "!f() { if [[ -z \"$1\" ]]; then git commit; else git commit -m \"$*\"; fi; }; f"
st = status st = status
ap = add -p ap = add -p
br = branch br = branch
pl = pull ba = branch -a
bm = branch --merged
bn = branch --no-merged
pu = "!git pull origin $(git rev-parse --abbrev-ref HEAD)"
pt = push origin --tags pt = push origin --tags
ph = push origin HEAD
pht = push origin --tags
merge2 = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout $1 && git merge $_CURRENT_BRANCH && git checkout $_CURRENT_BRANCH' - merge2 = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout $1 && git merge $_CURRENT_BRANCH && git checkout $_CURRENT_BRANCH' -
bg = "!f() { git branch | grep $1; }; f" bg = "!f() { git branch | grep $1; }; f"
delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f" delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f"
@@ -31,6 +81,7 @@
# list files which have changed since REVIEW_BASE # list files which have changed since REVIEW_BASE
# (REVIEW_BASE defaults to 'master' in my zshrc) # (REVIEW_BASE defaults to 'master' in my zshrc)
files = !git diff --name-only $(git merge-base HEAD \"$REVIEW_BASE\") files = !git diff --name-only $(git merge-base HEAD \"$REVIEW_BASE\")
rmsubmodule = "!f(){ git submodule deinit -f \"$1\"; git rm -f \"$1\"; git commit -m \"Removed submodule $1\"; };f"
# Same as above, but with a diff stat instead of just names # Same as above, but with a diff stat instead of just names
# (better for interactive use) # (better for interactive use)
@@ -44,4 +95,42 @@
# instead of opening all files: # instead of opening all files:
# git reviewone foo.js bar.js # git reviewone foo.js bar.js
reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\" reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"
#git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Laily'; GIT_AUTHOR_EMAIL='i@laily.net'; GIT_COMMITTER_NAME='Laily'; GIT_COMMITTER_EMAIL='i@laily.net';" HEAD
# worktree
# git wt add <路径> <分支名>
# git wt add -b <新分支名> <路径> [基分支名]
wt="worktree"
#wta="worktree add"
#wtb="worktree add -b"
wtr="worktree remove"
wtl="worktree list"
wtp="worktree prune"
# 基于分支创建新分支+worktree
# git wtb <分支名> [<基分支名|当前分支>]
wtb = "!f(){ local base_branch=${2:-HEAD}; local clean_name=$(echo \"$1\" | sed \"s/\\//_/g\"); git worktree add -b \"$1\" \"../$clean_name\" $base_branch; }; f"
# 基于指定分支+worktree
# git wta <分支名>
wta = "!f(){ local base_branch=${1:-HEAD}; local clean_name=$(echo \"$1\" | sed \"s/\\//_/g\"); git worktree add \"../$clean_name\" $base_branch; }; f"
[protocol "file"]
allow = always
# https://hyperzsb.io/posts/git-ssl-error/
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
[http]
sslVerify = false
# 凭据:统一 wrapper,不依赖 includeIf ondarwin/onlinux(需 Git 2.36+)
# 低版本 Git 也会加载本节;回退为 git-credential-store(~/.git-credentials)
[credential]
helper = !$HOME/.dotfile/git/git-credential.sh
# 以下 includeIf 需 Git 2.36+;仅用于其它平台差异配置(若有)
[includeIf "ondarwin"]
path = ~/.dotfile/git/.gitconfig.darwin
[includeIf "onlinux"]
path = ~/.dotfile/git/.gitconfig.linux
+3
View File
@@ -0,0 +1,3 @@
# macOS 专用(需 Git 2.36+ includeIf ondarwin)
[help]
autocorrect = prompt
+3
View File
@@ -0,0 +1,3 @@
# Linux 专用(需 Git 2.36+ includeIf onlinux)
[help]
autocorrect = prompt
+7
View File
@@ -26,7 +26,14 @@ _testmain.go
*.sublime-workspace *.sublime-workspace
.idea/ .idea/
.vscode/ .vscode/
.SpaceVim.d/.netrwhist
.SpaceVim.d/init.vim
.DS_Store .DS_Store
.log .log
go.work go.work
go.work.sum go.work.sum
_set_env*.sh
.env*
!.env.example
Makefile.local
.netrc
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
# 已合并到 git-credential.sh;保留此文件仅为兼容旧配置引用
exec "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/git-credential.sh" "$@"
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
# 跨平台 Git 凭据 helper(不依赖 includeIf ondarwin/onlinux,兼容 Git < 2.36)
# macOS: osxkeychain → store
# Linux: libsecret → store
set -euo pipefail
warn_store_fallback() {
local reason="$1"
local marker="${XDG_CACHE_HOME:-$HOME/.cache}/git-credential-store.warned"
[[ -f "$marker" ]] && return 0
mkdir -p "$(dirname "$marker")"
touch "$marker"
cat >&2 <<EOF
提示: Git 凭据使用 store 明文保存到 ~/.git-credentials(${reason})。
建议:
macOS: 通常可用 osxkeychain(Keychain)
Linux: sudo apt install libsecret-1-0 git-credential-libsecret
请确保 ~/.git-credentials 权限为 600。
EOF
}
case "$(uname -s)" in
Darwin)
if command -v git-credential-osxkeychain >/dev/null 2>&1; then
exec git-credential-osxkeychain "$@"
fi
warn_store_fallback "未找到 osxkeychain"
exec git-credential-store "$@"
;;
Linux)
if command -v git-credential-libsecret >/dev/null 2>&1; then
exec git-credential-libsecret "$@"
fi
warn_store_fallback "未找到 git-credential-libsecret"
exec git-credential-store "$@"
;;
*)
warn_store_fallback "未知系统 $(uname -s)"
exec git-credential-store "$@"
;;
esac
+1
View File
@@ -0,0 +1 @@
git remote set-url origin git@github.com:hilaily/.dotfile.git
+255
View File
@@ -0,0 +1,255 @@
version: "2"
run:
allow-parallel-runners: true
timeout: 5m # 超时时间
tests: false
linters:
default: none
enable:
- bodyclose
- errcheck
- errorlint
- govet
- ineffassign
- misspell
- revive
- staticcheck
settings:
errcheck:
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)
- net.(*)
misspell:
locale: US
revive:
max-open-files: 2048
confidence: 0.1
severity: error
enable-all-rules: false
rules:
- name: argument-limit
arguments:
- 15
severity: warning
disabled: true
- name: atomic
severity: warning
disabled: false
- name: banned-characters
arguments:
- Ω
- Σ
- σ
severity: warning
disabled: false
- name: bool-literal-in-expr
severity: warning
disabled: false
- name: call-to-gc
severity: warning
disabled: false
- name: cognitive-complexity
arguments:
- 25
severity: warning
disabled: false
- name: constant-logical-expr
severity: warning
disabled: false
- name: context-as-argument
severity: warning
disabled: false
- name: context-keys-type
severity: warning
disabled: false
- name: cyclomatic
arguments:
- 25
severity: warning
disabled: false
- name: datarace
severity: warning
disabled: false
- name: deep-exit
severity: warning
disabled: false
- name: defer
arguments:
- - call-chain
- loop
severity: warning
disabled: false
- name: duplicated-imports
severity: warning
disabled: false
- name: early-return
severity: warning
disabled: false
- name: error-naming
severity: warning
disabled: false
- name: error-return
severity: warning
disabled: false
- name: error-strings
severity: warning
disabled: false
- name: errorf
severity: warning
disabled: false
- name: exported
arguments:
- checkPrivateReceivers
- sayRepetitiveInsteadOfStutters
severity: warning
disabled: false
- name: function-result-limit
arguments:
- 6
severity: warning
disabled: false
- name: function-length
arguments:
- 100
- 0
severity: warning
disabled: false
- name: get-return
severity: warning
disabled: false
- name: if-return
severity: warning
disabled: false
- name: increment-decrement
severity: warning
disabled: false
- name: indent-error-flow
severity: warning
disabled: false
- name: modifies-value-receiver
severity: warning
disabled: false
- name: nested-structs
severity: warning
disabled: true
- name: optimize-operands-order
severity: warning
disabled: false
- name: package-comments
severity: warning
disabled: false
- name: range
severity: warning
disabled: false
- name: range-val-in-closure
severity: warning
disabled: false
- name: range-val-address
severity: warning
disabled: false
- name: receiver-naming
severity: warning
disabled: false
- name: redefines-builtin-id
severity: warning
disabled: false
- name: string-of-int
severity: warning
disabled: false
- name: string-format
arguments:
- - core.WriteError[1].Message
- /^([^A-Z]|$)/
- must not start with a capital letter
- - fmt.Errorf[0]
- /(^|[^\.!?])$/
- must not end in punctuation
- - panic
- /^[^\n]*$/
- must not contain line breaks
severity: warning
disabled: false
- name: struct-tag
severity: warning
disabled: false
- name: superfluous-else
severity: warning
disabled: false
- name: time-equal
severity: warning
disabled: false
- name: time-naming
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
arguments:
- ["ID", "Id", "id"]
- ["VM"]
- [{ skipInitialismNameChecks = true }]
severity: warning
disabled: true
- name: var-declaration
severity: warning
disabled: false
- name: unconditional-recursion
severity: warning
disabled: false
- name: unexported-naming
severity: warning
disabled: false
- name: unexported-return
disabled: true
- name: unhandled-error
arguments:
- fmt.Printf
- os.(Create|WriteFile|Chmod)
- net.*
- bytes.Buffer.WriteString
- con.WriteString
severity: warning
disabled: true
- name: unnecessary-stmt
severity: warning
disabled: false
- name: unreachable-code
severity: warning
disabled: false
- name: useless-break
severity: warning
disabled: false
- name: waitgroup-by-value
severity: warning
disabled: false
staticcheck:
checks:
- all
- -ST1000
- -ST1001
- -ST1003
- -ST1016
- -ST1020
- -ST1021
- -ST1022
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
+89 -16
View File
@@ -1,20 +1,93 @@
#!bin/sh #!/bin/bash
#git clone https://github.com/hilaily/.dotfile.git ~/.dotfile # 安装并初始化 Fish、tmux 与 Git 的基础 dotfile 环境
# 判断 zsh 是否安装 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#sudo yum update && sudo yum -y install zsh # shellcheck disable=SC1091
source "$SCRIPT_DIR/script/common/help.sh"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/script/common/os-arch.sh"
# 判断 oh-my-zsh 是否安装 set -euo pipefail
if [ ! -d "$HOME/.oh-my-zsh" ];then
export ZSH=$HOME/.oh-my-zsh usage() {
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" cat <<'EOF'
用法: ./init.sh
安装缺失的基础工具(fish、tmux、git),随后依次执行:
1. fish-init 初始化 Fish 配置、插件与默认 shell
2. tmux-init 初始化 tmux 配置与 TPM 插件
3. git-init 初始化 Git 配置
支持:
macOS Homebrew
Debian/Ubuntu apt
选项:
-h, --help 显示此帮助
说明:
请以需要配置的普通用户运行,不要使用 sudo 运行本脚本。
Linux 安装缺失软件时会请求 sudo;Fish 初始化也会请求 sudo 将 fish
加入 /etc/shells。
EOF
}
dotfile_help_requested "${1:-}" && dotfile_show_help
[[ $# -eq 0 ]] || { echo "错误: 不支持参数: $*" >&2; usage >&2; exit 1; }
die() {
echo "错误: $*" >&2
exit 1
}
run_with_sudo() {
if [[ $EUID -eq 0 ]]; then
"$@"
else
sudo "$@"
fi
}
[[ $EUID -ne 0 ]] || die "请以需要配置的普通用户运行,不要使用 sudo ./init.sh"
[[ -d "$HOME/.dotfile" ]] || die "未找到 $HOME/.dotfile;请将仓库放在该路径后重试"
[[ "$SCRIPT_DIR" -ef "$HOME/.dotfile" ]] || die "当前仓库不是 $HOME/.dotfile;现有初始化脚本依赖该路径"
missing_packages=()
command -v fish >/dev/null 2>&1 || missing_packages+=(fish)
command -v tmux >/dev/null 2>&1 || missing_packages+=(tmux)
command -v git >/dev/null 2>&1 || missing_packages+=(git)
if ((${#missing_packages[@]} == 0)); then
echo "基础工具已安装:fish、tmux、git"
else
echo "安装缺失工具: ${missing_packages[*]}"
case "$(get_os)" in
darwin)
command -v brew >/dev/null 2>&1 || die "未找到 Homebrew;请先运行: bash script/brew-install.sh"
brew install "${missing_packages[@]}"
;;
linux)
command -v apt-get >/dev/null 2>&1 || die "仅支持 apt;请先通过系统包管理器安装: ${missing_packages[*]}"
run_with_sudo apt-get update
run_with_sudo apt-get install -y "${missing_packages[@]}"
;;
*)
die "不支持的系统: $(get_os)"
;;
esac
fi fi
ln -sf ~/.dotfile/.zshrc ~/
ln -sf ~/.dotfile/laily.zsh-theme ~/.oh-my-zsh/themes/
ln -sf ~/.dotfile/.tmux.conf ~/
ln -sf ~/.dotfile/git/.gitconfig ~/.gitconfig
# install neovim echo
cd /usr/local echo "== 初始化 Fish =="
wget https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-macos.tar.gz bash "$SCRIPT_DIR/script/fish-init.sh"
tar zxvf nvim-macos.tar.gz
echo
echo "== 初始化 tmux =="
bash "$SCRIPT_DIR/script/tmux-init.sh"
echo
echo "== 初始化 Git =="
bash "$SCRIPT_DIR/script/git-init.sh"
echo
echo "基础环境初始化完成。重新打开终端后 Fish 将作为默认 shell 生效。"
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true
+3
View File
@@ -0,0 +1,3 @@
#/bin/bash
defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string "~/.dotfile/iterm2"
# then open iterm2, Preferences->General->Settings, Mark 'load preferences from xxx'
-7
View File
@@ -1,7 +0,0 @@
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m ${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
+1
View File
@@ -0,0 +1 @@
[tools]
-20
View File
@@ -1,20 +0,0 @@
# Nvim config
## Backup plugin version
Because nvim have some breaking changes sometimes. I can not alwaexys use the latest version of plugins.
### Backup
Execute `get_packer_snapshot.sh`. This script will backup all the plugin commit information to a json file.
### Restore
document: https://github.com/wbthomason/packer.nvim#usage
```
vim +"PackerSnapshot lock-${version}.json"
```
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
require('lang.go')
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
setl commentstring={/*%s*/} ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
require('lang.js-ts')
-3
View File
@@ -1,3 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
require('lang/lua')
-2
View File
@@ -1,2 +0,0 @@
require('lang.bash')
-1
View File
@@ -1 +0,0 @@
require('lang.js-ts')
-2
View File
@@ -1,2 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
-2
View File
@@ -1,2 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2 ts=2 ai et
-10
View File
@@ -1,10 +0,0 @@
#!/bin/bash
version=$(vim -v | awk 'NR==1{print $2}')
path="$HOME/.cache/nvim/packer.nvim/lock-${version}.json"
rm -rf ${path}
vim +"PackerSnapshot lock-${version}.json"
cp -f ${path} .
echo 'file at '${path}
+47 -28
View File
@@ -1,33 +1,52 @@
CONFIG_PATH = vim.fn.stdpath('config') if vim.loader then
DATA_PATH = vim.fn.stdpath('data') vim.loader.enable()
CACHE_PATH = vim.fn.stdpath('cache') end
P = vim.inspect
require('lv-globals') -- 让 Mason / 健康检查能找到本仓库常用的本地 CLI(fd、lazygit、tree-sitter 等)
vim.cmd('luafile '..CONFIG_PATH..'/settings.lua') local _local_bin = vim.fn.expand("~/.local/bin")
require('settings') if vim.fn.isdirectory(_local_bin) == 1 then
require('plugins') vim.env.PATH = _local_bin .. ":" .. vim.env.PATH
require('utils') end
require('pluginconfig') -- 全局 npm 包(如 mermaid-cli 的 `mmdc`)通常在 $(npm prefix -g)/bin
require('autocommands') do
require('keymappings') local ok, out = pcall(vim.fn.system, { "npm", "prefix", "-g" })
require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings if ok and out and out ~= "" then
local npm_bin = vim.fn.trim(out) .. "/bin"
if vim.fn.isdirectory(npm_bin) == 1 then
vim.env.PATH = npm_bin .. ":" .. vim.env.PATH
end
end
end
-- TODO is there a way to do this without vimscript vim.g.loaded_netrw = 1
vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') vim.g.loaded_netrwPlugin = 1
-- LSP _G.dd = function(...)
require('lsp') require("utils.debug").dump(...)
end
vim.print = _G.dd
--[[ require("config.lazy")
require('lsp.css-ls')
require('lsp.docker-ls')
require('lsp.emmet-ls') -- CONFIG_PATH = vim.fn.stdpath('config')
require('lsp.html-ls') -- DATA_PATH = vim.fn.stdpath('data')
require('lsp.json-ls') -- CACHE_PATH = vim.fn.stdpath('cache')
require('lsp.latex-ls') -- P = vim.inspect
require('lsp.python-ls')
require('lsp.rust-ls') -- require('lv-globals')
require('lsp.yaml-ls') -- vim.cmd('luafile '..CONFIG_PATH..'/settings.lua')
]] -- require('settings')
-- require('plugins')
-- require('utils')
-- require('pluginconfig')
-- require('autocommands')
-- require('keymappings')
-- require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings
-- -- TODO is there a way to do this without vimscript
-- vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim')
-- -- LSP
-- require('lsp')
+65
View File
@@ -0,0 +1,65 @@
{
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
"LazyVim": { "branch": "main", "commit": "fca0af57cc3851b14f96a795a9c9bfafc5096dd1" },
"SchemaStore.nvim": { "branch": "main", "commit": "4f1c58a59d3a4da095743dd6f04b73caa0cefc3d" },
"avante.nvim": { "branch": "main", "commit": "e89eb79abf5754645e20aa6074da10ed20bba33c" },
"barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" },
"blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" },
"blink.cmp": { "branch": "main", "commit": "451168851e8e2466bc97ee3e026c3dcb9141ce07" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"catppuccin": { "branch": "main", "commit": "a7788416689dbefea659d9e9415c87926b0ba5d8" },
"codecompanion.nvim": { "branch": "main", "commit": "e0780fa9fda504ffb89307cabcb6cbe1ce8eb60c" },
"conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" },
"dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
"flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"fzf-lua": { "branch": "main", "commit": "c9e7b7bfbd01f949164988ee1684035468e1995c" },
"gemini-cli.nvim": { "branch": "main", "commit": "c9fd62adda823628f5131a939d9c56ef7a898600" },
"gitsigns.nvim": { "branch": "main", "commit": "caa98e2e5e4c23a1652c23be839d2e1722cecc29" },
"grug-far.nvim": { "branch": "main", "commit": "dc4684e163971bb1f5bfb93fbd4bb3e892bf9b15" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" },
"lsp_signature.nvim": { "branch": "master", "commit": "af7e4074d85d785cf6614352ba9ad3b28a1f8a56" },
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" },
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
"mini.ai": { "branch": "main", "commit": "4b0a6207341d895b6cfe9bcb1e4d3e8607bfe4f4" },
"mini.icons": { "branch": "main", "commit": "5b9076dae1bfbe47ba4a14bc8b967cde0ab5d77e" },
"mini.pairs": { "branch": "main", "commit": "b7fde3719340946feb75017ef9d75edebdeb0566" },
"neo-tree.nvim": { "branch": "main", "commit": "84c75e7a7e443586f60508d12fc50f90d9aee14e" },
"neotest": { "branch": "master", "commit": "72bc8f1ec62a590fb47368c81f89610e0f353e28" },
"neotest-golang": { "branch": "main", "commit": "58d07a76d714f8f768bbe27711b06d41ca237728" },
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
"nvim-dap": { "branch": "master", "commit": "4f5deb110d9ff8994d96c21df95e2271d11214f9" },
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
"nvim-dap-ui": { "branch": "master", "commit": "f5b6673f374626515401c5bc51b005f784a4f252" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-lint": { "branch": "master", "commit": "4b03656c09c1561f89b6aa0665c15d292ba9499d" },
"nvim-lspconfig": { "branch": "master", "commit": "5492a24edd68f78d8a778edcb8905d0a28993abc" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-tree.lua": { "branch": "master", "commit": "3603f069ff783c31986894a56c2a6755331b0802" },
"nvim-treesitter": { "branch": "main", "commit": "7caec274fd19c12b55902a5b795100d21531391f" },
"nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" },
"nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" },
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
"persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"render-markdown.nvim": { "branch": "main", "commit": "c7188a8f9d2953696b6303caccbf39c51fa2c1b1" },
"sidekick.nvim": { "branch": "main", "commit": "17447a05f9385e5f8372b61530f6f9329cb82421" },
"snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" },
"symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
"telescope.nvim": { "branch": "master", "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" },
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
"tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" },
"trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" },
"ts-comments.nvim": { "branch": "main", "commit": "123a9fb12e7229342f807ec9e6de478b1102b041" },
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
}
+17
View File
@@ -0,0 +1,17 @@
{
"extras": [
"lazyvim.plugins.extras.editor.telescope",
"lazyvim.plugins.extras.test.core",
"lazyvim.plugins.extras.lang.go",
"lazyvim.plugins.extras.lang.typescript",
"lazyvim.plugins.extras.lang.json",
"lazyvim.plugins.extras.dap.core",
"lazyvim.plugins.extras.formatting.prettier",
"lazyvim.plugins.extras.ai.avante"
],
"install_version": 7,
"news": {
"NEWS.md": "11866"
},
"version": 8
}
-1
View File
@@ -1 +0,0 @@
{"nvim-dap": {"commit": "2cfd770"}, "FixCursorHold.nvim": {"commit": "5aa5ff1"}, "nvcode-color-schemes.vim": {"commit": "3a0e624"}, "telescope-fzf-native.nvim": {"commit": "65c0ee3"}, "codi.vim": {"commit": "2898369"}, "packer.nvim": {"commit": "6afb674"}, "nvim-lspconfig": {"commit": "51775b1"}, "playground": {"commit": "bcfab84"}, "numb.nvim": {"commit": "453c50a"}, "nvim-dap-virtual-text": {"commit": "2971ce3"}, "which-key.nvim": {"commit": "92d924d"}, "telescope-file-browser.nvim": {"commit": "60bcf4e"}, "aerial.nvim": {"commit": "f7d6ca8"}, "nvim-autopairs": {"commit": "14cc2a4"}, "neotest-go": {"commit": "d506f83"}, "nvim-colorizer.lua": {"commit": "36c610a"}, "nvim-comment": {"commit": "e9ac16a"}, "tabular": {"commit": "339091a"}, "rnvimr": {"commit": "4ced809"}, "gitsigns.nvim": {"commit": "4d8a6e0"}, "glow.nvim": {"commit": "8dca358"}, "nvim-ts-autotag": {"commit": "fdefe46"}, "telescope.nvim": {"commit": "30e2dc5"}, "nvim-compe": {"commit": "d186d73"}, "telescope-project.nvim": {"commit": "91e9a97"}, "trouble.nvim": {"commit": "929315e"}, "nvim-ts-context-commentstring": {"commit": "4d3a68c"}, "lsp_signature.nvim": {"commit": "e65a638"}, "one-monokai-vim": {"commit": "4fdfd93"}, "gruvbox.nvim": {"commit": "c632f62"}, "hop.nvim": {"commit": "75f73d3"}, "lush.nvim": {"commit": "fabf012"}, "LuaSnip": {"commit": "e687d78"}, "vim-go-coverage": {"commit": "d9b0c9f"}, "vim-matchup": {"commit": "ab8575d"}, "popup.nvim": {"commit": "b7404d3"}, "nvim-bqf": {"commit": "aac1ff9"}, "FTerm.nvim": {"commit": "efd1065"}, "lua-dev.nvim": {"commit": "315ad43"}, "nvim-treesitter": {"commit": "8689f61"}, "neotest": {"commit": "15c0bb2"}, "nvim-dap-ui": {"commit": "ebebd42"}, "nvim-luapad": {"commit": "9815e26"}, "monokai.nvim": {"commit": "4fc970e"}, "lspsaga.nvim": {"commit": "9ec569a"}, "vim-markdown": {"commit": "8a0b434"}, "dashboard-nvim": {"commit": "d82ddae"}, "barbar.nvim": {"commit": "c41ad6e"}, "nvim-tree.lua": {"commit": "fb8735e"}, "bracey.vim": {"commit": "4e1a22a"}, "fzf-lua": {"commit": "9b23c2c"}, "nvim-lsp-installer": {"commit": "ae913cb"}, "lsp-rooter.nvim": {"commit": "7c83364"}, "toggleterm.nvim": {"commit": "f494c61"}, "plenary.nvim": {"commit": "62dc2a7"}, "telescope-dap.nvim": {"commit": "b4134ff"}, "markdown-preview.nvim": {"commit": "02cc387"}, "nvim-web-devicons": {"commit": "2d02a56"}, "DAPInstall.nvim": {"commit": "bbda2b0"}, "galaxyline.nvim": {"commit": "eb81be0"}}
-76
View File
@@ -1,76 +0,0 @@
local utils = require('utils')
local auto_formatters = { }
local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.tsserver.autoformat then
table.insert(auto_formatters, javascript_autoformat)
table.insert(auto_formatters, javascriptreact_autoformat)
table.insert(auto_formatters, typescript_autoformat)
table.insert(auto_formatters, typescriptreact_autoformat)
end
local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.json.autoformat then table.insert(auto_formatters, json_format) end
local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
if O.go.autoformat then table.insert(auto_formatters, go_format) end
utils.define_augroups({
_general_settings = {
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'VimLeavePre', '*', 'set title set titleold='},
{'FileType', 'qf', 'set nobuflisted'},
-- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
-- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
},
_java = {
{'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
{'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
},
_go = {
-- Go generally requires Tabs instead of spaces.
{'FileType', 'go', 'setlocal tabstop=4'},
{'FileType', 'go', 'setlocal shiftwidth=4'},
{'FileType', 'go', 'setlocal softtabstop=4'},
{'FileType', 'go', 'setlocal noexpandtab'},
},
_dashboard = {
-- seems to be nobuflisted that makes my stuff disapear will do more testing
{
'FileType', 'dashboard',
'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
}, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'}
},
_markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
_solidity = {
{'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
{'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
},
_gemini = {
{'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'},
{'BufNewFile', '*.gmi', 'setlocal filetype=markdown'}
},
_buffer_bindings = {
{'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'},
{'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'},
{'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
},
_auto_formatters = auto_formatters
})
-3
View File
@@ -1,3 +0,0 @@
vim.cmd('let g:nvcode_termcolors=256')
vim.cmd('colorscheme ' .. O.colorscheme)
+22
View File
@@ -0,0 +1,22 @@
vim.api.nvim_create_user_command("W", function()
require("utils").sudo_write()
end, { desc = "Write file with sudo (tee)" })
-- Turn off paste mode when leaving insert
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
command = "set nopaste",
})
-- Disable the concealing in some file formats
-- The default conceallevel is 3 in LazyVim
vim.api.nvim_create_autocmd("FileType", {
pattern = { "js", "tsx", "ts", "json", "jsonc", "markdown", "md", "css", "html" },
callback = function()
vim.opt.conceallevel = 0
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
vim.bo.shiftwidth = 2
-- vim.bo.expand = true
end,
})
+180
View File
@@ -0,0 +1,180 @@
local keymap = vim.keymap
-- <Leader>b for buffer
keymap.set("n", "<Leader>bq", "<cmd>q<cr>", { desc = "quit" })
keymap.set("n", "<Leader>bs", "<cmd>w<cr>", { desc = "save" })
keymap.set("n", "<Leader>br", "<cmd>e!<cr>", { desc = "reload" })
keymap.set("n", "<Leader>bd", "<cmd>BufferClose<cr>", { desc = "close buffer" })
-- <Leader>c
keymap.set("n", "<Leader>cs", "<cmd>SymbolsOutline<cr>", { desc = "Symbols Outline" })
-- <Leader>D for Trouble (v3 syntax)
keymap.set("n", "<Leader>Dt", "<cmd>Trouble diagnostics toggle<cr>", { desc = "trouble diagnostics" })
keymap.set("n", "<Leader>Dd", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", { desc = "document diagnostics" })
keymap.set("n", "<Leader>Dq", "<cmd>Trouble qflist toggle<cr>", { desc = "quickfix" })
keymap.set("n", "<Leader>Dl", "<cmd>Trouble loclist toggle<cr>", { desc = "loclist" })
keymap.set("n", "<Leader>Dr", "<cmd>Trouble lsp_references toggle<cr>", { desc = "references" })
-- <Leader>d for debug
keymap.set("n", "<Leader>dd", "<cmd>lua vim.diagnostic.open_float()<cr>", { desc = "show diagnostics" })
keymap.set("n", "<Leader>dc", '<cmd>lua require("dap").continue()<cr>', { desc = "continue" })
keymap.set("n", "<Leader>db", '<cmd>lua require("dap").toggle_breakpoint()<cr>', { desc = "Toggle Breakpoint" })
keymap.set("n", "<Leader>dj", '<cmd>lua require("dap").step_over()<cr>', { desc = "step over" })
keymap.set("n", "<Leader>dk", '<cmd>lua require("dap").step_out()<cr>', { desc = "step out" })
keymap.set("n", "<Leader>dl", '<cmd>lua require("dap").step_into()<cr>', { desc = "step into" })
keymap.set("n", "<Leader>du", '<cmd>lua require("dap").up()<cr>', { desc = "up" })
keymap.set("n", "<Leader>d_", '<cmd>lua require("dap").disconnect();require("dap").stop();require("dap").run_last()<cr>', { desc = "disconnect" })
keymap.set("n", "<Leader>di", '<cmd>lua require("dap.ui.variables").visual_hover()<cr>', { desc = "visual hover" })
keymap.set("n", "<Leader>ds", '<cmd>lua local w=require("dap.ui.widgets");w.centered_float(w.scopes)<cr>', { desc = "scopes" })
-- <Leader>f
keymap.set("n", "<Leader>fm", "<cmd>lua require('utils').open_md()<cr>", { desc = "open markdown in external app" })
keymap.set("n", "<Leader>fs", "<cmd>w<cr>", { desc = "save file" })
keymap.set("n", "<Leader>ft", "<cmd>NvimTreeToggle<cr>", { desc = "toggle nvim tree" })
keymap.set("n", "<Leader>fy", "<cmd>lua require('utils').yank_filepath()<cr>", { desc = "copy file path" })
keymap.set("n", "<Leader>fd", "<cmd>lua require('utils').yank_file_dir()<cr>", { desc = "copy dir path" })
keymap.set("n", "<Leader>fl", "<cmd>NvimTreeFindFile<CR>", { desc = "find file in tree" })
-- <Leader>g
keymap.set("n", "<Leader>gj", "<cmd>lua require('gitsigns').next_hunk()<cr>", { desc = "Next Hunk" })
keymap.set("n", "<Leader>gk", "<cmd>lua require('gitsigns').prev_hunk()<cr>", { desc = "Prev Hunk" })
keymap.set("n", "<Leader>gl", "<cmd>lua require('gitsigns').blame_line()<cr>", { desc = "Blame" })
keymap.set("n", "<Leader>gp", "<cmd>lua require('gitsigns').preview_hunk()<cr>", { desc = "Preview Hunk" })
keymap.set("n", "<Leader>gr", "<cmd>lua require('gitsigns').reset_hunk()<cr>", { desc = "Reset Hunk" })
keymap.set("n", "<Leader>gR", "<cmd>lua require('gitsigns').reset_buffer()<cr>", { desc = "Reset Buffer" })
keymap.set("n", "<Leader>gs", "<cmd>lua require('gitsigns').stage_hunk()<cr>", { desc = "Stage Hunk" })
keymap.set("n", "<Leader>gS", "<cmd>lua require('gitsigns').stage_buffer()<cr>", { desc = "Stage Buffer" })
keymap.set("n", "<Leader>gu", "<cmd>lua require('gitsigns').undo_stage_hunk()<cr>", { desc = "Undo Stage Hunk" })
keymap.set("n", "<Leader>go", "<cmd>Telescope git_status<cr>", { desc = "Open changed file" })
keymap.set("n", "<Leader>gb", "<cmd>Telescope git_branches<cr>", { desc = "Checkout branch" })
keymap.set("n", "<Leader>gc", "<cmd>Telescope git_commits<cr>", { desc = "Checkout commit" })
keymap.set("n", "<Leader>gC", "<cmd>Telescope git_bcommits<cr>", { desc = "Checkout commit(for current file)" })
keymap.set("n", "<Leader>gd", "<cmd>Gitsigns diffthis HEAD<cr>", { desc = "Git Diff" })
-- <Leader>h
keymap.set("n", "<Leader>h", ":set hlsearch!<CR>", { noremap = true, silent = true, desc = "toggle hlsearch" })
-- <Leader>q
keymap.set("n", "<Leader>qq", "<cmd>qall<cr>", { desc = "quit all" })
-- <Leader>s for search
keymap.set("n", "<Leader>sb", "<cmd>Telescope git_branches<cr>", { desc = "Checkout branch" })
keymap.set("n", "<Leader>sc", "<cmd>nohl<cr>", { desc = "no highlight" })
keymap.set("n", "<Leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", { desc = "Document Diagnostics" })
keymap.set("n", "<Leader>sD", "<cmd>Telescope diagnostics<cr>", { desc = "Workspace Diagnostics" })
keymap.set("n", "<Leader>sf", "<cmd>Telescope find_files<cr>", { desc = "Find File" })
keymap.set("n", "<Leader>sr", function()
require("telescope.builtin").oldfiles({ cwd = vim.uv.cwd() })
end, { desc = "Old File" })
keymap.set("n", "<Leader>sm", "<cmd>Telescope marks<cr>", { desc = "Marks" })
keymap.set("n", "<Leader>sM", "<cmd>Telescope man_pages<cr>", { desc = "Man Pages" })
keymap.set("n", "<Leader>sR", "<cmd>Telescope registers<cr>", { desc = "Registers" })
keymap.set("n", "<Leader>st", "<cmd>Telescope live_grep<cr>", { desc = "Text" })
keymap.set("n", "<Leader>s,", function()
local ok, fzf_lua = pcall(require, "fzf-lua")
if ok then
fzf_lua.grep_cword()
else
require("telescope.builtin").grep_string({ word_match = "-w" })
end
end, { desc = "Search word under cursor" })
-- <Leader>t for test
keymap.set("n", "<Leader>tt", '<cmd>lua require("neotest").run.run()<cr>', { desc = "TestNearest" })
keymap.set("n", "<Leader>tf", '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', { desc = "TestFile" })
keymap.set("n", "<Leader>tc", "<cmd>GoCover<cr>", { desc = "go coverage" })
keymap.set("n", "<Leader>tC", "<cmd>GoCoverClear<cr>", { desc = "go coverage clear" })
keymap.set("n", "<Leader>tb", '<cmd>lua require("dap").toggle_breakpoint()<cr>', { desc = "set break point" })
keymap.set("n", "<Leader>tr", '<cmd>lua require("dap").continue()<cr>', { desc = "continue" })
-- <Leader>;
keymap.set("n", "<Leader>;", "<cmd>Dashboard<CR>", { noremap = true, silent = true, desc = "Dashboard" })
-- Ctrl-p: find files with recent-first boost
keymap.set("n", "<C-p>", function()
local builtin = require("telescope.builtin")
local recent_paths = {}
for _, file in ipairs(vim.v.oldfiles) do
if vim.fn.filereadable(file) == 1 then
local abs_path = vim.fn.fnamemodify(file, ":p")
local rel_path = vim.fn.fnamemodify(file, ":.")
recent_paths[abs_path] = true
recent_paths[rel_path] = true
recent_paths[vim.fn.fnamemodify(file, ":t")] = true
end
end
local ok, _ = pcall(require, "telescope._extensions.fzf")
if ok then
builtin.find_files({ hidden = true, no_ignore = false })
else
local sorters = require("telescope.sorters")
builtin.find_files({
hidden = true,
no_ignore = false,
sorter = sorters.Sorter:new({
discard = true,
scoring_function = function(_, prompt, line, entry)
local score = 0
local path = entry.path or entry.value or line
local abs_path = vim.fn.fnamemodify(path, ":p")
local rel_path = vim.fn.fnamemodify(path, ":.")
local filename = vim.fn.fnamemodify(path, ":t")
if recent_paths[abs_path] or recent_paths[rel_path] or recent_paths[filename] then
score = 1000
end
if prompt and prompt ~= "" then
if path:lower():find(prompt:lower(), 1, true) then
score = score + 100
end
end
return score
end,
}),
})
end
end, { noremap = true, silent = true, desc = "Find Files (Recent First)" })
-- Window movement
keymap.set("n", "<C-h>", "<C-w>h", { silent = true })
keymap.set("n", "<C-j>", "<C-w>j", { silent = true })
keymap.set("n", "<C-k>", "<C-w>k", { silent = true })
keymap.set("n", "<C-l>", "<C-w>l", { silent = true })
-- Resize with arrows
keymap.set("n", "<C-Up>", ":resize -2<CR>", { silent = true })
keymap.set("n", "<C-Down>", ":resize +2<CR>", { silent = true })
keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { silent = true })
keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { silent = true })
-- Quickfix toggle
keymap.set("n", "<C-q>", function()
for _, win in pairs(vim.fn.getwininfo()) do
if win.quickfix == 1 then
vim.cmd("cclose")
return
end
end
vim.cmd("copen")
end, { noremap = true, silent = true, desc = "Toggle Quickfix" })
-- Two spaces → live_grep
keymap.set("n", " ", function()
require("telescope.builtin").live_grep()
end, { noremap = true, silent = true, desc = "Search in Files" })
-- Misc
keymap.set("n", "Y", "y$", {})
keymap.set("v", "<", "<gv", { noremap = true, silent = true })
keymap.set("v", ">", ">gv", { noremap = true, silent = true })
keymap.set("i", "jk", "<ESC>", { noremap = true, silent = true })
keymap.set("i", "kj", "<ESC>", { noremap = true, silent = true })
keymap.set("i", "jj", "<ESC>", { noremap = true, silent = true })
-- Tab switch buffer (barbar)
keymap.set("n", "<TAB>", "<cmd>BufferNext<CR>", { noremap = true, silent = true })
keymap.set("n", "<S-TAB>", "<cmd>BufferPrevious<CR>", { noremap = true, silent = true })
-- Move selected line / block in visual mode
keymap.set("x", "K", ":move '<-2<CR>gv-gv", { noremap = true, silent = true })
keymap.set("x", "J", ":move '>+1<CR>gv-gv", { noremap = true, silent = true })
+47
View File
@@ -0,0 +1,47 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
-- LazyVim will automatically load extras from lazyvim.json
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
},
-- 本机未装 luarocks 时避免 Lazy 健康检查报 ERROR;需要 rocks 依赖的插件时再打开
rocks = {
enabled = false,
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = { enabled = false}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
+54
View File
@@ -0,0 +1,54 @@
vim.g.autoformat = true
-- 关闭不常用的远程宿主,减少 :checkhealth 里无意义的 WARNING
vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0
-- 明确指向已安装 pynvim 的解释器
vim.g.python3_host_prog = "/usr/bin/python3"
vim.cmd("set iskeyword+=-") -- treat dash separated words as a word text object
vim.cmd("set shortmess+=c") -- Don't pass messages to |ins-completion-menu|.
vim.cmd("set inccommand=split") -- Make substitution work in realtime
vim.opt.hidden = true -- Required to keep multiple buffers open multiple buffers
vim.opt.title = true
TERMINAL = vim.fn.expand("$TERMINAL")
vim.cmd('let &titleold="' .. TERMINAL .. '"')
vim.opt.titlestring = "%<%F%=%l/%L - nvim"
vim.wo.wrap = true -- Display long lines as just one line
vim.cmd("set whichwrap+=<,>,[,],h,l") -- move to next line with theses keys
vim.opt.pumheight = 10 -- Makes popup menu smaller
vim.opt.fileencoding = "utf-8" -- The encoding written to file
vim.opt.cmdheight = 2 -- More space for displaying messages
vim.opt.mouse = "a" -- Enable your mouse
vim.opt.splitbelow = true -- Horizontal splits will automatically be below
vim.opt.termguicolors = true -- set term gui colors most terminals support this
vim.opt.splitright = true -- Vertical splits will automatically be to the right
vim.opt.conceallevel = 0 -- So that I can see `` in markdown files
vim.o.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true -- Makes indenting smart
vim.wo.number = true -- set numbered lines
vim.wo.relativenumber = true -- set relative number
vim.wo.cursorline = true -- Enable highlighting of the current line
vim.opt.showtabline = 2 -- Always show tabs
vim.opt.showmode = false -- We don't need to see things like -- INSERT -- anymore
vim.opt.backup = false
vim.opt.writebackup = false
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
vim.opt.updatetime = 300 -- Faster completion
vim.opt.timeoutlen = 500 -- By default timeoutlen is 1000 ms
vim.opt.clipboard = "unnamedplus" -- Copy paste between vim and everything else
vim.opt.guifont = "FiraCode Nerd Font:h17"
vim.g.vim_markdown_folding_disabled = 1
-- git blame
vim.cmd("highlight default link gitblame SpecialComment")
vim.g.gitblame_enabled = 0
-- vim.cmd('let g:nvcode_termcolors=256')
-- --local cc = 'gruvbox'
-- local cc = 'lunar'
-- vim.opt.background="dark"
-- vim.cmd('colorscheme ' .. cc)
-81
View File
@@ -1,81 +0,0 @@
vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle<CR>', { noremap = true, silent = true })
-- better window movement
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { silent = true })
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { silent = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { silent = true })
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { silent = true })
-- better edit
vim.api.nvim_set_keymap('n', 'Y', 'y$', {})
-- TODO fix this
-- Terminal window navigation
-- vim.cmd([[
-- tnoremap <C-h> <C-\><C-N><C-w>h
-- tnoremap <C-j> <C-\><C-N><C-w>j
-- tnoremap <C-k> <C-\><C-N><C-w>k
-- tnoremap <C-l> <C-\><C-N><C-w>l
-- inoremap <C-h> <C-\><C-N><C-w>h
-- inoremap <C-j> <C-\><C-N><C-w>j
-- inoremap <C-k> <C-\><C-N><C-w>k
-- inoremap <C-l> <C-\><C-N><C-w>l
-- tnoremap <Esc> <C-\><C-n>
-- ]])
-- TODO fix this
-- resize with arrows
vim.api.nvim_set_keymap('n', '<C-Up>', ':resize -2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Down>', ':resize +2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Left>', ':vertical resize -2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Right>', ':vertical resize +2<CR>', { silent = true })
-- better indenting
vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true, silent = true })
-- I hate escape
vim.api.nvim_set_keymap('i', 'jk', '<ESC>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', 'kj', '<ESC>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', 'jj', '<ESC>', { noremap = true, silent = true })
-- Tab switch buffer
vim.api.nvim_set_keymap('n', '<TAB>', ':bnext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-TAB>', ':bprevious<CR>', { noremap = true, silent = true })
-- Move selected line / block of text in visual mode
vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
-- Better nav for omnicomplete
vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
vim.cmd('vnoremap p "0p')
vim.cmd('vnoremap P "0P')
-- vim.api.nvim_set_keymap('v', 'p', '"0p', {silent = true})
-- vim.api.nvim_set_keymap('v', 'P', '"0P', {silent = true})
-- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
-- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')
-- vim.api.nvim_set_keymap('i', '<C-TAB>', 'compe#complete()', {noremap = true, silent = true, expr = true})
-- vim.cmd([[
-- map p <Plug>(miniyank-autoput)
-- map P <Plug>(miniyank-autoPut)
-- map <leader>n <Plug>(miniyank-cycle)
-- map <leader>N <Plug>(miniyank-cycleback)
-- ]])
-- Toggle the QuickFix window
vim.api.nvim_set_keymap('', '<C-q>', ':call QuickFixToggle()<CR>', { noremap = true, silent = true })
-- nvim-compe key map
-- vim.cmd('inoremap <silent><expr> <C-Space> compe#complete()')
-- vim.cmd("inoremap <silent><expr> <CR> compe#confirm('<CR>')")
-- vim.cmd("inoremap <silent><expr> <C-e> compe#close('<C-e>')")
-- vim.cmd("inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })")
-- vim.cmd("inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })")
-6
View File
@@ -1,6 +0,0 @@
-- npm i -g bash-language-server
require'lspconfig'.bashls.setup {
cmd = {DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start"},
on_attach = require'lsp'.common_on_attach,
filetypes = { "sh", "zsh" }
}
-8
View File
@@ -1,8 +0,0 @@
-- npm install -g vscode-css-languageserver-bin
require'lspconfig'.cssls.setup {
cmd = {
"node", DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js",
"--stdio"
},
on_attach = require'lsp'.common_on_attach
}
-6
View File
@@ -1,6 +0,0 @@
-- npm install -g dockerfile-language-server-nodejs
require'lspconfig'.dockerls.setup {
cmd = {DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio"},
on_attach = require'lsp'.common_on_attach,
root_dir = vim.loop.cwd
}
-19
View File
@@ -1,19 +0,0 @@
local nvim_lsp = require'lspconfig'
local configs = require'lspconfig/configs'
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
configs.emmet_ls = {
default_config = {
cmd = {'emmet-ls', '--stdio'};
filetypes = {'html', 'css'};
root_dir = function()
return vim.loop.cwd()
end;
settings = {};
};
}
nvim_lsp.emmet_ls.setup{
-- on_attach = on_attach;
}
-146
View File
@@ -1,146 +0,0 @@
-- LSP
require 'lspconfig'.gopls.setup {
-- cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
cmd = { "gopls", "serve" }, -- use cmd in path, I can update it easily
settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } },
root_dir = require 'lspconfig'.util.root_pattern(".git", "go.mod", "go.work"),
init_options = { usePlaceholders = true, completeUnimported = true },
on_attach = require 'lsp'.common_on_attach
}
--[[
require'dap-install'.config("go_delve",{})
-- DAP
local dap = require "dap"
vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''})
--vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''})
local M = {}
local ts_utils = require 'nvim-treesitter.ts_utils'
function M.get_node()
local n = ts_utils.get_node_at_cursor()
put(ts_utils.get_node_text(n))
end
function M.get_node2()
local current_node = ts_utils.get_node_at_cursor()
if not current_node then
return ""
end
local expr = current_node
while expr do
if expr:type() == 'function_definition' then
put(expr:type())
break
end
expr = expr:parent()
end
if not expr then return "" end
put(ts_utils.get_node_text(expr))
return (ts_utils.get_node_text(expr:child(1)))[1]
end
return M
--[[
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
dap.configurations.go = {
{
type = "go",
name = "Debug",
request = "launch",
program = "${file}"
},
-- works with go.mod packages and sub packagesfunction M.get_current_function_name() local current_node = ts_utils.get_node_at_cursor() if not current_node then return "" end
local expr = current_node
while expr do
if expr:type() == 'function_definition' then
break
end
expr = expr:parent()
end
if not expr then return "" end
return (ts_utils.get_node_text(expr:child(1)))[1]
end
{
type = "go",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}"
}
}
--[[
local dap = require('dap')
dap.adapters.go = function(callback, config)
local stdout = vim.loop.new_pipe(false)
local handle
local pid_or_err
local port = 38697
local opts = {
stdio = {nil, stdout},
args = {"dap", "-l", "127.0.0.1:" .. port},
detached = true
}
handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code)
stdout:close()
handle:close()
if code ~= 0 then
print('dlv exited with code', code)
end
end)
assert(handle, 'Error running dlv: ' .. tostring(pid_or_err))
stdout:read_start(function(err, chunk)
assert(not err, err)
if chunk then
vim.schedule(function()
require('dap.repl').append(chunk)
end)
end
end)
-- Wait for delve to start
vim.defer_fn(
function()
callback({type = "server", host = "127.0.0.1", port = port})
end,
100)
end
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
dap.configurations.go = {
{
type = "go",
name = "Debug",
request = "launch",
program = "${file}"
},
{
type = "go",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "${file}"
},
-- works with go.mod packages and sub packages
{
type = "go",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}"
}
}
]]
-9
View File
@@ -1,9 +0,0 @@
-- npm install -g vscode-html-languageserver-bin
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.html.setup {
cmd = {"node", DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", "--stdio"},
on_attach = require'lsp'.common_on_attach,
capabilities = capabilities
}
-28
View File
@@ -1,28 +0,0 @@
-- npm install -g typescript typescript-language-server
-- require'snippets'.use_suggested_mappings()
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
-- capabilities.textDocument.completion.completionItem.snippetSupport = true;
-- local on_attach_common = function(client)
-- print("LSP Initialized")
-- require'completion'.on_attach(client)
-- require'illuminate'.on_attach(client)
-- end
require'lspconfig'.tsserver.setup {
cmd = {DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", "--stdio"},
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
on_attach = require'lsp'.tsserver_on_attach,
-- This makes sure tsserver is not used for formatting (I prefer prettier)
-- on_attach = require'lsp'.common_on_attach,
root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
settings = {documentFormatting = false},
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.tsserver.diagnostics.virtual_text,
signs = O.tsserver.diagnostics.signs,
underline = O.tsserver.diagnostics.underline,
update_in_insert = true
})
}
}
-16
View File
@@ -1,16 +0,0 @@
-- npm install -g vscode-json-languageserver
require'lspconfig'.jsonls.setup {
cmd = {
"node", DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
"--stdio"
},
on_attach = require'lsp'.common_on_attach,
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, {0, 0}, {vim.fn.line("$"), 0})
end
}
}
}
-4
View File
@@ -1,4 +0,0 @@
require'lspconfig'.texlab.setup{
cmd = {DATA_PATH .. "/lspinstall/latex/texlab"},
on_attach = require'lsp'.common_on_attach
}
-28
View File
@@ -1,28 +0,0 @@
-- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
local brew_path = "/usr/local/Cellar/lua-language-server/2.5.5/libexec"
local sumneko_root_path = brew_path
local sumneko_binary = brew_path .. "/bin/lua-language-server"
require'lspconfig'.sumneko_lua.setup {
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
on_attach = require'lsp'.common_on_attach,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = vim.split(package.path, ';')
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true},
maxPreload = 10000
}
}
}
}
-22
View File
@@ -1,22 +0,0 @@
-- npm i -g pyright
require'lspconfig'.pyright.setup {
cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"},
on_attach = require'lsp'.common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.python.diagnostics.virtual_text,
signs = O.python.diagnostics.signs,
underline = O.python.diagnostics.underline,
update_in_insert = true
})
},
settings = {
python = {
analysis = {
typeCheckingMode = O.python.analysis.type_checking,
autoSearchPaths = O.python.analysis.auto_search_paths,
useLibraryCodeForTypes = O.python.analysis.use_library_code_types
}
}
}
}
-5
View File
@@ -1,5 +0,0 @@
require'lspconfig'.rust_analyzer.setup{
cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
on_attach = require'lsp'.common_on_attach
}
-5
View File
@@ -1,5 +0,0 @@
-- npm install -g yaml-language-server
require'lspconfig'.yamlls.setup{
cmd = {DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio"},
on_attach = require'lsp'.common_on_attach,
}
-119
View File
@@ -1,119 +0,0 @@
-- TODO figure out why this don't work
vim.fn.sign_define(
"LspDiagnosticsSignError",
{ texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" }
)
vim.fn.sign_define(
"LspDiagnosticsSignWarning",
{ texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning" }
)
vim.fn.sign_define(
"LspDiagnosticsSignHint",
{ texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint" }
)
vim.fn.sign_define(
"LspDiagnosticsSignInformation",
{ texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation" }
)
vim.cmd("nnoremap gd <cmd>lua vim.lsp.buf.definition()<CR>")
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>")
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>")
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>")
vim.cmd("nnoremap <silent> ca :Lspsaga code_action<CR>")
vim.cmd("nnoremap <silent> K :Lspsaga hover_doc<CR>")
-- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>')
vim.cmd("nnoremap <silent> <C-m> :Lspsaga diagnostic_jump_prev<CR>")
vim.cmd("nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>")
-- scroll down hover doc or scroll in definition preview
vim.cmd("nnoremap <silent> <C-f> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>")
-- scroll up hover doc
vim.cmd("nnoremap <silent> <C-b> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>")
vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()')
-- Set Default Prefix.
-- Note: You can set a prefix per lsp server in the lv-globals.lua file
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = {
prefix = "",
spacing = 0,
},
signs = true,
underline = true,
}
)
-- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = {
"  (Text) ",
"  (Method)",
"  (Function)",
"  (Constructor)",
" ﴲ (Field)",
"[] (Variable)",
"  (Class)",
" ﰮ (Interface)",
"  (Module)",
" 襁 (Property)",
"  (Unit)",
"  (Value)",
" 練 (Enum)",
"  (Keyword)",
"  (Snippet)",
"  (Color)",
"  (File)",
"  (Reference)",
"  (Folder)",
"  (EnumMember)",
" ﲀ (Constant)",
" ﳤ (Struct)",
"  (Event)",
"  (Operator)",
"  (TypeParameter)"
}
--[[ " autoformat
autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
-- Java
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
local function documentHighlight(client, bufnr)
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]] ,
false
)
end
end
local lsp_config = {}
if O.document_highlight then
function lsp_config.common_on_attach(client, bufnr)
documentHighlight(client, bufnr)
end
end
--function lsp_config.tsserver_on_attach(client, bufnr)
-- lsp_config.common_on_attach(client, bufnr)
-- client.resolved_capabilities.document_formatting = false
--end
-- Use a loop to conveniently both setup defined servers
-- and map buffer local keybindings when the language server attaches
-- local servers = {"pyright", "tsserver"}
-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end
return lsp_config
-66
View File
@@ -1,66 +0,0 @@
O = {
extras = false,
--database = {save_location = '~/.config/nvcode_db', auto_execute = 1},
python = {
linter = '',
-- @usage can be 'yapf', 'black'
formatter = '',
autoformat = false,
isort = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true},
analysis = {type_checking = "basic", auto_search_paths = true, use_library_code_types = true}
},
dart = {sdk_path = '/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot'},
lua = {
-- @usage can be 'lua-format'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
sh = {
-- @usage can be 'shellcheck'
linter = '',
-- @usage can be 'shfmt'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
tsserver = {
-- @usage can be 'eslint'
linter = '',
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
json = {
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
tailwindls = {filetypes = {'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact'}},
clang = {diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}},
ruby = {
diagnostics = {virtualtext = {spacing = 0, prefix = ""}, signs = true, underline = true},
filetypes = {'rb', 'erb', 'rakefile'}
},
go = {},
-- css = {formatter = '', autoformat = false, virtual_text = true},
-- json = {formatter = '', autoformat = false, virtual_text = true}
}
function _G.put(...)
local objects = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
table.insert(objects, vim.inspect(v))
end
print(table.concat(objects, '\n'))
return ...
end
-3
View File
@@ -1,3 +0,0 @@
vim.api.nvim_set_keymap('n', '<TAB>', ':BufferNext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferPrevious<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-x>', ':BufferClose<CR>', { noremap = true, silent = true })
-63
View File
@@ -1,63 +0,0 @@
--[[
local dashboard = {
custom_header = {
' _..._ ',
' .\' (_`. _ __ ___ ',
' : . : | | _ _ _ __ __ _ _ _\\ \\ / (_)_ __ ___ ',
' :) () : | | | | | | \'_ \\ / _` | \'__\\ \\ / /| | \'_ ` _ \\ ',
' `. . .\' | |__| |_| | | | | (_| | | \\ V / | | | | | | |',
' `-...-\' |_____\\__,_|_| |_|\\__,_|_| \\_/ |_|_| |_| |_|',
},
footer= {'Laily'}
}
]]
local dashboard = {
custom_header = {
'███╗ ██╗██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗',
'████╗ ██║██║ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝',
'██╔██╗ ██║██║ ██║██║ ██║ ██║██║ ██║█████╗',
'██║╚██╗██║╚██╗ ██╔╝██║ ██║ ██║██║ ██║██╔══╝',
'██║ ╚████║ ╚████╔╝ ╚██████╗╚██████╔╝██████╔╝███████╗',
'╚═╝ ╚═══╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝'
},
footer= {'Laily'},
}
-- vim.g.dashboard_custom_header = {
--
-- ' _..._ ',
-- ' .\' `. ██  ██  ██ ███  ██  █████  ██████  ██  ██ ██ ███  ███ ',
-- ' : : ██  ██  ██ ████  ██ ██   ██ ██   ██ ██  ██ ██ ████  ████ ',
-- ' : : ██  ██  ██ ██ ██  ██ ███████ ██████  ██  ██ ██ ██ ████ ██ ',
-- ' `. .\' ██  ██  ██ ██  ██ ██ ██   ██ ██   ██  ██  ██  ██ ██  ██  ██ ',
-- ' `-...-\' ███████  ██████  ██   ████ ██  ██ ██  ██   ████   ██ ██      ██ ',
--
-- }
vim.g.dashboard_custom_header = dashboard.custom_header
vim.g.dashboard_default_executive = 'telescope'
vim.g.dashboard_custom_section = {
a = {description = {' Find File '}, command = 'Telescope find_files'},
b = {description = {' Recently Used Files'}, command = 'Telescope oldfiles'},
c = {description = {' Load Last Session '}, command = 'SessionLoad'},
d = {description = {' Find Word '}, command = 'Telescope live_grep'},
e = {description = {' Settings '}, command = ':e '..CONFIG_PATH..'/lv-settings.lua'}
-- e = {description = {' Marks '}, command = 'Telescope marks'}
}
-- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'},
-- vim.g.dashboard_custom_shortcut = {
-- a = 'f',
-- find_word = 'SPC f a',
-- last_session = 'SPC s l',
-- new_file = 'SPC c n',
-- book_marks = 'SPC f b'
-- }
-- find_history = 'SPC f h',
-- vim.g.dashboard_session_directory = CACHE_PATH..'/session'
vim.g.dashboard_custom_footer = dashboard.footer
-11
View File
@@ -1,11 +0,0 @@
require'fzf-lua'.setup {
fzf_opts = { ['--keep-right'] = ''},
fzf_cli_args = '--keep-right',
--[[
winopts = {
preview = {
layout = "vertical"
}
}
]]
}
-220
View File
@@ -1,220 +0,0 @@
local gl = require('galaxyline')
-- get my theme in galaxyline repo
-- local colors = require('galaxyline.theme').default
local colors = {
-- bg = '#2E2E2E',
bg = '#292D38',
yellow = '#DCDCAA',
dark_yellow = '#D7BA7D',
cyan = '#4EC9B0',
green = '#608B4E',
light_green = '#B5CEA8',
string_orange = '#CE9178',
orange = '#FF8800',
purple = '#C586C0',
magenta = '#D16D9E',
grey = '#858585',
blue = '#569CD6',
vivid_blue = '#4FC1FF',
light_blue = '#9CDCFE',
red = '#D16969',
error_red = '#F44747',
info_yellow = '#FFCC66'
}
local condition = require('galaxyline.condition')
local gls = gl.section
gl.short_line_list = {'NvimTree', 'vista', 'dbui', 'packer'}
table.insert(gls.left, {
ViMode = {
provider = function()
-- auto change color according the vim mode
local mode_color = {
n = colors.blue,
i = colors.green,
v = colors.purple,
[''] = colors.purple,
V = colors.purple,
c = colors.magenta,
no = colors.blue,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.red,
Rv = colors.red,
cv = colors.blue,
ce = colors.blue,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.blue,
t = colors.blue
}
vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
return '▊ '
end,
highlight = {colors.red, colors.bg}
}
})
print(vim.fn.getbufvar(0, 'ts'))
vim.fn.getbufvar(0, 'ts')
table.insert(gls.left, {
GitIcon = {
provider = function()
return ''
end,
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.orange, colors.bg}
}
})
table.insert(gls.left, {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.left, {
DiffAdd = {
provider = 'DiffAdd',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.green, colors.bg}
}
})
table.insert(gls.left, {
DiffModified = {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = ' 柳',
highlight = {colors.blue, colors.bg}
}
})
table.insert(gls.left, {
DiffRemove = {
provider = 'DiffRemove',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.red, colors.bg}
}
})
table.insert(gls.right, {
DiagnosticError = {provider = 'DiagnosticError', icon = '', highlight = {colors.error_red, colors.bg}}
})
table.insert(gls.right, {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '', highlight = {colors.orange, colors.bg}}})
table.insert(gls.right, {
DiagnosticHint = {provider = 'DiagnosticHint', icon = '', highlight = {colors.vivid_blue, colors.bg}}
})
table.insert(gls.right, {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '', highlight = {colors.info_yellow, colors.bg}}})
table.insert(gls.right, {
TreesitterIcon = {
provider = function()
if next(vim.treesitter.highlighter.active) ~= nil then return '' end
return ''
end,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.green, colors.bg}
}
})
table.insert(gls.right, {
ShowLspClient = {
provider = 'GetLspClient',
condition = function()
local tbl = {['dashboard'] = true, [' '] = true}
if tbl[vim.bo.filetype] then return false end
return true
end,
icon = '',
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
LineInfo = {
provider = 'LineColumn',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
PerCent = {
provider = 'LinePercent',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
Tabstop = {
provider = function()
return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
end,
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
BufferType = {
provider = 'FileTypeName',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
FileEncode = {
provider = 'FileEncode',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
Space = {
provider = function()
return ' '
end,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.orange, colors.bg}
}
})
table.insert(gls.short_line_left, {
BufferType = {
provider = 'FileTypeName',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.short_line_left, {
SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}}
})
--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})
-23
View File
@@ -1,23 +0,0 @@
require('gitsigns').setup {
signs = {
-- TODO add hl to colorscheme
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'},
},
numhl = false,
linehl = false,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
},
watch_gitdir = {
interval = 1000
},
sign_priority = 6,
update_debounce = 200,
status_formatter = nil, -- Use default
}
-2
View File
@@ -1,2 +0,0 @@
vim.api.nvim_set_keymap('n', 's', ":HopChar2<cr>", {silent = true})
vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", {silent = true})
-37
View File
@@ -1,37 +0,0 @@
-- source plugin config
require('pluginconfig/barbar')
require('pluginconfig/dashboard-nvim')
require('pluginconfig/galaxyline')
require('pluginconfig/gitsigns')
require('pluginconfig/hop')
require('pluginconfig/lspinstall')
require('pluginconfig/lua-dev') -- must before lspconfig
require('pluginconfig/mkdx')
require('pluginconfig/neotest')
require('pluginconfig/numb')
require('pluginconfig/nvim-autopairs')
require('pluginconfig/nvim-colorizer')
require('pluginconfig/nvim-cmp')
require('pluginconfig/fzf-lua')
require('pluginconfig/nvim-tree') -- This plugin must be required somewhere before colorscheme. Placing it after will break navigation keymappings
require('pluginconfig/nvim-treesitter')
require('pluginconfig/rnvimr')
require('pluginconfig/telescope')
require('pluginconfig/toggleterm')
require('pluginconfig/vim-matchup')
require('pluginconfig/which-key')
-- nvim_comment
require('nvim_comment').setup()
-- lsp-rooter
require("lsp-rooter").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
-- lsp signature
require("lsp_signature").setup()
-21
View File
@@ -1,21 +0,0 @@
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.settings({
install_root_dir = table.concat { vim.fn.stdpath("data"), "/lspinstall" },
})
-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished
-- or if the server is already installed).
lsp_installer.on_server_ready(function(server)
local opts = {
}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function will take the provided server configuration and decorate it with the necessary properties
-- before passing it onwards to lspconfig.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)
-3
View File
@@ -1,3 +0,0 @@
require("lua-dev").setup({
-- add any options here, or leave empty to use the default settings
})
-7
View File
@@ -1,7 +0,0 @@
vim.cmd([[
let g:mkdx#settings = { 'highlight': { 'enable': 1 },
\ 'enter': { 'shift': 1 },
\ 'links': { 'external': { 'enable': 1 } },
\ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 },
\ 'fold': { 'enable': 1 } }
]])

Some files were not shown because too many files have changed in this diff Show More