diff options
Diffstat (limited to 'configs')
33 files changed, 1091 insertions, 0 deletions
diff --git a/configs/Microsoft.PowerShell_profile.ps1 b/configs/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..aeced5f --- /dev/null +++ b/configs/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,35 @@ +function Use-VC { + param( + [Parameter()] + [ValidateSet('x64', 'x86')] + $Arch = 'x64' + ) + + if ($Arch -eq 'x86') { + $p = 'x86'; + } + else { + $p = 'amd64' + } + + cmd /c "`"$(vswhere.exe -format value -property installationPath)\VC\Auxiliary\Build\vcvars64.bat`" $p & set" | + ForEach-Object { + if ($_ -match '=') { + $v = $_ -split '=' + Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])" + } + } + Pop-Location + Write-Host "Visual Studio Command Prompt variables set." -ForegroundColor Yellow +} + + +function Set-Proxy { + $env:http_proxy = "http://127.0.0.1:2080" + $env:https_proxy = "http://127.0.0.1:2080" +} + +function Reset-Proxy { + Remove-Item env:http_proxy + Remove-Item env:https_proxy +} diff --git a/configs/bruno/ComfyUI/Get Object Info.bru b/configs/bruno/ComfyUI/Get Object Info.bru new file mode 100644 index 0000000..d1a833c --- /dev/null +++ b/configs/bruno/ComfyUI/Get Object Info.bru @@ -0,0 +1,11 @@ +meta { + name: Get Object Info + type: http + seq: 4 +} + +get { + url: {{BASE_URL}}/object_info + body: none + auth: none +} diff --git a/configs/bruno/ComfyUI/Get Prompt History.bru b/configs/bruno/ComfyUI/Get Prompt History.bru new file mode 100644 index 0000000..2e26888 --- /dev/null +++ b/configs/bruno/ComfyUI/Get Prompt History.bru @@ -0,0 +1,15 @@ +meta { + name: Get Prompt History + type: http + seq: 6 +} + +get { + url: {{BASE_URL}}/history/{{prompt_id}} + body: none + auth: none +} + +vars:pre-request { + prompt_id: 7e345a55-21c4-4bdc-9b34-add561775144 +} diff --git a/configs/bruno/ComfyUI/Post Prompt.bru b/configs/bruno/ComfyUI/Post Prompt.bru new file mode 100644 index 0000000..09bf89a --- /dev/null +++ b/configs/bruno/ComfyUI/Post Prompt.bru @@ -0,0 +1,124 @@ +meta { + name: Post Prompt + type: http + seq: 5 +} + +post { + url: {{BASE_URL}}/prompt + body: json + auth: none +} + +body:json { + { + "client_id": "crupest", + "prompt": { + "3": { + "inputs": { + "seed": 156680208700286, + "steps": 20, + "cfg": 8, + "sampler_name": "euler", + "scheduler": "normal", + "denoise": 1, + "model": [ + "4", + 0 + ], + "positive": [ + "6", + 0 + ], + "negative": [ + "7", + 0 + ], + "latent_image": [ + "5", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "4": { + "inputs": { + "ckpt_name": "SUPIR/SUPIR-v0Q.ckpt" + }, + "class_type": "CheckpointLoaderSimple", + "_meta": { + "title": "Load Checkpoint" + } + }, + "5": { + "inputs": { + "width": 512, + "height": 512, + "batch_size": 1 + }, + "class_type": "EmptyLatentImage", + "_meta": { + "title": "Empty Latent Image" + } + }, + "6": { + "inputs": { + "text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", + "clip": [ + "4", + 1 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Prompt)" + } + }, + "7": { + "inputs": { + "text": "text, watermark", + "clip": [ + "4", + 1 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Prompt)" + } + }, + "8": { + "inputs": { + "samples": [ + "3", + 0 + ], + "vae": [ + "4", + 2 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "9": { + "inputs": { + "filename_prefix": "ComfyUI", + "images": [ + "8", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + } + } + } +} diff --git a/configs/bruno/ComfyUI/Upload Image.bru b/configs/bruno/ComfyUI/Upload Image.bru new file mode 100644 index 0000000..92b4aeb --- /dev/null +++ b/configs/bruno/ComfyUI/Upload Image.bru @@ -0,0 +1,18 @@ +meta { + name: Upload Image + type: http + seq: 2 +} + +post { + url: {{BASE_URL}}/upload/image + body: multipartForm + auth: none +} + +body:multipart-form { + overwrite: true + type: input + subfolder: crupest-test + image: @file(/Users/crupest/codes/crupest/assets/crupest-transparent.png) +} diff --git a/configs/bruno/ComfyUI/View Image.bru b/configs/bruno/ComfyUI/View Image.bru new file mode 100644 index 0000000..395eccd --- /dev/null +++ b/configs/bruno/ComfyUI/View Image.bru @@ -0,0 +1,19 @@ +meta { + name: View Image + type: http + seq: 1 +} + +get { + url: {{BASE_URL}}/view?filename=crupest-transparent.png&type=input&subfolder=crupest-test&preview=jpeg;90&channel=rgb + body: none + auth: none +} + +query { + filename: crupest-transparent.png + type: input + subfolder: crupest-test + preview: jpeg;90 + channel: rgb +} diff --git a/configs/bruno/ComfyUI/bruno.json b/configs/bruno/ComfyUI/bruno.json new file mode 100644 index 0000000..ee35540 --- /dev/null +++ b/configs/bruno/ComfyUI/bruno.json @@ -0,0 +1,9 @@ +{ + "version": "1", + "name": "ComfyUI", + "type": "collection", + "ignore": [ + "node_modules", + ".git" + ] +}
\ No newline at end of file diff --git a/configs/bruno/ComfyUI/environments/ChimerAI ComfyUI Server.bru b/configs/bruno/ComfyUI/environments/ChimerAI ComfyUI Server.bru new file mode 100644 index 0000000..480c8da --- /dev/null +++ b/configs/bruno/ComfyUI/environments/ChimerAI ComfyUI Server.bru @@ -0,0 +1,3 @@ +vars:secret [ + BASE_URL +] diff --git a/configs/crupest-winget.json b/configs/crupest-winget.json new file mode 100644 index 0000000..df2e7d9 --- /dev/null +++ b/configs/crupest-winget.json @@ -0,0 +1,104 @@ +{
+ "$schema" : "https://aka.ms/winget-packages.schema.2.0.json",
+ "CreationDate" : "2024-10-31T18:34:15.174-00:00",
+ "Sources" :
+ [
+ {
+ "Packages" :
+ [
+ {
+ "PackageIdentifier" : "7zip.7zip"
+ },
+ {
+ "PackageIdentifier" : "Docker.DockerDesktop"
+ },
+ {
+ "PackageIdentifier" : "Git.Git"
+ },
+ {
+ "PackageIdentifier" : "Mozilla.Firefox"
+ },
+ {
+ "PackageIdentifier" : "Mozilla.Thunderbird"
+ },
+ {
+ "PackageIdentifier" : "VideoLAN.VLC"
+ },
+ {
+ "PackageIdentifier" : "vim.vim"
+ },
+ {
+ "PackageIdentifier" : "Neovim.Neovim"
+ },
+ {
+ "PackageIdentifier" : "OpenJS.NodeJS"
+ },
+ {
+ "PackageIdentifier" : "voidtools.Everything"
+ },
+ {
+ "PackageIdentifier" : "Neovide.Neovide"
+ },
+ {
+ "PackageIdentifier" : "Microsoft.PowerShell"
+ },
+ {
+ "PackageIdentifier" : "Kitware.CMake"
+ },
+ {
+ "PackageIdentifier" : "JetBrains.PyCharm.Community"
+ },
+ {
+ "PackageIdentifier" : "Tencent.QQ.NT"
+ },
+ {
+ "PackageIdentifier" : "Tencent.WeChat"
+ },
+ {
+ "PackageIdentifier" : "Python.Launcher"
+ },
+ {
+ "PackageIdentifier" : "NetEase.CloudMusic"
+ },
+ {
+ "PackageIdentifier" : "agalwood.Motrix"
+ },
+ {
+ "PackageIdentifier" : "BurntSushi.ripgrep.MSVC"
+ },
+ {
+ "PackageIdentifier" : "Microsoft.VisualStudio.Locator"
+ },
+ {
+ "PackageIdentifier" : "Ninja-build.Ninja"
+ },
+ {
+ "PackageIdentifier" : "Rufus.Rufus"
+ },
+ {
+ "PackageIdentifier" : "Rustlang.Rustup"
+ },
+ {
+ "PackageIdentifier" : "Python.Python.3.13"
+ },
+ {
+ "PackageIdentifier" : "Microsoft.PowerToys"
+ },
+ {
+ "PackageIdentifier" : "Microsoft.VisualStudioCode"
+ },
+ {
+ "PackageIdentifier" : "Microsoft.WinDbg"
+ }
+ ],
+ "SourceDetails" :
+ {
+ "Argument" : "https://cdn.winget.microsoft.com/cache",
+ "Identifier" : "Microsoft.Winget.Source_8wekyb3d8bbwe",
+ "Name" : "winget",
+ "Type" : "Microsoft.PreIndexed.Package"
+ }
+ }
+ ],
+ "WinGetVersion" : "1.9.2411-preview"
+}
\ No newline at end of file diff --git a/configs/magic/extend-script.js b/configs/magic/extend-script.js new file mode 100644 index 0000000..519cee9 --- /dev/null +++ b/configs/magic/extend-script.js @@ -0,0 +1,21 @@ +// Define main function (script entry) + +function main(config, profileName) { + delete config.dns; + delete config.tun; + delete config.hosts; + + delete config["cfw-latency-timeout"] + delete config["cfw-latency-url"] + delete config["cfw-conn-break-strategy"] + + config["proxies"] = [config["crupest-proxy"], ...config["proxies"]] + delete config["crupest-proxy"] + + select_proxy = { name: "node-select", type: "select", proxies: ["auto-select", ...config.proxies.map(p => p.name)] } + auto_select_proxy = config["crupest-auto-select"] + config["proxy-groups"] = [ select_proxy, auto_select_proxy ] + delete config["crupest-auto-select"] + + return config; +} diff --git a/configs/magic/extend.yaml b/configs/magic/extend.yaml new file mode 100644 index 0000000..3006f08 --- /dev/null +++ b/configs/magic/extend.yaml @@ -0,0 +1,65 @@ +# Profile Enhancement Merge Template for Clash Verge + +profile: + store-selected: true + +rules: + - "GEOSITE,github,node-select" + - "GEOSITE,google,node-select" + - "GEOSITE,youtube,node-select" + - "GEOSITE,twitter,node-select" + - "GEOSITE,facebook,node-select" + - "GEOSITE,discord,node-select" + - "GEOSITE,reddit,node-select" + - "GEOSITE,twitch,node-select" + - "GEOSITE,quora,node-select" + - "GEOSITE,telegram,node-select" + - "GEOSITE,imgur,node-select" + - "GEOSITE,stackexchange,node-select" + - "GEOSITE,onedrive,node-select" + + - "GEOSITE,duckduckgo,node-select" + - "GEOSITE,wikimedia,node-select" + - "GEOSITE,gitbook,node-select" + - "GEOSITE,gitlab,node-select" + - "GEOSITE,creativecommons,node-select" + - "GEOSITE,archive,node-select" + - "GEOSITE,matrix,node-select" + - "GEOSITE,tor,node-select" + + - "GEOSITE,python,node-select" + - "GEOSITE,ruby,node-select" + - "GEOSITE,rust,node-select" + - "GEOSITE,nodejs,node-select" + - "GEOSITE,npmjs,node-select" + - "GEOSITE,qt,node-select" + - "GEOSITE,docker,node-select" + - "GEOSITE,v2ray,node-select" + - "GEOSITE,homebrew,node-select" + - "GEOSITE,bootstrap,node-select" + + - "GEOSITE,heroku,node-select" + - "GEOSITE,vercel,node-select" + + - "GEOSITE,ieee,node-select" + - "GEOSITE,sci-hub,node-select" + - "GEOSITE,libgen,node-select" + + - "DOMAIN-SUFFIX,gnu.org,node-select" + - "DOMAIN-SUFFIX,nongnu.org,node-select" + - "DOMAIN-SUFFIX,ietf.org,node-select" + - "DOMAIN-SUFFIX,packagist.org,node-select" + - "DOMAIN-SUFFIX,metacubex.one,node-select" + - "MATCH,DIRECT" + +crupest-proxy: + ... + +crupest-auto-select: + name: "auto-select" + type: url-test + interval: 1800 + include-all-proxies: true + url: 'https://www.gstatic.com/generate_204' + filter: "日本|新加坡|香港|台湾|美国" + expected-status: 204 diff --git a/configs/nvim/config-root/.gitignore b/configs/nvim/config-root/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/configs/nvim/config-root/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/configs/nvim/config-root/.luarc.json b/configs/nvim/config-root/.luarc.json new file mode 100644 index 0000000..f704d01 --- /dev/null +++ b/configs/nvim/config-root/.luarc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", + "runtime.version": "LuaJIT" +}
\ No newline at end of file diff --git a/configs/nvim/config-root/cspell.yaml b/configs/nvim/config-root/cspell.yaml new file mode 100644 index 0000000..2a716e2 --- /dev/null +++ b/configs/nvim/config-root/cspell.yaml @@ -0,0 +1,13 @@ +dictionaryDefinitions: + - name: nvim-words + path: './nvim-words.txt' + addWords: true + +dictionaries: + - nvim-words + +words: + - crupest + +ignorePaths: + - lazy-lock.json diff --git a/configs/nvim/config-root/init.lua b/configs/nvim/config-root/init.lua new file mode 100644 index 0000000..9de0b2c --- /dev/null +++ b/configs/nvim/config-root/init.lua @@ -0,0 +1,63 @@ +if vim.g.neovide then + -- spellchecker: disable-next-line + vim.opt.guifont = "FiraCode Nerd Font"; + vim.g.neovide_window_blurred = true; + vim.g.neovide_transparency = 0.9; + vim.g.neovide_input_ime = false; + vim.g.neovide_cursor_animate_in_insert_mode = false + vim.g.neovide_cursor_vfx_mode = "pixiedust"; + vim.g.neovide_input_macos_option_key_is_meta = 'only_left' +end + +local is_win = vim.fn.has("win32") ~= 0 + +-- spellchecker: disable +if is_win then + vim.cmd([[ + let &shell = executable('pwsh') ? 'pwsh' : 'powershell' + let &shellcmdflag = '-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;' + let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' + let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' + set shellquote= shellxquote= + ]]) + vim.opt.completeslash = 'slash' +end +-- spellchecker: enable + +-- spellchecker: disable +vim.opt.termguicolors = true; +vim.opt.fileformats = "unix,dos"; +vim.opt.softtabstop = 4; +vim.opt.shiftwidth = 4; +vim.opt.expandtab = true; +vim.opt.wrap = false; +vim.opt.number = true; +-- spellchecker: enable + +vim.g.load_doxygen_syntax = true; +vim.g.doxygen_javadoc_autobrief = false; + +-- Init lazy.nvim +local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.uv.fs_stat(lazy_path) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazy_path, + }) +end +vim.opt.rtp:prepend(lazy_path) + +-- Use lazy.nvim +require("lazy").setup("plugins") + +vim.cmd("colorscheme catppuccin-macchiato") + +require("crupest.nvim.lsp").setup() +require("crupest.nvim.plugins").setup() +require("crupest.nvim.keymap").setup() + +vim.cmd("autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete") diff --git a/configs/nvim/config-root/lazy-lock.json b/configs/nvim/config-root/lazy-lock.json new file mode 100644 index 0000000..3d08239 --- /dev/null +++ b/configs/nvim/config-root/lazy-lock.json @@ -0,0 +1,20 @@ +{ + "LuaSnip": { "branch": "master", "commit": "0f7bbce41ea152a94d12aea286f2ce98e63c0f58" }, + "catppuccin": { "branch": "main", "commit": "faf15ab0201b564b6368ffa47b56feefc92ce3f4" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-cmp": { "branch": "main", "commit": "ed31156aa2cc14e3bc066c59357cc91536a2bc01" }, + "nvim-lint": { "branch": "master", "commit": "6b46370d02cd001509a765591a3ffc481b538794" }, + "nvim-lspconfig": { "branch": "master", "commit": "4ae9796c4e95ca84ec77946a9f9089b8f1a3eec9" }, + "nvim-tree.lua": { "branch": "master", "commit": "ca7c4c33cac2ad66ec69d45e465379716ef0cc97" }, + "nvim-web-devicons": { "branch": "master", "commit": "edbe0a65cfacbbfff6a4a1e98ddd60c28c560509" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" } +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/keymap.lua b/configs/nvim/config-root/lua/crupest/nvim/keymap.lua new file mode 100644 index 0000000..624c04c --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/keymap.lua @@ -0,0 +1,9 @@ +local function setup() + vim.keymap.set("n", "<c-tab>", "<cmd>bnext<cr>") + vim.keymap.set("n", "<c-s-tab>", "<cmd>bNext<cr>") + vim.keymap.set("n", "<esc>", require("crupest.utils.nvim").close_float) +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua new file mode 100644 index 0000000..bb1f6f7 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua @@ -0,0 +1,25 @@ +local lspconfig = require("lspconfig") + +local brew_clangd_path = "/usr/local/opt/llvm/bin/clangd" + +local function setup() + local clangd = "clangd" + + if vim.uv.fs_stat(brew_clangd_path) ~= nil then + clangd = brew_clangd_path + end + + -- setup lsp clangd + lspconfig.clangd.setup { + cmd = { clangd }, + on_attach = function(_, bufnr) + vim.keymap.set('n', '<space>s', "<cmd>ClangdSwitchSourceHeader<cr>", { + buffer = bufnr + }) + end + } +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua new file mode 100644 index 0000000..0fd29a3 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua @@ -0,0 +1,50 @@ +local lspconfig = require("lspconfig") +local cmp_nvim_lsp = require("cmp_nvim_lsp") +local cmp_default_caps = cmp_nvim_lsp.default_capabilities() + +local lspconfig_default_caps = lspconfig.util.default_config.capabilities + +lspconfig.util.default_config = vim.tbl_extend( + "force", + lspconfig.util.default_config, + { + capabilities = vim.tbl_extend("force", lspconfig_default_caps, cmp_default_caps), + autostart = false, + }) + +local function setup() + lspconfig.cmake.setup {} + lspconfig.bashls.setup {} + require("crupest.nvim.lsp.c").setup() + require("crupest.nvim.lsp.lua").setup() + + -- Use LspAttach auto command to only map the following keys + -- after the language server attaches to the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', '<space>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', '<space>f', vim.lsp.buf.format, opts) + end, + }) +end + + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua new file mode 100644 index 0000000..93aa503 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua @@ -0,0 +1,29 @@ +local lspconfig = require("lspconfig") + +local function setup() + lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { + version = "LuaJIT" + }, + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, + } +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua new file mode 100644 index 0000000..9b1d876 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua @@ -0,0 +1,31 @@ +local function setup() + local cmp = require("cmp") + local luasnip = require("luasnip") + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + }, + mapping = cmp.mapping.preset.insert({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }) + } +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua new file mode 100644 index 0000000..220c91a --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua @@ -0,0 +1,51 @@ +local function setup() + local gitsigns = require('gitsigns') + gitsigns.setup { + on_attach = function(bufnr) + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', '<leader>hs', gitsigns.stage_hunk) + map('n', '<leader>hr', gitsigns.reset_hunk) + map('v', '<leader>hs', function() gitsigns.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('v', '<leader>hr', function() gitsigns.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('n', '<leader>hS', gitsigns.stage_buffer) + map('n', '<leader>hu', gitsigns.undo_stage_hunk) + map('n', '<leader>hR', gitsigns.reset_buffer) + map('n', '<leader>hp', gitsigns.preview_hunk) + map('n', '<leader>hb', function() gitsigns.blame_line { full = true } end) + map('n', '<leader>tb', gitsigns.toggle_current_line_blame) + map('n', '<leader>hd', gitsigns.diffthis) + map('n', '<leader>hD', function() gitsigns.diffthis('~') end) + map('n', '<leader>td', gitsigns.toggle_deleted) + + -- Text object + map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>') + end + } +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua new file mode 100644 index 0000000..24e0c2e --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua @@ -0,0 +1,12 @@ +local function setup() + require("crupest.nvim.plugins.lint").setup() + require("crupest.nvim.plugins.snip").setup() + require("crupest.nvim.plugins.cmp").setup() + require("crupest.nvim.plugins.telescope").setup() + require("crupest.nvim.plugins.gitsigns").setup() + require("crupest.nvim.plugins.others").setup() +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua new file mode 100644 index 0000000..5e348d6 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua @@ -0,0 +1,82 @@ +local lint = require("lint") + +local find = require('crupest.utils.find') +local is_win = vim.fn.has("win32") ~= 0 + +local cspell_config_patterns = { + ".cspell.json", + "cspell.json", + ".cSpell.json", + "cSpell.json", + "cspell.config.js", + "cspell.config.cjs", + "cspell.config.json", + "cspell.config.yaml", + "cspell.config.yml", + "cspell.yaml", + "cspell.yml", +} + +--- @type FindExeForBufOpts[] +local my_linters = { + { + name = "cspell", + places = { "node_modules", "global" }, + config_files = cspell_config_patterns, + }, +} + +local function run(opt) + if not opt then + opt = {} + end + + if not opt.buf then + opt.buf = 0 + end + + local linters = {} + + for _, l in ipairs(my_linters) do + local linter = find.find_exe_for_buf(opt.buf, l) + if linter then table.insert(linters, linter) end + end + + + local linter_names = {} + + for _, linter in ipairs(linters) do + table.insert(linter_names, linter.name) + require('lint.linters.' .. linter.name).cmd = linter.exe_path + end + + lint.try_lint(linter_names) +end + +local function setup() + if is_win then + for _, l in ipairs(my_linters) do + local name = l.name + local linter = require('lint.linters.' .. name) + if linter.cmd == 'cmd.exe' then + linter.cmd = linter.args[2] + end + table.remove(linter.args, 1) + table.remove(linter.args, 1) + end + end + + vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function(opt) + run({ + buf = opt.buffer + }) + end, + }) + + vim.keymap.set('n', '<leader>lr', run) +end + +return { + setup = setup, +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua new file mode 100644 index 0000000..2ef0d75 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua @@ -0,0 +1,9 @@ +local function setup() + require('lualine').setup {} + require("nvim-tree").setup {} + require("nvim-autopairs").setup {} +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua new file mode 100644 index 0000000..78ed2eb --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua @@ -0,0 +1,75 @@ +--- spellchecker: disable + +local luasnip = require("luasnip") + +local ls = luasnip +-- some shorthands... +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local l = require("luasnip.extras").lambda +local rep = require("luasnip.extras").rep +local p = require("luasnip.extras").partial +local m = require("luasnip.extras").match +local n = require("luasnip.extras").nonempty +local dl = require("luasnip.extras").dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local types = require("luasnip.util.types") +local conds = require("luasnip.extras.conditions") +local conds_expand = require("luasnip.extras.conditions.expand") + +local function copy(args) + return args[1] +end + +local function setup() + vim.keymap.set({ "i", "s" }, "<C-L>", function() luasnip.jump(1) end, { silent = true }) + vim.keymap.set({ "i", "s" }, "<C-J>", function() luasnip.jump(-1) end, { silent = true }) + + vim.keymap.set({ "i", "s" }, "<C-E>", function() + if luasnip.choice_active() then + luasnip.change_choice(1) + end + end, { silent = true }) + + luasnip.add_snippets("cpp", { + s("cs", { + i(1, "classname"), + t("::"), + f(copy, 1), + t("("), + i(0), + t(") { }") + }), + + s("ds", { + i(1, "classname"), + t("::~"), + f(copy, 1), + t("() { }") + }), + + s("csds", { + i(1, "classname"), + t("::"), + f(copy, 1), + t("("), + i(0), + t({ ") { }", "", "" }), + f(copy, 1), + t("::~"), + f(copy, 1), + t("() { }") + }), + }) +end + +return { + setup = setup, +} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua new file mode 100644 index 0000000..d68b7f2 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua @@ -0,0 +1,11 @@ +local function setup() + local builtin = require('telescope.builtin') + vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) + vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) + vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) + vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) +end + +return { + setup = setup +} diff --git a/configs/nvim/config-root/lua/crupest/utils/find.lua b/configs/nvim/config-root/lua/crupest/utils/find.lua new file mode 100644 index 0000000..dd1f663 --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/utils/find.lua @@ -0,0 +1,101 @@ +local is_win = vim.fn.has("win32") ~= 0 + +local M = {} + +local windows_exe_ext = { "exe", "bat", "cmd", "ps1" } + +--- Find real path (with ext) for an executable. +--- @param dir string +--- @param name string | string[] +--- @return string | nil +function M.find_exe_file(dir, name) + if type(name) == "string" then + name = { name } + end + for _, n in ipairs(name) do + if vim.uv.fs_stat(vim.fs.joinpath(dir, n)) ~= nil then + return n + end + if is_win then + for _, ext in ipairs(windows_exe_ext) do + if vim.uv.fs_stat(vim.fs.joinpath(dir, n .. "." .. ext)) ~= nil then + return n .. "." .. ext + end + end + end + end + return nil +end + +--- Walk up until found an executable in node_modules. +--- @param path string +--- @param name string +--- @return string | nil exe_path Path to the executable. +function M.find_node_modules_exe(path, name) + local bin_dirs = vim.fs.find("node_modules/.bin", { path = path, upward = true, type = "directory" }) + if #bin_dirs == 0 then return nil end + local exe = M.find_exe_file(bin_dirs[1], name) + return exe and vim.fs.joinpath(bin_dirs[1], exe) +end + +--- Find executable in PATH. +--- @param name string +--- @return string | nil +function M.find_global_exe(name) + local exe = vim.fn.exepath(name) + if exe == "" then return nil end + return exe +end + +--- @alias ExePlace "node_modules" | "global" +--- @param path string +--- @param name string +--- @param places ExePlace[] +--- @return string | nil, ExePlace? +function M.find_exe(path, name, places) + for _, place in ipairs(places) do + if place == "node_modules" then + local r = M.find_node_modules_exe(path, name) + if r then return r, "node_modules" end + end + if place == "global" then + local r = M.find_global_exe(name) + if r then return r, "global" end + end + end + return nil, nil +end + +--- @alias FindExeForBufOpts { name: string, exe: string?, places: ExePlace[], config_files: string[]?, filetypes: string[]? } +--- @alias FindExeForBufResult { name: string, file: string, exe: string, exe_path: string, place: ExePlace, config_file: string?, filetype: string? } +--- @param buf number +--- @param opts FindExeForBufOpts +--- @return FindExeForBufResult | nil +function M.find_exe_for_buf(buf, opts) + local r = {} --- @type FindExeForBufResult + r.name = opts.name + r.file = vim.api.nvim_buf_get_name(buf) + r.exe = opts.exe or opts.name + + if opts.filetypes then + r.filetype = vim.api.nvim_get_option_value("filetype", { scope = "buffer", buf = buf }) + if not vim.tbl_contains(opts.filetypes, r.filetype) then return nil end + end + + if opts.config_files then + local config_file_list = vim.fs.find(opts.config_files, { path = r.file, upward = true }) + if #config_file_list == 0 then return nil end + r.config_file = config_file_list[1] + end + + local exe_path, place = M.find_exe(r.file, r.exe, opts.places) + if exe_path == nil then return nil end + r.exe_path = exe_path + + --- @cast place ExePlace + r.place = place + + return r +end + +return M diff --git a/configs/nvim/config-root/lua/crupest/utils/nvim.lua b/configs/nvim/config-root/lua/crupest/utils/nvim.lua new file mode 100644 index 0000000..4477ecc --- /dev/null +++ b/configs/nvim/config-root/lua/crupest/utils/nvim.lua @@ -0,0 +1,12 @@ +local M = {} + +function M.close_float() + local wins = vim.api.nvim_list_wins() + for _, v in ipairs(wins) do + if vim.api.nvim_win_get_config(v).relative ~= '' then + vim.api.nvim_win_close(v, false) + end + end +end + +return M diff --git a/configs/nvim/config-root/lua/plugins.lua b/configs/nvim/config-root/lua/plugins.lua new file mode 100644 index 0000000..b689559 --- /dev/null +++ b/configs/nvim/config-root/lua/plugins.lua @@ -0,0 +1,30 @@ +-- spellchecker: disable +return { + { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, + "neovim/nvim-lspconfig", + "L3MON4D3/LuaSnip", + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + { + "nvim-tree/nvim-tree.lua", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, + { + "nvim-lualine/lualine.nvim", + dependencies = { 'nvim-tree/nvim-web-devicons' } + }, + { + "nvim-telescope/telescope.nvim", + dependencies = { 'nvim-lua/plenary.nvim' } + }, + "windwp/nvim-autopairs", + "mfussenegger/nvim-lint", + "lewis6991/gitsigns.nvim", +} diff --git a/configs/nvim/config-root/nvim-words.txt b/configs/nvim/config-root/nvim-words.txt new file mode 100644 index 0000000..564904f --- /dev/null +++ b/configs/nvim/config-root/nvim-words.txt @@ -0,0 +1,27 @@ +nvim +vimruntime +bnext +bufhidden +exepath +stdpath +augroup +autocmd +autobrief +autopairs +keymap +joinpath +bufnr + +neovide +pixiedust + +lspconfig +clangd +bashls + +catppuccin +macchiato +diffthis +gitsigns +lualine +luasnip diff --git a/configs/nvim/copy-nvim-config b/configs/nvim/copy-nvim-config new file mode 100755 index 0000000..92863a9 --- /dev/null +++ b/configs/nvim/copy-nvim-config @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +MYDIR="$(dirname "$(realpath "$0")")/config-root" + +mkdir -p ${MYDIR} +cp -R ~/.config/nvim/. ${MYDIR} diff --git a/configs/nvim/homebrew-packages b/configs/nvim/homebrew-packages new file mode 100644 index 0000000..03a95bf --- /dev/null +++ b/configs/nvim/homebrew-packages @@ -0,0 +1,6 @@ +llvm +cmake-language-server +bash-language-server +shellcheck +shfmt +lua-language-server |