├── .editorconfig
├── .github
└── workflows
│ ├── load_vimrc.yml
│ └── release.yml
├── .gitignore
├── .luarc.json
├── .vimrc
├── README.md
├── cog.toml
├── install
├── README.md
├── build_cmake.sh
├── build_nvim.sh
├── build_satanson_ag.sh
├── build_tmux.sh
├── build_vim.sh
├── centos7.sh
├── git.sh
├── rust-toolchain.sh
├── setup.sh
├── sync-llvm-vim.sh
├── sync-scripts.sh
├── tpm_install.sh
└── ubuntu.sh
├── project_files
├── .clangd
├── .clangd-cuda-12.1-cmake
├── .clangd-cuda-12.1-single-file
├── .editorconfig
├── .ocamlformat
├── .vscode
│ ├── go-debug-single-file.launch.json
│ └── launch.json
├── coc-settings-languageserver-clangd.json
├── cpp.project.vim
├── latex.project.vim
└── pyproject.toml
├── root
├── .condarc
├── .config
│ ├── clangd
│ │ └── config.yaml
│ ├── ctags
│ │ └── myconfig.ctags
│ ├── himalaya
│ │ ├── README.md
│ │ └── config.toml
│ ├── lazygit
│ │ └── config.yml
│ ├── nvim
│ │ ├── .gitignore
│ │ ├── .project.vim
│ │ ├── ftplugin
│ │ │ └── java.lua
│ │ ├── lazy.lua
│ │ ├── lua
│ │ │ ├── .luarc.json
│ │ │ ├── dapconfig.lua
│ │ │ ├── detect.lua
│ │ │ ├── lsp
│ │ │ │ ├── diagnostic.lua
│ │ │ │ └── init.lua
│ │ │ ├── nvim_cmp.lua
│ │ │ └── plugins
│ │ │ │ ├── ai.lua
│ │ │ │ ├── csv.lua
│ │ │ │ ├── dap.lua
│ │ │ │ ├── init.lua
│ │ │ │ ├── lsp.lua
│ │ │ │ ├── lualine.lua
│ │ │ │ ├── nvim_cmp.lua
│ │ │ │ ├── telescope.lua
│ │ │ │ ├── treesitter.lua
│ │ │ │ ├── ui.lua
│ │ │ │ ├── vimplug.lua
│ │ │ │ └── wsl.lua
│ │ └── snippets
│ │ │ └── markdown.json
│ └── zellij
│ │ └── config.kdl
├── .gitconfig
├── .gitconfig-delta
├── .gitconfig-ict
├── .globalrc
├── .ripgreprc
├── .tmux.conf
├── .vim
│ ├── README.md
│ ├── UltiSnips
│ │ ├── markdown.snippets
│ │ ├── python.snippets
│ │ └── tex.snippets
│ ├── after
│ │ └── ftplugin
│ │ │ ├── c.vim
│ │ │ ├── cpp.vim
│ │ │ ├── csv.vim
│ │ │ ├── cuda.vim
│ │ │ ├── markdown.vim
│ │ │ ├── quarto.vim
│ │ │ └── tex.vim
│ ├── autoload
│ │ ├── ai.vim
│ │ ├── asynctasks_custom.vim
│ │ ├── coc_clang.vim
│ │ ├── coc_custom.vim
│ │ ├── common.vim
│ │ ├── cpp.vim
│ │ ├── fzf_custom
│ │ │ ├── fzf.vim
│ │ │ ├── palette.vim
│ │ │ ├── quickfix.vim
│ │ │ ├── rg.vim
│ │ │ ├── tabs.vim
│ │ │ └── tags.vim
│ │ ├── jupyter_ascending_custom.vim
│ │ ├── jupyter_custom.vim
│ │ ├── largefile.vim
│ │ ├── latex.vim
│ │ ├── markdown.vim
│ │ ├── marks.vim
│ │ ├── mergetool_custom.vim
│ │ ├── mycpp.vim
│ │ ├── noplug.vim
│ │ ├── plug.vim
│ │ ├── statusline.vim
│ │ ├── tagsystem.vim
│ │ ├── timer.vim
│ │ ├── wsl.vim
│ │ └── yank.vim
│ ├── coc-settings.json
│ ├── config.vim.example
│ ├── configurations
│ │ └── linux
│ │ │ ├── _all
│ │ │ └── vimspector.json
│ │ │ ├── go
│ │ │ └── vimspcetor.json
│ │ │ ├── java
│ │ │ └── vimspcetor.json
│ │ │ └── python
│ │ │ └── vimspcetor.json
│ ├── doc
│ │ ├── ai.txt
│ │ ├── c-cpp-cuda.txt
│ │ ├── clean-disk.txt
│ │ ├── coc-nvim.txt
│ │ ├── code.txt
│ │ ├── collaboration.txt
│ │ ├── command-line-tool.txt
│ │ ├── complete.md
│ │ ├── data-science.txt
│ │ ├── docker.txt
│ │ ├── draw.txt
│ │ ├── gdb-dap.txt
│ │ ├── git
│ │ │ ├── git-help.txt
│ │ │ └── git-shallow-clone.md
│ │ ├── golang.txt
│ │ ├── http-proxy.txt
│ │ ├── interview.txt
│ │ ├── java.txt
│ │ ├── linux
│ │ │ ├── centos.txt
│ │ │ ├── filesystem.md
│ │ │ ├── linux.txt
│ │ │ └── ubuntu.txt
│ │ ├── luajit.txt
│ │ ├── mongodb.txt
│ │ ├── mydoc.txt
│ │ ├── neovim.txt
│ │ ├── network.txt
│ │ ├── nodejs.txt
│ │ ├── objdump.txt
│ │ ├── palette.txt
│ │ ├── port3128.md
│ │ ├── python-env.txt
│ │ ├── realtime-collaboration.md
│ │ ├── rg.txt
│ │ ├── sed.txt
│ │ ├── sftp-server.md
│ │ ├── ssh-help.txt
│ │ ├── tags.txt
│ │ ├── writing.txt
│ │ └── wsl.txt
│ ├── ftdetect
│ │ ├── llvm-lit.vim
│ │ ├── mir.vim
│ │ ├── mlir.vim
│ │ └── tablegen.vim
│ ├── ftplugin
│ │ ├── floaterm.vim
│ │ ├── gitcommit.vim
│ │ ├── html.vim
│ │ ├── java.vim
│ │ ├── mir.vim
│ │ ├── mlir.vim
│ │ ├── ocaml.vim
│ │ ├── python.vim
│ │ ├── qf.vim
│ │ ├── sql.vim
│ │ └── tablegen.vim
│ ├── indent
│ │ ├── llvm.vim
│ │ └── mlir.vim
│ ├── pack
│ │ └── my_plugins
│ │ │ ├── opt
│ │ │ └── gtags_asyncrun
│ │ │ │ └── plugin
│ │ │ │ └── gtags_asyncrun.vim
│ │ │ └── start
│ │ │ ├── diffbuffer.vim
│ │ │ ├── autoload
│ │ │ │ └── diffbuffer.vim
│ │ │ └── plugin
│ │ │ │ └── diffbuffer.vim
│ │ │ ├── duckdb.vim
│ │ │ ├── autoload
│ │ │ │ └── duckdb.vim
│ │ │ ├── doc
│ │ │ │ └── duckdb.txt
│ │ │ └── plugin
│ │ │ │ └── duckdb.vim
│ │ │ └── project.vim
│ │ │ ├── doc
│ │ │ └── project-vim.txt
│ │ │ └── plugin
│ │ │ └── project.vim
│ ├── syntax
│ │ ├── llvm.vim
│ │ ├── machine-ir.vim
│ │ ├── mir.vim
│ │ ├── mlir.vim
│ │ └── tablegen.vim
│ ├── tasks.ini
│ ├── vim-ai-roles.ini
│ ├── vimrc
│ └── vimrc.d
│ │ ├── ai.vim
│ │ ├── asynctasks.vim
│ │ ├── coc.vim
│ │ ├── fzf.vim
│ │ ├── golang.vim
│ │ ├── latex.vim
│ │ ├── leaderf.vim
│ │ ├── plugin_setup.vim
│ │ └── vimplug.vim
├── bashrc
├── bashrc_noi
├── common.awk
├── fzf.bash
├── goto.sh
├── latexindent.yaml
├── process_ctags.awk
├── scripts
│ ├── calltree.pl
│ ├── clean-vim-backup.py
│ ├── cpptree.pl
│ ├── deptree.pl
│ ├── extract-pptx.py
│ ├── forget
│ ├── git-rm-file-in-history
│ ├── java_calltree.pl
│ ├── javatree.pl
│ ├── jupyter_ascending.sh
│ ├── lsix
│ ├── oscyank
│ ├── pbpaste
│ ├── pdf-anno.py
│ ├── ppt2pdf.sh
│ ├── preview.sh
│ ├── rgpipe
│ ├── rsync-git
│ ├── sumatrapdf.bash
│ ├── sumatrapdf.zsh
│ ├── tab2table.py
│ ├── v
│ ├── vim-edit-tmux-output
│ ├── wsl
│ │ └── ical2text
│ └── zhihu2bib.py
├── wsl-init-noi.bash
├── wsl-init.bash
└── z.sh
├── terminal
├── .wezterm.lua
└── README.md
└── wsl
├── convert-pptx.ps1
├── execute_command.c
├── execute_command.h
├── mycmd.reg
├── setup-wsl.sh
├── sumarapdf_no_terminal.c
├── symlink-wayland-socket.service
└── url_scheme.c
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | [{.vimrc,vimrc,*.vim,*.lua}]
7 | indent_size = 2
8 | indent_style = tab
9 |
--------------------------------------------------------------------------------
/.github/workflows/load_vimrc.yml:
--------------------------------------------------------------------------------
1 | name: load_vimrc
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - '**/*.md'
8 | - '**/*.txt'
9 | pull_request:
10 | branches: [ "main" ]
11 | paths-ignore:
12 | - '**/*.md'
13 | - '**/*.txt'
14 |
15 | jobs:
16 | load_vimrc_in_vim7_4:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v4
20 | - name: single vimrc with vim.tiny
21 | run: vim.tiny -E -s -u .vimrc -c "qa!"
22 | - name: install vim
23 | # CentOS 7.1 uses Vim 7.4.629
24 | run: sudo ./install/build_vim.sh v7.4.629
25 | - name: single vimrc
26 | run: vim -E -s -u .vimrc -c "qa!"
27 | - name: single vimrc with view
28 | run: vim -R -E -s -u .vimrc -c "qa!"
29 | - name: full vimrc
30 | run: ln -s `pwd`/root/.vim ~/.vim && vim -E -s -c "qa!"
31 | - name: full vimrc with vim.tiny
32 | run: vim.tiny -E -s -c "qa!"
33 | - name: full vimrc with view
34 | run: vim -R -E -s -c "qa!"
35 | load_vimrc_in_latest_vim:
36 | runs-on: ubuntu-latest
37 | steps:
38 | - uses: actions/checkout@v4
39 | - name: single vimrc with vim.tiny
40 | run: vim.tiny -E -s -u .vimrc -c "qa!"
41 | - name: install X11
42 | run: sudo apt update && sudo apt install -y libx11-dev xorg-dev
43 | - name: install vim
44 | run: sudo ./install/build_vim.sh
45 | - name: single vimrc
46 | run: vim -E -s -u .vimrc -c "qa!"
47 | - name: single vimrc with view
48 | run: vim -R -E -s -u .vimrc -c "qa!"
49 | - name: full vimrc
50 | run: ln -s `pwd`/root/.vim ~/.vim && vim -E -s -c "qa!"
51 | - name: full vimrc with vim.tiny
52 | run: vim.tiny -E -s -c "qa!"
53 | - name: full vimrc with view
54 | run: vim -R -E -s -c "qa!"
55 | - name: vim noplugin
56 | run: vim --noplugin -E -s -c "qa!"
57 | - name: vim -u NONE
58 | run: vim -u NONE -E -s -c "qa!"
59 | - name: vim -u NORC
60 | run: vim -u NORC -E -s -c "qa!"
61 | - name: vim -u DEFAULTS
62 | run: vim -u DEFAULTS -E -s -c "qa!"
63 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | on:
2 | workflow_dispatch:
3 | branches: main
4 |
5 | jobs:
6 | release:
7 | name: Perform release
8 | runs-on: ubuntu-latest
9 | permissions:
10 | contents: write
11 | steps:
12 | - uses: actions/checkout@v4
13 | with:
14 | fetch-depth: 0
15 |
16 | - name: Cocogitto release
17 | id: release
18 | uses: cocogitto/cocogitto-action@v3.8
19 | with:
20 | release: true
21 | check-latest-tag-only: true
22 |
23 | - name: Generate Changelog
24 | run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md
25 |
26 | - name: Upload github release
27 | uses: softprops/action-gh-release@v1
28 | with:
29 | body_path: GITHUB_CHANGELOG.md
30 | tag_name: ${{ steps.release.outputs.version }}
31 | token: ${{ secrets.GITHUB_TOKEN }}
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | root/.config/lazygit/state.yml
3 | root/.vim/.netrwhist
4 | root/.vim/plugged
5 | root/.vim/doc/tags
6 | root/.vim/doc/tags-cn
7 | root/.vim/backup
8 | root/.vim/coc
9 | root/.vim/gadgets
10 | root/.vim/.viminfo
11 | root/.vim/sessions
12 | root/.vim/spell
13 | root/.vim/view
14 | root/.vim/undodir
15 | root/.vim/config.vim
16 | __pycache__
17 | *.exe
18 | *.tar
19 | *.tmp
20 | tags
21 | GPATH
22 | GTAGS
23 | GRTAGS
24 |
--------------------------------------------------------------------------------
/.luarc.json:
--------------------------------------------------------------------------------
1 | {
2 | "Lua.workspace.library": [
3 | "/usr/local/share/nvim/runtime/lua",
4 | "/usr/local/share/nvim/runtime/lua/vim",
5 | "/usr/local/share/nvim/runtime/lua/vim/lsp"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vimrc
2 |
3 |
4 |
5 | [wiki](https://github.com/jiangyinzuo/vimrc/wiki)
6 |
7 | My personal Vim/Neovim configuration files, dotfiles, docs and other scripts.
8 |
9 | ## Requirements
10 |
11 | OS: Linux, WSL
12 |
13 | Vim/Neovim requirements:
14 |
15 | - vim 9.1+ (full features)
16 | - vim 7.4.629+ (minimal, tested in CentOS 7)
17 | - plugin manager: [vim-plug](https://github.com/junegunn/vim-plug)
18 | - neovim 0.11.0+
19 | - plugin manager: [lazy.nvim](https://github.com/folke/lazy.nvim)
20 | - Git 2.19.0+
21 |
22 | ## Installation
23 |
24 | See [install/README.md](./install/README.md).
25 |
26 | ## File Structure
27 |
28 | | File Name | Description |
29 | |:------------------|:--------------------------------------|
30 | | install | installation scripts |
31 | | project_files | config files for local project |
32 | | root | dotfiles |
33 | | root/.config/nvim | neovim configurations |
34 | | root/.vim/vimrc | full vimrc file |
35 | | .vimrc | single vimrc file |
36 | | root/.vim/doc | my help files |
37 | | terminal | configurations for terminal emulators |
38 | | wsl | scripts for WSL, `:h wsl.txt` |
39 |
40 | ### Vimrc Files
41 |
42 | **Vim**
43 |
44 | - Full vimrc file: `.vim/vimrc`
45 | - Custom vim configuration file: `~/.vim/config.vim`. See `root/.vim/config.vim.example`.
46 | - Local project vimrc file: `.project.vim`
47 | - Single vimrc file: `.vimrc`
48 | - Custom vim configuration file `~/config_single_vimrc.vim`
49 | - Local project vimrc file: `.vimrc` (:h 'exrc')
50 |
51 | **Neovim**
52 |
53 | init.vim(`root/.config/nvim/init.vim`) is a soft link to `root/.vim/vimrc`, you can run `install/setup.sh` to create it.
54 |
55 | - Custom vim configuration file: `~/.vim/config.vim`. See `root/.vim/config.vim.example`.
56 | - Local project vimrc file: `.project.vim`
57 |
--------------------------------------------------------------------------------
/cog.toml:
--------------------------------------------------------------------------------
1 | ignore_merge_commits = false
2 | tag_prefix = "v"
3 |
4 | [commit_types]
5 | chore = { changelog_title = "Chore", omit_from_changelog = true }
6 | ci = { changelog_title = "CI", omit_from_changelog = true }
7 | docs = { changelog_title = "Docs", omit_from_changelog = true }
8 | enhance = { changelog_title = "Enhancement", omit_from_changelog = false }
9 |
10 | [changelog]
11 | path = "CHANGELOG.md"
12 | authors = []
13 |
14 | [bump_profiles]
15 |
16 |
--------------------------------------------------------------------------------
/install/README.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | 1. Install dependencies:
4 | ```bash
5 | # Ubuntu
6 | sudo -E ./install/ubuntu.sh
7 | # CentOS7
8 | sudo yum install centos-release-scl
9 | sudo yum install devtoolset-11
10 | scl enable devtoolset-11
11 | sudo -E ./install/centos7.sh
12 | ```
13 |
14 | 2. Setup environment variables and soft links
15 | ```bash
16 | ./install/setup.sh
17 | ```
18 |
19 | **optional:**
20 |
21 | - Setup `$DOC2` manually
22 | - Run `sync-scripts.sh` and `:PlugUpgrade` to sync scripts
23 | - Reinstall `lazy.nvim` manually
24 |
25 | ## Vim
26 |
27 | Unofficial PPA for Vim: https://launchpad.net/~jonathonf/+archive/ubuntu/vim
28 |
29 | ### Build from Source
30 |
31 | ```bash
32 | sudo -E install/build_vim.sh
33 | ```
34 |
35 | ### Install Vim from Conda-Forge
36 |
37 | https://github.com/conda-forge/vim-feedstock
38 |
39 | ## Neovim
40 |
41 | Source code and executables: https://github.com/neovim/neovim/releases
42 |
43 | ### Install from Package
44 |
45 | Supported build needs glibc 2.29, while glibc versions of Ubuntu18.04 and CentOS 7.1 are lower than 2.28.
46 |
47 | https://github.com/neovim/neovim/blob/nightly/INSTALL.md#install-from-package
48 |
49 | [Unstable PPA (requires Ubuntu 20.04+)](https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable)
50 |
51 | See also: https://github.com/neovim/neovim-releases
52 |
53 | ### Install via Snap in CentOS 7
54 |
55 | https://snapcraft.io/nvim
56 |
57 | ```bash
58 | sudo yum install epel-release
59 | sudo yum install snapd
60 | sudo systemctl enable --now snapd.socket
61 | sudo ln -s /var/lib/snapd/snap /snap
62 | # edge: nightly version
63 | sudo snap install nvim --classic --edge
64 | # update
65 | sudo snap refresh nvim --edge --classic
66 | ```
67 |
68 | Reference: https://gist.github.com/backroot/add72227c11759615207cbae79362287
69 |
70 | ### Build from Source
71 |
72 | ```bash
73 | sudo -E install/build_nvim.sh
74 | ```
75 |
76 | ## tmux and tpm
77 |
78 | ```bash
79 | ./install/build_tmux.sh
80 | ./install/tpm_install.sh
81 | ```
82 |
83 | ## Node.js
84 |
85 | coc.nvim and copilot.vim depend on Node.js.
86 |
87 | `:h nodejs`
88 |
89 | ## Command Line Tools
90 |
91 | We install fzf via vim plugin.
92 |
93 | ## Install Plugins Manually
94 |
95 | [vim-plug](https://github.com/junegunn/vim-plug)/[lazy.nvim](https://github.com/folke/lazy.nvim) plugin directory:
96 | `g:vim_plug_dir` (`~/plugged` by default).
97 |
98 | [coc.nvim](https://github.com/neoclide/coc.nvim) home: `~/coc`, run `:CocInstall`.
99 |
100 | [vimspector](https://github.com/puremourning/vimspector) gadgets home: `~/gadgets`
101 |
102 | You can manually pack them and upload to a remote server:
103 | ```
104 | cd ~/plugged
105 | tar -cf plugged.tar fzf LeaderF coc.nvim fzf.vim
106 | ```
107 |
--------------------------------------------------------------------------------
/install/build_cmake.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . install/git.sh
4 |
5 | commit=$1
6 |
7 | $SUDO apt-get -y install libssl-dev
8 |
9 | function _uninstall() {
10 | $SUDO make uninstall
11 | }
12 |
13 | function _install() {
14 | ./bootstrap && make && $SUDO make install
15 | }
16 |
17 | main https://gitlab.kitware.com/cmake/cmake.git cmake $commit
18 |
--------------------------------------------------------------------------------
/install/build_nvim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | . install/git.sh
6 |
7 | PYTHON=/usr/bin/python3
8 |
9 | commit=$1
10 |
11 | # $SUDO apt-get -y install ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip
12 | # $PYTHON -m pip install -U neovim
13 |
14 | function _uninstall() {
15 | $SUDO cmake --build build/ --target uninstall
16 | }
17 |
18 | function _install() {
19 | make CMAKE_BUILD_TYPE=RelWithDebInfo
20 | $SUDO make install
21 | }
22 |
23 | main https://github.com/neovim/neovim.git neovim $commit
24 |
25 |
--------------------------------------------------------------------------------
/install/build_satanson_ag.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . install/git.sh
4 |
5 | commit=$1
6 |
7 | if [ -x "$(command -v apt)" ]; then
8 | $SUDO apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
9 | elif [ -x "$(command -v yum)" ]; then
10 | $SUDO yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-devel
11 | fi
12 |
13 | function _uninstall() {
14 | $SUDO make uninstall
15 | }
16 |
17 | function _install() {
18 | ./build.sh
19 | $SUDO make install
20 | }
21 |
22 | main https://github.com/satanson/the_silver_searcher the_silver_searcher $commit
23 |
--------------------------------------------------------------------------------
/install/build_tmux.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . install/git.sh
4 |
5 | commit=$1
6 |
7 | if [ -f /etc/os-release ]; then
8 | . /etc/os-release
9 | if [ "$ID" = "ubuntu" ]; then
10 | $SUDO apt-get install libevent-dev ncurses-dev build-essential bison pkg-config automake
11 | elif [ "$ID" = "centos" ]; then
12 | $SUDO yum install libevent-devel ncurses-devel gcc make bison automake
13 | fi
14 | else
15 | echo "Unsupported Linux distribution"
16 | exit 1
17 | fi
18 |
19 | function _uninstall() {
20 | $SUDO make uninstall
21 | }
22 |
23 | function _install() {
24 | sh autogen.sh
25 | ./configure && make
26 | $SUDO make install
27 | }
28 |
29 | main https://github.com/tmux/tmux.git tmux $commit
30 |
--------------------------------------------------------------------------------
/install/build_vim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | . install/git.sh
6 |
7 | commit=$1
8 |
9 | MAKE_FLAG=${MAKE_FLAG:-"-j$((`nproc`-2))"}
10 | CONFIGURE_FLAG=${CONFIGURE_FLAG:-"--enable-gui --with-x"}
11 | # $SUDO apt-get -y install libgtk-3-dev libxt-dev libncurses-dev
12 |
13 | function _uninstall() {
14 | $SUDO make uninstall
15 | }
16 |
17 | function _install() {
18 | ./configure --with-features=huge --enable-fontset=yes --enable-cscope=yes --enable-multibyte --enable-python3interp=yes --with-python3-config-dir ${CONFIGURE_FLAG}
19 | make ${MAKE_FLAG}
20 | $SUDO make install
21 | }
22 |
23 | main https://github.com/vim/vim.git vim $commit
24 |
--------------------------------------------------------------------------------
/install/centos7.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # vim: set noet:
3 |
4 | set -e
5 |
6 | SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
7 | source $SCRIPT_DIR/rust-toolchain.sh
8 |
9 | if command -v sudo >/dev/null 2>&1; then
10 | # sudo 命令存在,使用sudo执行命令
11 | SUDO=sudo
12 | else
13 | # sudo 命令不存在,直接执行命令
14 | SUDO=
15 | fi
16 |
17 | prompt=""
18 |
19 | # words: 字典
20 | # python*: LeaderF
21 | $SUDO yum install words python-devel python3 python3-devel
22 |
23 | # nvim-treesitter和pynvim需要高版本gcc,切换devtoolset来使用高版本gcc,或手动添加-std=c99 flag
24 | # https://github.com/nvim-treesitter/nvim-treesitter/pull/7490
25 | pip3 install neovim
26 |
27 | if command -v snap >/dev/null 2>&1; then
28 | $SUDO snap install ripgrep --classic
29 | fi
30 |
31 | install_git_delta
32 |
33 | # lazy.nvim requires Git >= 2.19.0
34 | prompt=$prompt"
35 | === git ===
36 | 安装高版本Git: https://www.endpointdev.com/blog/2021/12/installing-git-2-on-centos-7/
37 | "
38 |
39 | # 加上双引号才能echo换行符
40 | echo "$prompt"
41 |
--------------------------------------------------------------------------------
/install/git.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if command -v sudo >/dev/null 2>&1; then
4 | # sudo 命令存在,使用sudo执行命令
5 | SUDO=sudo
6 | else
7 | # sudo 命令不存在,直接执行命令
8 | SUDO=
9 | fi
10 |
11 | function git_clone_and_cd() {
12 | local url=$1
13 | local repo=$2
14 |
15 | # git clone first if not exist
16 | if [ ! -d $repo ]; then
17 | (
18 | set -v
19 | git clone --no-checkout --depth=1 $url $repo
20 | )
21 | cd $repo
22 | else
23 | cd $repo
24 | _uninstall
25 | fi
26 | }
27 |
28 | function git_fetch_and_reset() {
29 | local commit=$1
30 | git fetch origin $commit --depth=1
31 | git reset --hard FETCH_HEAD
32 | }
33 |
34 | function main() {
35 | local url=$1
36 | local repo=$2
37 | local commit=$3
38 | build_dir=$(pwd)/build
39 | mkdir -p $build_dir
40 | $SUDO chmod 777 $build_dir
41 | cd $build_dir
42 | git_clone_and_cd $url $repo
43 | git_fetch_and_reset $commit
44 | _install
45 | }
46 |
--------------------------------------------------------------------------------
/install/rust-toolchain.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | _cargo_installed=false
4 | if command -v cargo >/dev/null 2>&1; then
5 | _cargo_installed=true
6 | fi
7 |
8 | function install_cargo() {
9 | if [ "$_cargo_installed" = false ]; then
10 | _cargo_installed=true
11 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
12 | fi
13 | }
14 |
15 | function install_git_delta() {
16 | install_cargo
17 | prompt=$prompt"
18 | === git-delta ===
19 | source ~/.bashrc
20 | cargo install git-delta
21 |
22 | "
23 | }
24 |
--------------------------------------------------------------------------------
/install/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | soft_link_files=(
4 | .condarc
5 | .config/clangd
6 | .config/ctags
7 | .config/himalaya
8 | .config/lazygit
9 | .config/nvim
10 | .config/zellij
11 | .gitconfig
12 | .gitconfig-ict
13 | .globalrc
14 | .ripgreprc
15 | .tmux.conf
16 | .vim
17 | )
18 |
19 | echo_green() {
20 | echo -e "\033[32m$1\033[0m"
21 | }
22 |
23 | echo_yellow() {
24 | echo -e "\033[33m$1\033[0m"
25 | }
26 |
27 | _make_soft_link() {
28 | local src=$1
29 | local target=$2
30 | if ! [[ -e $target ]]; then
31 | if ln -s "$src" "$target"; then
32 | echo "ln -s $src $target success"
33 | fi
34 | else
35 | echo "File $target exists, skip."
36 | fi
37 | }
38 |
39 | do_setup() {
40 | # 检查 $VIMRC_ROOT 是否存在
41 | if [ -z "$VIMRC_ROOT" ]; then
42 | # 如果不存在,则追加到 .bashrc
43 | echo_green "Add source ~/vimrc/root/bashrc to .bashrc:"
44 | echo "source ~/vimrc/root/bashrc" >>~/.bashrc
45 | . ~/vimrc/root/bashrc
46 | fi
47 |
48 | echo_green "Setup soft links:"
49 | mkdir -p ~/.local/share/bash-completion/completions
50 | mkdir -p ~/.config
51 | for f in "${soft_link_files[@]}"; do
52 | _make_soft_link "$VIMRC_ROOT"/"$f" ~/"$f"
53 | done
54 |
55 | # soft links for neovim
56 | _make_soft_link ~/.vim/coc-settings.json ~/.config/nvim/coc-settings.json
57 | _make_soft_link ~/.vim/vimrc ~/.config/nvim/init.vim
58 |
59 | mkdir -p ~/gadgets
60 | _make_soft_link ~/gadgets ~/.vim/gadgets
61 |
62 | echo_green "Environment variables used:"
63 | echo DOC2="$DOC2"
64 |
65 | echo_green "Add the following to your .bashrc if you want to use pygments for gtags:"
66 | echo "export GTAGSLABEL=native-pygments"
67 |
68 | echo_yellow "NOTE: Change name and email in .gitconfig if needed."
69 |
70 | echo_green "Done!"
71 | }
72 |
73 | do_setup
74 |
--------------------------------------------------------------------------------
/install/sync-llvm-vim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # LLVM Project
3 | # remove llvm.vim since vim-patch 9.1.0866
4 | for vimscript in mir.vim tablegen.vim ; do
5 | ( wget --output-document root/.vim/ftplugin/$vimscript https://github.com/llvm/llvm-project/raw/main/llvm/utils/vim/ftplugin/$vimscript )
6 | done
7 | # remove llvm.vim since vim-patch 9.1.0866
8 | for vimscript in mir.vim tablegen.vim llvm-lit.vim ; do
9 | ( wget --output-document root/.vim/ftdetect/$vimscript https://github.com/llvm/llvm-project/raw/main/llvm/utils/vim/ftdetect/$vimscript )
10 | done
11 | for vimscript in llvm.vim machine-ir.vim mir.vim tablegen.vim ; do
12 | ( wget --output-document root/.vim/syntax/$vimscript https://github.com/llvm/llvm-project/raw/main/llvm/utils/vim/syntax/$vimscript )
13 | done
14 | for vimscript in llvm.vim ; do
15 | ( wget --output-document root/.vim/indent/$vimscript https://github.com/llvm/llvm-project/raw/main/llvm/utils/vim/indent/$vimscript )
16 | done
17 |
18 | wait
19 |
--------------------------------------------------------------------------------
/install/sync-scripts.sh:
--------------------------------------------------------------------------------
1 | wget --output-document root/z.sh https://github.com/rupa/z/raw/master/z.sh &
2 | wget --output-document root/scripts/lsix https://github.com/hackerb9/lsix/raw/master/lsix &
3 | wget --output-document root/scripts/v https://github.com/rupa/v/raw/master/v &
4 | wget --output-document root/goto.sh https://github.com/iridakos/goto/raw/master/goto.sh &
5 |
6 | # Satanson's perl scripts: https://github.com/satanson/cpp_etudes
7 | # C++阅码神器cpptree.pl和calltree.pl的使用 - satanson的文章 - 知乎 https://zhuanlan.zhihu.com/p/339910341
8 | for perl_script in calltree.pl java_calltree.pl cpptree.pl javatree.pl deptree.pl ; do
9 | ( wget --output-document root/scripts/$perl_script https://github.com/satanson/cpp_etudes/raw/master/$perl_script && chmod +x root/scripts/$perl_script ) &
10 | done
11 |
12 | wait
13 |
--------------------------------------------------------------------------------
/install/tpm_install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "TPM directory: ~/.tmux/plugins/tpm"
4 | echo "See: https://github.com/tmux-plugins/tpm"
5 |
6 | if test ! -d ~/.tmux/plugins/tpm; then
7 | echo "Installing TPM..."
8 | git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
9 | ~/.tmux/plugins/tpm/bin/install_plugins
10 | else
11 | echo "TPM already installed"
12 | fi
13 |
--------------------------------------------------------------------------------
/project_files/.clangd:
--------------------------------------------------------------------------------
1 | CompileFlags:
2 | # use absolute path
3 | CompilationDatabase: /home/jiangyinzuo/gpudb-project-ictdb/gpudb-project-code-ictdb/duckdb-anns/build/debug
4 |
5 |
--------------------------------------------------------------------------------
/project_files/.clangd-cuda-12.1-cmake:
--------------------------------------------------------------------------------
1 | If:
2 | PathMatch: .*\.cuh?
3 | CompileFlags:
4 | Compiler: clang++-15
5 | Remove:
6 | - "-ccbin*"
7 | - -forward-unknown-to-host-compiler
8 | - --generate-code=*
9 | - -rdc=*
10 | - --options-file
11 | Add:
12 | # half type
13 | - '-include cuda_fp16.h'
14 |
--------------------------------------------------------------------------------
/project_files/.clangd-cuda-12.1-single-file:
--------------------------------------------------------------------------------
1 | CompileFlags:
2 | Compiler: /usr/local/cuda-12.1/bin/nvcc
3 |
--------------------------------------------------------------------------------
/project_files/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 |
11 | # Matches multiple files with brace expansion notation
12 | # Set default charset
13 | [*.{js,py}]
14 | charset = utf-8
15 |
16 | # 4 space indentation
17 | [*.py]
18 | indent_style = space
19 | indent_size = 4
20 |
21 | # Tab indentation (no size specified)
22 | [Makefile]
23 | indent_style = tab
24 |
25 | # Indentation override for all JS under lib directory
26 | [lib/**.js]
27 | indent_style = space
28 | indent_size = 2
29 |
30 | # Matches the exact files either package.json or .travis.yml
31 | [{package.json,.travis.yml}]
32 | indent_style = space
33 | indent_size = 2
34 |
--------------------------------------------------------------------------------
/project_files/.ocamlformat:
--------------------------------------------------------------------------------
1 | profile = default
2 | version = 0.26.0
3 |
--------------------------------------------------------------------------------
/project_files/.vscode/go-debug-single-file.launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Launch file",
6 | "type": "go",
7 | "request": "launch",
8 | "mode": "debug",
9 | "program": "${file}"
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/project_files/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Launch unittest via codelldb",
6 | "type": "codelldb",
7 | "request": "launch",
8 | "program": "${workspaceFolder}/cmake_build/bin/all_tests",
9 | "cwd": "${workspaceFolder}",
10 | "args": ["--gtest_filter=Query.ShowExecutor"],
11 | "env": {
12 | "LD_LIBRARY_PATH": "${env:LD_LIBRARY_PATH}:${workspaceFolder}/internal/core/output/lib"
13 | },
14 | "stopOnEntry": false
15 | },
16 | {
17 | "name": "Launch unittest via cpptools",
18 | "type": "cppdbg",
19 | "request": "launch",
20 | "program": "${workspaceFolder}/cmake_build/bin/all_tests",
21 | "cwd": "${workspaceFolder}",
22 | "args": ["--gtest_filter=Query.ShowExecutor"],
23 | "environment": [{
24 | "name": "LD_LIBRARY_PATH",
25 | "value": "${env:LD_LIBRARY_PATH}:${workspaceFolder}/internal/core/output/lib"
26 | }],
27 | "stopAtEntry": true
28 | }
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/project_files/coc-settings-languageserver-clangd.json:
--------------------------------------------------------------------------------
1 | {
2 | "languageserver": {
3 | "clangd": {
4 | "command": "clangd",
5 | "args": [
6 | "--clang-tidy",
7 | "--compile-commands-dir=_build/debug",
8 | "--pretty",
9 | "--cross-file-rename",
10 | "--inlay-hints=true"
11 | ],
12 | "rootPatterns": [
13 | ".git",
14 | "compile_flags.txt",
15 | "compile_commands.json"
16 | ],
17 | "filetypes": [
18 | "c",
19 | "cc",
20 | "cpp",
21 | "c++",
22 | "objc",
23 | "objcpp",
24 | "h",
25 | "hpp"
26 | ]
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/project_files/cpp.project.vim:
--------------------------------------------------------------------------------
1 | " Clangd
2 | let g:nvim_lsp_autostart = {'clangd': v:true}
3 | " use `CompilationDatabase` in .clangd instead
4 | " let g:clangd_args = ["--clang-tidy", "--compile-commands-dir=build_debug", "--pretty", "--background-index", "--header-insertion=iwyu"]
5 | " let g:clangd_cmd = [g:clangd_path] + g:clangd_args
6 |
7 | " Ccls
8 | " let g:nvim_lsp_autostart = {'ccls': v:true}
9 | " let g:ccls_init_options = { "compilationDatabaseDirectory": "build_debug", "index": { "threads": 0 }, "clang": { "excludeArgs": ["-frounding-math"] }}
10 |
11 | " Run google test using alepez/vim-gtest
12 | function CustomGTestRun(cmd)
13 | " Use asyncrun.vim
14 | exe ":AsyncRun -pos=tab -mode=term -focus=1 " . a:cmd
15 | endfunction
16 |
17 | let g:gtest#gtest_runner = function('CustomGTestRun')
18 | let g:gtest#gtest_command = "path/to/test/executable"
19 |
20 | " Copilot
21 | " let g:copilot_workspace_folders = ['~/Projects/myproject']
22 |
23 | if has('nvim')
24 | let g:gitsign_default_base = 'HEAD~1'
25 | else
26 | let g:gitgutter_diff_base = 'HEAD~1'
27 | endif
28 |
--------------------------------------------------------------------------------
/project_files/latex.project.vim:
--------------------------------------------------------------------------------
1 | let g:nvim_lsp_autostart = {'texlab': v:true}
2 | " https://github.com/lervag/vimtex/issues/3089
3 | let g:vimtex_complete_enabled = 0
4 |
--------------------------------------------------------------------------------
/project_files/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.basedpyright]
2 | pythonVersion = "3.10"
3 |
--------------------------------------------------------------------------------
/root/.condarc:
--------------------------------------------------------------------------------
1 | channels:
2 | - defaults
3 | - conda-forge
4 | # - nodefaults
5 | default_channels:
6 | - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
7 | - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
8 | - https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
9 | - https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
10 | - https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
11 | custom_channels:
12 | conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
13 | msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
14 | bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
15 | menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
16 | pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud
17 | simpleitk: https://mirrors.bfsu.edu.cn/anaconda/cloud
18 | auto_activate_base: false
19 | show_channel_urls: true
20 | solver: libmamba
21 | # strict: 如果最高优先级通道中的包不满足要求,不会从其他通道中寻找替代包,而是会报错。
22 | # flexible: 如果最高优先级通道中的包不满足要求,conda 会自动从其他优先级较低的通道中寻找替代包。
23 | # https://blog.csdn.net/qq_52964132/article/details/141195025?spm=1001.2014.3001.5502
24 | # channel_priority: strict
25 |
--------------------------------------------------------------------------------
/root/.config/clangd/config.yaml:
--------------------------------------------------------------------------------
1 | CompileFlags:
2 | Add: [-Wall]
3 |
4 | Diagnostics:
5 | # Still invalid for system header
6 | UnusedIncludes: Strict
7 | # Valid for system header
8 | MissingIncludes: Strict
9 | ClangTidy:
10 | Add:
11 | - modernize*
12 | - clang-analyzer-*
13 | - llvm-*
14 | - google-*
15 | - cppcoreguidelines-*
16 | # Warning for short variables like `a`
17 | # - readability-*
18 | # auto foo() -> int;
19 | Remove:
20 | - cppcoreguidelines-avoid-c-arrays
21 | - cppcoreguidelines-avoid-do-while
22 | - cppcoreguidelines-avoid-magic-numbers
23 | - cppcoreguidelines-pro-bounds-array-to-pointer-decay
24 | - cppcoreguidelines-pro-bounds-pointer-arithmetic
25 | - cppcoreguidelines-pro-type-vararg
26 | - llvmlibc-restrict-system-libc-headers
27 | - google-runtime-int
28 | - modernize-avoid-c-arrays
29 | - modernize-use-nodiscard
30 | - modernize-use-trailing-return-type
31 |
32 | InlayHints:
33 | DeducedTypes: true
34 |
35 |
--------------------------------------------------------------------------------
/root/.config/ctags/myconfig.ctags:
--------------------------------------------------------------------------------
1 | --fields=+niazSR
2 | --extras=+qrs
3 | --exclude=target
4 | --exclude=build
5 | --exclude=dist
6 | --exclude=doc
7 | --exclude=docs
8 | --exclude=contribs
9 | --exclude=extension
10 | --exclude=third_party
11 | #--fields-Markdown=+{hashtag}
12 | --c++-kinds=+pxl
13 | --c-kinds=+pxl
14 |
--------------------------------------------------------------------------------
/root/.config/himalaya/README.md:
--------------------------------------------------------------------------------
1 | # Himalaya
2 |
3 | ## 解析邮件中的icalendar格式
4 |
5 | 安装依赖
6 | ```bash
7 | pip install icalendar
8 | ```
9 |
10 | ```bash
11 | himalaya read 1657253743 | ical2text
12 | ```
13 |
14 | See: root/scripts/wsl/ical2text
15 |
16 | ## 设置密码
17 |
18 | 修改密码读取方式时,不要直接编辑`config.toml`,要先备份原来的`config.toml`,
19 | 删除`config.toml`后,再按照初始化配置流程,根据提示一步步输入。
20 |
21 | ### pass 命令行密码管理工具
22 |
23 | 安装
24 | ```bash
25 | sudo apt install pass
26 | ```
27 |
28 | 在使用 `pass`, 一款基于 Unix shell 的密码管理器时,您需要生成一个 GPG (GNU Privacy Guard) 密钥来加密密码。这是一个涉及公钥/私钥加密的过程。以下是生成 GPG 密钥的步骤:
29 |
30 | 1. **安装 GPG**:首先确保您的系统上安装了 GPG。在大多数 Linux 发行版中,它可以通过包管理器安装。例如,在 Ubuntu 或 Debian 上,您可以使用以下命令安装:
31 | ```bash
32 | sudo apt-get install gnupg
33 | ```
34 |
35 | 2. **生成 GPG 密钥**:运行 GPG 密钥生成命令:
36 | ```bash
37 | gpg --full-gen-key
38 | ```
39 | 这将启动一个交互式命令行过程,引导您完成一系列步骤来设置您的密钥。
40 |
41 | 3. **选择密钥类型**:您通常可以选择默认的密钥类型(RSA 和 RSA),除非有特定的需求。
42 |
43 | 4. **密钥长度**:选择一个适当的密钥长度。2048 位通常是安全的,但 4096 位提供了更高的安全性。
44 |
45 | 5. **设置密钥有效期限**:您可以为密钥设置一个有效期限,或选择让密钥永久有效。
46 |
47 | 6. **确认信息并设置密码**:输入您的姓名、电子邮件地址等信息,然后为您的私钥设置一个强密码。这个密码将在您使用 GPG 密钥时被要求输入。
48 |
49 | 7. **生成密钥**:完成这些步骤后,GPG 将生成密钥对。这可能需要一些时间,取决于所选的密钥长度和系统的处理能力。
50 |
51 | 8. **确认密钥生成**:一旦密钥生成完成,您可以通过以下命令列出 GPG 密钥来确认:
52 | ```bash
53 | gpg --list-secret-keys
54 | ```
55 |
56 | 9. **将 GPG 密钥与 `pass` 配置**:一旦密钥生成,您需要配置 `pass` 以使用该密钥。首先,获取您的 GPG 密钥 ID:
57 | ```bash
58 | gpg --list-secret-keys --keyid-format LONG
59 | ```
60 |
61 | 输出形如
62 | ```
63 | gpg: checking the trustdb
64 | gpg: marginals needed: 3 completes needed: 1 trust model: pgp
65 | gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
66 | /root/.gnupg/pubring.kbx
67 | ------------------------
68 | sec rsa3072/ 2024-01-05 [SC]
69 |
70 | uid [ultimate] jiangyinzuo (gpgkey)
71 | ssb rsa3072/ 2024-01-05 [E]
72 | ```
73 |
74 | 然后,初始化 `pass`,使用您的 GPG 密钥 ID:
75 | ```bash
76 | pass init "您的GPG密钥ID"
77 | ```
78 |
79 |
--------------------------------------------------------------------------------
/root/.config/himalaya/config.toml:
--------------------------------------------------------------------------------
1 | [ucas]
2 | backend = "imap"
3 | email = "jiangyinzuo22@mails.ucas.ac.cn"
4 | default = true
5 | display-name = "Yinzuo Jiang"
6 | imap-host = "mail.cstnet.cn"
7 | imap-port = 993
8 | imap-ssl = true
9 | imap-login = "jiangyinzuo22@mails.ucas.ac.cn"
10 | imap-auth = "passwd"
11 | sender = "smtp"
12 | smtp-host = "mail.cstnet.cn"
13 | smtp-port = 465
14 | smtp-ssl = true
15 | smtp-login = "jiangyinzuo22@mails.ucas.ac.cn"
16 | smtp-auth = "passwd"
17 |
18 | [ucas.imap-passwd]
19 | cmd = "pass show ucas-imap-passwd"
20 |
21 | [ucas.smtp-passwd]
22 | cmd = "pass show ucas-smtp-passwd"
23 |
24 | [ucas.pgp]
25 | backend = "none"
26 |
27 | [foxmail]
28 | backend = "imap"
29 | email = "jiangyinzuo@foxmail.com"
30 | default = false
31 | display-name = "Yinzuo Jiang"
32 | imap-host = "imap.qq.com"
33 | imap-port = 993
34 | imap-ssl = true
35 | imap-login = "jiangyinzuo@foxmail.com"
36 | imap-auth = "passwd"
37 | sender = "smtp"
38 | smtp-host = "smtp.qq.com"
39 | smtp-port = 465
40 | smtp-ssl = true
41 | smtp-login = "jiangyinzuo@foxmail.com"
42 | smtp-auth = "passwd"
43 |
44 | [foxmail.imap-passwd]
45 | cmd = "pass show foxmail-imap-passwd"
46 |
47 | [foxmail.smtp-passwd]
48 | cmd = "pass show foxmail-smtp-passwd"
49 |
50 | [foxmail.pgp]
51 | backend = "none"
52 |
53 | [ict]
54 | backend = "imap"
55 | email = "jiangyinzuo22s@ict.ac.cn"
56 | default = false
57 | display-name = "Yinzuo Jiang"
58 | imap-host = "mail.cstnet.cn"
59 | imap-port = 993
60 | imap-ssl = true
61 | imap-login = "jiangyinzuo22s@ict.ac.cn"
62 | imap-auth = "passwd"
63 | sender = "smtp"
64 | smtp-host = "mail.cstnet.cn"
65 | smtp-port = 465
66 | smtp-ssl = true
67 | smtp-login = "jiangyinzuo22s@ict.ac.cn"
68 | smtp-auth = "passwd"
69 |
70 | [ict.imap-passwd]
71 | cmd = "pass show ict-imap-passwd"
72 |
73 | [ict.smtp-passwd]
74 | cmd = "pass show ict-smtp-passwd"
75 |
76 | [ict.pgp]
77 | backend = "none"
78 |
--------------------------------------------------------------------------------
/root/.config/lazygit/config.yml:
--------------------------------------------------------------------------------
1 | os:
2 | editCommand: 'vim'
3 | gui:
4 | editor:
5 | program: vim
6 | args: []
7 |
8 |
--------------------------------------------------------------------------------
/root/.config/nvim/.gitignore:
--------------------------------------------------------------------------------
1 | init.vim
2 | coc-settings.json
3 | lazy-lock.json
4 |
--------------------------------------------------------------------------------
/root/.config/nvim/.project.vim:
--------------------------------------------------------------------------------
1 | let g:nvim_lsp_autostart = {'lua_ls': v:true}
2 |
--------------------------------------------------------------------------------
/root/.config/nvim/ftplugin/java.lua:
--------------------------------------------------------------------------------
1 | -- See: https://github.com/mfussenegger/nvim-jdtls
2 |
3 | local root_dir = vim.env.PWD
4 |
5 | local config = {
6 | cmd = { vim.g.jdtls_exe, "--java-executable", vim.g.jdtls_java_exe },
7 | root_dir = root_dir,
8 | init_options = {
9 | bundles = {
10 | -- vscode java debug
11 | vim.fn.glob(
12 | vim.fn.stdpath("data")
13 | .. "/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin*.jar"
14 | ),
15 | },
16 | },
17 | settings = {
18 | java = {
19 | configuration = {
20 | -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
21 | -- And search for `interface RuntimeOption`
22 | -- The `name` is NOT arbitrary, but must match one of the elements from `enum ExecutionEnvironment` in the link above
23 | runtimes = vim.g.jdtls_java_runtimes,
24 | },
25 | },
26 | },
27 | }
28 | require("jdtls").start_or_attach(config)
29 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/.luarc.json:
--------------------------------------------------------------------------------
1 | {
2 | "workspace.checkThirdParty": false
3 | }
--------------------------------------------------------------------------------
/root/.config/nvim/lua/dapconfig.lua:
--------------------------------------------------------------------------------
1 | local M = {}
2 |
3 | function M.dapconfig()
4 | local dap, dapui = require("dap"), require("dapui")
5 | dapui.setup()
6 |
7 | -- 自动开启/关闭dapui
8 | dap.listeners.before.attach.dapui_config = function()
9 | dapui.open()
10 | end
11 | dap.listeners.before.launch.dapui_config = function()
12 | dapui.open()
13 | end
14 | dap.listeners.before.event_terminated.dapui_config = function()
15 | dapui.close()
16 | end
17 | dap.listeners.before.event_exited.dapui_config = function()
18 | dapui.close()
19 | end
20 |
21 | vim.api.nvim_create_user_command("DapUiClose", function(opts)
22 | dapui.close()
23 | end, { nargs = 0 })
24 | -- c, cpp, rust
25 | -- 调试有控制台输入输出的程序时,由于gdb的一个issue(https://github.com/microsoft/vscode-cpptools/issues/3953),
26 | -- printf必须输出\n,或者手动fflush(stdout)/setbuf(stdout, NULL)后,才能在console中看到输出。
27 | --
28 | -- 向控制台输入时,切换到console 窗口(element)需要通过CTRL-W hjkl,输入完后先鼠标单击代码窗口,再鼠标单击REPL窗口,
29 | -- 防止出现"Debug adapter reported a frame at line 12 column 1, but: Cursor position outside buffer. Ensure executable is up2date and if using a source mapping ensure it is correct"这样的错误
30 | dap.adapters.cppdbg = {
31 | id = "cppdbg",
32 | type = "executable",
33 | command = "OpenDebugAD7",
34 | }
35 |
36 | -- TODO: Data Visualization? https://github.com/vadimcn/codelldb/wiki/Data-visualization
37 | dap.adapters.codelldb = {
38 | type = "server",
39 | port = "${port}",
40 | executable = {
41 | -- CHANGE THIS to your path!
42 | command = vim.fn.stdpath("data") .. "/mason/bin/codelldb",
43 | args = { "--port", "${port}" },
44 |
45 | -- On windows you may have to uncomment this:
46 | -- detached = false,
47 | },
48 | }
49 |
50 | dap.configurations.cpp = {
51 | {
52 | name = "Launch debugger(codelldb)",
53 | type = "codelldb",
54 | request = "launch",
55 | cwd = "${workspaceFolder}",
56 | program = function()
57 | return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
58 | end,
59 | stopOnEntry = false,
60 | },
61 | {
62 | name = "Launch file(cppdbg)",
63 | type = "cppdbg",
64 | request = "launch",
65 | program = function()
66 | return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
67 | end,
68 | cwd = "${workspaceFolder}",
69 | stopAtEntry = true,
70 | },
71 | {
72 | name = "Attach to gdbserver :1234(cppdbg)",
73 | type = "cppdbg",
74 | request = "launch",
75 | MIMode = "gdb",
76 | miDebuggerServerAddress = "localhost:1234",
77 | miDebuggerPath = "/usr/bin/gdb",
78 | cwd = "${workspaceFolder}",
79 | program = function()
80 | return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
81 | end,
82 | },
83 | }
84 | for _, language in ipairs({ "c", "rust" }) do
85 | -- append dap.configurations[language] with gdb configurations
86 | dap.configurations[language] = dap.configurations["cpp"]
87 | end
88 |
89 | require("dap-python").setup("python3")
90 | vim.api.nvim_create_user_command("DapPytestMethod", function(_)
91 | local dap_python = require("dap-python")
92 | dap_python.test_runner = "pytest"
93 | dap_python.test_method()
94 | end, { nargs = 0 })
95 | local python_table = require('dap').configurations.python
96 | table.insert(python_table, {
97 | type = 'python';
98 | request = 'launch';
99 | name = 'Launch module with arguments (调试本地module注意要在module所在目录运行)';
100 | module = function()
101 | return vim.fn.input('Module: ')
102 | end;
103 | args = function()
104 | local args_string = vim.fn.input('Arguments: ')
105 | return vim.split(args_string, " +")
106 | end;
107 | console = nil;
108 | pythonPath = nil,
109 | })
110 | table.insert(python_table, {
111 | type = 'python';
112 | request = 'launch';
113 | name = 'Launch module (调试本地module注意要在module所在目录运行)';
114 | module = function()
115 | return vim.fn.input('Module: ')
116 | end;
117 | console = nil;
118 | pythonPath = nil,
119 | })
120 | end
121 |
122 | return M
123 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/detect.lua:
--------------------------------------------------------------------------------
1 | local M = {}
2 |
3 | M.has_typst_executable = vim.fn.executable("typst") == 1
4 | M.has_go_executable = vim.fn.executable("go") == 1
5 | M.has_rust_executable = vim.fn.executable("rustc") == 1
6 | M.has_coqtop_executable = vim.fn.executable("coqtop") == 1
7 | M.has_pdflatex_executable = vim.fn.executable("pdflatex") == 1
8 | M.has_quarto_executable = vim.fn.executable("quarto") == 1
9 |
10 | return M
11 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/lsp/diagnostic.lua:
--------------------------------------------------------------------------------
1 | --- 自动浮窗展示diagnostic
2 | local function create_floating_window_autocmd()
3 | vim.api.nvim_create_augroup("nvim_lsp_floating_window", {})
4 | vim.api.nvim_create_autocmd("CursorHold", {
5 | group = "nvim_lsp_floating_window",
6 | callback = function()
7 | local opts = {
8 | border = "rounded",
9 | source = "always",
10 | prefix = " ",
11 | scope = "cursor",
12 | }
13 | vim.diagnostic.open_float(opts)
14 | end,
15 | })
16 | end
17 |
18 | local function toggle_auto_floating_window()
19 | if vim.g.nvim_lsp_diagnostic_enable_auto_floating_window then
20 | vim.api.nvim_del_augroup_by_name("nvim_lsp_floating_window")
21 | else
22 | create_floating_window_autocmd()
23 | end
24 | vim.g.nvim_lsp_diagnostic_enable_auto_floating_window = not vim.g.nvim_lsp_diagnostic_enable_auto_floating_window
25 | end
26 | vim.api.nvim_create_user_command("LspFloatToggle", toggle_auto_floating_window, {})
27 |
28 | if vim.g.nvim_lsp_diagnostic_enable_auto_floating_window == nil then
29 | -- 默认关闭自动浮窗,因为这会挡住其它手动打开的浮窗,textDocument/hover (K)
30 | vim.g.nvim_lsp_diagnostic_enable_auto_floating_window = false
31 | end
32 | if vim.g.nvim_lsp_diagnostic_enable_auto_floating_window then
33 | create_floating_window_autocmd()
34 | end
35 |
36 | -- local USE_VIRTUAL_LINE = vim.version.gt(vim.version(), { 0, 10, 3 })
37 | local USE_VIRTUAL_LINE = false
38 | if USE_VIRTUAL_LINE then
39 | vim.keymap.set("n", "da", function()
40 | local old_config = vim.diagnostic.config().virtual_lines
41 | if old_config then
42 | vim.diagnostic.config({ virtual_lines = false })
43 | else
44 | vim.diagnostic.config({ virtual_lines = { current_line = true } })
45 | end
46 | end, { desc = "Toggle diagnostic virtual_lines" })
47 | else
48 | vim.keymap.set("n", "da", vim.diagnostic.open_float)
49 | end
50 |
51 | local function setup_vim_diagnostic()
52 | vim.diagnostic.config({
53 | -- virtual text is too noisy!
54 | virtual_text = false,
55 | virtual_lines = USE_VIRTUAL_LINE and { current_line = true },
56 | -- ERROR 比 INFO优先级更高显示
57 | severity_sort = true,
58 | })
59 | end
60 |
61 | local function setup_vim_diagnostic_on_attach()
62 | setup_vim_diagnostic()
63 | vim.keymap.set("n", "]da", function()
64 | vim.diagnostic.jump({ count = 1, float = not USE_VIRTUAL_LINE })
65 | end, bufopts)
66 | vim.keymap.set("n", "[da", function()
67 | vim.diagnostic.jump({ count = -1, float = not USE_VIRTUAL_LINE })
68 | end, bufopts)
69 | vim.keymap.set("n", "]dw", function()
70 | vim.diagnostic.jump({
71 | count = 1,
72 | severity = { min = vim.diagnostic.severity.WARN },
73 | float = not USE_VIRTUAL_LINE,
74 | })
75 | end, bufopts)
76 | vim.keymap.set("n", "[dw", function()
77 | vim.diagnostic.jump({
78 | count = -1,
79 | severity = { min = vim.diagnostic.severity.WARN },
80 | float = not USE_VIRTUAL_LINE,
81 | })
82 | end, bufopts)
83 | vim.keymap.set("n", "]de", function()
84 | vim.diagnostic.jump({ count = 1, severity = vim.diagnostic.severity.ERROR, float = not USE_VIRTUAL_LINE })
85 | end, bufopts)
86 | vim.keymap.set("n", "[de", function()
87 | vim.diagnostic.jump({ count = -1, severity = vim.diagnostic.severity.ERROR, float = not USE_VIRTUAL_LINE })
88 | end, bufopts)
89 | end
90 |
91 | local M = {
92 | setup_vim_diagnostic = setup_vim_diagnostic,
93 | setup_vim_diagnostic_on_attach = setup_vim_diagnostic_on_attach,
94 | }
95 | return M
96 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/csv.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "hat0uma/csvview.nvim",
3 | ---@module "csvview"
4 | ---@type CsvView.Options
5 | opts = {
6 | parser = { comments = { "#", "//" } },
7 | keymaps = {
8 | -- Text objects for selecting fields
9 | textobject_field_inner = { "if", mode = { "o", "x" } },
10 | textobject_field_outer = { "af", mode = { "o", "x" } },
11 | -- Excel-like navigation:
12 | -- Use and to move horizontally between fields.
13 | -- Use and to move vertically between rows and place the cursor at the end of the field.
14 | -- Note: In terminals, you may need to enable CSI-u mode to use and .
15 | jump_next_field_end = { "", mode = { "n", "v" } },
16 | jump_prev_field_end = { "", mode = { "n", "v" } },
17 | jump_next_row = { "", mode = { "n", "v" } },
18 | jump_prev_row = { "", mode = { "n", "v" } },
19 | },
20 | },
21 | cmd = { "CsvViewEnable", "CsvViewDisable", "CsvViewToggle" },
22 | }
23 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/dap.lua:
--------------------------------------------------------------------------------
1 | -- alternate: https://github.com/sakhnik/nvim-gdb
2 | if vim.g.vim_dap == "nvim-dap" then
3 | return {
4 | {
5 | "rcarriga/nvim-dap-ui",
6 | event = "VeryLazy",
7 | dependencies = {
8 | "mfussenegger/nvim-dap",
9 | "nvim-neotest/nvim-nio",
10 | "theHamsta/nvim-dap-virtual-text",
11 | "mfussenegger/nvim-dap-python",
12 | },
13 | config = require("dapconfig").dapconfig,
14 | },
15 | {
16 | "mfussenegger/nvim-dap",
17 | event = "VeryLazy",
18 | lazy = true,
19 | config = function()
20 | vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" })
21 | end,
22 | },
23 | {
24 | "mfussenegger/nvim-dap-python",
25 | event = "VeryLazy",
26 | lazy = true,
27 | dependencies = {
28 | "mfussenegger/nvim-dap",
29 | },
30 | },
31 | {
32 | "theHamsta/nvim-dap-virtual-text",
33 | event = "VeryLazy",
34 | lazy = true,
35 | opts = {
36 | commented = true,
37 | },
38 | },
39 | }
40 | else
41 | return {}
42 | end
43 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/lualine.lua:
--------------------------------------------------------------------------------
1 | local lualine = {
2 | "nvim-lualine/lualine.nvim",
3 | event = "UIEnter",
4 | dependencies = {}
5 | }
6 |
7 | -- WARN: DO NOT USE AndreM222/copilot-lualine
8 |
9 | if vim.g.vimrc_lsp == "nvim-lsp" then
10 | table.insert(lualine.dependencies, "neovim/nvim-lspconfig")
11 | table.insert(lualine.dependencies, "linrongbin16/lsp-progress.nvim")
12 | else
13 | table.insert(lualine.dependencies, "neoclide/coc.nvim")
14 | end
15 |
16 | return lualine
17 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/nvim_cmp.lua:
--------------------------------------------------------------------------------
1 | return {
2 | {
3 | "micangl/cmp-vimtex",
4 | lazy = true,
5 | event = "VeryLazy",
6 | cond = require("detect").has_pdflatex_executable,
7 | },
8 | {
9 | "hrsh7th/nvim-cmp",
10 | event = "VeryLazy",
11 | dependencies = {
12 | "hrsh7th/cmp-nvim-lsp",
13 | "hrsh7th/cmp-buffer",
14 | -- "hrsh7th/cmp-path",
15 | "https://codeberg.org/FelipeLema/cmp-async-path.git",
16 | "hrsh7th/cmp-cmdline",
17 | -- "saadparwaiz1/cmp_luasnip",
18 | -- 'quangnguyen30192/cmp-nvim-ultisnips',
19 | "p00f/clangd_extensions.nvim",
20 | -- 如果cmp-omni和cmp-vimtex配置失败: 在`:CmpStatus`中显示unavailable source name
21 | -- 请检查:verbose set omnifunc? 是否符合预期
22 | "garymjr/nvim-snippets",
23 | "hrsh7th/cmp-omni",
24 | },
25 | config = require("nvim_cmp").nvim_cmp,
26 | },
27 | {
28 | "uga-rosa/cmp-dictionary",
29 | lazy = true,
30 | event = "VeryLazy",
31 | ft = { "tex", "bib", "markdown", "text" },
32 | },
33 | -- 'SirVer/ultisnips' is slow in Neovim.
34 | -- {
35 | -- "L3MON4D3/LuaSnip",
36 | -- -- follow latest release.
37 | -- version = "v2.*", -- Replace by the latest released major (first number of latest release)
38 | -- -- install jsregexp (optional!).
39 | -- build = "make install_jsregexp",
40 | -- config = function()
41 | -- require("luasnip.loaders.from_snipmate").lazy_load()
42 | -- end,
43 | -- },
44 | {
45 | "garymjr/nvim-snippets",
46 | event = "VeryLazy",
47 | dependencies = {
48 | "rafamadriz/friendly-snippets",
49 | },
50 | opts = {
51 | friendly_snippets = true,
52 | },
53 | },
54 | }
55 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/telescope.lua:
--------------------------------------------------------------------------------
1 | return {
2 | {
3 | "nvim-telescope/telescope.nvim",
4 | lazy = true,
5 | keys = {
6 | "fb",
7 | "ff",
8 | "fh",
9 | "ft",
10 | "rg",
11 | },
12 | cmd = { "Telescope" },
13 | dependencies = {
14 | "nvim-lua/plenary.nvim",
15 | "aaronhallaert/advanced-git-search.nvim",
16 | "nvim-telescope/telescope-media-files.nvim",
17 | "rmagatti/auto-session",
18 | "nvim-tree/nvim-web-devicons",
19 | "nvim-telescope/telescope-bibtex.nvim",
20 | -- "benfowler/telescope-luasnip.nvim",
21 | "2kabhishek/nerdy.nvim",
22 | "albenisolmos/telescope-oil.nvim",
23 | },
24 | config = function()
25 | local layout_strategy
26 | if vim.o.columns <= 125 then
27 | layout_strategy = "vertical"
28 | else
29 | layout_strategy = "horizontal"
30 | end
31 | local builtin = require("telescope.builtin")
32 | vim.keymap.set("n", "ff", function()
33 | builtin.find_files({ layout_strategy = layout_strategy })
34 | end, {})
35 | vim.keymap.set("n", "rg", builtin.grep_string, {})
36 | vim.keymap.set("x", "rg", builtin.grep_string, {})
37 | vim.keymap.set("n", "fb", builtin.buffers, {})
38 | vim.keymap.set("n", "fh", function()
39 | builtin.oldfiles({ layout_strategy = layout_strategy })
40 | end, {})
41 |
42 | local telescope = require("telescope")
43 | telescope.setup({
44 | extensions = {
45 | advanced_git_search = {
46 | -- See Config
47 | git_flags = { "-c", "delta.pager=never" },
48 | },
49 | bibtex = {
50 | -- Depth for the *.bib file
51 | depth = 999,
52 | -- Custom format for citation label
53 | custom_formats = {},
54 | -- Format to use for citation label.
55 | -- Try to match the filetype by default, or use 'plain'
56 | format = "",
57 | -- Path to global bibliographies (placed outside of the project)
58 | global_files = {},
59 | -- Define the search keys to use in the picker
60 | search_keys = { "year", "title" },
61 | -- Template for the formatted citation
62 | citation_format = "{{author}} ({{year}}), {{title}}.",
63 | -- Only use initials for the authors first name
64 | citation_trim_firstname = true,
65 | -- Max number of authors to write in the formatted citation
66 | -- following authors will be replaced by "et al."
67 | citation_max_auth = 2,
68 | -- Context awareness disabled by default
69 | context = false,
70 | -- Fallback to global/directory .bib files if context not found
71 | -- This setting has no effect if context = false
72 | context_fallback = true,
73 | -- Wrapping in the preview window is disabled by default
74 | wrap = false,
75 | },
76 | media_files = {
77 | -- filetypes whitelist
78 | -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
79 | filetypes = { "png", "webp", "jpg", "jpeg" },
80 | -- find command (defaults to `fd`)
81 | find_cmd = "fd",
82 | },
83 | fzf = {
84 | fuzzy = true, -- false will only do exact matching
85 | override_generic_sorter = true, -- override the generic sorter
86 | override_file_sorter = true, -- override the file sorter
87 | case_mode = "smart_case", -- or "ignore_case" or "respect_case"
88 | -- the default case_mode is "smart_case"
89 | },
90 | },
91 | })
92 |
93 | telescope.load_extension("media_files")
94 | telescope.load_extension("fzf")
95 | telescope.load_extension("advanced_git_search")
96 | telescope.load_extension("session-lens")
97 | telescope.load_extension("bibtex")
98 | -- telescope.load_extension("luasnip")
99 | telescope.load_extension("nerdy")
100 | telescope.load_extension("oil")
101 |
102 | vim.keymap.set("n", "to", "Telescope oil", { noremap = true, silent = true })
103 | end,
104 | },
105 | { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
106 | }
107 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/treesitter.lua:
--------------------------------------------------------------------------------
1 | return {
2 | {
3 | "nvim-tree/nvim-web-devicons",
4 | },
5 | {
6 | "nvim-treesitter/nvim-treesitter",
7 | build = ":TSUpdate",
8 | branch = "master",
9 | config = function()
10 | require("nvim-treesitter.configs").setup({
11 | -- 安装 language parser
12 | -- :TSInstallInfo 命令查看支持的语言
13 | ensure_installed = {
14 | "c",
15 | "cpp",
16 | "go",
17 | "lua",
18 | "vim",
19 | "vimdoc",
20 | "python",
21 | "rust",
22 | "html",
23 | "query",
24 | "markdown",
25 | "markdown_inline",
26 | },
27 | -- Install parsers synchronously (only applied to `ensure_installed`)
28 | sync_install = false,
29 | -- 启用代码高亮模块
30 | highlight = {
31 | enable = true,
32 | additional_vim_regex_highlighting = false,
33 | },
34 | -- https://github.com/RRethy/nvim-treesitter-endwise
35 | endwise = {
36 | enable = false, -- nvim-treesitter-endwise is not maintained
37 | },
38 | -- https://github.com/andymass/vim-matchup
39 | matchup = {
40 | enable = true, -- mandatory, false will disable the whole extension
41 | -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled
42 | -- [options]
43 | },
44 | })
45 | end,
46 | dependencies = {
47 | -- "RRethy/nvim-treesitter-endwise",
48 | },
49 | },
50 | {
51 | "nvim-treesitter/nvim-treesitter-context",
52 | opts = {
53 | max_lines = 4, -- How many lines the window should span. Values <= 0 mean no limit.
54 | min_window_height = 30, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
55 | },
56 | },
57 | {
58 | "nvim-treesitter/nvim-treesitter-textobjects",
59 | config = function()
60 | require("nvim-treesitter.configs").setup({
61 | textobjects = {
62 | select = {
63 | enable = true,
64 |
65 | -- Automatically jump forward to textobj, similar to targets.vim
66 | lookahead = true,
67 | keymaps = {
68 | ib = "@block.inner",
69 | ab = "@block.outer",
70 | ic = "@class.inner",
71 | ac = "@class.outer",
72 | ["if"] = "@function.inner",
73 | af = "@function.outer",
74 | },
75 | },
76 | move = {
77 | enable = true,
78 | set_jumps = true, -- whether to set jumps in the jumplist
79 | goto_next_start = {
80 | -- ["]b"] = "@block.outer",
81 | ["]f"] = "@function.outer",
82 | ["]]"] = { query = "@class.outer", desc = "Next class start" },
83 | },
84 | goto_next_end = {
85 | -- ["]B"] = "@block.outer",
86 | ["]F"] = "@function.outer",
87 | ["]["] = "@class.outer",
88 | },
89 | goto_previous_start = {
90 | -- ["[b"] = "@block.outer",
91 | ["[f"] = "@function.outer",
92 | ["[["] = "@class.outer",
93 | },
94 | goto_previous_end = {
95 | -- ["[B"] = "@block.outer",
96 | ["[F"] = "@function.outer",
97 | ["[]"] = "@class.outer",
98 | },
99 | },
100 | },
101 | })
102 | end,
103 | dependencies = "nvim-treesitter/nvim-treesitter",
104 | },
105 | {
106 | "windwp/nvim-ts-autotag",
107 | opts = {},
108 | },
109 | }
110 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/ui.lua:
--------------------------------------------------------------------------------
1 | return {
2 | {
3 | "ray-x/guihua.lua",
4 | event = "VeryLazy",
5 | lazy = true,
6 | build = "cd lua/fzy && make",
7 | },
8 | {
9 | "stevearc/dressing.nvim",
10 | event = "VeryLazy",
11 | lazy = true,
12 | dependencies = { "MunifTanjim/nui.nvim" },
13 | opts = {
14 | input = {
15 | enabled = true,
16 | },
17 | select = {
18 | -- Set to false to disable the vim.ui.select implementation
19 | enabled = true,
20 |
21 | -- Priority list of preferred vim.select implementations
22 | backend = { "fzf", "telescope", "builtin", "nui" },
23 | },
24 | },
25 | },
26 | -- {
27 | -- "j-hui/fidget.nvim",
28 | -- opts = {
29 | -- notification = {
30 | -- override_vim_notify = false, -- Automatically override vim.notify() with Fidget
31 | -- },
32 | -- },
33 | -- },
34 | }
35 |
--------------------------------------------------------------------------------
/root/.config/nvim/lua/plugins/wsl.lua:
--------------------------------------------------------------------------------
1 | if vim.fn.has('wsl') == 1 then
2 | return {
3 | {
4 | "iamcco/markdown-preview.nvim",
5 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
6 | -- or "cd app && yarn install"
7 | build = "cd app && npx --yes yarn install",
8 | init = function()
9 | vim.g.mkdp_filetypes = { "markdown", "quarto" }
10 | end,
11 | ft = { "markdown", "quarto" },
12 | },
13 | }
14 | else
15 | return {}
16 | end
17 |
--------------------------------------------------------------------------------
/root/.config/nvim/snippets/markdown.json:
--------------------------------------------------------------------------------
1 | {
2 | "header 1 align center": {
3 | "prefix": "h1center",
4 | "body": [" ${0}
"],
5 | "description": "Add header level 1, align center"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/root/.gitconfig:
--------------------------------------------------------------------------------
1 | #[url "https://gitclone.com/github.com/"]
2 | # insteadOf = https://github.com/
3 | [user]
4 | email = jiangyinzuo@foxmail.com
5 | name = Yinzuo Jiang
6 | [core]
7 | editor = vim
8 | quotepath = false
9 |
10 | [include]
11 | # use delta to take place of diff, use git --no-pager diff if delta is not installed
12 | # https://github.com/dandavison/delta
13 | path = ~/vimrc/root/.gitconfig-delta
14 |
15 | [diff]
16 | tool = vimdiff
17 | [difftool]
18 | prompt = false
19 |
20 | #################################################
21 | # See: https://github.com/samoshkin/vim-mergetool
22 | [merge]
23 | # tool = vimdiff
24 | tool = vim_mergetool
25 | conflictstyle = diff3
26 | [mergetool]
27 | keepBackup = false
28 | [mergetool "vim_mergetool"]
29 | cmd = USE_VIM_MERGETOOL=1 vim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"
30 | # When trustExitCode = true, checks exit code of merge tool process.
31 | # When trustExitCode = false, checks if MERGED file was modified.
32 | trustExitCode = true
33 | prompt = false
34 | #################################################
35 |
36 | [includeIf "gitdir:/mnt/d/doc2/group-meeting/"]
37 | path = ~/.gitconfig-ict
38 | [includeIf "gitdir:/mnt/d/doc2/PROJECTS/blade/"]
39 | path = ~/.gitconfig-ict
40 |
41 | [filter "lfs"]
42 | clean = git-lfs clean -- %f
43 | smudge = git-lfs smudge -- %f
44 | process = git-lfs filter-process
45 | required = true
46 | [safe]
47 | directory = *
48 |
49 | # use utf-8
50 | # https://m.php.cn/tool/git/506129.html
51 | # git config --global i18n.commitencoding utf-8
52 | # git config --global i18n.logoutputencoding utf-8
53 | # git config --global core.quotepath false
54 | # git config --global gui.encoding utf-8
55 | # git config --global utf8.auto false
56 | [i18n]
57 | logoutputencoding = utf-8
58 | [gui]
59 | encoding = utf-8
60 | [utf8]
61 | auto = false
62 |
63 | [alias]
64 | # https://how-to.dev/how-to-display-git-branches-as-a-tree-in-cli
65 | # Config command: git config --global alias.tree "log --oneline --graph --decorate --all"
66 | #
67 | # --oneline = show each commit as a single line
68 | # --graph = show ASCII graph of branch and merge history
69 | # --decorate = show branch and tag names on graph
70 | # --all = show all commits (by default only shows commits reachable from HEAD)
71 | # --pretty=format: = use custom format
72 | #
73 | # https://stackoverflow.com/questions/1441010/the-shortest-possible-output-from-git-log-containing-author-and-date/1441062#1441062
74 | # %h = abbreviated commit hash
75 | # %an = author name
76 | # %ad = author date (format respects --date= option)
77 | # %d = ref names, like the --decorate option of git-log(1)
78 | # %s = subject
79 | # %C(auto,yellow) = yellow text
80 | # %C(auto,green) = green text
81 | # %C(auto,blue) = blue text
82 | # %C(reset) = reset color
83 | # %x09 = tab
84 | # --date=short = show date in short format
85 | #
86 | # Valid in the following versions:
87 | # git 2.8.3 (CentOS 7.1, updated version by sudo yum install git)
88 | # git 2.7.4 (Ubuntu 16.04)
89 | # Invalid in the following versions:
90 | # git 1.8.3.1 (CentOS 7.1, default git version)
91 | # Usage:
92 | # git tree -2 # last 2 commits
93 | # git tree --all # 显示所有分支
94 | tree = log --graph --decorate --pretty=format:'%C(auto,yellow)%h %C(auto,green)%an %C(auto,blue)%ad%C(auto)%d%n%x09%C(reset)%s' --date=format-local:'%Y-%m-%d %H:%M:%S'
95 | oneline = log --oneline --graph --decorate
96 | picture = log --oneline --graph --simplify-by-decoration
97 | # git status, but exclude some files
98 | status-ex = "!f() { git ls-files | grep -v \"^$1/\" | xargs git status; }; f"
99 | rm-file-in-history = !git-rm-file-in-history
100 |
--------------------------------------------------------------------------------
/root/.gitconfig-delta:
--------------------------------------------------------------------------------
1 | [core]
2 | pager = delta
3 | [interactive]
4 | diffFilter = delta --color-only
5 | [diff]
6 | colorMoved = default
7 | [delta]
8 | navigate = true
9 | line-numbers = true
10 | file-style = yellow
11 |
--------------------------------------------------------------------------------
/root/.gitconfig-ict:
--------------------------------------------------------------------------------
1 | [user]
2 | email = jiangyinzuo22s@ict.ac.cn
3 | name = jiangyinzuo
4 |
--------------------------------------------------------------------------------
/root/.ripgreprc:
--------------------------------------------------------------------------------
1 | # Reference: https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file
2 |
3 | --max-columns=50
4 | --max-columns-preview
5 |
6 | --glob=!.git/*
7 | --glob=!*.html
8 | --glob=!__pycache__/*
9 | --glob=!.DS_Store/*
10 | --glob=!.svn/*
11 | --glob=!.cache/*
12 | --glob=!deps/*
13 | --glob=!build/*
14 | --glob=!*.exe
15 | --glob=!*.dll
16 | --glob=!*.so
17 | --glob=!*.o
18 | --glob=!*.pyc
19 | --glob=!*.jpg
20 | --glob=!*.png
21 | --glob=!*.gif
22 | --glob=!*.svg
23 | --glob=!*.ico
24 | --glob=!*.db
25 | --glob=!*.tgz
26 | --glob=!*.tar.gz
27 | --glob=!*.gz
28 | --glob=!*.zip
29 | --glob=!*.bin
30 | --glob=!*.ppt
31 | --glob=!*.pptx
32 | --glob=!*.xls
33 | --glob=!*.xlsx
34 | --glob=!*.doc
35 | --glob=!*.docx
36 | --glob=!*.pdf
37 | --glob=!*.tmp
38 | --glob=!*.wmv
39 | --glob=!*.mkv
40 | --glob=!*.mp4
41 | --glob=!*.rmvb
42 | --glob=!*.ttf
43 | --glob=!*.ttc
44 | --glob=!*.otf
45 | --glob=!*.mp3
46 | --glob=!*.aac
47 | --glob=!*.orig
48 | --glob=!*.html
49 | --glob=!*.htm
50 | --glob=!*.webp
51 |
52 | --smart-case
53 |
--------------------------------------------------------------------------------
/root/.tmux.conf:
--------------------------------------------------------------------------------
1 | # Ubuntu18.04默认安装tmux2.6
2 | # tmux2.6中,使用fzf的CTRL-R快捷键会卡死,请手动运行 cd ~/vimrc && ./install/build_tmux.sh安装
3 | #
4 | # 在bash中使用 tmux source-file ~/.tmux.conf 重新加载配置
5 | # 或者在tmux中使用 :source-file ~/.tmux.conf 重新加载配置
6 |
7 | set-window-option -g mode-keys vi # tmux2.1+
8 | setw -g mode-keys vi # tmux1.8
9 | set -g history-limit 40000
10 |
11 | bind-key C-e run-shell "~/vimrc/root/scripts/vim-edit-tmux-output"
12 |
13 | # Add truecolor support (tmux>2.2)
14 | # https://github.com/lifepillar/vim-solarized8#troubleshooting
15 | set-option -ga terminal-overrides ",xterm-256color:Tc"
16 |
17 | # Default terminal is 256 colors
18 | set -g default-terminal "screen-256color"
19 |
20 | # sane scrolling
21 | set -g mouse on
22 | bind-key m setw synchronize-panes
23 |
24 | set -g set-clipboard on
25 | # transfer copied text to attached terminal with yank
26 | bind-key -T copy-mode-vi y send-keys -X copy-pipe "$VIMRC_ROOT/scripts/oscyank > #{pane_tty}"
27 |
28 | unbind -T copy-mode-vi Space
29 | # 在 copy mode 中,使用 v 开始选择
30 | bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
31 |
32 | # 在 copy mode 中,使用 V 选择整行
33 | bind-key -T copy-mode-vi 'V' send-keys -X select-line
34 |
35 | # https://vi.stackexchange.com/questions/16148/slow-vim-escape-from-insert-mode
36 | # 高版本下-g和-s可以合并,但出于兼容性考虑,还是分开写
37 | # escape-time设置为20在kiwi服务器上会导致tmux出现随机字符串,故设置为25
38 | # https://github.com/microsoft/WSL/issues/5931
39 | set -g escape-time 25
40 | set -s escape-time 25
41 |
42 | set -g status-interval 0 # 不刷新
43 | set -g status-right "#(hostname -s) #(ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1 | head -n 1)"
44 |
45 | #### tpm,要求tmux1.9+
46 | #### 安装: git clone --depth=1 https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
47 | #### Ctrl-B I安装插件
48 |
49 | # List of plugins
50 | set -g @plugin 'tmux-plugins/tpm'
51 | # 自动备份tmux会话并恢复,防止服务器断电重启后会话丢失
52 | # 5分钟搞定tmux备份 - Kevin的文章 - 知乎 https://zhuanlan.zhihu.com/p/533349040
53 | set -g @plugin 'tmux-plugins/tmux-resurrect'
54 | set -g @plugin 'tmux-plugins/tmux-continuum'
55 |
56 | # 打开tmux后自动restore
57 | # set -g @continuum-restore 'on'
58 | # 设置自动保存的时间间隔,默认是15分钟
59 | # 下面意为改为60分钟,如果改成0则停止自动保存
60 | # set -g @continuum-save-interval '60'
61 |
62 | # for vim
63 | # set -g @resurrect-strategy-vim 'session'
64 | # for neovim
65 | # set -g @resurrect-strategy-nvim 'session'
66 | # 保存pane中内容
67 | set -g @resurrect-capture-pane-contents 'on'
68 |
69 | # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
70 | run '~/.tmux/plugins/tpm/tpm'
71 |
--------------------------------------------------------------------------------
/root/.vim/README.md:
--------------------------------------------------------------------------------
1 | See Also:
2 |
3 | https://github.com/llvm/llvm-project/tree/main/llvm/utils/vim
4 |
5 | https://github.com/llvm/llvm-project/tree/main/mlir/utils/vim
6 |
--------------------------------------------------------------------------------
/root/.vim/UltiSnips/markdown.snippets:
--------------------------------------------------------------------------------
1 | snippet h1center "h1 align=center" b
2 | $0
3 | endsnippet
4 |
--------------------------------------------------------------------------------
/root/.vim/UltiSnips/python.snippets:
--------------------------------------------------------------------------------
1 | snippet main "if __name__ == '__main__'" b
2 | if __name__ == '__main__':
3 | $0
4 | endsnippet
5 |
--------------------------------------------------------------------------------
/root/.vim/UltiSnips/tex.snippets:
--------------------------------------------------------------------------------
1 | snippet xelatex "xelatex CJK" b
2 | %编译 xelatex main.tex
3 | \documentclass{ctexart} % apt install texlive-lang-chinese
4 | %\setCJKmainfont{WenQuanYi Micro Hei Mono} % 选择你系统中安装的一个中文字体 fc-list :lang=zh
5 | \usepackage{amsmath,amsfonts,amssymb}
6 |
7 | \begin{document}
8 | $0
9 | \[
10 | \text{CPU利用率(\%)} = \left( \frac{{\text{当前 utime + stime} - \text{一分钟前的 utime + stime}}}{{\text{当前系统 uptime} - \text{一分钟前的系统 uptime}} \times \text{每秒钟的jiffies数}} \right) \times 100
11 | \]
12 | \end{document}
13 | endsnippet
14 |
15 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/c.vim:
--------------------------------------------------------------------------------
1 | setlocal commentstring=//\ %s
2 | " setlocal equalprg=indent
3 | " setlocal equalprg=uncrustify\ -c\ .uncrustify.cfg\ --replace\ --no-backup
4 | if expand('%:p') =~ '^/usr/include/\(\(c++\)\|\(\w\+\.h$\)\)'
5 | setlocal tabstop=8 shiftwidth=8 softtabstop=8
6 | else
7 | setlocal tabstop=2 shiftwidth=2 softtabstop=2
8 | endif
9 |
10 | if !has('nvim')
11 | " 搜索的模式是一个正则表达式,用来匹配不是在if, for, while, switch, 和catch后面的左花括号{,因为在C++中函数的定义是以左花括号开始的。
12 | " 需要注意的是,这个搜索模式可能并不完全精确,因为函数的定义还可能包含许多其他的复杂性,比如模板函数,函数指针,宏定义等等。对于一些简单的代码文件,这个方法通常可以工作得很好。
13 | " 这些配置会更好地在代码中快速导航,但如果你需要更精确地识别函数,你可能需要考虑使用一些更高级的插件,比如ctags,cscope等等。
14 |
15 | " jump to the previous function
16 | " 向后(b表示backward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。
17 | nnoremap [f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64
18 | " jump to the next function
19 | " 向前(w表示forward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。
20 | nnoremap ]f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64
21 |
22 | nnoremap [[ :call search('\\|\\|\\|\', "bW")
23 | nnoremap ]] :call search('\\|\\|\\|\', "wW")
24 |
25 | setlocal foldmethod=expr foldexpr=mycpp#FoldExpr(v:lnum)
26 | endif
27 |
28 | setlocal completefunc=mycpp#CompleteFunc
29 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/cpp.vim:
--------------------------------------------------------------------------------
1 | command! -buffer -nargs=? YDef call cpp#YDef()
2 | runtime! after/ftplugin/c.vim
3 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/csv.vim:
--------------------------------------------------------------------------------
1 | setlocal commentstring=#\ %s
2 | setlocal nowrap
3 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/cuda.vim:
--------------------------------------------------------------------------------
1 | runtime! after/ftplugin/cpp.vim
2 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/markdown.vim:
--------------------------------------------------------------------------------
1 | command -range -nargs=0 -buffer YankWikiLink call markdown#YankWikiLink(, )
2 | command -nargs=0 -buffer NumberHeadings call markdown#NumberHeadings()
3 | command -nargs=0 -buffer RemoveNumberHeadings call markdown#RemoveNumberHeadings()
4 |
5 | setlocal conceallevel=0
6 |
7 | " ASCII of ~ is 126
8 | " See: :h surround-customizing
9 | let b:surround_126 = "~~\r~~"
10 | let g:markdown_folding = 1
11 | if exists('$WSLENV')
12 | command! -buffer -nargs=0 BrowserPreview call wsl#BrowserPreview()
13 | endif
14 |
15 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/quarto.vim:
--------------------------------------------------------------------------------
1 | setlocal conceallevel=0
2 |
--------------------------------------------------------------------------------
/root/.vim/after/ftplugin/tex.vim:
--------------------------------------------------------------------------------
1 | " 选中想格式化的段落后,可以用gq格式化
2 | " 设置textwidth,可以让文本格式化时自动换行
3 | " 内置的format会考虑virtual text,如果需要忽略virtual
4 | " text,可以使用外部命令行工具,比如
5 | " set formatprg=par\ 80
6 | " set formatprg=fmt\ -w81\ -g81
7 | " See: https://github.com/vim/vim/issues/14276
8 | setlocal textwidth=80
9 | " 不要自动换行。因为表格换行后可能不好看
10 | setlocal formatoptions-=t
11 | setlocal tabstop=2 shiftwidth=2 softtabstop=2
12 | if exists('$WSLENV')
13 | " [[palette]]打开当前tex文件中PDF对应的pptx文件 :OpenPPTX
14 | command -buffer -nargs=0 OpenPPTX call latex#OpenPPTX()
15 | let g:PasteImageFunction = 'latex#LatexPasteImage'
16 | endif
17 |
--------------------------------------------------------------------------------
/root/.vim/autoload/ai.vim:
--------------------------------------------------------------------------------
1 | function ai#CreateInitialPrompt(prompt)
2 | let l:config = {
3 | \ "options": {
4 | \ "initial_prompt": ">>> system\n" . a:prompt,
5 | \ },
6 | \}
7 | return l:config
8 | endfunction
9 |
10 | function ai#RunWithInitialPrompt(func, prompt, range, ...) range
11 | let l:config = {
12 | \ "options": {
13 | \ "initial_prompt": ">>> system\n" . a:prompt,
14 | \ },
15 | \}
16 | let l:prompt = a:0 ? a:1 : ''
17 | call call(a:func, [a:range, l:config, l:prompt])
18 | endfunction
19 | function ai#GitCommitMessage()
20 | let l:range = 0
21 | let l:diff = system('git --no-pager diff --staged')
22 | let l:prompt = "generate a short git commit message from the diff below, using conventional commit format:\n" . l:diff
23 | let l:config = {
24 | \ "engine": "chat",
25 | \ "options": {
26 | \ "endpoint_url": g:openai_endpoint . "/chat/completions",
27 | \ "model": g:openai_model,
28 | \ "initial_prompt": ">>> system\nyou are a code assistant",
29 | \ "temperature": 0.2,
30 | \ },
31 | \}
32 | call vim_ai#AIRun(l:range, l:config, l:prompt)
33 | endfunction
34 |
--------------------------------------------------------------------------------
/root/.vim/autoload/asynctasks_custom.vim:
--------------------------------------------------------------------------------
1 | function! asynctasks_custom#MakefileComplete(ArgLead, CmdLine, CursorPos)
2 | " See Also: https://github.com/jiangyinzuo/vimrc/commit/29a7f3f4686c4ea8246c2f149f698fd01d7cdba4#commitcomment-139545459
3 | " read and parse Makefile
4 | try
5 | let l:lines = readfile('Makefile')
6 | catch /.*/
7 | return []
8 | endtry
9 | let l:targets = []
10 |
11 | for line in l:lines
12 | if line =~ '^\w.*:'
13 | let target = matchstr(line, '^\([a-zA-Z/0-9_-]\|\.\)\+')
14 | " Only add targets that match ArgLead
15 | if target =~ '^' . a:ArgLead
16 | call add(l:targets, target)
17 | endif
18 | endif
19 | endfor
20 |
21 | return l:targets->uniq()
22 | endfunction
23 |
24 | function asynctasks_custom#Open(prefix)
25 | let l:cfile = expand("")
26 | let l:prefix = a:prefix
27 | if empty(l:prefix) && exists('g:default_open_prefixes')
28 | let l:longest_matched_index = 99999
29 | let l:current_buffer_filepath = expand('%:t')
30 | for pair in g:default_open_prefixes
31 | let l:matched_index = match(l:current_buffer_filepath, glob2regpat(pair[0]))
32 | if l:matched_index >= 0 && l:matched_index < l:longest_matched_index
33 | let l:longest_matched_index = l:matched_index
34 | let l:prefix = pair[1]
35 | endif
36 | endfor
37 | endif
38 | let l:filename = l:prefix . l:cfile
39 | if (l:filename =~# '^mycmd://.*') && exists('$WSLENV')
40 | let l:command = '/mnt/d/url_scheme.exe'
41 | else
42 | let l:command = 'xdg-open'
43 | endif
44 | call asyncrun#run('', {'silent': 1}, l:command . ' ' . l:filename)
45 | endfunction
46 |
--------------------------------------------------------------------------------
/root/.vim/autoload/coc_clang.vim:
--------------------------------------------------------------------------------
1 | function coc_clang#setup_coc_clangd()
2 | call coc#config('clangd.arguments', g:clangd_args)
3 | call coc#config('clangd.path', g:clangd_path)
4 | endfunction
5 |
6 | " alternative: https://github.com/rhysd/vim-clang-format
7 | exe 'autocmd FileType c,cpp,cuda setlocal equalprg=' . g:clang_format . '\ -style=file'
8 |
--------------------------------------------------------------------------------
/root/.vim/autoload/coc_custom.vim:
--------------------------------------------------------------------------------
1 | fun coc_custom#NetrwGxHandler()
2 | let result = CocAction('runCommand', 'explorer.getNodeInfo', 0)['fullpath']
3 | echo result
4 | call wsl#WSLOpen(result)
5 | endfun
6 |
--------------------------------------------------------------------------------
/root/.vim/autoload/common.vim:
--------------------------------------------------------------------------------
1 | " https://www.zhihu.com/question/26248191/answer/2680677733
2 | function! common#GoToFile(file,lineNum)
3 | let bufName = bufname(a:file)
4 | if bufName == ""
5 | execute 'edit +'.a:lineNum a:file
6 | else
7 | let bufNum = bufnr(bufName)
8 | execut 'b '.bufNum
9 | call feedkeys(a:lineNum."G","n")
10 | endif
11 |
12 | if foldclosed('.') != -1
13 | call feedkeys("zo","n")
14 | end
15 |
16 | call feedkeys("zz","n")
17 | endfunction
18 |
19 |
--------------------------------------------------------------------------------
/root/.vim/autoload/cpp.vim:
--------------------------------------------------------------------------------
1 | function s:yank_def(lineNumber, className)
2 | let l:current_line = getline(a:lineNumber)
3 | " 去掉末尾)和;之间的内容
4 | let l:current_line = substitute(l:current_line, ').*;.*$', ');', '')
5 | " 去掉开头的virtual关键字
6 | let l:current_line = substitute(l:current_line, '^\s*virtual\s*', '', '')
7 | " 将l:current_line中的;替换为{}
8 | let l:current_line = substitute(l:current_line, ';', ' {\n}', '')
9 | " 在l:current_line中方法名前面添加 className::
10 | let l:current_line = substitute(l:current_line, '\(\w\+\)(\(.*\))', a:className .'::\1(\2)', '')
11 | " 复制到默认寄存器
12 | let @" = l:current_line
13 | endfunction
14 |
15 | " [[palette]]生成cpp类方法的函数定义,放在默认寄存器 :YDef
16 | function cpp#YDef(...)
17 | let l:current_line_number = line('.')
18 |
19 | if a:0 == 0
20 | let className = ''
21 | " 向上找到类名
22 | let l:class_line_number = l:current_line_number
23 | while l:class_line_number > 0 && className == ''
24 | let className = matchstr(getline(l:class_line_number), 'class \zs\w\+')
25 | let l:class_line_number = l:class_line_number - 1
26 | endwhile
27 | else
28 | let className = a:1
29 | endif
30 | call s:yank_def(l:current_line_number, className)
31 | endfunction
32 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/fzf.vim:
--------------------------------------------------------------------------------
1 | function fzf_custom#fzf#mergetool_start(f)
2 | execute 'tabnew ' . a:f
3 | :MergetoolStart
4 | tabclose -1
5 | endfunction
6 |
7 | function fzf_custom#fzf#backup(f)
8 | let current_ft = &ft
9 | exe 'vsp ' . a:f
10 | exe 'set ft=' . current_ft
11 | endfunction
12 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/palette.vim:
--------------------------------------------------------------------------------
1 | function s:exec_command_palette(line)
2 | let l:cmd = filter(split(a:line, '\t'), 'v:val != ""')
3 | " 把l:cmd放到Command Line且不执行
4 | call feedkeys(l:cmd[1])
5 | endfunction
6 |
7 | function fzf_custom#palette#Palette()
8 | call fzf#run(fzf#wrap({'source': "$VIMRC_ROOT/palette.sh", 'sink': function("s:exec_command_palette")}))
9 | endfunction
10 |
11 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/quickfix.vim:
--------------------------------------------------------------------------------
1 | function! s:QuickfixListFormat()
2 | let qf_list = getqflist()
3 | let formatted_list = []
4 |
5 | let l:i = 0
6 | for item in qf_list
7 | let filename = bufname(item.bufnr)
8 | let line_number = item.lnum
9 | let text = item.text
10 |
11 | call add(formatted_list, l:i . ' ' . filename . ':' . line_number . ' ' . text)
12 | let l:i = l:i + 1
13 | endfor
14 |
15 | return formatted_list
16 | endfunction
17 |
18 | function! fzf_custom#quickfix#Quickfix()
19 | call fzf#run(fzf#wrap({
20 | \ 'source': s:QuickfixListFormat(),
21 | \ 'sink': function('s:open_quickfix_item'),
22 | \ 'options': '--ansi'
23 | \ }))
24 | endfunction
25 |
26 | function! s:open_quickfix_item(line)
27 | let items = getqflist()
28 | let item = items[split(a:line, ' ')[0]]
29 | execute item.bufnr . 'buffer'
30 | call cursor(item.lnum, item.col)
31 | endfunction
32 |
33 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/rg.vim:
--------------------------------------------------------------------------------
1 | " See: github.com/junegunn/fzf.vim/issues/1037
2 | " HelpRg command -- like helpgrep but with FZF and ripgrep
3 | let s:helppaths = uniq(sort(split(globpath(&runtimepath, 'doc/', 1), '\n')))
4 |
5 | function fzf_custom#rg#ListDocs(A, L, P)
6 | let result = ''
7 | for helppath in s:helppaths
8 | let result = result . system("ls " . helppath . " | grep ^" . a:A)
9 | endfor
10 | return result
11 | endfunction
12 |
13 | function s:help_rg_sink(item)
14 | let parts = split(a:item, ':')
15 | let filename = parts[0]
16 | let lnum = parts[1]
17 | execute 'edit +' . lnum . ' ' . filename
18 | set ft=help
19 | set readonly
20 | set nomodifiable
21 | norm! zz
22 | endfunction
23 |
24 | function fzf_custom#rg#HelpRg(word, fullscreen)
25 | if a:word == ""
26 | call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case -g "*.txt" -g "*.cnx" "" '. join(s:helppaths), 1, fzf#wrap({'sink': function('s:help_rg_sink')}), a:fullscreen)
27 | else
28 | call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case -g "*.txt" -g "*.cnx" "' . a:word . '" '. join(s:helppaths), 1, fzf#wrap({'sink': function('s:help_rg_sink')}), a:fullscreen)
29 | end
30 | set readonly
31 | set ft=help
32 | endfunction
33 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/tabs.vim:
--------------------------------------------------------------------------------
1 | function! fzf_custom#tabs#FzfTabs()
2 | let tab_list = []
3 | let tcount = tabpagenr('$')
4 |
5 | " Generate the list of all tabs with their windows
6 | for i in range(1, tcount)
7 | let win_list = []
8 | for j in range(1, len(tabpagebuflist(i)))
9 | let bufnr = tabpagebuflist(i)[j - 1]
10 | let filename = bufname(bufnr)
11 | let win_list += [filename]
12 | endfor
13 | let tab_list += [printf("Tab %d: %s", i, join(win_list, ' | '))]
14 | endfor
15 |
16 | " Use fzf#run to select the tab
17 | call fzf#run({
18 | \ 'source': tab_list,
19 | \ 'sink': function('s:SwitchToTab'),
20 | \ 'options': '--prompt="Select Tab> " --preview-window=up:1'
21 | \ })
22 | endfunction
23 |
24 | function! s:SwitchToTab(tab)
25 | let match = matchlist(a:tab, 'Tab \(\d\+\):')
26 | let tabnr = match[1]
27 | execute 'tabn ' . tabnr
28 | endfunction
29 |
--------------------------------------------------------------------------------
/root/.vim/autoload/fzf_custom/tags.vim:
--------------------------------------------------------------------------------
1 | """"""""""""" Ctags 类""""""""""""""""""
2 | " 作者:成隽
3 | " 链接:https://www.zhihu.com/question/26248191/answer/2680677733
4 | " 来源:知乎
5 | function s:tag_sink(line)
6 | let l:lines = split(a:line)[1]
7 | let l:lines = split(l:lines, ':')
8 | call common#GoToFile(l:lines[0], l:lines[1])
9 | endfunction
10 |
11 | function fzf_custom#tags#CTags(query, fullscreen)
12 | let tags = join(map(tagfiles(), 'fzf#shellescape(fnamemodify(v:val, ":p"))'))
13 | " TODO: 处理多tag文件
14 | echom tags
15 |
16 | " 输出不以!开头的行
17 | " ^! 是正则表达式,表示以!开头的行
18 | " !/^!/ 是否定模式,用于匹配不以!开头的行
19 | let l:cmd = "awk -f " . $VIMRC_ROOT . "/process_ctags.awk regex=" . a:query . " " . tags
20 |
21 | try
22 | return fzf#run(fzf#wrap({
23 | \ 'source': l:cmd,
24 | \ 'sink': function('s:tag_sink'),
25 | \ 'options': ['--query', a:query, '--prompt', 'CTags> ', '--color', 'hl:148,hl+:190' ],
26 | \ }))
27 | catch
28 | echom v:exception
29 | endtry
30 | endfunction
31 |
32 | " Example:
33 | " a 5 hello.py a = 3
34 | function s:global_sink(line)
35 | let l:lines = split(a:line)
36 | call common#GoToFile(l:lines[2], l:lines[1])
37 | endfunction
38 |
39 | function s:global(cmd)
40 | let l:source = systemlist(a:cmd)
41 | if len(l:source) == 1
42 | " 只有一行结果时,直接跳转
43 | call s:global_sink(l:source[0])
44 | return
45 | endif
46 | " 有多行结果时,使用fzf选择
47 | try
48 | return fzf#run(fzf#wrap({
49 | \ 'source': l:source,
50 | \ 'sink': function('s:global_sink'),
51 | \ 'options': [ '--prompt', 'Global> ', '--color', 'hl:148,hl+:190' ],
52 | \ }))
53 | catch
54 | echom v:exception
55 | endtry
56 | endfunction
57 |
58 | function! s:global_sym(query)
59 | let l:cmd = 'global -s -rx ' . a:query
60 | call s:global(l:cmd)
61 | endfunction
62 |
63 | function! s:global_def(query)
64 | let l:cmd = 'global -d -rx ' . a:query
65 | call s:global(l:cmd)
66 | endfunction
67 |
68 | function fzf_custom#tags#GlobalSym()
69 | let l:cmd = 'GTAGSDBPATHGTAGSROOT=' . getcwd() . ' global -c'
70 | return fzf#run(fzf#wrap({
71 | \ 'source': l:cmd,
72 | \ 'sink': function('s:global_sym'),
73 | \ 'options': [ '--prompt', 'Global -c> ', '--color', 'hl:148,hl+:190' ],
74 | \ }))
75 | endfunction
76 |
77 | function fzf_custom#tags#GlobalDef()
78 | let l:cmd = 'GTAGSROOT=' . getcwd() . ' global -c'
79 | let l:source = systemlist(l:cmd)
80 | return fzf#run(fzf#wrap({
81 | \ 'source': l:source,
82 | \ 'sink': function('s:global_def'),
83 | \ 'options': [ '--prompt', 'Global -c> ', '--color', 'hl:148,hl+:190' ],
84 | \ }))
85 | endfunction
86 |
87 |
--------------------------------------------------------------------------------
/root/.vim/autoload/jupyter_ascending_custom.vim:
--------------------------------------------------------------------------------
1 | vim9script
2 | # Use # %% to separate cells. Use # %% [markdown] to make a markdown block.
3 | export def JupyterOpenNotebook()
4 | var name = ''
5 | if expand('%') =~# '\.sync\.py$'
6 | # This is a sync file, open the corresponding notebook
7 | name = expand('%:r:r')
8 | else
9 | name = input('Notebook name: ')
10 | name = trim(name)
11 | endif
12 |
13 | if name != ''
14 | execute 'e ' .. name .. '.sync.py'
15 | execute 'AsyncRun -pos=tab -mode=term -name=JupyterCreateNotebook -cwd=' .. getcwd() ..
16 | ' jupyter_ascending.sh ' .. name
17 | endif
18 | enddef
19 |
20 |
--------------------------------------------------------------------------------
/root/.vim/autoload/jupyter_custom.vim:
--------------------------------------------------------------------------------
1 | function jupyter_custom#MatplotlibInit(timer)
2 | :MatplotlibQtInline
3 | " edit: 高亮绿色的cell (##分隔)
4 | silent! edit
5 | endfunction
6 |
--------------------------------------------------------------------------------
/root/.vim/autoload/largefile.vim:
--------------------------------------------------------------------------------
1 | function! largefile#LargeFile()
2 | " no syntax highlighting etc
3 | set eventignore+=FileType
4 | " save memory when other file is viewed
5 | setlocal bufhidden=unload
6 | " is read-only (write with :w new_filename)
7 | setlocal buftype=nowrite
8 | " no undo possible
9 | setlocal undolevels=-1
10 | " display message
11 | autocmd VimEnter * echo "The file is larger than " . (g:LargeFile / 1024 / 1024) . " MB, so some options are changed (see vimrc for details)."
12 | endfunction
13 |
14 |
--------------------------------------------------------------------------------
/root/.vim/autoload/latex.vim:
--------------------------------------------------------------------------------
1 | function latex#OpenPPTX()
2 | normal! vi{"ay
3 | let current_word = @a
4 | let pptx_file = substitute(current_word, 'pdf', 'pptx', '')
5 | if filereadable(pptx_file)
6 | call asyncrun#run('', {'silent': 1}, 'xdg-open ' . pptx_file)
7 | else
8 | echoerr 'File not found: ' . pptx_file
9 | endif
10 | endfunction
11 |
12 | function latex#SumatraPDFSendToVim(args)
13 | "24 d:\hello\world.tex -> ['24', 'd', '\hello\world.tex']
14 | let l:arglist = split(a:args, '[: ]')
15 |
16 | let l:line = l:arglist[0]
17 | let l:diskname = l:arglist[1]
18 | let l:diskname = tolower(l:diskname)
19 |
20 | " \hello\world.tex -> /mnt/d/hello/world.tex
21 | let l:wslpath = l:arglist[2]
22 | let l:wslpath = substitute(l:wslpath, '\', "/", "g")
23 |
24 | let l:newargs = join([l:line, ' /mnt/', l:diskname, l:wslpath], '')
25 | execute 'edit +' . l:newargs
26 | endfunction
27 |
28 | function latex#LatexPasteImage(relpath)
29 | execute "normal! i\\includegraphics{" . a:relpath . "}\r\\caption{I"
30 | let ipos = getcurpos()
31 | execute "normal! a" . "mage}"
32 | call setpos('.', ipos)
33 | execute "normal! ve\"
34 | endfunction
35 |
--------------------------------------------------------------------------------
/root/.vim/autoload/markdown.vim:
--------------------------------------------------------------------------------
1 | function markdown#YankWikiLink(line1, line2)
2 | let s:wiki_link ='[[' . expand("%") . ']]'
3 | let @" = s:wiki_link"
4 | if a:line1 == a:line2
5 | let @" .= "\n"
6 | else
7 | let @" .= "\n" . join(getline(a:line1, a:line2), "\n")
8 | let @" .= "\n"
9 | endif
10 | endfunction
11 |
12 | function! markdown#NumberHeadings()
13 | let l:heading_start_level = 2 " 从2级标题开始编号
14 | let last_level = 0
15 | let l:empty = [0, 0, 0, 0, 0, 0]
16 | let l:count = [0, 0, 0, 0, 0, 0]
17 | execute "normal! gg"
18 | let l:last_line = line("$")
19 | for i in range(1, l:last_line)
20 | let line_text = getline(".")
21 | let line_level = len(matchstr(line_text, '^#\+\s')) - l:heading_start_level
22 | if line_level > 0
23 | if line_level == 1
24 | let l:count = [l:count[0] + 1] + l:empty[1 : 5]
25 | else
26 | let l:count = l:count[0 : line_level - 2] + [l:count[line_level - 1] + 1] + l:empty[line_level + 1 : 5]
27 | endif
28 | " Two Styles:
29 | "
30 | " 1.
31 | " 1.1.
32 | " 1.1.1.
33 | " let number_text = join(l:count[0 : line_level - 1], '.') . '.'
34 | " let line_text = substitute(line_text, '^\(\s*#\+\s*\)\(\(\d\+\.\)*\d\+\. \)\?', '\1', '')
35 | " 1
36 | " 1.1
37 | " 1.1.1
38 | let number_text = join(l:count[0 : line_level - 1], '.')
39 | let line_text = substitute(line_text, '^\(\s*#\+\s*\)\(\d\+\.\)*\d\+\s\+', '\1', '')
40 |
41 | call setline('.', matchstr(line_text, '^\s*#\+') . ' ' . number_text . matchstr(line_text, '^\s*#\+\zs.*'))
42 | endif
43 | execute "normal! j"
44 | endfor
45 | endfunction
46 |
47 | function! markdown#RemoveNumberHeadings()
48 | execute "normal! gg"
49 | let l:last_line = line("$")
50 | for i in range(1, l:last_line)
51 | let line_text = getline(".")
52 | " Two Styles:
53 | "
54 | " 1.
55 | " 1.1.
56 | " 1.1.1.
57 | " let line_text = substitute(line_text, '^\(\s*#\+\s*\)\(\d\+\.\)*\d\+\. ', '\1', '')
58 | " 1
59 | " 1.1
60 | " 1.1.1
61 | let line_text = substitute(line_text, '^\(\s*#\+\s*\)\(\d\+\.\)*\d\+ ', '\1', '')
62 | call setline('.', line_text)
63 | execute "normal! j"
64 | endfor
65 | endfunction
66 |
67 |
--------------------------------------------------------------------------------
/root/.vim/autoload/marks.vim:
--------------------------------------------------------------------------------
1 | sign define marka text='a texthl=Todo
2 | sign define markb text='b texthl=Todo
3 | sign define markc text='c texthl=Todo
4 | sign define markd text='d texthl=Todo
5 | sign define marke text='e texthl=Todo
6 | sign define markf text='f texthl=Todo
7 | sign define markg text='g texthl=Todo
8 | sign define markh text='h texthl=Todo
9 | sign define marki text='i texthl=Todo
10 | sign define markj text='j texthl=Todo
11 | sign define markk text='k texthl=Todo
12 | sign define markl text='l texthl=Todo
13 | sign define markm text='m texthl=Todo
14 | sign define markn text='n texthl=Todo
15 | sign define marko text='o texthl=Todo
16 | sign define markp text='p texthl=Todo
17 | sign define markq text='q texthl=Todo
18 | sign define markr text='r texthl=Todo
19 | sign define marks text='s texthl=Todo
20 | sign define markt text='t texthl=Todo
21 | sign define marku text='u texthl=Todo
22 | sign define markv text='v texthl=Todo
23 | sign define markw text='w texthl=Todo
24 | sign define markx text='x texthl=Todo
25 | sign define marky text='y texthl=Todo
26 | sign define markz text='z texthl=Todo
27 |
28 | " A-Z mark目前不支持在初始化阶段添加sign
29 | sign define markA text='A texthl=Todo
30 | sign define markB text='B texthl=Todo
31 | sign define markC text='C texthl=Todo
32 | sign define markD text='D texthl=Todo
33 | sign define markE text='E texthl=Todo
34 | sign define markF text='F texthl=Todo
35 | sign define markG text='G texthl=Todo
36 | sign define markH text='H texthl=Todo
37 | sign define markI text='I texthl=Todo
38 | sign define markJ text='J texthl=Todo
39 | sign define markK text='K texthl=Todo
40 | sign define markL text='L texthl=Todo
41 | sign define markM text='M texthl=Todo
42 | sign define markN text='N texthl=Todo
43 | sign define markO text='O texthl=Todo
44 | sign define markP text='P texthl=Todo
45 | sign define markQ text='Q texthl=Todo
46 | sign define markR text='R texthl=Todo
47 | sign define markS text='S texthl=Todo
48 | sign define markT text='T texthl=Todo
49 | sign define markU text='U texthl=Todo
50 | sign define markV text='V texthl=Todo
51 | sign define markW text='W texthl=Todo
52 | sign define markX text='X texthl=Todo
53 | sign define markY text='Y texthl=Todo
54 | sign define markZ text='Z texthl=Todo
55 |
56 | function! marks#SignMark(mark)
57 | call sign_unplace(a:mark, {'buffer': bufnr()})
58 | call sign_place(0, a:mark, a:mark, bufnr(), {'lnum': line('.'), 'priority': 20})
59 | endfunction
60 |
--------------------------------------------------------------------------------
/root/.vim/autoload/mergetool_custom.vim:
--------------------------------------------------------------------------------
1 | function mergetool_custom#MergetoolLayoutCallback(split)
2 | if exists('*CocActionAsync')
3 | call CocActionAsync('diagnosticToggleBuffer')
4 | endif
5 | setlocal syntax=off
6 | " disabling gitgutter may not work, so use setlocal signcolumn=no
7 | " call gitgutter#buffer_disable()
8 | setlocal signcolumn=no
9 | endfunction
10 |
11 | function mergetool_custom#Restore()
12 | syntax on
13 | if has("nvim-0.5.0") || has("patch-8.1.1564")
14 | set signcolumn=number " 合并git状态与行号
15 | elseif v:version >= 801
16 | set signcolumn=yes " 同时显示git状态和行号
17 | endif
18 | endfunction
19 |
20 | command -nargs=0 MergetoolRestore call mergetool_custom#Restore()
21 |
--------------------------------------------------------------------------------
/root/.vim/autoload/mycpp.vim:
--------------------------------------------------------------------------------
1 | function! mycpp#FoldExpr(lnum)
2 | let line = getline(a:lnum)
3 | if !exists('b:cpp_fold_level')
4 | let b:cpp_fold_level = 0
5 | let b:last_primitive = ''
6 | endif
7 |
8 | let open_braces = len(split(line, '{', 1)) - 1
9 | let close_braces = len(split(line, '}', 1)) - 1
10 |
11 | if b:last_primitive == 'if'
12 | let b:cpp_fold_level += 1
13 | elseif b:last_primitive == 'end'
14 | let b:cpp_fold_level -= 1
15 | endif
16 | let b:last_primitive = ''
17 |
18 | if line =~ '^\s*#\s*\(ifdef\|ifndef\|if\)' || open_braces > close_braces
19 | let b:cpp_fold_level += 1
20 | let b:last_primitive = 'if'
21 | return b:cpp_fold_level
22 | elseif line =~ '^\s*#\s*\(else\|elif\)' || (open_braces == close_braces && open_braces > 0)
23 | return b:cpp_fold_level - 1
24 | elseif line =~ '^\s*#\s*endif' || close_braces > open_braces
25 | let b:last_primitive = 'end'
26 | let b:cpp_fold_level -= 1
27 | return b:cpp_fold_level
28 | endif
29 |
30 | return b:cpp_fold_level
31 | endfunction
32 |
33 | " VIM学习笔记 自动补全详解(Auto-Completion Detail) - YYQ的文章 - 知乎
34 | " https://zhuanlan.zhihu.com/p/106309525
35 | function! mycpp#CompleteFunc(findstart, base)
36 | if a:findstart
37 | " 确定补全开始的位置
38 | let line = getline('.')
39 | let start = col('.') - 1
40 | while start > 0 && line[start - 1] =~ '\S'
41 | let start -= 1
42 | endwhile
43 | if line[start] != '<' && line[start] != '"'
44 | return -3
45 | endif
46 | return start + 1
47 | endif
48 |
49 | if getline('.') =~# &include
50 | let filetype = &filetype
51 | if filetype == 'cpp' || filetype == 'cuda'
52 | " r! ls -1 /usr/include/c++/13 | awk '{print " \x27"$0"\x27"}' | paste -sd,
53 | let completions = ['algorithm', 'any', 'array', 'atomic', 'backward', 'barrier', 'bit', 'bits', 'bitset', 'cassert', 'ccomplex', 'cctype', 'cerrno', 'cfenv', 'cfloat', 'charconv', 'chrono', 'cinttypes', 'ciso646', 'climits', 'clocale', 'cmath', 'codecvt', 'compare', 'complex', 'complex.h', 'concepts', 'condition_variable', 'coroutine', 'csetjmp', 'csignal', 'cstdalign', 'cstdarg', 'cstdbool', 'cstddef', 'cstdint', 'cstdio', 'cstdlib', 'cstring', 'ctgmath', 'ctime', 'cuchar', 'cwchar', 'cwctype', 'cxxabi.h', 'debug', 'decimal', 'deque', 'exception', 'execution', 'expected', 'experimental', 'ext', 'fenv.h', 'filesystem', 'format', 'forward_list', 'fstream', 'functional', 'future', 'initializer_list', 'iomanip', 'ios', 'iosfwd', 'iostream', 'istream', 'iterator', 'latch', 'limits', 'list', 'locale', 'map', 'math.h', 'memory', 'memory_resource', 'mutex', 'new', 'numbers', 'numeric', 'optional', 'ostream', 'parallel', 'pstl', 'queue', 'random', 'ranges', 'ratio', 'regex', 'scoped_allocator', 'semaphore', 'set', 'shared_mutex', 'source_location', 'span', 'spanstream', 'sstream', 'stack', 'stacktrace', 'stdatomic.h', 'stdexcept', 'stdfloat', 'stdlib.h', 'stop_token', 'streambuf', 'string', 'string_view', 'syncstream', 'system_error', 'tgmath.h', 'thread', 'tr1', 'tr2', 'tuple', 'typeindex', 'typeinfo', 'type_traits', 'unordered_map', 'unordered_set', 'utility', 'valarray', 'variant', 'vector', 'version']
54 | call filter(completions, 'v:val =~ "^" . a:base')
55 | else
56 | let completions = []
57 | endif
58 | " 使用getcompletion()获取文件类型的补全列表
59 | echom a:base
60 | let completions += getcompletion(a:base . '*.h*', 'file_in_path', 1)
61 | let completions += getcompletion(a:base . '*/$', 'file_in_path', 1)
62 | return completions
63 | endif
64 | return []
65 | endfunction
66 |
--------------------------------------------------------------------------------
/root/.vim/autoload/noplug.vim:
--------------------------------------------------------------------------------
1 | function noplug#GetVisualSelection()
2 | " https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript
3 | " Why is this not a built-in Vim script function?!
4 | let [line_start, column_start] = getpos("'<")[1:2]
5 | let [line_end, column_end] = getpos("'>")[1:2]
6 | let lines = getline(line_start, line_end)
7 | if len(lines) == 0
8 | return ''
9 | endif
10 | let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
11 | let lines[0] = lines[0][column_start - 1:]
12 | return join(lines, "\n")
13 | endfunction
14 |
15 | function! noplug#MyRead(file)
16 | " 获取文件大小
17 | let l:size = getfsize(a:file)
18 | " 将文件大小转换为MB
19 | let l:sizeMB = l:size / 1024.0 / 1024.0
20 |
21 | " 检查文件大小是否超过20MB
22 | if l:sizeMB > 20
23 | echo "File size exceeds 20MB. Operation cancelled."
24 | else
25 | " 调用原生的:read命令读取文件
26 | execute 'read ' . a:file
27 | endif
28 | endfunction
29 | function noplug#ToggleQuickfix(list)
30 | if empty(filter(range(1, winnr('$')), 'getwinvar(v:val, "&buftype") == "quickfix"'))
31 | if a:list == 'c'
32 | let height = len(getqflist())
33 | let height = height > 7 ? 7 : height
34 | let height = height < 2 ? 2 : height
35 | exe 'copen ' . height
36 | else
37 | let height = len(getloclist(0))
38 | if height == 0
39 | echom 'empty loclist'
40 | return
41 | endif
42 | let height = height > 7 ? 7 : height
43 | let height = height < 2 ? 2 : height
44 | exe 'lopen ' . height
45 | endif
46 | else
47 | if a:list == 'c'
48 | cclose
49 | else
50 | lclose
51 | endif
52 | endif
53 | endfunction
54 | function s:ShowQuickfixListIfNotEmpty()
55 | let length = len(getqflist())
56 | if length > 1
57 | let height = length > 7 ? 7 : length
58 | exe 'copen ' . height
59 | elseif length == 1
60 | copen
61 | ccl
62 | elseif length == 0
63 | echo 'empty quickfix list'
64 | endif
65 | endfunction
66 |
67 | function noplug#FindWord(word)
68 | if &filetype == 'c' || &filetype == 'cpp' || &filetype == 'cuda'
69 | let l:extension = '**/*.c* **/*.h*'
70 | else
71 | let l:extension = '**/*.' . expand('%:e')
72 | endif
73 | " : 匹配整个单词
74 | exe 'vimgrep /\<'.a:word.'\>/ ' . l:extension
75 | call s:ShowQuickfixListIfNotEmpty()
76 | endfunction
77 |
78 | function noplug#FindType(word)
79 | " : 匹配整个单词
80 | if &filetype == 'cpp' || &filetype == 'c' || &filetype == 'cuda'
81 | exe 'vimgrep' '/\<\(struct\|union\|class\) '.a:word.'\>/' '**/*.c*' '**/*.h*'
82 | elseif &filetype == 'python'
83 | exe 'vimgrep' '/\/' '**/*.py'
84 | elseif &filetype == 'go'
85 | exe 'vimgrep' '/\/' '**/*.go'
86 | else
87 | echo 'unsupport filetype: '.&filetype
88 | return
89 | endif
90 | call s:ShowQuickfixListIfNotEmpty()
91 | endfunction
92 |
93 | function noplug#FindDefinitionFunction(word)
94 | if &filetype == 'cpp' || &filetype == 'c' || &filetype == 'cuda'
95 | exe 'vimgrep' '/\<'.a:word.'\s*(/ **/*.c* **/*.h*'
96 | elseif &filetype == 'python'
97 | exe 'vimgrep' '/\ l:maxsize
127 | return
128 | endif
129 | if !exists("b:backup_dir")
130 | let b:backup_dir = expand("~/.vim/backup") . expand("%:p:h")
131 | if !isdirectory(b:backup_dir)
132 | call mkdir(b:backup_dir, "p", 0700)
133 | endif
134 | endif
135 | call noplug#AsyncRunOrSystem('cp ' . expand('%:p') . ' ' . b:backup_dir . '/' . expand('%:t') . strftime("~~%Y-%m%d-%X") . '.bak')
136 | endfunction
137 |
--------------------------------------------------------------------------------
/root/.vim/autoload/statusline.vim:
--------------------------------------------------------------------------------
1 | vim9script
2 |
3 | export def Left(): string
4 | var result = ''
5 | if !&diff && winwidth(0) > 60
6 | result = ' | '
7 | if exists('*g:FugitiveHead')
8 | const gitbranch = g:FugitiveHead()
9 | if gitbranch != ''
10 | result ..= ' ' .. gitbranch .. ' '
11 | endif
12 | endif
13 | if exists('*coc#status')
14 | # Some functions are too long to put into statusline.
15 | # Please directly echo b:coc_current_function.
16 | result ..= coc#status()
17 | endif
18 | endif
19 | return result
20 | enddef
21 |
22 | export def Right(): string
23 | var result = ''
24 | if !&diff && winwidth(0) > 60 && exists('g:asyncrun_status')
25 | if g:asyncrun_status == 'running'
26 | result ..= ' '
27 | elseif g:asyncrun_status == 'success'
28 | result ..= ' '
29 | elseif g:asyncrun_status == 'failure'
30 | result ..= ' '
31 | endif
32 | result ..= '%l/%L:%v %Y %{&fenc} %{&ff}'
33 | endif
34 | return result
35 | enddef
36 |
--------------------------------------------------------------------------------
/root/.vim/autoload/tagsystem.vim:
--------------------------------------------------------------------------------
1 | " :h gtags-cscope
2 | function tagsystem#GtagsCscopeAdd()
3 | let l:project_root = asyncrun#current_root()
4 | if l:project_root != $HOME && l:project_root != ''
5 | let l:gtags_db = l:project_root . '/GTAGS'
6 | if filereadable(l:gtags_db) && cscope_connection(2, l:gtags_db) == 0
7 | execute 'cs add ' . l:gtags_db
8 | endif
9 | endif
10 | endfunction
11 |
--------------------------------------------------------------------------------
/root/.vim/autoload/timer.vim:
--------------------------------------------------------------------------------
1 | let g:timers = {}
2 |
3 | function s:autoSave(timer)
4 | if &readonly == 0 && &modified == 1
5 | silent write
6 | " echo 'auto saved at ' . strftime('%X')
7 | endif
8 | endfunction
9 |
10 | function timer#startAutoSave()
11 | if !has_key(g:timers, 'auto_save')
12 | let g:timers.auto_save = timer_start(30000, 's:autoSave', {'repeat': -1})
13 | endif
14 | endfunction
15 |
16 | function timer#stopAutoSave()
17 | if has_key(g:timers, 'auto_save')
18 | let timer = g:timers['auto_save']
19 | call timer_stop(timer)
20 | unlet g:timers['auto_save']
21 | endif
22 | endfunction
23 |
--------------------------------------------------------------------------------
/root/.vim/autoload/wsl.vim:
--------------------------------------------------------------------------------
1 | function ConvertWSLPath(uri)
2 | " alternative: wslpath -w
3 | if a:uri =~ '^/mnt/d/'
4 | return substitute(a:uri, '/mnt/d', 'D:', '')
5 | elseif uri =~ '^/mnt/c/'
6 | return substitute(a:uri, '/mnt/c', 'C:', '')
7 | else
8 | return 'file://wsl.localhost/Ubuntu-22.04' . uri
9 | endif
10 | endfunction
11 |
12 | " xdg-open
13 | " cmd.exe /C start "" 需要使用cmd.exe /c mklink创建软链接
14 | " explorer.exe
15 | "
16 | " do not work.
17 | "
18 | " x-www-browser need `update-alternatives --config x-www-browser` to setup default programs.
19 | "
20 | " sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser
21 | "
22 | " Example:
23 | " sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe' 200
24 | " sudo update-alternatives --config x-www-browser
25 | function wsl#BrowserPreview()
26 | if has('nvim')
27 | call jobstart('x-www-browser "' . ConvertWSLPath(expand("%:p")) . '"')
28 | else
29 | call job_start('x-www-browser "' . ConvertWSLPath(expand("%:p")) . '"')
30 | endif
31 | endfunction
32 |
33 | function WSLOpen(uri)
34 | let uri_converted = ConvertWSLPath(a:uri)
35 | if has('nvim')
36 | if uri_converted =~ '\.md$'
37 | call jobstart('x-www-browser "' . uri_converted . '"')
38 | else
39 | call jobstart('cmd.exe /c start "" ' . uri_converted . '')
40 | endif
41 | else
42 | if uri_converted =~ '\.md$'
43 | call job_start('x-www-browser "' . uri_converted . '"')
44 | else
45 | call job_start('cmd.exe /c start "" ' . uri_converted . '')
46 | endif
47 | endif
48 | endfunction
49 |
--------------------------------------------------------------------------------
/root/.vim/autoload/yank.vim:
--------------------------------------------------------------------------------
1 | function yank#YankPathLine()
2 | let current_root = asyncrun#current_root()
3 | let @" = expand('%:p')[len(current_root) + 1:] . ':' . line(".")
4 | endfunction
5 |
6 | function yank#YankPathLineAndContent() range
7 | let current_root = asyncrun#current_root()
8 | let @" = expand('%:p')[len(current_root) + 1:] . ':' . a:firstline
9 | let @" .= "\n" . join(getline(a:firstline, a:lastline), "\n")
10 | endfunction
11 |
12 | function yank#YankGDB() range
13 | " 复制选中的内容到临时变量
14 | let temp_text = getline(a:firstline, a:lastline)
15 | " 通过正则表达式匹配 /path/to/file.ext:linenumber 格式的行
16 | let result_lines = filter(temp_text, 'v:val =~# "[A-Za-z0-9\\-./]\\+:[0-9]\\+"')
17 | " 将结果复制到匿名寄存器中
18 | let l:content = join(result_lines, "\n")
19 | if exists("g:coderepo_dir")
20 | let l:pattern = substitute(g:coderepo_dir . '/', "/", "\\\\/", "g")
21 | let l:content = substitute(l:content, l:pattern, "", "g")
22 | endif
23 | let @" = l:content
24 | endfunction
25 |
26 |
--------------------------------------------------------------------------------
/root/.vim/coc-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "languageserver": {
3 | "cmake": {
4 | "command": "cmake-language-server",
5 | "filetypes": [
6 | "cmake"
7 | ],
8 | "rootPatterns": [
9 | "build/"
10 | ],
11 | "initializationOptions": {
12 | "buildDirectory": "build"
13 | }
14 | },
15 | "ocaml-lsp": {
16 | "command": "opam",
17 | "args": [
18 | "exec",
19 | "--",
20 | "ocamllsp"
21 | ],
22 | "filetypes": [
23 | "ocaml",
24 | "reason"
25 | ]
26 | },
27 | "typst": {
28 | "command": "typst-lsp",
29 | "filetypes": [
30 | "typst"
31 | ]
32 | },
33 | "bash": {
34 | "enable": false,
35 | "command": "bash-language-server",
36 | "args": [
37 | "start"
38 | ],
39 | "filetypes": [
40 | "sh"
41 | ],
42 | "ignoredRootPaths": [
43 | "~"
44 | ]
45 | },
46 | "mlir": {
47 | "command": "mlir-lsp-server",
48 | "filetypes": [
49 | "mlir"
50 | ]
51 | }
52 | },
53 | "coc.preferences.currentFunctionSymbolAutoUpdate": true,
54 | "coc.preferences.currentFunctionSymbolDebounceTime": 500,
55 | "coc.preferences.useQuickfixForLocations": true,
56 | "outline.keepWindow": false,
57 | "clangd.enabled": true,
58 | "html.format.enable": true,
59 | "Lua.format.enable": false,
60 | "ltex.enabled": false,
61 | "python.pythonPath": "/bin/python3",
62 | "python.formatting.provider": "black",
63 | "python.linting.mypyEnabled": false,
64 | "python.linting.pylintEnabled": true,
65 | "pyright.enable": true,
66 | "pyright.testing.provider": "unittest",
67 | "basedpyright.enable": false,
68 | "rust-analyzer.enable": true,
69 | "rust-analyzer.cargo.autoreload": true,
70 | "rust-analyzer.procMacro.enable": true,
71 | "workspace.ignoredFolders": [
72 | "$HOME",
73 | "$HOME/.cargo/**",
74 | "$HOME/.rustup/**"
75 | ],
76 | "go.enable": true,
77 | "go.goplsPath": "/usr/bin/gopls",
78 | "java.enabled": true,
79 | "json.enable": true,
80 | "json.schemaDownload.enable": true,
81 | "marksman.enable": false,
82 | "texlab.latexFormatter": "latexindent",
83 | "coc.source.around.shortcut": "around",
84 | "coc.source.buffer.shortcut": "buffer",
85 | "coc.source.dictionary.enable": true,
86 | "coc.source.dictionary.filetypes": [
87 | "markdown",
88 | "text",
89 | "latex"
90 | ],
91 | "coc.source.dictionary.shortcut": "dict",
92 | "coc.source.word.enable": true,
93 | "coc.source.word.filetypes": [
94 | "markdown",
95 | "text",
96 | "latex"
97 | ],
98 | "coc.source.word.shortcut": "word",
99 | "coc.source.emoji.enable": true,
100 | "coc.source.tag.enable": true,
101 | "coc.source.tag.shortcut": "tag",
102 | "coc.source.ultisnips.shortcut": "snip",
103 | "coc.source.vimtex.enable": true,
104 | "suggest.formatItems": [
105 | "abbr",
106 | "menu",
107 | "kind",
108 | "shortcut"
109 | ],
110 | "explorer.git.enable": false,
111 | "explorer.file.showHiddenFiles": true,
112 | "explorer.icon.enableNerdfont": true,
113 | "session.saveOnVimLeave": true
114 | }
115 |
--------------------------------------------------------------------------------
/root/.vim/config.vim.example:
--------------------------------------------------------------------------------
1 | " vim:ft=vim
2 | " copy this file to config.vim
3 |
4 | let g:ai_suggestion = 'copilot.vim'
5 | " aiproxy (default) | kimichat | 01ai
6 | let g:ai_service = '01ai'
7 | let g:clangd_path = '/usr/bin/clangd'
8 | if has('nvim')
9 | else
10 | set grepprg=rg\ --vimgrep\ -uu
11 | set grepformat=%f:%l:%c:%m
12 | endif
13 |
--------------------------------------------------------------------------------
/root/.vim/configurations/linux/_all/vimspector.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
3 | "configurations": {
4 | "Launch": {
5 | "adapter": "vscode-cpptools",
6 | "filetypes": [ "cpp", "c", "objc", "rust" ],
7 | "configuration": {
8 | "request": "launch",
9 | "program": "${fileBasenameNoExtension}",
10 | "cwd": "${workspaceRoot}",
11 | "args": ["*${CommandLineArgs}"],
12 | "console": "integratedTerminal",
13 | "externalConsole": false,
14 | "MIMode": "gdb"
15 | }
16 | },
17 | "Attach": {
18 | "adapter": "vscode-cpptools",
19 | "filetypes": [ "cpp", "c", "objc", "rust" ],
20 | "configuration": {
21 | "request": "attach",
22 | "program": "hello",
23 | "console": "integratedTerminal",
24 | "externalConsole": false,
25 | "MIMode": "gdb"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/root/.vim/configurations/linux/go/vimspcetor.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
3 | "inputs": [
4 | {
5 | "id": "binaryName",
6 | "type": "promptString",
7 | "description": "Enter the binary name to debug."
8 | }
9 | ],
10 | "configurations": {
11 | "run": {
12 | "adapter": "delve",
13 | "default": true,
14 | "configuration": {
15 | "request": "launch",
16 | "program": "${file}",
17 | "cwd": "${workspaceRoot}",
18 | "args": [
19 | "*${CommandLineArgs}"
20 | ],
21 | "console": "integratedTerminal",
22 | "stopOnEntry": true
23 | },
24 | "breakpoints": {
25 | "exception": {
26 | "raised": "N",
27 | "uncaught": "",
28 | "userUnhandled": ""
29 | }
30 | }
31 | },
32 | "launch-binary": {
33 | "adapter": "delve",
34 | "default": true,
35 | "configuration": {
36 | "request": "launch",
37 | "program": "${workspaceRoot}/bin/${input:binaryName}",
38 | "cwd": "${workspaceRoot}",
39 | "args": [
40 | "*${CommandLineArgs}"
41 | ],
42 | "mode": "exec",
43 | "console": "integratedTerminal",
44 | "stopOnEntry": true
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/root/.vim/configurations/linux/java/vimspcetor.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
3 | "adapters": {
4 | "java-debug-server": {
5 | "name": "vscode-java",
6 | "port": "${AdapterPort}"
7 | }
8 | },
9 | "configurations": {
10 | "Java Attach": {
11 | "default": true,
12 | "adapter": "java-debug-server",
13 | "configuration": {
14 | "request": "attach",
15 | "host": "127.0.0.1",
16 | "port": "5005"
17 | },
18 | "breakpoints": {
19 | "exception": {
20 | "caught": "N",
21 | "uncaught": "N"
22 | }
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/root/.vim/configurations/linux/python/vimspcetor.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
3 | "configurations": {
4 | "run": {
5 | "adapter": "debugpy",
6 | "default": true,
7 | "configuration": {
8 | "request": "launch",
9 | "program": "${file}",
10 | "cwd": "${workspaceRoot}",
11 | "args": ["*${CommandLineArgs}"],
12 | "console": "integratedTerminal",
13 | "stopOnEntry": true
14 | },
15 | "breakpoints": {
16 | "exception": {
17 | "raised": "N",
18 | "uncaught": "",
19 | "userUnhandled": ""
20 | }
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/root/.vim/doc/clean-disk.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *clean-disk*
3 |
4 | rust ~
5 | cargo install cargo-cache
6 | cargo-cache -a
7 |
8 | ocaml ~
9 | opam clean
10 |
11 | go ~
12 | go clean -cache
13 |
14 | 系统 ~
15 | 寻找当前文件夹下最大的10个文件目录
16 | >bash
17 | du -Sh . | sort -rh | head -n10
18 | du -h --max-depth=1 | sort -hr | head -n 10
19 | <
20 |
21 | *$XDG_CACHE_HOME* 默认为`$HOME/.cache`,可以按需修改。
22 |
23 | *WSL2设置自动清理磁盘空间*
24 | >
25 | wsl --manage Ubuntu-22.04 --set-sparse true
26 | <
27 | https://devblogs.microsoft.com/commandline/windows-subsystem-for-linux-september-2023-update/#automatic-disk-space-clean-up-set-sparse-vhd
28 |
29 | 如果不是sparese disk,可以手动使用diskpart清理
30 | https://stackoverflow.com/questions/70946140/docker-desktop-wsl-ext4-vhdx-too-large
31 | >
32 | diskpart
33 | select vdisk file="D:\wsl2\ext4.vhdx"
34 | compact vdisk
35 | <
36 | |docker|
37 |
--------------------------------------------------------------------------------
/root/.vim/doc/coc-nvim.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *coc-nvim.txt* *coc.nvim*
3 |
4 | -------------------------------------------------------
5 | 自v0.15.0后,coc-list替代了mksession.vim
6 |
7 | *基于coc-list保存会话session* :Mksession
8 | *基于coc-list加载会话session* :Loadsession
9 |
10 | -------------------------------------------------------
11 | coc.nvim插件 ~
12 |
13 | coc-snippets 不如coc-ultisnips配合UltiSnips插件好用
14 |
15 | coc-git => gitgutter lazygit
16 |
17 | coc-pairs => auto-pairs插件暂时不需要auto-pair补全
18 | other sources: https://github.com/neoclide/coc-sources
19 | Reference: https://github.com/neoclide
20 |
21 | 语法类插件(不好用):coc-grammarly
22 |
23 | |clangd|
24 | 可以使用coc.nvim自带的支持(:CocConfig添加languageserver配置),也可以下载coc-clangd插件(clangd.enabled: true),两者不能同时使用
25 |
26 | coc-marksman: 需要在根目录放一份.marksman.toml
27 |
28 | coc-codegeex: Aminer的代码片段生成器,暂时不可用
29 |
30 | coc-ltex: latex语法检查
31 |
32 | coc-emoji: 会卡顿,使用Leaderf emoji
33 | coc-word, coc-dictionary: 会卡顿,使用 CTRL-X CTRL-K 或者`:Dictionary`
34 |
--------------------------------------------------------------------------------
/root/.vim/doc/code.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *code-search* *novimrc* *noplugged*
3 |
4 | 打开历史文件 ~
5 | |:oldfiles| 查看oldfiles
6 | |c_#<|
7 | `:command #
9 | :e #<3
10 | <
11 | 打开第3个历史文件
12 |
13 | 查找文本 ~
14 | :vim /func main/ **/*.txt
15 | :grep def foo.py
16 | :grep 'def foo' foo.py
17 | 全字匹配
18 | :grep -w def foo.py
19 |
20 | 文件内case insensitive search
21 | /\chello
22 |
23 | 使用grep ~
24 | `grep 'func main' -r --exclude tags .`
25 | `grep 'func main' ~/hello.go` 查找~/hello.go文件中的func main
26 | `grep -i` 忽略大小写
27 | `grep -w` 全字匹配
28 |
29 | 使用ripgrep ~
30 | 可以添加.rgignore/.ignore文件, 用于忽略文件
31 | 设置|grepprg|为rg
32 | >
33 | set grepprg=rg\ --vimgrep
34 | <
35 |
36 | 查找文件 ~
37 | >
38 | :find **/*.py
39 | <
40 | 按Tab键自动补全
41 |
42 | `find . -name 'scheduler*.py'`
43 | `find -type f` 查找文件
44 | `find -type d` 查找目录
45 |
46 | 使用fd ~
47 | 可以添加.fdignore/.ignore文件, 用于忽略文件
48 | https://github.com/sharkdp/fd
49 |
50 | 其它 ~
51 | `tldr find`
52 | `tldr grep`
53 |
54 | |tagsystem|
55 |
56 | -------------------------------------------------------------------------------
57 | |ctags|
58 |
59 | 创建tags
60 | ctags -R .
61 |
62 | :ta main
63 | CTRL-]
64 |
65 | 其它 :h tags
66 |
67 | -------------------------------------------------------------------------------
68 | |gtags|
69 |
70 | :set csprg=gtags-cscope
71 |
72 | 创建gtags数据库
73 | gtags
74 |
75 | vim连接数据库
76 | :cs add GTAGS
77 |
78 | 使用其它前端解析(注意.globalrc配置文件, 可以从/etc/gtags.conf, /etc/gtags/gtags.conf复制)
79 | pip install pygments
80 | GTAGSLABEL=pygments gtags
81 | GTAGSLABEL=native-pygments gtags
82 |
83 | 查找文件
84 | :cs f f hello
85 | 查找符号
86 | :cs f s main
87 |
88 | 也可以用`:cstag `命令查找符号
89 |
90 | -------------------------------------------------------------------------------
91 | |coc.nvim|
92 |
93 | cmake可以在不执行编译的情况下生成compile_commands.json文件
94 |
95 | -------------------------------------------------------------------------------
96 | 代码质量检查 ~
97 |
98 | https://www.sonarsource.com/
99 |
100 | -------------------------------------------------------------------------------
101 | 文档生成 ~
102 |
103 | doxygen https://www.doxygen.nl/
104 | -------------------------------------------------------------------------------
105 | 补全
106 | See: complete.md
107 |
108 | ===============================================================================
109 | NOTE: 搭环境考验
110 |
111 | 大型单文件考验 ~
112 |
113 | 4万行的Oceanbase单源文件。
114 |
115 | https://github.com/oceanbase/oceanbase/blob/develop/src/rootserver/ob_ddl_service.cpp
116 |
117 | 据Vscode用户描述
118 |
119 | - clangd可能会非常慢(显示diagnostic可能需要2-3分钟以上)
120 | - 某些重命名功能可能会失败
121 | - clangd重命名功能可能要等1-2分钟,或者coredump
122 | - 机器内存不够可能导致clangd coredump
123 |
124 | 或许需要选择性关闭某些功能。
125 |
126 | 寻找大文件的方法: `find . -type f -size +1M`
127 |
128 | 40核kiwi服务器,128GB内存:
129 | - 第一次下载依赖文件,编译项目花费19分钟
130 | - clangd索引构建11:08~12:02,花了近一小时
131 | - 重命名功能报错
132 | - clangd: -32001: The number of affected files exceeds the max limit 50
133 | - `:Far ObTableSchema ObTableSchema222 src/**/*.cpp src/**/*.h` 运行1~2秒,但 `:Far ObTableSchema ObTableSchema222 src/**/*.*` 会卡顿很久
134 | - `:Rg` 很快
135 |
136 |
--------------------------------------------------------------------------------
/root/.vim/doc/collaboration.txt:
--------------------------------------------------------------------------------
1 | vim:set ft=help:
2 |
3 | *collaboration*
4 |
5 | Based on ssh, tmux ~
6 | https://hamvocke.com/blog/remote-pair-programming-with-tmux/
7 | https://iagoleal.com/posts/tmux-pair-programming/
8 | https://github.com/zolrath/wemux
9 |
10 | Shared terminal ~
11 | https://tmate.io/
12 |
13 | (Neo)Vim plugins ~
14 | https://github.com/FredKSchott/CoVim
15 | https://github.com/jbyuki/instant.nvim/wiki/Technical-Overview
16 |
17 |
18 | Microsoft Visual Studio Live Share ~
19 | https://visualstudio.microsoft.com/zh-hans/services/live-share/
20 | https://github.com/microsoft/live-share/issues/3020
21 |
22 | Jetbrains Code With Me ~
23 | https://www.jetbrains.com/code-with-me/
24 |
25 | Zed Collaboration ~
26 | https://zed.dev/docs/collaboration
27 |
28 | Other Business Solutions ~
29 | https://www.codetogether.com/
30 | https://github.com/Floobits (Inactive)
31 |
32 | Technique ~
33 |
34 | realtime-collaboration.md
35 |
36 | *operational-transformation*
37 | https://en.wikipedia.org/wiki/Operational_transformation
38 | *sharedb*
39 | https://github.com/share/sharedb
40 |
41 | *CRDT*
42 | https://crdt.tech/implementations
43 | 探秘前端 CRDT 实时协作库 Yjs 工程实现 - doodlewind的文章 - 知乎
44 | https://zhuanlan.zhihu.com/p/452980520
45 | 对可多人协同编辑的在线编辑器,如何设计其 undo/redo 的逻辑? - 知乎
46 | https://www.zhihu.com/question/367915946
47 | 协同编辑领域是否存在 CRDT 取代 OT 的趋势? - 知乎
48 | https://www.zhihu.com/question/510215494
49 | 8-Conflict-Free Replicated Data Type(CRDT) - Cookie.Z的文章 - 知乎
50 | https://zhuanlan.zhihu.com/p/580094985
51 | 富文本 CRDT crdt-richtext 开源啦 - 陈子轩的文章 - 知乎
52 | https://zhuanlan.zhihu.com/p/629580388
53 |
54 | https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type
55 |
56 | https://en.wikipedia.org/wiki/Collaborative_real-time_editor
57 |
58 | *automerge*
59 | https://automerge.org/
60 |
61 | *yjs*
62 | https://github.com/yjs/yjs
63 | https://github.com/y-crdt
64 |
65 | *yorkie*
66 | https://github.com/yorkie-team/yorkie
67 | https://yorkie.dev/examples/codemirror
68 |
69 | 文档协作 ~
70 |
71 | 语雀 飞书 腾讯文档 Notion Affine
72 |
--------------------------------------------------------------------------------
/root/.vim/doc/complete.md:
--------------------------------------------------------------------------------
1 | ## omnicomplete
2 |
3 | 在没有插件的情况下,Vim 提供了一些基础的代码自动补全选项。其中最常用的可能是 Omnicomplete 和关键字补全。
4 |
5 | 1. **Omnicomplete(全能补全)**: Omnicomplete 可以对诸如 C/C++, Python, Java 等编程语言进行上下文相关的补全。使用 ``(按住 `Ctrl` 键然后依次按 `x` 和 `o`)来触发 Omnicomplete。
6 |
7 | 2. **关键字补全**: 使用 `` 和 `` 可以进行关键字补全。这个功能会查找当前打开的所有文件,找到与你已经键入的文本匹配的单词。
8 |
9 | 3. **行补全**: 使用 `` 可以补全整行。这在编写具有重复模式的代码时非常有用。
10 |
11 | 4. **文件名补全**: `` 可以用来补全文件名。
12 |
13 | 5. **字典补全**: 通过在 `.vimrc` 文件中设置字典,你可以使用 `` 来进行字典补全。
14 |
15 | 6. **标签补全**: 如果你有一个标签文件(通常由 `ctags` 程序生成),你可以使用 `` 来进行标签补全。
16 |
17 | 例如,在 `.vimrc` 中为 Python 设置 Omnicomplete:
18 |
19 | ```vim
20 | autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
21 | ```
22 |
23 | 虽然 Vim 的内建补全功能相对较弱,但是它们是可用的,并且在没有插件的情况下也能提供一定程度的自动补全支持。如果你需要更高级的功能,那通常需要依赖外部插件,比如 `YouCompleteMe` 或 `Coc.nvim`。
24 |
25 |
26 | `filetype plugin on` 通常是启用 Omnicomplete(全能补全)所需的。这个设置不仅激活 Vim 的文件类型检测机制,还启用了针对各种文件类型的插件,这其中就包括 Omnicomplete 功能。
27 |
28 | 在你的 `.vimrc` 文件里,你可能会看到这样的设置:
29 |
30 | ```vim
31 | filetype plugin on
32 | ```
33 |
34 | 或者更全面地:
35 |
36 | ```vim
37 | filetype plugin indent on
38 | ```
39 |
40 | 这样也会启用针对不同文件类型的自动缩进。
41 |
42 | 设置了 `filetype plugin on` 之后,Vim 会根据当前文件的类型来加载相应的插件。这些插件通常会设置一些特定于该文件类型的行为,比如补全函数、语法高亮等。对于像 Python 这样的编程语言,这通常也会设置一个适当的 `omnifunc`(全能补全函数),从而使得 `` 可以工作。
43 |
44 | 所以,如果你想用 Omnicomplete,确保在 `.vimrc` 文件中启用了 `filetype plugin on` 是一个好主意。
45 |
46 | ## completefunc thesaurusfunc和omnicomplete
47 |
48 | 在Vim中,`completefunc`、`thesaurusfunc`和`omnifunc`是三种不同的补全功能,它们提供了不同的补全机制和用途。以下是每种功能的概述和它们之间的主要区别:
49 |
50 | ### 1. `completefunc` (或称为`'completefunc'`)
51 |
52 | - **用途**:`completefunc`是用户定义的补全函数,通常用于实现特定类型的补全,例如基于项目或文件类型的自定义补全逻辑。它不依赖于Vim的内置补全机制,而是允许用户通过脚本自定义补全行为。
53 | - **触发方式**:通过按下``(在插入模式下)手动触发,或者通过脚本自动触发。
54 | - **自定义性**:高。用户可以完全自定义补全逻辑和数据来源。
55 |
56 | ### 2. `thesaurusfunc` (或称为`'thesaurusfunc'`)
57 |
58 | - **用途**:`thesaurusfunc`是用户定义的查找同义词的函数,主要用于在编辑文本时查找词汇的同义词。这个功能特别适合写作和编辑任务,帮助用户寻找词汇的变体或替代词。
59 | - **触发方式**:通常通过特定的命令或快捷键触发(如用户自定义的命令或快捷键),并不像`completefunc`或`omnifunc`那样直接与代码补全集成。
60 | - **自定义性**:非常高。用户需要提供完整的同义词查找逻辑,包括如何检索和显示同义词。
61 |
62 | ### 3. `omnifunc` (或称为`'omnifunc'`)
63 |
64 | - **用途**:`omnifunc`提供了一种上下文相关的补全机制,主要用于编程语言的语法和代码补全。Vim本身或通过插件可以为不同的编程语言提供`omnifunc`,以支持变量名、函数名等的自动补全。
65 | - **触发方式**:通过按下``(在插入模式下)手动触发。许多现代Vim配置和IDE风格插件也可能提供更自动化的触发方式。
66 | - **自定义性**:中等。虽然`omnifunc`通常由插件或Vim的语言支持提供,但用户仍然可以指定自定义的函数来覆盖默认行为或增加对新语言的支持。
67 |
68 | **总结**:这三种补全函数各有其用途和特点。`completefunc`提供了一种完全自定义的补全机制,适用于特定的补全需求;`thesaurusfunc`专注于文本编辑中的同义词查找;而`omnifunc`则是为编程和代码编辑提供上下文相关的补全功能。用户可以根据具体的编辑需求和偏好来选择和配置这些功能。
69 |
--------------------------------------------------------------------------------
/root/.vim/doc/data-science.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 |
3 | *data-science* *data-wrangling*
4 |
5 | Vscode Data Wrangler plugin
6 |
7 | Jupyter Lab
8 |
9 | *quarto*
10 | Quarto®: an open-source scientific and technical publishing system built on Pandoc.
11 | - next generation of R Markdown
12 |
13 | marimo: jupyter notebook竞品 https://github.com/marimo-team/marimo
14 |
--------------------------------------------------------------------------------
/root/.vim/doc/draw.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *draw.txt*
3 |
4 | ===============================================================================
5 |
6 | *drawio*
7 | 在Windows宿主机中安装,wsl2中使用
8 |
9 | See: $DOC2/academic/draw.md
10 |
11 | *ppt*
12 |
13 | WSL2中可以使用`ppt2pdf.sh` 将Microsoft PowerPoint自动转为PDF。
14 | 自动化脚本难以直接转svg,可以用`pdf2svg`工具转换,也可以在PowerPoint中全选所有对
15 | 象, 右击“另存为图片”转换。但这两种转换方式均无法用drawio重新编辑。
16 |
17 | 其它绘图工具 ~
18 |
19 | inkspace
20 |
--------------------------------------------------------------------------------
/root/.vim/doc/golang.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 |
3 | *golang.txt*
4 |
5 | LSP
6 |
7 | 1. `godef`:godef 是 Go 语言的一个老工具,可以快速找到定义的位置。它的优点是简单快捷,但缺点是功能相对单一,不支持如代码提示、重构和诊断等功能。
8 | 2. `guru`:guru 提供了更多高级功能,如查找所有引用、查找接口实现等。然而,它的使用相对更复杂,也需要更多的计算资源。
9 | 3. `gopls`:gopls 是 Go 团队发布的官方语言服务器,功能最为全面,包括代码自动完成、查找定义、重构、诊断等。由于是官方工具,与最新的 Go 语言特性和改动的兼容性也最好。然而,它可能会比较消耗计算资源。
10 |
11 | 现在来看,`gopls`可能是最全面且最实用的选择。作为官方的 Go 语言服务器,它可以提供全面的 IDE 功能,并且可以完全兼容最新的 Go 语言特性。然而,如果你只需要一些简单的功能,比如快速查找定义,那么`godef`可能就足够了。而`guru`则介于两者之间,提供了一些更高级的功能,但也更复杂一些。
12 |
13 | golangci-lint
14 |
15 | https://github.com/daixiang0/gci
16 |
--------------------------------------------------------------------------------
/root/.vim/doc/http-proxy.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 |
3 | *http-proxy*
4 |
5 | WSL启动http proxy server ~
6 |
7 | *squid*
8 | apt install squid
9 | /etc/squid/squid.conf配置文件中,找到 >
10 | http_access deny all
11 | <
12 | 改为
13 | http_access allow all
14 | <
15 |
16 | 运行squid:
17 |
18 | squid --foreground
19 | 或者
20 | sudo systemctl start squid
21 |
22 | http转发到能连外网的跳板机 ~
23 |
24 | 在跳板机中后台(tmux)执行
25 | >
26 | ssh -NR 3128:localhost:3128 kiwi
27 | <
28 |
29 | http转发到个人电脑 ~
30 |
31 | 假设目标机器为kiwi-nf,跳板机为cherry01,个人电脑启动squid,端口号为3128.
32 | 服务器http proxy也转发到3128
33 | >
34 | Host kiwi-nf
35 | HostName 10.208.130.1
36 | User jiangyinzuo
37 | Port 3527
38 | # 防止长时间断连
39 | ServerAliveInterval 60
40 | # ProxyJump grape
41 | ProxyJump cherry01
42 | # 服务器端口:本地端口
43 | RemoteForward 3128 localhost:3128
44 | <
45 |
46 | Warning: remote port forwarding failed for listen port 3128 ~
47 | >
48 | sudo netstat -tulnp | grep 3128
49 | <
50 | 找到占用端口的进程(可能是之前的ssh异常退出),然后kill
51 |
52 | 查看日志
53 | sudo tail -f /var/log/squid/access.log
54 | sudo tail -f /var/log/squid/cache.log
55 |
56 | bash环境变量 ~
57 |
58 | export http_proxy=http://localhost:3128
59 | export https_proxy=http://localhost:3128
60 |
61 | apt源 ~
62 |
63 | /etc/apt/apt.conf.d/proxy.conf
64 |
65 | >
66 | # modified by jiangyinzuo 2023/12/12
67 | Acquire::http::Proxy "http://localhost:3128";
68 | Acquire::https::Proxy "http://localhost:3128";
69 | <
70 |
71 | |docker设置http代理|
72 |
73 | pip http代理 ~
74 |
75 | pip3 install pandas --proxy=localhost:3128
76 |
77 | Java Maven ~
78 |
79 | https://maven.apache.org/guides/mini/guide-proxies.html
80 |
81 | ~/.m2/settings.xml
82 | >xml
83 |
84 |
85 |
86 | example-proxy
87 | true
88 | http
89 | localhost
90 | 3128
91 |
92 |
93 |
94 | <
95 |
--------------------------------------------------------------------------------
/root/.vim/doc/linux/centos.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *centos*
3 | ===================================================================
4 | *yum*
5 |
6 | yum whatprovides */lspci 查看包含 lspci 的软件包
7 | yum clean all 清除所有缓存
8 | yum makecache 重新构建缓存
9 |
10 | 2024年6月30日,CentOS 7停止服务后, mirrorlist.centos.org无法访问
11 |
12 | - http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container
13 |
14 | 解决方法:更换阿里云镜像 https://www.bilibili.com/read/cv36141293/?jump_opus=1
15 |
16 | >bash
17 | http_proxy=http://localhost:3128 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
18 | yum clean all # 清除所有缓存
19 | yum makecache # 重新构建缓存
20 | <
21 |
22 | Transaction check error ~
23 |
24 | `yum update` 报错
25 | >
26 | Transaction check error:
27 | Unknown error during transaction test in RPM
28 |
29 | Error Summary
30 | -------------
31 | <
32 |
33 | 解决方法:Unknown error,没有指出明确的依赖错误,试试 `sudo yum update`
34 |
35 | ===================================================================
36 | CentOS 7 安装新版软件
37 |
38 | scl: Setup and run software from Software Collection environment
39 |
40 | gcc: *devtoolset* / conda
41 | >bash
42 | sudo yum install devtoolset-11
43 | scl enable devtoolset-11 bash
44 | # 退出scl环境
45 | exit
46 | <
47 | git: https://www.endpointdev.com/blog/2021/12/installing-git-2-on-centos-7/
48 |
49 | ===================================================================
50 | CentOS 7重新分区 ~
51 |
52 | See also: ~/.vim/doc/linux/filesystem.md
53 |
54 | 增加/home分区大小,减小/分区大小
55 |
56 | 要备份 `/home` 分区的数据并重新创建文件系统,然后恢复数据,您可以按照以下步骤操作:
57 |
58 | 1. 备份数据
59 |
60 | 使用 `xfsdump` 工具备份 `/home` 分区。确保您有足够的空间来存储备份文件。
61 | >bash
62 | sudo yum install xfsdump
63 | xfsdump -f /path/to/backup/file /home
64 | <
65 |
66 | 这里的 `/path/to/backup/file` 是您存放备份文件的路径,确保该路径有足够的空间。
67 |
68 | 2. 卸载 `/home` 分区:
69 |
70 | 在进行任何操作之前,您需要卸载 `/home` 分区。
71 | >bash
72 | umount /home
73 | <
74 |
75 | 3. 缩小`/home` 分区
76 |
77 | 使用 `lvreduce` 命令减小 `/home` 分区的大小。请小心操作,因为这可能会导致数据丢失。
78 | >bash
79 | lvreduce -L 10G /dev/mapper/centos-home
80 | <
81 |
82 | 这里将 `/home` 分区缩小到 10GB。请确保您有足够的空间来容纳缩小后的分区。
83 |
84 | 4. 扩展 `root` 分区
85 |
86 | 使用 `lvextend` 命令扩展 `root` 分区,使用 `/home` 分区释放出来的空间。
87 | >bash
88 | lvextend -l +100%FREE /dev/mapper/centos-root
89 | <
90 |
91 | 5. 重新创建 `/home` 分区的文件系统
92 |
93 | 缩小分区后,您需要重新创建 `/home` 分区的文件系统。
94 | >bash
95 | mkfs.xfs -f /dev/mapper/centos-home
96 | <
97 |
98 | 6. 恢复数据
99 |
100 | 重新挂载 `/home`分区,并使用 `xfsrestore` 工具恢复之前备份的数据。
101 | >bash
102 | mount /home
103 | xfsrestore -f /path/to/backup/file /home
104 | <
105 |
106 | 7. 更新 `/etc/fstab`
107 | 如果 `/home` 分区的 UUID 发生了变化,您需要更新 `/etc/fstab` 文件中的相应条目。
108 |
109 | 8. 验证:
110 | 最后,您可以使用 `df -h` 命令来验证分区大小是否已经按照您的预期进行了调整。
111 |
112 | 请注意,这些步骤涉及到的数据操作可能会导致数据丢失,因此在执行之前一定要确保已经备份了所有重要数据。另外,这些操作需要 root 权限。如果您不确定如何操作,或者没有信心完成这些步骤,可能需要寻求专业的系统管理员帮助。
113 |
114 | 修改Hostname ~
115 |
116 | >bash
117 | sudo hostnamectl set-hostname 新的主机名
118 | <
119 |
120 | 添加用户 ~
121 |
122 | >bash
123 | sudo useradd $username
124 | sudo passwd $username
125 | # 添加到sudo组
126 | sudo usermod -aG wheel $username
127 | <
128 |
--------------------------------------------------------------------------------
/root/.vim/doc/linux/filesystem.md:
--------------------------------------------------------------------------------
1 | ## XFS对比EXT4
2 |
3 | http://xiaqunfeng.cc/2017/07/06/XFS-vs-EXT4/
4 |
5 | ## LVM,Logical Volume Manager,逻辑卷管理器
6 |
7 | 在 Linux 系统中,LVM(Logical Volume Manager,逻辑卷管理器)是一种用于管理硬盘驱动器的灵活方式,它允许系统管理员以更灵活和动态的方式来处理存储空间。LVM 通过将物理硬盘组合成卷组(Volume Groups),然后将卷组分割成逻辑卷(Logical Volumes),从而提供了一系列优点。
8 |
9 | ### LVM 的主要组件包括:
10 |
11 | 1. **物理卷(Physical Volumes, PVs)**:
12 | - 物理卷是 LVM 分区中的最小单位,可以是整个硬盘或者硬盘上的一个分区。物理卷是实际存储数据的地方。
13 |
14 | 2. **卷组(Volume Groups, VGs)**:
15 | - 卷组是由两个或更多物理卷组成的集合,它们被组合在一起以提供更大的存储池。卷组跨越一个或多个物理硬盘,提供了一个统一的存储空间。
16 |
17 | 3. **逻辑卷(Logical Volumes, LVs)**:
18 | - 逻辑卷是卷组中的一块区域,它被格式化并挂载以供文件系统使用。逻辑卷是用户实际使用的存储空间,可以被视为一个独立的硬盘。逻辑卷可以动态地调整大小,而不影响数据和文件系统。
19 |
20 | ### LVM 的优点:
21 |
22 | 1. **灵活性**:
23 | - 可以轻松地调整逻辑卷的大小,而不需要重新分区或复制数据。
24 |
25 | 2. **可扩展性**:
26 | - 可以在线添加更多硬盘到卷组中,以扩展存储空间。
27 |
28 | 3. **性能**:
29 | - 可以通过将数据分散到多个物理硬盘上来提高性能。
30 |
31 | 4. **数据保护**:
32 | - LVM 支持快照功能,可以创建逻辑卷的即时副本,用于备份和恢复。
33 |
34 | 5. **简化管理**:
35 | - 通过集中管理卷组和逻辑卷,简化了存储管理。
36 |
37 | ### LVM 的操作命令:
38 |
39 | - **创建物理卷**:
40 | ```bash
41 | pvcreate /dev/sdb1
42 | ```
43 |
44 | - **创建卷组**:
45 | ```bash
46 | vgcreate myvg /dev/sdb1
47 | ```
48 |
49 | - **创建逻辑卷**:
50 | ```bash
51 | lvcreate -L 10G -n mylv myvg
52 | ```
53 |
54 | - **格式化逻辑卷**:
55 | ```bash
56 | mkfs.ext4 /dev/myvg/mylv
57 | ```
58 |
59 | - **挂载逻辑卷**:
60 | ```bash
61 | mount /dev/myvg/mylv /mnt/mylv
62 | ```
63 |
64 | - **调整逻辑卷大小**:
65 | ```bash
66 | lvextend -L +5G /dev/myvg/mylv
67 | ```
68 |
69 | - **缩小逻辑卷**:
70 | ```bash
71 | lvreduce -L 5G /dev/myvg/mylv
72 | ```
73 |
74 | LVM 提供了一种高级的存储管理解决方案,适用于需要灵活和可扩展存储的服务器和工作站。
75 |
76 | ## XFS 文件系统和 LVM
77 |
78 | XFS 文件系统在 LVM 管理下是可以动态调整大小的,但是这种调整是单向的,即只能增加不能减少。这意味着,您可以很容易地使用 `lvextend` 和 `xfs_growfs` 命令来增加逻辑卷和文件系统的大小,但是不能缩小它们。
79 |
80 | 要增加 XFS 文件系统的大小,您可以按照以下步骤操作:
81 |
82 | 1. 确保有足够的空间在卷组中,您可以使用 `vgs` 命令查看卷组的可用空间。
83 | 2. 使用 `lvextend` 命令来增加逻辑卷的大小,例如:`lvextend -L +sizeG /dev/mapper/vg-lv`。
84 | 3. 然后,使用 `xfs_growfs` 命令来扩展文件系统以使用新分配的空间,例如:`xfs_growfs /dev/mapper/vg-lv`。
85 |
86 | 然而,如果您需要减小 XFS 文件系统的大小,这将涉及到更复杂的过程,因为 XFS 不支持在线缩小。您将需要:
87 |
88 | 1. 备份数据。
89 | 2. 卸载文件系统。
90 | 3. 使用 `lvreduce` 命令减小逻辑卷的大小(请注意,这可能会破坏数据)。
91 | 4. 重新格式化逻辑卷,这将删除所有数据:`mkfs.xfs /dev/mapper/vg-lv`。
92 | 5. 恢复数据(如果之前有备份)。
93 |
94 |
--------------------------------------------------------------------------------
/root/.vim/doc/linux/linux.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *linux*
3 |
4 | --------------------------------------------------------------------------
5 | Linux发行版 ~
6 |
7 | Ubuntu 18.04和CentOS 7 对应
8 | Ubuntu 22.04和CentOS 9 对应 (见OceanBase安装依赖脚本 d714ba809a438602eb6d7b47e9d95c769fd21d93)
9 |
10 | --------------------------------------------------------------------------
11 | *trace工具*
12 | `ktrace`, `ptrace`, 和 `strace` 都是与跟踪和监控系统调用和进程执行相关的工具,但它们适用于不同的操作系统和有着不同的用途。
13 |
14 | ktrace ~
15 | `ktrace` 是在某些类Unix操作系统上,特别是BSD系统(如FreeBSD、OpenBSD等)中使用的一个工具。它能够跟踪和记录内核和用户空间程序之间的交互,包括系统调用、信号传递等。通过`ktrace`,开发者可以理解程序是如何与操作系统交互的,这对于调试和性能分析非常有用。`ktrace` 生成的跟踪输出通常通过 `kdump` 命令以人类可读的形式查看。
16 |
17 | ptrace ~
18 | `ptrace` 是一个Unix和类Unix操作系统的系统调用,允许一个进程观察和控制另一个进程的执行,以及读写其内存和寄存器。它是许多调试工具和系统监控工具背后的底层机制。`ptrace` 提供了一种手段来实现断点、单步执行以及在运行时检查和改变CPU寄存器和内存地址的能力。它是实现像 gdb 这样的调试器的核心功能之一。
19 |
20 | strace ~
21 | `strace` 是在Linux和一些其他类Unix系统上用于监控进程系统调用和接收到的信号的工具。它对于理解程序如何与操作系统交云以及诊断运行时问题非常有帮助。`strace` 工作在用户空间,无需特殊的内核模块或支持。它利用了 `ptrace` 系统调用来实现其功能,通过拦截和记录系统调用,可以帮助开发者和系统管理员分析程序行为和性能问题。
22 |
23 | 总结来说,`ktrace`、`ptrace`和`strace`都是强大的工具,用于分析和调试程序与操作系统之间的交互。它们分别在不同的系统和场景下使用,但目的相似,都是为了提供对程序执行的深入了解。
24 | --------------------------------------------------------------------------
25 | *sudo保留用户当前环境变量* `sudo -E`
26 | *sudo从stdin读取密码,防止脚本被sudo输密码暂停* `echo "mypassword" | sudo -S `
27 |
28 | Linux修改他人用户名 ~
29 |
30 | *linux-user*
31 |
32 | 在Linux中修改他人的用户名涉及到管理员权限。这通常通过使用命令行实现。以下是修改用户名的步骤:
33 |
34 | 1. 登录为root用户 或者 使用具有sudo权限的用户。
35 |
36 | 2. 确保要修改的用户没有运行的进程。您可以使用 `pkill` 命令结束所有由该用户运行的进程,例如:
37 | >
38 | sudo pkill -u oldusername
39 | <
40 | 或者确保该用户已注销或未运行任何进程。
41 |
42 | 3. 使用`usermod`命令来修改用户名。基本的命令结构是:
43 | >
44 | sudo usermod -l newusername oldusername
45 | <
46 | 这里 `-l` 参数用于更改用户的登录名。
47 |
48 | 4. (可选)更改用户的主目录名称。如果您也想更改用户的主目录以匹配新的用户名,可以使用:
49 | >
50 | sudo usermod -d /home/newusername -m newusername
51 | <
52 | 这里 `-d` 参数用于指定新的主目录,而 `-m` 参数将移动旧主目录中的文件到新目录。
53 |
54 | 5. (可选)更改用户的邮件目录。如果系统使用邮件服务,并且每个用户都有一个邮件目录,那么您可能还需要更新这个目录的名称。
55 |
56 | 6. 检查与旧用户名相关的所有配置和权限设置,并进行必要的更新。
57 |
58 | 请注意,更改用户名可能会影响到用户的配置和权限。建议在执行这些操作之前做好备份,并检查所有与用户相关的服务和应用程序。在生产环境中,此类更改应谨慎进行,以避免任何不必要的服务中断。
59 |
60 | *给他人添加sudo权限*
61 |
62 | >
63 | sudo usermod -aG sudo username
64 | <
65 |
66 | *查看sudo组的成员*
67 |
68 | >
69 | getent group sudo
70 | <
71 |
72 | 手动创建误删除的home目录 ~
73 |
74 | >bash
75 | sudo mkdir /home/username
76 | sudo chown username:username /home/username
77 | sudo chmod 700 /home/username
78 | <
79 |
80 | 打开 `/etc/passwd` 文件,查看对应用户的home目录是否正确。
81 |
82 | 查看进程 ~
83 |
84 | >bash
85 | # 查看当前用户的进程
86 | ps
87 | # 查看所有进程
88 | ps -ef
89 | <
90 |
91 | 增加动态链接库查找路径 ~
92 |
93 | *LD_LIBRARY_PATH*
94 | >bash
95 | export LD_LIBRARY_PATH=/your/custom/path:$LD_LIBRARY_PATH
96 | <
97 |
--------------------------------------------------------------------------------
/root/.vim/doc/linux/ubuntu.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *ubuntu*
3 |
4 | ===============================================================================
5 | *ubuntu查看版本号*
6 | cat /etc/os-release
7 |
8 | ===============================================================================
9 | *apt*
10 |
11 | 配置国内镜像。位于`/etc/apt/sources.list`或者`/etc/apt/sources.list.d/ubuntu.sources`
12 | http://mirrors.aliyun.com/ubuntu/
13 | http://repo.huaweicloud.com/ubuntu/
14 |
15 | apt update失败,ModuleNotFoundError: No module named 'apt_pkg'
16 | 和python3升级有关
17 |
18 | >
19 | sudo apt install python3-apt
20 | # Ubuntu18.04 默认python为3.6版本
21 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
22 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
23 | # 使用此命令切换python3指定的版本
24 | update-alternatives --config python3
25 | <
26 | ————————————————
27 | 版权声明:本文为CSDN博主「-Lanausee-」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
28 | 原文链接:https://blog.csdn.net/StillOnMyWay/article/details/114492675
29 |
30 | *aptitude*
31 | aptitude是apt的一个前端,功能更强大,可以用来解决apt的依赖问题,但可能给出卸载软件的建议
32 |
33 | The following packages have unmet dependencies 依赖问题 ~
34 |
35 | 可能是私加ppa源导致的,可以尝试在`/etc/apt/sources.list.d`删除ppa源,然后更新apt源`sudo apt dist-clean`, `sudo apt update`
36 |
37 | -------------------------------------------------------------------------------
38 |
39 | apt配置代理服务器 在`/etc/apt/apt.conf` 或者 `/etc/apt/apt.conf.d/proxy.conf`中添加
40 | >
41 | Acquire::http::Proxy "http://proxy_server:proxy_port";
42 | <
43 |
44 | 访问PPA添加第三方apt源 http://ppa.launchpad.net/jonathonf/vim/ubuntu
45 |
46 | 添加PPA, 导入GPG密钥
47 | >
48 | sudo add-apt-repository ppa:jonathonf/vim
49 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4AB0F789CBA31744CC7DA76A8CF63AD3F06FC659
50 | <
51 |
52 | 手动添加PPA源
53 | >
54 | sudo vim /etc/apt/sources.list.d/jonathonf-vim.list
55 | <
56 | >
57 | deb http://ppa.launchpad.net/jonathonf/vim/ubuntu YOUR_UBUNTU_VERSION_HERE main
58 | deb-src http://ppa.launchpad.net/jonathonf/vim/ubuntu YOUR_UBUNTU_VERSION_HERE main
59 | <
60 |
61 | 手动添加apt-key: curl失效时,可以尝试 *wget* 或直接浏览器访问
62 | http://keyserver.ubuntu.com 查询
63 | >
64 | wget -O - http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x4AB0F789CBA31744CC7DA76A8CF63AD3F06FC659 | sudo apt-key add -
65 | <
66 |
67 | ===============================================================================
68 | *snap* 设置http proxy
69 | >
70 | sudo snap set system proxy.http="http://localhost:3128"
71 | sudo snap set system proxy.https="http://localhost:3128"
72 | <
73 |
74 | ===============================================================================
75 | *ubuntu升级*
76 |
77 | >
78 | do-release-upgrade
79 | <
80 |
81 | 手工清理source list,保证`sudo apt update`不报错
82 | 更新重启后,ssh端口配置变为默认值22
83 |
84 | Your python3 install is corrupted
85 | >
86 | sudo ln -fs /usr/bin/python3.6 /usr/bin/python3
87 | <
88 |
89 | devel版本升级时,apt依赖可能会出一些bug,比如依赖xxxt64库,实际安装xxx库,并报错apt源中没有xxxt64库
90 | ,第二天更新apt源,发现问题被修复
91 |
92 | ===============================================================================
93 | *font设置* *fc-cache*
94 |
95 | 中文字体
96 | https://source.typekit.com/source-han-serif/cn/
97 |
98 | 手动安装方式:
99 |
100 | 可以将字体文件复制到~/.local/share/fonts(推荐,仅限当前用户使用)或/usr/share/fonts(系统级别,所有用户均可使用)目录下。之后,运行以下命令更新字体缓存:
101 | >
102 | fc-cache -fv
103 | <
104 |
105 | locale 语言环境改为zh_CN.UTF-8 ~
106 |
107 | 可以让|sort|按照中文拼音顺序排序
108 |
109 | https://www.cnblogs.com/BillyLV/p/12658463.html
110 |
111 | `locale -a`: 查看支持的字符集。
112 |
113 | 安装zh_CN.UTF-8
114 | >bash
115 | sudo apt-get install -y language-pack-zh-hans
116 | <
117 |
118 | 临时修改
119 | >bash
120 | export LANG=zh_CN.UTF-8
121 | <
122 |
123 | 永久修改
124 | >bash
125 | localectl set-locale LANG=zh_CN.UTF8
126 | <
127 | 或编辑`/etc/locale.conf`, `/etc/default/locale`文件, 并reboot重启系统
128 |
--------------------------------------------------------------------------------
/root/.vim/doc/luajit.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 | *luajit*
3 |
4 | lua not enough memory
5 |
6 | LUA jit的垃圾回收只能管理2GB内存。即使一台服务器上有N个进程,
7 | 这N个进程之间总共也只能有2GB内存。
8 |
9 | CentOS 7 默认的luajit存在2GB内存限制。
10 |
11 | 2016年,luajit官方发布了GC64模式,上限可达128TB。
12 | https://www.jianshu.com/p/e6912de3059f
13 |
--------------------------------------------------------------------------------
/root/.vim/doc/mongodb.txt:
--------------------------------------------------------------------------------
1 | *mongodb*
2 |
3 | Docker镜像 ~
4 | https://hub.docker.com/_/mongo
5 |
6 | docker pull mongo
7 |
8 | MongoDB官网上的
9 | docker pull mongodb/mongodb-community-server
10 | 速度太慢
11 |
12 | 创建容器 ~
13 | docker run --name some-mongo -v /usr3/jiangyinzuo_data/mongodata:/data/db -p 27017:27017 -d mongo
14 |
--------------------------------------------------------------------------------
/root/.vim/doc/neovim.txt:
--------------------------------------------------------------------------------
1 | *neovim.txt*
2 |
3 | Toggle lsp diagnostic auto floating window *:LspFloatToggle*
4 |
5 | Enable lsp diagnostic auto floating window *g:nvim_lsp_diagnostic_enable_auto_floating_window*
6 |
--------------------------------------------------------------------------------
/root/.vim/doc/nodejs.txt:
--------------------------------------------------------------------------------
1 | *nodejs*
2 |
3 | coc.nvim, copilot.vim depend on nodejs.
4 |
5 | Installation ~
6 |
7 | - Ubuntu18.04: https://github.com/nodesource/distributions#debian-and-ubuntu-based-distributions
8 | - https://github.com/tj/n
9 | - https://github.com/nvm-sh/nvm
10 | - https://github.com/neoclide/coc.nvim
11 |
--------------------------------------------------------------------------------
/root/.vim/doc/objdump.txt:
--------------------------------------------------------------------------------
1 | vim:ft=help
2 |
3 | *objdump.txt*
4 |
5 | 检查一个 C 语言编译得到的动态链接库(在 Windows 中通常是 `.dll` 文件,在 Linux 或 macOS 中是 `.so` 或 `.dylib` 文件)中是否包含某个特定函数 ~
6 |
7 | 在 Windows 上 ~
8 |
9 | 1. 使用 `dumpbin` 工具:
10 | - `dumpbin` 是 Visual Studio 提供的一个工具,可以用来显示二进制文件(包括 DLL)的信息。
11 | - 使用 `dumpbin /exports yourlibrary.dll` 命令来查看 DLL 中所有导出的符号,其中包括函数名。这个命令会列出所有导出的函数,你可以在输出中搜索你的函数名。
12 |
13 | 2. 使用 `Dependency Walker`(depends.exe):
14 | - 这是一个图形界面工具,可以用来查看 DLL 中的所有导出和导入的函数。
15 | - 打开你的 DLL 文件,查看 "Exports" 标签页中列出的函数。
16 |
17 | 在 Linux 或 macOS 上 ~
18 |
19 | 1. 使用 `nm` 工具:
20 | - 打开终端,使用命令 `nm -D yourlibrary.so` 或 `nm -g yourlibrary.dylib` 来查看动态链接库中的符号。
21 | - 使用 `grep` 命令可以帮助你快速搜索特定的函数名,例如 `nm -D yourlibrary.so | grep your_function_name`。
22 |
23 | 2. 使用 `objdump` 工具:
24 | - 使用命令 `objdump -T yourlibrary.so` 可以显示动态链接库中所有的符号,包括函数。
25 | - 同样可以使用 `grep` 来搜索特定的函数名。
26 |
27 | 这些工具可以帮助你验证 DLL 或 SO 文件中是否包含特定的函数。在 Windows 上,如果你没有安装 Visual Studio,你可能需要下载 `Dependency Walker`。在 Linux 或 macOS 上,`nm` 和 `objdump` 通常已经包含在大多数发行版中。
28 |
--------------------------------------------------------------------------------
/root/.vim/doc/palette.txt:
--------------------------------------------------------------------------------
1 | *smile* :smile
2 | *intro* :intro
3 | *cd当前文件所在目录* :cd %:h
4 | *cd到项目根目录* :Cd
5 | *搜索当前buffer的LSP-symbol-outline(nvim)* :Telescope lsp_document_symbols
6 | *显示当前buffer的LSP-symbol-outline(nvim)* :SymbolsOutline
7 | *搜索当前buffer的LSP-symbol-outline(vim)* :CocList outline
8 | *查看coc-symbol-outline* :CocOutline
9 | *Vista查看outline* :Vista coc
10 | *Coc搜索当前插件* :CocList extensions
11 | *FZF-Vim命令* :Commands
12 | *Vim命令* :command
13 | *FZF-搜索所有buffers* :Buffers
14 | *FZF-选择git-commits* :Commits
15 | *FZF-选择maps* :Maps
16 | *vim-查看map* :map
17 | *vim-查看tmap* :tmap
18 | *FZF-查看helptags* :Helptags
19 | *vim-helpgrep* :helpgrep
20 | *在新标签页(tab)中创建终端* :tab ter
21 | *执行复制到默认寄存器中的命令(:h-:@)* :@"
22 | *Save-with-sudo* :w !sudo tee %
23 | *另存为* :w foo.txt
24 | *当前行作为vim-command执行* :exe getline('.')
25 | *关闭preview窗口* :pc
26 | *查看当前文件名* :f
27 | *关闭其它所有windows* :only
28 | *关闭其它所有标签页(tab)* :tabonly
29 | *clang-format当前文件* :%!clang-format
30 | *跳转到第一行* gg
31 | *跳转到之前的位置* ``
32 | *跳转到函数头* [[
33 | *高亮当前word,跳转到下一个word* *
34 | *高亮当前word,跳转到上一个word* #
35 | *+1* :exe "normal \"
36 | *-1* :exe "normal \"
37 | *开启自动保存(vim)* :call timer#startAutoSave()
38 | *关闭自动保存(vim)* :call timer#stopAutoSave()
39 | *neovim打开dap调试界面* :DapContinue
40 | *leaderf通过rg搜索所有c文件* :Leaderf rg -g *.c
41 | *leaderf通过rg全字匹配* :Leaderf rg -w 'func main'
42 | *leaderf通过rg大小写敏感* :Leaderf rg -s
43 | *leaderf通过rg搜索,不使用正则表达式* :Leaderf rg -F
44 | *tab分隔的表格转md-table* :'<,'>!tab2table.py
45 | *查看某个option是在什么位置设置的* :verbose set