This commit is contained in:
subcrip 2024-07-29 18:06:36 +08:00
parent 6a6a24b560
commit c42dd6b9bf
Signed by: subcrip
SSH Key Fingerprint: SHA256:dFPFi68d8C87YkFkEBU4TkcrYRySWpekRR1hbnDWUCw
9 changed files with 433 additions and 341 deletions

4
.zshrc
View File

@ -115,11 +115,13 @@ source $ZSH/oh-my-zsh.sh
alias python="python3"
alias pip3="python3 -m pip"
alias pip="python -m pip"
alias comp="cd ~/RustIsBestLang/src/bin && nvim"
alias comp="cd ~/CompetitiveProgramming/src/bin && nvim"
alias upgrade="yay --noconfirm --overwrite '*' && nix-channel --update && home-manager switch && brew upgrade && flatpak update -y && rustup update && pipx upgrade-all"
alias backup="git add . && git commit -S -m 'backup' && git push"
export LD_LIBRARY_PATH=/home/user/.local/lib/mojo:$LD_LIBRARY_PATH
export PATH=/home/user/.modular/pkg/packages.modular.com_mojo/bin/:/home/user/.npm-packages/bin:/home/user/.cabal/bin:/home/user/.ghcup/bin:/home/linuxbrew/.linuxbrew/bin:/home/user/.cargo/bin:/home/user/.local/bin:/usr/local/cuda/bin:$PATH
export PAGER=less
export EDITOR=nvim
me () {
md "$@" && cd "$@"

View File

@ -27,3 +27,6 @@ cp $HOME/.config/home-manager . -r
# NPM
cp $HOME/.npmrc .
# LF
cp $HOME/.config/lf . -r

View File

@ -23,19 +23,41 @@
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
pkgs.mtr
# Install contour through Flatpak instead.
# pkgs.contour
# Editor
pkgs.neovim
pkgs.htop
pkgs.python312
pkgs.pyright
pkgs.nodejs_22
pkgs.pipx
pkgs.fx
pkgs.gdb
pkgs.lua-language-server
pkgs.cmake-language-server
pkgs.helix
pkgs.zed-editor
# Tools
pkgs.btop
pkgs.fx
pkgs.mtr
pkgs.htop
pkgs.gdb
# Python
(pkgs.python312.withPackages (ps: with ps; [
]))
pkgs.pyright
pkgs.pipx
# Node
pkgs.nodejs_22
# Waybar
pkgs.waybar
pkgs.waybar-mpris
pkgs.zed-editor
# Misc
pkgs.lf # Terminal file manager
# pkgs.smassh # Typing test
pkgs.you-get # YouTube video downloader
pkgs.asciinema # Record terminal sessions
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
@ -88,12 +110,4 @@
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.helix = {
enable = true;
};
programs.btop = {
enable = true;
};
}

4
lf/lfrc Normal file
View File

@ -0,0 +1,4 @@
set icons
set number
set relativenumber
set hidden

View File

@ -23,19 +23,19 @@
"eslint.nvim": { "branch": "main", "commit": "158f2289907d377018752fcfe0d61b746dc11767" },
"feline.nvim": { "branch": "master", "commit": "3587f57480b88e8009df7b36dc84e9c7ff8f2c49" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"fzf-lua": { "branch": "main", "commit": "fb058bd718aabe9a5abb3e9df3d5c1023d06cdae" },
"fzf-lua": { "branch": "main", "commit": "769b6636af07ea4587e6c06067d8fe9fb0629390" },
"git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" },
"gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" },
"gitsigns.nvim": { "branch": "main", "commit": "f074844b60f9e151970fbcdbeb8a2cd52b6ef25a" },
"goto-preview": { "branch": "main", "commit": "1519ea3512828c944eed5b2bbb66a8f8deb92447" },
"haskell-vim": { "branch": "master", "commit": "f35d02204b4813d1dbe8b0e98cc39701a4b8e15e" },
"heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" },
"hlargs.nvim": { "branch": "main", "commit": "cc0d9ee75e5ffba730393049119361b9e3a5b1b6" },
"hop.nvim": { "branch": "master", "commit": "036462a345792279c58f2f6445756efab706f04a" },
"indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
"lazy.nvim": { "branch": "main", "commit": "9a374a0fb4d3ac42dac4a129d4bead7252473c77" },
"lazydev.nvim": { "branch": "main", "commit": "02f1055a777264d4b65896051ec28d0f322f7932" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" },
"leetcode.nvim": { "branch": "master", "commit": "02fb2c855658ad6b60e43671f6b040c812181a1d" },
"legendary.nvim": { "branch": "master", "commit": "0705f207ba79ee3c687fc77c451faeeb4828d5ad" },
"legendary.nvim": { "branch": "master", "commit": "543bbbba4e7b54222362f312e1d2e3dac1eaae75" },
"listish.nvim": { "branch": "master", "commit": "3bc4bb02036f3802c6428c6232633d3192ac3604" },
"lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" },
"lspkind.nvim": { "branch": "master", "commit": "67ec67c68f05ca41dab0d426c9e7c94ad86085f9" },
@ -43,35 +43,35 @@
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"markdown-toc.nvim": { "branch": "main", "commit": "75eabbdcb921f402b2e5b476e1a797a1004cdeaa" },
"marks.nvim": { "branch": "master", "commit": "74e8d01b2a2131b6e46354cffc553aa7f81bcf5b" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "58bc9119ca273c0ce5a66fad1927ef0f617bd81b" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"melange-nvim": { "branch": "master", "commit": "800490ee87ce3e1b4afe751ff81f2864cb01937d" },
"mini.nvim": { "branch": "main", "commit": "23669ab7abc2cd10f9a5166de07400bb34eaecda" },
"mini.nvim": { "branch": "main", "commit": "e24ec1fcf885990fec1a993fe8304a033fd1806d" },
"modicator.nvim": { "branch": "main", "commit": "d1d327fd4bdfc3af4cfdf83b85c2eaefa71de7a8" },
"neogit": { "branch": "master", "commit": "af1d8d88f426a4da63c913f3b81a37350dbe8d02" },
"none-ls.nvim": { "branch": "main", "commit": "2cde745aadc2c36f6860a77a556494870675771a" },
"neogit": { "branch": "master", "commit": "2b74a777b963dfdeeabfabf84d5ba611666adab4" },
"none-ls.nvim": { "branch": "main", "commit": "a8594ef3dabb484adabc0ebbf5800be1b807c9e7" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" },
"nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" },
"nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
"nvim-colorizer.lua": { "branch": "master", "commit": "08bd34bf0ed79723f62764c7f9ca70516d461d0d" },
"nvim-lspconfig": { "branch": "master", "commit": "e26da408cf955afa8e9ddbadd510e84ea8976cd7" },
"nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" },
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
"nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-numbertoggle": { "branch": "main", "commit": "c5827153f8a955886f1b38eaea6998c067d2992f" },
"nvim-origami": { "branch": "main", "commit": "5d6b63bab5406e439937b04fc4ead201ba8dc88f" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "4e387dd47833c1bb8c8df6c3a7cab0d4c55583f3" },
"nvim-treesitter": { "branch": "master", "commit": "2b4881286ad73c9ece7e5e4da130b2e4726c09fc" },
"nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
"nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"oil.nvim": { "branch": "master", "commit": "9e5eb2fcd1dfee2ff30c89273ffff179e42034b9" },
"nvim-web-devicons": { "branch": "master", "commit": "a2af6aa13a2ad3ad361d562a319a91bcd68c43a4" },
"oil.nvim": { "branch": "master", "commit": "71c972fbd218723a3c15afcb70421f67340f5a6d" },
"outline.nvim": { "branch": "main", "commit": "2175b6da5b7b5be9de14fd3f54383a17f5e4609c" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" },
"render-markdown": { "branch": "main", "commit": "5e4e33102b784353998c83d57dbacea4db71d55b" },
"render-markdown": { "branch": "main", "commit": "b75f681d675e21b5a09909997e9fffa6313c946e" },
"search.nvim": { "branch": "main", "commit": "27191f6c10a13c8018136b2490342d35960ed0ab" },
"sg.nvim": { "branch": "master", "commit": "8bdd4d19da2268072708d5fe18fda9c23e16509d" },
"smart-open.nvim": { "branch": "0.2.x", "commit": "87626ee8748b9bba22093adec7bb58c63e7214f0" },
@ -84,9 +84,9 @@
"telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" },
"todo-comments.nvim": { "branch": "main", "commit": "96fee098a90e7c09c9811aa7df71d773ba8b9b53" },
"trouble.nvim": { "branch": "main", "commit": "ad8ef38666834e9e438f84bd446657445bc2a71e" },
"twilight.nvim": { "branch": "main", "commit": "38dc017474ef05605ca14a2577e01e09f0db7133" },
"todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" },
"vim-cursorword": { "branch": "master", "commit": "34852083276c1fd9ff4cccaf052111e7d5a2472e" },
"vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" },
@ -94,6 +94,6 @@
"vim-prosession": { "branch": "master", "commit": "4b8323d4e9b74afe9132a34b2d7ea6cfa9461550" },
"vim-visual-multi": { "branch": "master", "commit": "38b0e8d94a5499ccc17d6159763d32c79f53417b" },
"vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" },
"vim-wakatime": { "branch": "master", "commit": "d72aac70fcee172413f89621b65b5383bd845e4b" },
"which-key.nvim": { "branch": "main", "commit": "6e61b0904e9c038b6c511c43591ae2d811b4975e" }
"vim-wakatime": { "branch": "master", "commit": "53bba6bb8342de9cbdafc82142a9b5e82008d858" },
"which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }
}

View File

@ -557,14 +557,16 @@ local has_words_before = function()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local is_empty_line = function()
unpack = unpack or table.unpack
local line, _ = unpack(vim.api.nvim_win_get_cursor(0))
return vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:match("%S") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local ELLIPSIS_CHAR = ''
local MAX_LABEL_WIDTH = 20
local MIN_LABEL_WIDTH = 20
cmp.setup {
snippet = {
expand = function(args)
@ -574,7 +576,11 @@ cmp.setup {
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if not is_empty_line() then
cmp.confirm({ select = true })
else
fallback()
end
elseif luasnip_status and luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then

View File

@ -288,3 +288,15 @@ ls.add_snippets(nil, {
}
})
local lca = require('snippets.lca')
ls.add_snippets(nil, {
cpp = {
snip({
trig = 'lca',
namr = 'lca',
dscr = 'LCA',
},{
text(lines(lca))
})
}
})

50
nvim/lua/snippets/lca.lua Normal file
View File

@ -0,0 +1,50 @@
return [=[
struct LCA {
vector<int> depth;
vector<vector<int>> pa;
LCA(const vector<vector<int>>& g, int root = 1) {
int n = g.size() - 1;
int m = 32 - __builtin_clz(n);
depth.resize(n + 1);
pa.resize(n + 1, vector<int>(m, -1));
function<void(int, int)> dfs = [&](int x, int fa) {
pa[x][0] = fa;
for (int y: g[x]) {
if (y != fa) {
depth[y] = depth[x] + 1;
dfs(y, x);
}
}
};
dfs(root, 0);
for (int i = 0; i < m - 1; i++)
for (int x = 1; x <= n; x++)
if (int p = pa[x][i]; p != -1)
pa[x][i + 1] = pa[p][i];
}
int get_kth_ancestor(int node, int k) {
for (; k; k &= k - 1)
node = pa[node][__builtin_ctz(k)];
return node;
}
int query(int x, int y) {
if (depth[x] > depth[y])
swap(x, y);
y = get_kth_ancestor(y, depth[y] - depth[x]);
if (y == x)
return x;
for (int i = pa[x].size() - 1; i >= 0; i--) {
int px = pa[x][i], py = pa[y][i];
if (px != py) {
x = px;
y = py;
}
}
return pa[x][0];
}
};
]=]

View File

@ -187,7 +187,7 @@
},
"custom/waybar-mpris": {
"return-type": "json",
"exec": "waybar-mpris --position --autofocus --order 'SYMBOL:TITLE:ARTIST:POSITION'",
"exec": "waybar-mpris --position --autofocus --order 'SYMBOL:POSITION:TITLE:ARTIST'",
"on-click": "waybar-mpris --send toggle",
// This option will switch between players on right click.
"on-click-right": "waybar-mpris --send player-next",
@ -198,6 +198,7 @@
// "on-scroll-up": "waybar-mpris --send next",
// "on-scroll-down": "waybar-mpris --send prev",
"escape": true,
"max-length": 50,
},
"custom/clock": {
"exec": "LC_TIME=en_US.UTF8 date +'%-m-%-d[%a] %H:%M'",