From d4034aec9c690bf6f2d82314e30a62de14bdf592 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Wed, 9 Oct 2024 17:13:16 -0700 Subject: [PATCH] initial commit --- .envrc | 1 + .gitignore | 2 + .stylua.toml | 1 + README.md | 7 + flake.lock | 791 +++++++++++++++++++++++++++++++++++++ flake.nix | 361 +++++++++++++++++ init.lua | 19 + lua/keymaps.lua | 2 + lua/lsp/init.lua | 22 ++ lua/plugins/blink-cmp.lua | 242 ++++++++++++ lua/plugins/init.lua | 12 + lua/plugins/lz-spec.lua | 25 ++ lua/scripts/intellitab.lua | 72 ++++ 13 files changed, 1557 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 .stylua.toml create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 init.lua create mode 100644 lua/keymaps.lua create mode 100644 lua/lsp/init.lua create mode 100644 lua/plugins/blink-cmp.lua create mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lz-spec.lua create mode 100644 lua/scripts/intellitab.lua diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4812d58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/ diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..394e884 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1 @@ +indent_type = "Spaces" diff --git a/README.md b/README.md new file mode 100644 index 0000000..55f53e9 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# neovim config in progress + +```lua +local test = test +``` + +[test](lsdjkfsdf) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f46ce3b --- /dev/null +++ b/flake.lock @@ -0,0 +1,791 @@ +{ + "nodes": { + "blink-cmp": { + "inputs": { + "devenv": "devenv", + "fenix": "fenix", + "flake-parts": "flake-parts_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728503719, + "narHash": "sha256-LMRZFzq3kP1JBbIcjOuiKstOfShdKHpyIGB9/wgxttA=", + "owner": "Saghen", + "repo": "blink.cmp", + "rev": "fc348dac16f190042d20aee62ea61b66c7c1380a", + "type": "github" + }, + "original": { + "owner": "Saghen", + "repo": "blink.cmp", + "type": "github" + } + }, + "cachix": { + "inputs": { + "devenv": "devenv_2", + "flake-compat": [ + "blink-cmp", + "devenv", + "flake-compat" + ], + "git-hooks": [ + "blink-cmp", + "devenv", + "pre-commit-hooks" + ], + "nixpkgs": [ + "blink-cmp", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726520618, + "narHash": "sha256-jOsaBmJ/EtX5t/vbylCdS7pWYcKGmWOKg4QKUzKr6dA=", + "owner": "cachix", + "repo": "cachix", + "rev": "695525f9086542dfb09fde0871dbf4174abbf634", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "cachix_2": { + "inputs": { + "devenv": "devenv_3", + "flake-compat": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "pre-commit-hooks": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1712055811, + "narHash": "sha256-7FcfMm5A/f02yyzuavJe06zLa9hcMHsagE28ADcmQvk=", + "owner": "cachix", + "repo": "cachix", + "rev": "02e38da89851ec7fec3356a5c04bc8349cae0e30", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat_2", + "nix": "nix_3", + "nixpkgs": "nixpkgs_3", + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1728113618, + "narHash": "sha256-oJj1d2VlFksl/45nBUtoM+lxxaWD3Z6yXBLR9vOp+2E=", + "owner": "cachix", + "repo": "devenv", + "rev": "a8495abab31ce52cd45d343caa760046c0c7ee74", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_2": { + "inputs": { + "cachix": "cachix_2", + "flake-compat": [ + "blink-cmp", + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix_2", + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "nixpkgs" + ], + "pre-commit-hooks": [ + "blink-cmp", + "devenv", + "cachix", + "git-hooks" + ] + }, + "locked": { + "lastModified": 1723156315, + "narHash": "sha256-0JrfahRMJ37Rf1i0iOOn+8Z4CLvbcGNwa2ChOAVrp/8=", + "owner": "cachix", + "repo": "devenv", + "rev": "ff5eb4f2accbcda963af67f1a1159e3f6c7f5f91", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_3": { + "inputs": { + "flake-compat": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix", + "pre-commit-hooks": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "cachix", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1708704632, + "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", + "owner": "cachix", + "repo": "devenv", + "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "python-rewrite", + "repo": "devenv", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "blink-cmp", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1728196311, + "narHash": "sha256-JoDDlmjPj0sGo1beOo3bRh7BDppm0Kuet7I7BqTmSl4=", + "owner": "nix-community", + "repo": "fenix", + "rev": "26971356e387b5ec0578f52be1bbd82ecf6dbad4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "blink-cmp", + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "blink-cmp", + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "libgit2": { + "flake": false, + "locked": { + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", + "type": "github" + }, + "original": { + "owner": "libgit2", + "repo": "libgit2", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870561, + "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixCats": { + "locked": { + "dir": "nix", + "lastModified": 1727835465, + "narHash": "sha256-Sj/eP/K/MHxp6K/ZqAYGY7cT+iyebf3P5HTnS/mLFCM=", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "rev": "b02e9655894c402e9398369b94fab57d2bf5f359", + "type": "github" + }, + "original": { + "dir": "nix", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "type": "github" + } + }, + "nix_2": { + "inputs": { + "flake-compat": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression_2" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix_3": { + "inputs": { + "flake-compat": [ + "blink-cmp", + "devenv", + "flake-compat" + ], + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-23-11": "nixpkgs-23-11", + "nixpkgs-regression": "nixpkgs-regression_3", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1727438425, + "narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=", + "owner": "domenkozar", + "repo": "nix", + "rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.24", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-23-11": { + "locked": { + "lastModified": 1717159533, + "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_2": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_3": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1716977621, + "narHash": "sha256-Q1UQzYcMJH4RscmpTkjlgqQDX5yi1tZL0O345Ri6vXQ=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1728409405, + "narHash": "sha256-kk530XBUGDpt0DQbyUb3yDpSddPqF9PA5KTo/nsmmg0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1366d1af8f58325602280e43ed6233849fb92216", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "blink-cmp", + "devenv", + "cachix", + "devenv", + "cachix", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692876271, + "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "blink-cmp", + "devenv", + "nix" + ], + "flake-utils": "flake-utils_2", + "gitignore": [ + "blink-cmp", + "devenv", + "nix" + ], + "nixpkgs": [ + "blink-cmp", + "devenv", + "nix", + "nixpkgs" + ], + "nixpkgs-stable": [ + "blink-cmp", + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712897695, + "narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { + "inputs": { + "flake-compat": [ + "blink-cmp", + "devenv", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "blink-cmp", + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "blink-cmp": "blink-cmp", + "nixCats": "nixCats", + "nixpkgs": "nixpkgs_4" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1728064742, + "narHash": "sha256-tFvUGvqUZjES1yxYT2zEFiTAE0iQKYd+eWKX/6ZqeVw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "5982d9c420d0dc90739171829f0d2e9c80d98979", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5d28f3e --- /dev/null +++ b/flake.nix @@ -0,0 +1,361 @@ +# Copyright (c) 2023 BirdeeHub +# Licensed under the MIT license + +# This is an empty nixCats config. +# you may import this template directly into your nvim folder +# and then add plugins to categories here, +# and call the plugins with their default functions +# within your lua, rather than through the nvim package manager's method. +# Use the help, and the example repository https://github.com/BirdeeHub/nixCats-nvim + +# It allows for easy adoption of nix, +# while still providing all the extra nix features immediately. +# Configure in lua, check for a few categories, set a few settings, +# output packages with combinations of those categories and settings. + +# All the same options you make here will be automatically exported in a form available +# in home manager and in nixosModules, as well as from other flakes. +# each section is tagged with its relevant help section. + +{ + description = "A Lua-natic's neovim flake, with extra cats! nixCats!"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixCats.url = "github:BirdeeHub/nixCats-nvim?dir=nix"; + + blink-cmp = { + url = "github:Saghen/blink.cmp"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # see :help nixCats.flake.inputs + # If you want your plugin to be loaded by the standard overlay, + # i.e. if it wasnt on nixpkgs, but doesnt have an extra build step. + # Then you should name it "plugins-something" + # If you wish to define a custom build step not handled by nixpkgs, + # then you should name it in a different format, and deal with that in the + # overlay defined for custom builds in the overlays directory. + # for specific tags, branches and commits, see: + # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#examples + + }; + + # see :help nixCats.flake.outputs + outputs = + { + self, + nixpkgs, + nixCats, + ... + }@inputs: + let + inherit (nixCats) utils; + luaPath = "${./.}"; + forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; + # the following extra_pkg_config contains any values + # which you want to pass to the config set of nixpkgs + # import nixpkgs { config = extra_pkg_config; inherit system; } + # will not apply to module imports + # as that will have your system values + extra_pkg_config = { + # allowUnfree = true; + }; + # sometimes our overlays require a ${system} to access the overlay. + # management of this variable is one of the harder parts of using flakes. + + # so I have done it here in an interesting way to keep it out of the way. + + # First, we will define just our overlays per system. + # later we will pass them into the builder, and the resulting pkgs set + # will get passed to the categoryDefinitions and packageDefinitions + # which follow this section. + + # this allows you to use ${pkgs.system} whenever you want in those sections + # without fear. + inherit + (forEachSystem ( + system: + let + # see :help nixCats.flake.outputs.overlays + dependencyOverlays = # (import ./overlays inputs) ++ + [ + # This overlay grabs all the inputs named in the format + # `plugins-` + # Once we add this overlay to our nixpkgs, we are able to + # use `pkgs.neovimPlugins`, which is a set of our plugins. + (utils.standardPluginOverlay inputs) + # add any flake overlays here. + ]; + in + # these overlays will be wrapped with ${system} + # and we will call the same utils.eachSystem function + # later on to access them. + { + inherit dependencyOverlays; + } + )) + dependencyOverlays + ; + # see :help nixCats.flake.outputs.categories + # and + # :help nixCats.flake.outputs.categoryDefinitions.scheme + categoryDefinitions = + { + pkgs, + settings, + categories, + name, + ... + }@packageDef: + { + # to define and use a new category, simply add a new list to a set here, + # and later, you will include categoryname = true; in the set you + # provide when you build the package using this builder function. + # see :help nixCats.flake.outputs.packageDefinitions for info on that section. + + # propagatedBuildInputs: + # this section is for dependencies that should be available + # at BUILD TIME for plugins. WILL NOT be available to PATH + # However, they WILL be available to the shell + # and neovim path when using nix develop + propagatedBuildInputs = { + general = + with pkgs; + [ + ]; + }; + + # lspsAndRuntimeDeps: + # this section is for dependencies that should be available + # at RUN TIME for plugins. Will be available to PATH within neovim terminal + # this includes LSPs + lspsAndRuntimeDeps = { + general = with pkgs; [ + lua-language-server + ripgrep + python312Packages.pylatexenc + ]; + }; + + # plugins that will load at startup + startupPlugins = { + gitPlugins = with pkgs.neovimPlugins; [ ]; + general = with pkgs.vimPlugins; [ + lz-n + telescope-nvim + markdown-preview-nvim + render-markdown-nvim + which-key-nvim + rose-pine + nvim-web-devicons + (nvim-treesitter.withPlugins ( + p: + (with p; [ + lua + c + javascript + typescript + rust + haskell + typst + latex + nix + json + toml + yaml + markdown + svelte + css + html + vim + bash + make + ]) + )) + ]; + }; + + # plugins which are installed and will be lazy-loaded by lz.n + optionalPlugins = { + gitPlugins = with pkgs.neovimPlugins; [ + inputs.blink-cmp.packages.${pkgs.system}.default + ]; + general = with pkgs.vimPlugins; [ + nvim-autopairs + nvim-lspconfig + intellitab-nvim + sleuth + ]; + }; + + # shared libraries to be added to LD_LIBRARY_PATH + # variable available to nvim runtime + sharedLibraries = { + general = with pkgs; [ + # libgit2 + ]; + }; + + # environmentVariables: + # this section is for environmentVariables that should be available + # at RUN TIME for plugins. Will be available to path within neovim terminal + # environmentVariables = { + # test = { + # CATTESTVAR = "It worked!"; + # }; + # }; + + # If you know what these are, you can provide custom ones by category here. + # If you dont, check this link out: + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh + # extraWrapperArgs = { + # test = [ + # ''--set CATTESTVAR2 "It worked again!"'' + # ]; + # }; + + # lists of the functions you would have passed to + # python.withPackages or lua.withPackages + + # get the path to this python environment + # in your lua config via + # vim.g.python3_host_prog + # or run from nvim terminal via :!-python3 + extraPython3Packages = { + test = (_: [ ]); + }; + # populates $LUA_PATH and $LUA_CPATH + extraLuaPackages = { + test = [ (_: [ ]) ]; + }; + }; + + # And then build a package with specific categories from above here: + # All categories you wish to include must be marked true, + # but false may be omitted. + # This entire set is also passed to nixCats for querying within the lua. + + # see :help nixCats.flake.outputs.packageDefinitions + packageDefinitions = { + # These are the names of your packages + # you can include as many as you wish. + nvim = + { pkgs, ... }: + { + # they contain a settings set defined above + # see :help nixCats.flake.outputs.settings + settings = { + wrapRc = true; + # IMPORTANT: + # your alias may not conflict with your other packages. + aliases = [ + "vim" + "vi" + ]; + # neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; + }; + # and a set of categories that you want + # (and other information to pass to lua) + categories = { + general = true; + gitPlugins = true; + customPlugins = true; + test = true; + example = { + youCan = "add more than just booleans"; + toThisSet = [ + "and the contents of this categories set" + "will be accessible to your lua with" + "nixCats('path.to.value')" + "see :help nixCats" + ]; + }; + }; + }; + }; + # In this section, the main thing you will need to do is change the default package name + # to the name of the packageDefinitions entry you wish to use as the default. + defaultPackageName = "nvim"; + in + + # see :help nixCats.flake.outputs.exports + forEachSystem ( + system: + let + nixCatsBuilder = utils.baseBuilder luaPath { + inherit + nixpkgs + system + dependencyOverlays + extra_pkg_config + ; + } categoryDefinitions packageDefinitions; + defaultPackage = nixCatsBuilder defaultPackageName; + # this is just for using utils such as pkgs.mkShell + # The one used to build neovim is resolved inside the builder + # and is passed to our categoryDefinitions and packageDefinitions + pkgs = import nixpkgs { inherit system; }; + in + { + # these outputs will be wrapped with ${system} by utils.eachSystem + + # this will make a package out of each of the packageDefinitions defined above + # and set the default package to the one passed in here. + packages = utils.mkAllWithDefault defaultPackage; + + # choose your package for devShell + # and add whatever else you want in it. + devShells = { + default = pkgs.mkShell { + name = defaultPackageName; + packages = [ defaultPackage ]; + inputsFrom = with pkgs; [ + lua-language-server + stylua + ]; + shellHook = ''''; + }; + }; + + } + ) + // { + + # these outputs will be NOT wrapped with ${system} + + # this will make an overlay out of each of the packageDefinitions defined above + # and set the default overlay to the one named here. + overlays = utils.makeOverlays luaPath { + inherit nixpkgs dependencyOverlays extra_pkg_config; + } categoryDefinitions packageDefinitions defaultPackageName; + + # we also export a nixos module to allow reconfiguration from configuration.nix + nixosModules.default = utils.mkNixosModules { + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; + }; + # and the same for home manager + homeModule = utils.mkHomeModules { + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; + }; + inherit utils; + inherit (utils) templates; + }; + +} diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..547252f --- /dev/null +++ b/init.lua @@ -0,0 +1,19 @@ +require("plugins") + +vim.opt.relativenumber = true +vim.opt.number = true + +-- Global statusline +vim.opt.laststatus = 3 +-- Persistent undos across session +vim.opt.undofile = true + +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 2 + +vim.treesitter.indent = true +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +vim.opt.foldmethod = "expr" +vim.opt.foldenable = false + +vim.cmd("colorscheme rose-pine") diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..b3189c6 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,2 @@ +-- Non-exhaustive collection of keymaps. I've decided it's more sane to place +-- plugin specific maps in their respective setup scripts diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua new file mode 100644 index 0000000..a6f22b2 --- /dev/null +++ b/lua/lsp/init.lua @@ -0,0 +1,22 @@ +local lspconfig = require("lspconfig") + +lspconfig.lua_ls.setup({ + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, +}) diff --git a/lua/plugins/blink-cmp.lua b/lua/plugins/blink-cmp.lua new file mode 100644 index 0000000..9b5cc57 --- /dev/null +++ b/lua/plugins/blink-cmp.lua @@ -0,0 +1,242 @@ +return { + "blink-cmp", + event = "BufEnter", + after = function() + require("blink-cmp").setup({ + -- for keymap, all values may be string | string[] + -- use an empty table to disable a keymap + keymap = { + show = "", + hide = "", + accept = "", + select_prev = { "", "" }, + select_next = { "", "" }, + + show_documentation = {}, + hide_documentation = {}, + scroll_documentation_up = "", + scroll_documentation_down = "", + + snippet_forward = "", + snippet_backward = "", + }, + + accept = { + create_undo_point = true, + auto_brackets = { + enabled = false, + default_brackets = { "(", ")" }, + override_brackets_for_filetypes = {}, + -- Overrides the default blocked filetypes + force_allow_filetypes = {}, + blocked_filetypes = {}, + -- Synchronously use the kind of the item to determine if brackets should be added + kind_resolution = { + enabled = true, + blocked_filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" }, + }, + -- Asynchronously use semantic token to determine if brackets should be added + semantic_token_resolution = { + enabled = true, + blocked_filetypes = {}, + }, + }, + }, + + trigger = { + completion = { + -- regex used to get the text when fuzzy matching + -- changing this may break some sources, so please report if you run into issues + -- todo: shouldnt this also affect the accept command? should this also be per language? + keyword_regex = "[%w_\\-]", + -- LSPs can indicate when to show the completion window via trigger characters + -- however, some LSPs (*cough* tsserver *cough*) return characters that would essentially + -- always show the window. We block these by default + blocked_trigger_characters = { " ", "\n", "\t" }, + -- when true, will show the completion window when the cursor comes after a trigger character when entering insert mode + show_on_insert_on_trigger_character = true, + }, + + signature_help = { + enabled = false, + blocked_trigger_characters = {}, + blocked_retrigger_characters = {}, + -- when true, will show the signature help window when the cursor comes after a trigger character when entering insert mode + show_on_insert_on_trigger_character = true, + }, + }, + + fuzzy = { + -- frencency tracks the most recently/frequently used items and boosts the score of the item + use_frecency = true, + -- proximity bonus boosts the score of items with a value in the buffer + use_proximity = true, + max_items = 200, + -- controls which sorts to use and in which order, these three are currently the only allowed options + sorts = { "label", "kind", "score" }, + + prebuiltBinaries = { + -- Whether or not to automatically download a prebuilt binary from github. If this is set to `false` + -- you will need to manually build the fuzzy binary dependencies by running `cargo build --release` + download = true, + -- When downloading a prebuilt binary force the downloader to resolve this version. If this is uset + -- then the downloader will attempt to infer the version from the checked out git tag (if any). + -- + -- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking. + forceVersion = nil, + }, + }, + + sources = { + -- similar to nvim-cmp's sources, but we point directly to the source's lua module + -- multiple groups can be provided, where it'll fallback to the next group if the previous + -- returns no completion items + -- WARN: This API will have breaking changes during the beta + providers = { + { + { "blink.cmp.sources.lsp" }, + { "blink.cmp.sources.path" }, + { "blink.cmp.sources.snippets", score_offset = -3 }, + }, + { { "blink.cmp.sources.buffer" } }, + }, + -- FOR REF: full example + providers = { + { + -- all of these properties work on every source + { + "blink.cmp.sources.lsp", + keyword_length = 0, + score_offset = 0, + trigger_characters = { "f", "o", "o" }, + opts = {}, + }, + -- the follow two sources have additional options + { + "blink.cmp.sources.path", + opts = { + trailing_slash = false, + label_trailing_slash = true, + get_cwd = function(context) + return vim.fn.expand(("#%d:p:h"):format(context.bufnr)) + end, + show_hidden_files_by_default = true, + }, + }, + { + "blink.cmp.sources.snippets", + score_offset = -3, + -- similar to https://github.com/garymjr/nvim-snippets + opts = { + friendly_snippets = true, + search_paths = { vim.fn.stdpath("config") .. "/snippets" }, + global_snippets = { "all" }, + extended_filetypes = {}, + ignored_filetypes = {}, + }, + }, + }, + { { "blink.cmp.sources.buffer" } }, + }, + }, + + windows = { + autocomplete = { + min_width = 30, + max_width = 60, + max_height = 10, + border = "none", + winhighlight = "Normal:BlinkCmpMenu,FloatBorder:BlinkCmpMenuBorder,CursorLine:BlinkCmpMenuSelection,Search:None", + -- keep the cursor X lines away from the top/bottom of the window + scrolloff = 2, + -- which directions to show the window, + -- falling back to the next direction when there's not enough space + direction_priority = { "s", "n" }, + -- whether to preselect the first item in the completion list + preselect = true, + -- Controls how the completion items are rendered on the popup window + -- 'simple' will render the item's kind icon the left alongside the label + -- 'reversed' will render the label on the left and the kind icon + name on the right + -- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering + draw = "simple", + -- Controls the cycling behavior when reaching the beginning or end of the completion list. + cycle = { + -- When `true`, calling `select_next` at the *bottom* of the completion list will select the *first* completion item. + from_bottom = true, + -- When `true`, calling `select_prev` at the *top* of the completion list will select the *last* completion item. + from_top = true, + }, + }, + documentation = { + min_width = 10, + max_width = 60, + max_height = 20, + border = "padded", + winhighlight = "Normal:BlinkCmpDoc,FloatBorder:BlinkCmpDocBorder,CursorLine:BlinkCmpDocCursorLine,Search:None", + -- which directions to show the documentation window, + -- for each of the possible autocomplete window directions, + -- falling back to the next direction when there's not enough space + direction_priority = { + autocomplete_north = { "e", "w", "n", "s" }, + autocomplete_south = { "e", "w", "s", "n" }, + }, + auto_show = true, + auto_show_delay_ms = 500, + update_delay_ms = 100, + }, + signature_help = { + min_width = 1, + max_width = 100, + max_height = 10, + border = "padded", + winhighlight = "Normal:BlinkCmpSignatureHelp,FloatBorder:BlinkCmpSignatureHelpBorder", + }, + }, + + highlight = { + ns = vim.api.nvim_create_namespace("blink_cmp"), + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = false, + }, + + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = "normal", + + kind_icons = { + Text = "󰉿", + Method = "󰊕", + Function = "󰊕", + Constructor = "󰒓", + + Field = "󰜢", + Variable = "󰆦", + Property = "󰖷", + + Class = "󱡠", + Interface = "󱡠", + Struct = "󱡠", + Module = "󰅩", + + Unit = "󰪚", + Value = "󰦨", + Enum = "󰦨", + EnumMember = "󰦨", + + Keyword = "󰻾", + Constant = "󰏿", + + Snippet = "󱄽", + Color = "󰏘", + File = "󰈔", + Reference = "󰬲", + Folder = "󰉋", + Event = "󱐋", + Operator = "󰪚", + TypeParameter = "󰬛", + }, + }) + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..a6a4476 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,12 @@ +-- Experimental Neovim byte-compiled module loader +vim.loader.enable() + +local pluginSpec = require("plugins.lz-spec") +require("lz.n").load(pluginSpec) + +-- require("markview").setup({ +-- codeblocks = { +-- icons = "devicons", +-- }, +-- filetypes = {"markdown", "quarto", "rmd", "nofile"} +-- }) diff --git a/lua/plugins/lz-spec.lua b/lua/plugins/lz-spec.lua new file mode 100644 index 0000000..0fef26b --- /dev/null +++ b/lua/plugins/lz-spec.lua @@ -0,0 +1,25 @@ +return { + require("plugins.blink-cmp"), + { + "nvim-autopairs", + event = "BufEnter", + after = function() + require("nvim-autopairs").setup() + end, + }, + { + "nvim-lspconfig", + event = "BufEnter", + after = function() + require("lsp") + end, + }, + { + "intellitab-nvim", + keys = "tab", + }, + { + "sleuth", + event = "BufEnter", + }, +} diff --git a/lua/scripts/intellitab.lua b/lua/scripts/intellitab.lua new file mode 100644 index 0000000..7a0a991 --- /dev/null +++ b/lua/scripts/intellitab.lua @@ -0,0 +1,72 @@ +-- `intellitab.nvim` by Pedro Alves (https://github.com/pta2002) +-- URL: https://github.com/pta2002/intellitab.nvim?tab=MIT-1-ov-file +-- Copyright 2021 Pedro Alves. Licensed under MIT. + +local v = vim.api + +local treesitter = require("nvim-treesitter") + +local function get_line_indent(line, sw) + local indent = 0 + + for c in line:gmatch("%s") do + if c == "\t" then + indent = indent + sw + else + indent = indent + 1 + end + end + + return indent +end + +local function indent() + local cursor = v.nvim_win_get_cursor(0) + local line = v.nvim_buf_get_lines(0, cursor[1] - 1, cursor[1], false)[1] + + local indentexpr = v.nvim_buf_get_option(0, "indentexpr") + local expand = v.nvim_buf_get_option(0, "expandtab") + local shiftwidth = v.nvim_eval("shiftwidth()") + local tab_char = v.nvim_replace_termcodes("", true, true, true) + local indent_goal + + if treesitter ~= nil and treesitter.get_indent ~= nil then + indent_goal = treesitter.get_indent(line) + end + + if indent_goal == nil or indent_goal < 0 then + if indentexpr ~= "" then + indent_goal = v.nvim_eval(indentexpr) + elseif v.nvim_buf_get_option(0, "cindent") then + indent_goal = v.nvim_call_function("cindent", { cursor[1] }) + else + indent_goal = v.nvim_call_function("indent", { cursor[1] }) + end + end + + if indent_goal == -1 and cursor[1] ~= 1 then + local prev_line = v.nvim_buf_get_lines(0, cursor[1] - 2, cursor[1] - 1, false)[1] + indent_goal = get_line_indent(prev_line, shiftwidth) + end + + -- Reset the cursor, since the functions are free to move it + v.nvim_win_set_cursor(0, cursor) + + if cursor[2] == 0 and line == "" and indent_goal ~= nil and indent_goal > 0 then + local i = 0 + while i < indent_goal do + if expand then + v.nvim_feedkeys(" ", "n", true) + i = i + 1 + else + v.nvim_feedkeys(tab_char, "n", true) + i = i + shiftwidth + end + end + print(i, indent_goal) + else + v.nvim_feedkeys(tab_char, "n", true) + end +end + +return { indent = indent }