1
Fork 0

Add miros support!

This commit is contained in:
prescientmoon 2024-04-16 23:25:20 +02:00
parent 5652b531ba
commit 1ed3a529c9
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
26 changed files with 910 additions and 1153 deletions

View file

@ -396,6 +396,22 @@
"type": "github"
}
},
"easy-purescript-nix": {
"flake": false,
"locked": {
"lastModified": 1710161569,
"narHash": "sha256-lcIRIOFCdIWEGyKyG/tB4KvxM9zoWuBRDxW+T+mvIb0=",
"owner": "justinwoo",
"repo": "easy-purescript-nix",
"rev": "117fd96acb69d7d1727df95b6fde9d8715e031fc",
"type": "github"
},
"original": {
"owner": "justinwoo",
"repo": "easy-purescript-nix",
"type": "github"
}
},
"fast-myers-diff": {
"flake": false,
"locked": {
@ -500,6 +516,22 @@
}
},
"flake-compat_3": {
"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-compat_4": {
"flake": false,
"locked": {
"lastModified": 1673956053,
@ -515,7 +547,7 @@
"type": "github"
}
},
"flake-compat_4": {
"flake-compat_5": {
"flake": false,
"locked": {
"lastModified": 1696426674,
@ -531,7 +563,7 @@
"type": "github"
}
},
"flake-compat_5": {
"flake-compat_6": {
"flake": false,
"locked": {
"lastModified": 1673956053,
@ -569,6 +601,29 @@
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"miros",
"purifix",
"nix-eval-jobs",
"nixpkgs"
]
},
"locked": {
"lastModified": 1690933134,
"narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
@ -589,7 +644,7 @@
"type": "github"
}
},
"flake-parts_3": {
"flake-parts_4": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
@ -647,6 +702,39 @@
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_5": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
@ -661,9 +749,9 @@
"type": "github"
}
},
"flake-utils_4": {
"flake-utils_6": {
"inputs": {
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1685518550,
@ -679,9 +767,9 @@
"type": "github"
}
},
"flake-utils_5": {
"flake-utils_7": {
"inputs": {
"systems": "systems_4"
"systems": "systems_5"
},
"locked": {
"lastModified": 1710146030,
@ -697,9 +785,9 @@
"type": "github"
}
},
"flake-utils_6": {
"flake-utils_8": {
"inputs": {
"systems": "systems_5"
"systems": "systems_6"
},
"locked": {
"lastModified": 1685518550,
@ -918,7 +1006,7 @@
},
"hercules-ci-effects": {
"inputs": {
"flake-parts": "flake-parts_3",
"flake-parts": "flake-parts_4",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
@ -980,7 +1068,7 @@
},
"home-manager_3": {
"inputs": {
"nixpkgs": "nixpkgs_6"
"nixpkgs": "nixpkgs_9"
},
"locked": {
"lastModified": 1710888565,
@ -1180,9 +1268,32 @@
"type": "github"
}
},
"neovim-flake": {
"miros": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs"
],
"purescript-overlay": "purescript-overlay",
"purifix": "purifix"
},
"locked": {
"lastModified": 1713302426,
"narHash": "sha256-29m8oM9CtmvHKzfK1xfz2R7/Ae1GimmRyb3i27oIOw0=",
"owner": "mateiadrielrafael",
"repo": "miros",
"rev": "45b9ce1c3fedd548d824a01608e1a5c9570b8d95",
"type": "github"
},
"original": {
"owner": "mateiadrielrafael",
"repo": "miros",
"type": "github"
}
},
"neovim-flake": {
"inputs": {
"flake-utils": "flake-utils_5",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
@ -1206,8 +1317,8 @@
},
"neovim-nightly-overlay": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts_2",
"flake-compat": "flake-compat_3",
"flake-parts": "flake-parts_3",
"hercules-ci-effects": "hercules-ci-effects",
"neovim-flake": "neovim-flake",
"nixpkgs": [
@ -1228,6 +1339,26 @@
"type": "github"
}
},
"nix-eval-jobs": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_5",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1693447927,
"narHash": "sha256-LMsk4jRsUtkDbSk+0To0rek7mEEdjRZnp/xzLF25umM=",
"owner": "nix-community",
"repo": "nix-eval-jobs",
"rev": "76994681653503b6691af1cacd3aca07d76665bc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-eval-jobs",
"type": "github"
}
},
"nix-index-database": {
"inputs": {
"nixpkgs": [
@ -1361,6 +1492,54 @@
}
},
"nixpkgs_10": {
"locked": {
"lastModified": 1705331948,
"narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
}
},
"nixpkgs_11": {
"locked": {
"lastModified": 1701539137,
"narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_12": {
"locked": {
"lastModified": 1689261696,
"narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "df1eee2aa65052a18121ed4971081576b25d6b5c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_13": {
"locked": {
"lastModified": 1710765496,
"narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=",
@ -1376,7 +1555,7 @@
"type": "github"
}
},
"nixpkgs_11": {
"nixpkgs_14": {
"locked": {
"lastModified": 1700856099,
"narHash": "sha256-RnEA7iJ36Ay9jI0WwP+/y4zjEhmeN6Cjs9VOFBH7eVQ=",
@ -1439,6 +1618,53 @@
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1693443141,
"narHash": "sha256-uvXHx0ysNeEPC4UjPiwNgX/8z9ItBS4GLkcM7ency+w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e35f1fd9763f2b11b3f723b88287949cc2afd37c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1679679161,
"narHash": "sha256-weTfVvy077MKvm+62R3dj+EpL9u7xe/PTWWH8nDHYfM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e1fa54a56982c5874f6941703c8b760541e40db1",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_7": {
"locked": {
"lastModified": 1658371388,
"narHash": "sha256-ACjtJNUAqjAdR+o5EDcOGgK3aseB+IF1TSBNPVftdLg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "af7d2aaa0d7fae44cdef463538833d536e3def1f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1711460390,
"narHash": "sha256-akSgjDZL6pVHEfSE6sz1DNSXuYX6hq+P/1Z5IoYWs7E=",
@ -1454,66 +1680,18 @@
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1705331948,
"narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_7": {
"locked": {
"lastModified": 1705331948,
"narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1701539137,
"narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1689261696,
"narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=",
"lastModified": 1705331948,
"narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "df1eee2aa65052a18121ed4971081576b25d6b5c",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
@ -1537,7 +1715,7 @@
"openapi-code-generator_2": {
"inputs": {
"autodocodec": "autodocodec_3",
"nixpkgs": "nixpkgs_8",
"nixpkgs": "nixpkgs_11",
"pre-commit-hooks": "pre-commit-hooks_2",
"safe-coloured-text": "safe-coloured-text_2",
"sydtest": "sydtest_2",
@ -1581,10 +1759,10 @@
},
"pre-commit-hooks_2": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_4",
"flake-compat": "flake-compat_4",
"flake-utils": "flake-utils_6",
"gitignore": "gitignore_2",
"nixpkgs": "nixpkgs_9",
"nixpkgs": "nixpkgs_12",
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
@ -1603,10 +1781,10 @@
},
"pre-commit-hooks_3": {
"inputs": {
"flake-compat": "flake-compat_4",
"flake-utils": "flake-utils_5",
"flake-compat": "flake-compat_5",
"flake-utils": "flake-utils_7",
"gitignore": "gitignore_3",
"nixpkgs": "nixpkgs_10",
"nixpkgs": "nixpkgs_13",
"nixpkgs-stable": "nixpkgs-stable_3"
},
"locked": {
@ -1623,6 +1801,103 @@
"type": "github"
}
},
"purenix": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1659759527,
"narHash": "sha256-4fKtudKLLUUN4vtu4xnPfWXD9wa0qUHLpA9iWIBwOpw=",
"owner": "purenix-org",
"repo": "purenix",
"rev": "5587e599a39811d6d1645e7d2cfed559506e3637",
"type": "github"
},
"original": {
"owner": "purenix-org",
"repo": "purenix",
"type": "github"
}
},
"purescript-overlay": {
"inputs": {
"flake-compat": "flake-compat_2",
"nixpkgs": [
"miros",
"nixpkgs"
],
"slimlock": "slimlock"
},
"locked": {
"lastModified": 1710339258,
"narHash": "sha256-Xu87DJ57Ekiepn0TP/j2EnCeuOO33qTgLUBnUMaLU34=",
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"rev": "3ed2339ff361ec1d2006ec9d0719a336ee827a90",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"type": "github"
}
},
"purescript-registry": {
"flake": false,
"locked": {
"lastModified": 1712854366,
"narHash": "sha256-DPFJOv2Qavv3L8PYkl4vTkI/f7Caml5M5FNLOco0nS4=",
"owner": "purescript",
"repo": "registry",
"rev": "ab38729b29eb7b124271b5b381587ed7ff34b59b",
"type": "github"
},
"original": {
"owner": "purescript",
"repo": "registry",
"type": "github"
}
},
"purescript-registry-index": {
"flake": false,
"locked": {
"lastModified": 1712854361,
"narHash": "sha256-vlxVNBARhTcuRLJptjRnc8l5XGeGnqOs8CDMs69c0zw=",
"owner": "purescript",
"repo": "registry-index",
"rev": "8af544890b852e31b0aa0c13bd808e1a5e39f292",
"type": "github"
},
"original": {
"owner": "purescript",
"repo": "registry-index",
"type": "github"
}
},
"purifix": {
"inputs": {
"easy-purescript-nix": "easy-purescript-nix",
"nix-eval-jobs": "nix-eval-jobs",
"nixpkgs": "nixpkgs_6",
"purenix": "purenix",
"purescript-registry": "purescript-registry",
"purescript-registry-index": "purescript-registry-index"
},
"locked": {
"lastModified": 1712864116,
"narHash": "sha256-vB2JgdqYbQYtSHt0O+7IvFlDM98IuOdyAAnJVfGP+cg=",
"owner": "purifix",
"repo": "purifix",
"rev": "508a183bd40909ab412977e4363098625c336112",
"type": "github"
},
"original": {
"owner": "purifix",
"repo": "purifix",
"type": "github"
}
},
"root": {
"inputs": {
"anyrun": "anyrun",
@ -1634,10 +1909,11 @@
"impermanence": "impermanence",
"intray": "intray",
"korora": "korora",
"miros": "miros",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nix-index-database": "nix-index-database",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_5",
"nixpkgs": "nixpkgs_8",
"nixpkgs-unstable": "nixpkgs-unstable",
"rosepine-base16": "rosepine-base16",
"smos": "smos",
@ -1742,6 +2018,28 @@
"type": "github"
}
},
"slimlock": {
"inputs": {
"nixpkgs": [
"miros",
"purescript-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688756706,
"narHash": "sha256-xzkkMv3neJJJ89zo3o2ojp7nFeaZc2G0fYwNXNJRFlo=",
"owner": "thomashoneyman",
"repo": "slimlock",
"rev": "cf72723f59e2340d24881fd7bf61cb113b4c407c",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "slimlock",
"type": "github"
}
},
"smos": {
"inputs": {
"autodocodec": "autodocodec_2",
@ -1763,7 +2061,7 @@
"linkcheck": "linkcheck_2",
"looper": "looper",
"mergeful": "mergeful",
"nixpkgs": "nixpkgs_7",
"nixpkgs": "nixpkgs_10",
"openapi-code-generator": "openapi-code-generator_2",
"pre-commit-hooks": "pre-commit-hooks_3",
"safe-coloured-text": "safe-coloured-text_3",
@ -1829,7 +2127,7 @@
},
"spicetify-nix": {
"inputs": {
"flake-utils": "flake-utils_6",
"flake-utils": "flake-utils_8",
"nixpkgs": [
"nixpkgs"
]
@ -1859,10 +2157,10 @@
"base16-kitty": "base16-kitty",
"base16-tmux": "base16-tmux",
"base16-vim": "base16-vim",
"flake-compat": "flake-compat_5",
"flake-compat": "flake-compat_6",
"gnome-shell": "gnome-shell",
"home-manager": "home-manager_4",
"nixpkgs": "nixpkgs_11"
"nixpkgs": "nixpkgs_14"
},
"locked": {
"lastModified": 1710366273,
@ -2002,6 +2300,21 @@
"type": "github"
}
},
"systems_6": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"template-haskell-reload": {
"flake": false,
"locked": {
@ -2018,6 +2331,29 @@
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"miros",
"purifix",
"nix-eval-jobs",
"nixpkgs"
]
},
"locked": {
"lastModified": 1693247164,
"narHash": "sha256-M6qZo8H8fBFnipCy6q6RlpSXF3sDvfTEtyFwdAP7juM=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "6befd3b6b8544952e0261f054cf16769294bacba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"validity": {
"flake": false,
"locked": {

View file

@ -56,6 +56,9 @@
anyrun.url = "github:Kirottu/anyrun";
anyrun.inputs.nixpkgs.follows = "nixpkgs";
miros.url = "github:mateiadrielrafael/miros";
miros.inputs.nixpkgs.follows = "nixpkgs";
# Spotify client with theming support
spicetify-nix.url = "github:the-argus/spicetify-nix";
spicetify-nix.inputs.nixpkgs.follows = "nixpkgs";

View file

@ -78,20 +78,6 @@ local abbreviations = {
}
local abolishAbbreviations = {
-- {{{ Special chars
-- System for writing special characters which need to also be easily
-- accessible as {sub/super}scripts.
--
-- The reason epsilon and lambda are separated out from everything else in
-- the pattern is because they are the only ones where `foo` doesn't expand
-- to `\\foo` directly (so I saved some keystrokes by letting scrap.nvim
-- repeat everything for me).
{
"{,e,s}{{eps,lam},{star,delta,Delta,pi,tau,psi,phi,rho,sigma,alpha,beta,theta,gamma,omega,Omega}}",
"{,^,_}\\\\{{epsilon,lambda},{}}",
options = A.no_capitalization,
},
-- }}}
-- {{{ Set symbols
-- - nats => naturals
-- - ints => integers

View file

@ -2,21 +2,20 @@ local M = {}
function M.setup()
vim.opt.runtimepath:append(vim.g.nix_extra_runtime)
local tempest = require("my.tempest")
local nix = require("nix")
-- Import my other files
tempest.configureMany(nix.pre)
require("my.keymaps").setup()
require("my.lazy").setup()
tempest.configureMany(nix.post)
vim.api.nvim_create_autocmd("FileType", {
pattern = "tex",
group = vim.api.nvim_create_augroup("luasnip-latex-snippets", {}),
once = true,
callback = function()
require("my.snippets.tex").setup()
end,
require("luasnip.loaders.from_lua").lazy_load({
fs_event_providers = {
libuv = true,
},
})
end

View file

@ -0,0 +1,76 @@
local M = {}
local conditions = require("luasnip.extras.conditions")
-- {{{ Math mode detection
-- Taken from: https://github.com/iurimateus/luasnip-latex-snippets.nvim/blob/main/lua/luasnip-latex-snippets/util/ts_utils.lua
local MATH_NODES = {
displayed_equation = true,
inline_formula = true,
math_environment = true,
}
local TEXT_NODES = {
text_mode = true,
label_definition = true,
label_reference = true,
}
local function get_node_at_cursor()
local pos = vim.api.nvim_win_get_cursor(0)
-- Subtract one to account for 1-based row indexing in nvim_win_get_cursor
local row, col = pos[1] - 1, pos[2]
local parser = vim.treesitter.get_parser(0, "latex")
if not parser then
return
end
local root_tree = parser:parse({ row, col, row, col })[1]
local root = root_tree and root_tree:root()
if not root then
return
end
return root:named_descendant_for_range(row, col, row, col)
end
local function in_text(check_parent)
local node = get_node_at_cursor()
while node do
if node:type() == "text_mode" then
if check_parent then
-- For \text{}
local parent = node:parent()
if parent and MATH_NODES[parent:type()] then
return false
end
end
return true
elseif MATH_NODES[node:type()] then
return false
end
node = node:parent()
end
return true
end
M.math = conditions.make_condition(function()
local node = get_node_at_cursor()
while node do
if TEXT_NODES[node:type()] then
return false
elseif MATH_NODES[node:type()] then
return true
end
node = node:parent()
end
return false
end)
M.text = conditions.make_condition(function()
return in_text(true)
end)
-- }}}
return M

View file

@ -1,264 +0,0 @@
local M = {}
local ls = require("luasnip")
local extras = require("luasnip.extras")
local conds = require("luasnip.extras.expand_conditions")
local t = ls.text_node
local i = ls.insert_node
local d = ls.dynamic_node
local c = ls.choice_node
local f = ls.function_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local n = extras.nonempty
local autosnippets = {}
-- {{{ Helpers
local function unlines(...)
return table.concat({ ... }, "\n")
end
local function flatten(arr)
local result = {}
for _, subarray in ipairs(arr) do
if type(subarray) == "table" then
for _, value in ipairs(subarray) do
table.insert(result, value)
end
else
table.insert(result, subarray)
end
end
return result
end
local function trig(name)
return { name = name, trig = name }
end
-- }}}
-- {{{ Math mode detection
-- Taken from: https://github.com/iurimateus/luasnip-latex-snippets.nvim/blob/main/lua/luasnip-latex-snippets/util/ts_utils.lua
local MATH_NODES = {
displayed_equation = true,
inline_formula = true,
math_environment = true,
}
local TEXT_NODES = {
text_mode = true,
label_definition = true,
label_reference = true,
}
local function get_node_at_cursor()
local pos = vim.api.nvim_win_get_cursor(0)
-- Subtract one to account for 1-based row indexing in nvim_win_get_cursor
local row, col = pos[1] - 1, pos[2]
local parser = vim.treesitter.get_parser(0, "latex")
if not parser then
return
end
local root_tree = parser:parse({ row, col, row, col })[1]
local root = root_tree and root_tree:root()
if not root then
return
end
return root:named_descendant_for_range(row, col, row, col)
end
local function in_text(check_parent)
local node = get_node_at_cursor()
while node do
if node:type() == "text_mode" then
if check_parent then
-- For \text{}
local parent = node:parent()
if parent and MATH_NODES[parent:type()] then
return false
end
end
return true
elseif MATH_NODES[node:type()] then
return false
end
node = node:parent()
end
return true
end
local function in_mathzone()
local node = get_node_at_cursor()
while node do
if TEXT_NODES[node:type()] then
return false
elseif MATH_NODES[node:type()] then
return true
end
node = node:parent()
end
return false
end
local function not_math()
return in_text(true)
end
-- }}}
-- {{{ Start of line & non-math
local beginTextCondition = function(...)
return conds.line_begin(...) and not_math()
end
local parseBeginText = ls.extend_decorator.apply(ls.parser.parse_snippet, {
condition = beginTextCondition,
}) --[[@as function]]
local snipBeginText = ls.extend_decorator.apply(ls.snippet, {
condition = beginTextCondition,
}) --[[@as function]]
local function env(name)
return "\\begin{" .. name .. "}\n\t$0\n\\end{" .. name .. "}"
end
local function optional_square_bracket_arg(index, default)
return sn(index, {
n(1, "[", ""),
i(1, default),
n(1, "]", ""),
})
end
local function theorem_env(name, prefix)
return snipBeginText(trig(name), {
t("\\begin{" .. name .. "}"),
optional_square_bracket_arg(1),
n(2, "\\label{" .. prefix .. ":", ""),
i(2),
n(2, "}", ""),
t({ "", "\t" }),
i(0),
t({ "", "\\end{" .. name .. "}" }),
})
end
vim.list_extend(autosnippets, {
parseBeginText(
{ trig = "begin", name = "Begin / end environment" },
env("$1")
),
-- {{{ Chapters / sections
parseBeginText(trig("chapter"), "\\chapter{$1}\n$0"),
parseBeginText(trig("section"), "\\section{$1}\n$0"),
parseBeginText(trig("subsection"), "\\subsection{$1}\n$0"),
parseBeginText(trig("subsubsection"), "\\subsubsection{$1}\n$0"),
-- }}}
-- {{{ Lists
parseBeginText({ trig = "item", name = "List item" }, "\\item"),
parseBeginText({ trig = "olist", name = "Ordered list" }, env("enumerate")),
parseBeginText({ trig = "ulist", name = "Unordered list" }, env("itemize")),
-- }}}
-- {{{ Theorem envs
theorem_env("theorem", "thm"),
theorem_env("lemma", "lem"),
theorem_env("exercise", "exe"),
theorem_env("definition", "def"),
theorem_env("corollary", "cor"),
theorem_env("example", "exa"),
snipBeginText(trig("proof"), {
t("\\begin{proof}"),
optional_square_bracket_arg(1),
t({ "", "\t" }),
i(0),
t({ "", "\\end{proof}" }),
}),
-- }}}
-- {{{ Special structures
parseBeginText(
{ trig = "ciff", name = "If and only if cases" },
unlines(
"\\begin{enumerate}",
"\t\\item[$\\implies$]$1",
"\t\\item[$\\impliedby$]$2",
"\\end{enumerate}",
"$0"
)
),
-- }}}
})
-- }}}
-- {{{ Non-math
local parseText = ls.extend_decorator.apply(ls.parser.parse_snippet, {
condition = not_math,
}) --[[@as function]]
local snipText = ls.extend_decorator.apply(ls.snippet, {
condition = not_math,
}) --[[@as function]]
local function ref(name, prefix)
return {
parseText(
{ trig = "r" .. name, name = name .. " reference" },
"\\ref{" .. prefix .. ":$1}$0"
),
parseText(
{ trig = "pr" .. name, name = name .. " reference" },
"(\\ref{" .. prefix .. ":$1})$0"
),
}
end
vim.list_extend(
autosnippets,
flatten({
-- {{{ References
ref("theorem", "thm"),
ref("lemma", "lem"),
ref("exercise", "exe"),
ref("definition", "def"),
ref("corollary", "cor"),
ref("example", "exa"),
{
parseText({ trig = "ref", name = "reference" }, "\\ref{$1}$0"),
parseText({ trig = "pref", name = "reference" }, "(\\ref{$1})$0"),
},
-- }}}
{
-- {{{ Misc
parseText(trig("quote"), "``$1''$0"),
parseText(trig("forcecr"), "{\\ \\\\\\\\}"),
-- }}}
-- {{{ Let ...
snipText(
{ trig = "([Ll]et)", trigEngine = "pattern", name = "definition" },
{
f(function(_, snip)
return snip.captures[1]
end),
t(" "),
sn(1, fmt("${} ≔ {}$", { i(1), i(2) })),
}
),
-- }}}
-- {{{ Display / inline math
parseText({ trig = "dm", name = "display math" }, env("align*")),
parseText({ trig = "im", name = "inline math" }, "\\$$1\\$$0"),
-- }}}
},
})
)
-- }}}
function M.setup()
ls.add_snippets("tex", autosnippets, {
type = "autosnippets",
default_priority = 0,
})
end
return M

View file

@ -1,103 +0,0 @@
for thmenv <- @{theorem,lemma,exercise,definition,corollary,example}
for thmprefix <- @{@thmenv:thm,lem,exe,def,cor,exa}
block auto !math start
for env <- @{$1,enumerate,itemize,align*}
string @{@env:begin,olist,ulist,dm}
name @{@env:environment,ordered list,unordered list,display math}
snip
\begin{@env}
$0
\end{@env}
end
string @thmprefix
snip
\begin{@thmenv}$?1{[@^{$1}]} \label{@thmprefix:$2}
$0
\end{@thmenv}
end
string proof
snip
\begin{proof}$?1{[Proof of @^{$1}]}
$0
\end{proof}
end
string ciff
name cases for ⟺
snip
\begin{enumerate}
\item[$\implies$]$1,
\item[$\impliedby$]$2,
\end{enumerate}
$0
end
string item
snip \item$|1{,[$1] $0}
block auto !math
string ref
snip \ref{$1}$0
string r@thmprefix
snip \ref{@thmprefix:$1}$0
string pref
snip (\ref{$1})$0
string pr@thmprefix
snip (\ref{@thmprefix:$1})$0
string quote
snip ``$1''$0
string forcecr
snip {\ \\\\}
pattern ([Ll]et)
name definition
snip @1 \$$1 = $2\$
string im
name inline math
snip \$$1\$$0
block math end
for suffix <- @{add,sub,rmul,pow,inv}
string ex@suffix
snip
&& \lrb{\square @{@suffix:
+ $1,
- $1,
\cdot $1,
^{$1\},
^{-1\},
}}$0
end
for prefix <- @{neg,mul,ln}
string ex@prefix
snip && \lrb{@{@prefix:-,$1,\ln} \square}$0
string exdiv
snip && \lrb{\frac \square {$1}}$0
string exint
snip && \lrb{\int\square \dif $1}$0
string exdint
snip && \lrb{\int_{$1}^{$2}\square \dif $3}$0
for kind <- @{texpl,extrin,exbound,exdef}
string @kind
snip
&& \lrb{\text{@{kind:
$1,
triangle inequality on \$$1\$,
\$$1\$ is bounded,
definition of \$$1\$,
}}}$0
end
for operator <- {overline,hat,abs,norm}
string @operator
snip \\@operator $|1{ $1,{$1\}$0}

View file

@ -1,3 +1,5 @@
-- This is the runtime for my custom nix-based neovim configuration system
local M = {}
local H = {}
M.helpers = H

View file

@ -1,77 +0,0 @@
" if exists("b:current_syntax")
" finish
" endif
set iskeyword+=-
syn match mirosComment "\v--.*$"
hi link mirosComment Comment
syn match mirosName /\v\@\h\w*/ contained
syn match mirosLiteral /\v.+/ contained contains=mirosName,mirosArray oneline
hi link mirosLiteral mirosString
syn match mirosFor /\vfor\s+\w+\s+\<-\s+/ nextgroup=mirosArray
syn match mirosForName /\vfor\s+\w+\s+/ contained containedin=mirosFor
hi link mirosForName mirosName
syn match mirosKeyword /\vfor/ contained containedin=mirosForName
syn match mirosOperator "\v\<\-" contained containedin=mirosFor
syn match mirosBlock /\v^\s*block(\s+(auto|!?(start|math)))*/
syn match mirosKeyword /\vblock/ contained containedin=mirosBlock
syn match mirosBlockContext /\v(auto|start|math)/ contained containedin=mirosBlock
hi link mirosBlockContext Constant
syn match mirosOperator /\v!/ contained containedin=mirosBlock
syn match mirosDecl /\v^\s*(desc|name|string|pattern)\s+/ nextgroup=mirosLiteral
syn match mirosKeyword /\v(desc|name|string|pattern)/ contained containedin=mirosDecl
syn match mirosDecl /\v^\s*postfix(\s+|$)/ nextgroup=mirosLiteral
syn match mirosKeyword /\vpostfix/ contained containedin=mirosDecl
syn region mirosArray matchgroup=mirosArrayBraces start=/\v\@\{/ skip=/\v\\\\|\\}/ end=/\v\}/ contained contains=mirosName,mirosArray,mirosTabStop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
hi link mirosArrayBraces mirosOperator
syn match mirosArrayMap /\v\@\w+:/ contained containedin=mirosArray contains=mirosName
syn match mirosArrayColon /\v:/ contained containedin=mirosArrayMap
hi link mirosArrayColon mirosOperator
syn region mirosShortSnipDecl matchgroup=mirosKeyword start=/\v^\s*snip\s+/ end=/\v$/ contains=mirosName,mirosArray,mirosTabstop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
syn region mirosLongSnipDecl matchgroup=mirosKeyword start=/\v^\s*snip\s*$/ end=/\v^\s*end/ contains=mirosName,mirosArray,mirosTabstop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
syn match mirosTabStop /\v\$\d/ contained
hi link mirosTabStop mirosOperator
syn region mirosNonempty start=/\v\$\?\d\{/ matchgroup=mirosOperator skip=/\v\\\\|\\}/ end=/\v\}/ contained contains=mirosName,mirosArray,mirosTabStop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
syn match mirosNonemptyDelim /\v\$\?\d\{/ contained containedin=mirosNonempty
hi link mirosNonemptyDelim mirosOperator
syn region mirosNeEscape matchgroup=mirosOperator start=/\v\@\^\{/ skip=/\v\\\\|\\}/ end=/\v\}/ contained contains=mirosName,mirosArray,mirosTabStop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice
syn match mirosCapture /\v\@\d/ contained
hi link mirosCapture mirosOperator
syn match mirosNumber /\v\d/ contained containedin=mirosCapture
syn region mirosChoice start=/\v\$\|\d\{/ matchgroup=mirosOperator skip=/\v\\\\|\\}/ end=/\v\}/ contained contains=mirosName,mirosArray,mirosTabStop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
syn match mirosChoiceDelim /\v\$\|\d\{/ contained containedin=mirosChoice
hi link mirosChoiceDelim mirosOperator
syn region mirosCall start=/@:\w\+(/ skip=/\v\\\\|\\\)/ matchgroup=mirosOperator end=')' contained contains=mirosName,mirosArray,mirosTabStop,mirosNonempty,mirosNeEscape,mirosCapture,mirosChoice,mirosCall
syn match mirosCallStart /\v\@:\w+/ contained containedin=mirosCall
hi link mirosCallStart mirosOperator
syn match mirosCallFunc /\v\w+/ contained containedin=mirosCallStart
hi link mirosCallFunc mirosName
syn match mirosOperator /(/ contained containedin=mirosCall
syn match mirosNumber /\v\d/ contained containedin=mirosNonemptyDelim,mirosTabStop,mirosChoiceDelim
syn match mirosComma /\v,/ contained containedin=mirosArray,mirosChoice
hi link mirosComma mirosOperator
hi link mirosString String
hi link mirosOperator Operator
hi link mirosFunction Function
hi link mirosKeyword Keyword
hi link mirosName Identifier
hi link mirosNumber Number
let b:current_syn = "miros"

View file

@ -18,11 +18,7 @@ let
{ inherit lib korora; }
{ tempestModule = "my.tempest"; };
# {{{ Config helpers
# :p => expands path
# :h => returns the head of the path
notmp = nlib.lua ''vim.fn.expand("%:p:h") ~= "/tmp"'';
# }}}
mirosSnippetCache = "${config.xdg.cacheHome}/miros";
generated = nlib.generateConfig
(lib.fix (self: with nlib; {
@ -807,6 +803,7 @@ let
b = mk true "%b()" "(" ")";
B = mk true "%b{}" "{" "}";
r = mk true "%b[]" "[" "]";
v = mk true "%b" "" "";
q = mk false "\".-\"" "\"" "\"";
a = mk false "'.-'" "'" "'";
};
@ -846,8 +843,6 @@ let
# {{{ luasnip
# snippeting engine
luasnip =
let reloadVscode = /* lua */ ''require("luasnip.loaders.from_vscode").lazy_load()'';
in
{
package = "L3MON4D3/LuaSnip";
version = "v2";
@ -858,16 +853,10 @@ let
enable_autosnippets = true;
update_events = ["TextChanged" "TextChangedI"];
}})
${reloadVscode}
'';
# {{{ Keybinds
keys = [
{
mapping = "<leader>rs";
action = thunk reloadVscode;
desc = "[R]eload [s]nippets";
}
{
mode = "i";
expr = true;
@ -911,6 +900,25 @@ let
# }}}
};
# }}}
# {{{ miros
# snippeting generation language
miros = with inputs.miros.packages.${pkgs.system}; {
dir = miros-nvim;
dependencies.nix = [ miros ];
cond = blacklist "vscode";
ft = "miros";
keys = {
mapping = "<leader>rm";
action = "<cmd>!miros generate"
+ " -i ${config.satellite.dev.path "home/features/neovim/snippets"}"
+ " -o ${mirosSnippetCache}/luasnippets"
+ " luasnip -r my.luasnip <cr>";
desc = "[R]erun [m]iros";
};
};
# }}}
# }}}
# {{{ ide
# {{{ lspconfig
@ -1514,20 +1522,11 @@ let
"lua/nix" "init"
generated.lua);
extraRuntime =
let snippets = config.satellite.dev.path
"home/features/neovim/snippets";
in
lib.concatStringsSep ","
[ generatedConfig snippets ];
extraRuntime = lib.concatStringsSep "," [ generatedConfig mirosSnippetCache ];
# }}}
# {{{ Client wrapper
# Wraps a neovim client, providing the dependencies
# and setting some flags:
#
# - NVIM_EXTRA_RUNTIME provides extra directories to add to the runtimepath.
# I cannot just install those dirs using the builtin package support because
# my package manager (lazy.nvim) disables those.
wrapClient = { base, name, binName ? name, extraArgs ? "", wrapFlags ? lib.id }:
let
startupScript = config.satellite.lib.lua.writeFile
@ -1598,6 +1597,7 @@ in
satellite.persistence.at.cache.apps.neovim.directories = [
"${config.xdg.cacheHome}/nvim"
mirosSnippetCache
];
# }}}
}

View file

@ -1,3 +0,0 @@
# Vscode snippets
These are snippets usable both in vscode and neovim, defined in vscode format.

View file

@ -0,0 +1,28 @@
block start
string msetup
name setup module
desc Create a lua module together with a .setup() function
snip
local M = {}
function M.setup()
$0
end
return M
string describe
name busted describe
desc Create a describe grouping for busted tests
snip
describe("$1", function ()
$0
end)
string it
name busted it
desc Create a busted test
snip
it("$1", function ()
$0
end)

View file

@ -0,0 +1,31 @@
block auto start
string for
snip
for $1 <- $|2⟨\@\⟨$2\⟩,$2⟩
$0
for kind <- @⟨string,pattern⟩
string @⟨@kind:s,p⟩snip
snip
@kind $1
name $2
snip $3
$0
block auto !word
string choice
name choice node
snip \$|$1⟨$2\⟩$0
string nonempty
name nonempty node
snip \$?$1⟨$2\⟩$0
string arrin
name array index
snip \@\⟨\@$1:$2\⟩
string nil
name ignore symbol
snip \⋄

View file

@ -0,0 +1,11 @@
block auto
string fetchgh
name fetch github
desc Fetch a GitHub repository
snip
pkgs.fetchFromGitHub {
owner = $1;
repo = $2;
rev = "";
sha256 = "";
}$0

View file

@ -1,55 +0,0 @@
{
"name": "lunar-snippets",
"engines": {
"vscode": "^1.11.0"
},
"contributes": {
"snippets": [
{
"language": [
"purs",
"purescript"
],
"path": "./snippets/purescript/other.json"
},
{
"language": [
"purs",
"purescript"
],
"path": "./snippets/purescript/imports.json"
},
{
"language": [
"purs",
"purescript"
],
"path": "./snippets/purescript/deriving.json"
},
{
"language": [
"tex"
],
"path": "./snippets/latex/core.json"
},
{
"language": [
"tex"
],
"path": "./snippets/latex/explain.json"
},
{
"language": [
"lua"
],
"path": "./snippets/lua/core.json"
},
{
"language": [
"nix"
],
"path": "./snippets/nix/core.json"
}
]
}
}

View file

@ -0,0 +1,108 @@
block start auto
string val
name value definition
desc Create a value-level declaration
snip
$1 :: $2
$1 $3 = $4
for kind <- @⟨type,newtype,data⟩
string @kind
name @kind definition
desc Define a @⟨@kind:type,newtype,adt⟩
snip data $1 = $2
string example
name example docstring
desc Provide example usage for some piece of code
snip
-- | Example:
-- | ```purs
-- | $0
-- | ```
string class
name typeclass declaration
desc Declare a typeclass
snip
class $1 $|2⟨
where
$2,
$2
string instance
name typeclass instance
desc Declare a typeclass instance
snip
instance $1 $|2⟨
where
$2,
$2
string derive
name derive typeclass instance
desc Derive a typeclass instance
snip
derive $|1⟨$1,newtype $1⟩instance $0
for typeclass <- @⟨Eq,Ord,Functor⟩
string d@⟨@typeclass:eq,ord,functor⟩
name derive @typeclass
snip derive @typeclass $0
for typeclass <- @⟨Newtype,Generic⟩
string d@⟨@typeclass:newtype,generic⟩
name derive @typeclass
snip derive @typeclass $1 _
for typeclass <- @⟨Show,Debug⟩
for lower <- @⟨@typeclass:show,debug⟩
string g@lower
name generic @lower instance
snip
instance @typeclass $1 where
@lower = generic@typeclass
string djson
name derive json instances
snip
derive newtype instance EncodeJson $",
derive newtype instance DecodeJson $1
string gjson
name generic json instances
snip
instance EncodeJson $1 where
encodeJson = genericEncodeJson
instance DecodeJson $1 where
decodeJson = genericDecodeJson
block auto
string ite
name if-then-else
snip if $1 then $2 else $0
string caseof
name pattern match
snip
case $1 of
$2 -> $0
block start
for module <- @⟨
Map,
HashMap,
Set,
HashSet,
Array,
List,
String,
Int,
Number
string imp@⟨@module:map,hashmap,set,hashset,array,list,string,int,number⟩
name import Data.@module
snip import Data.@module as @module

View file

@ -1,193 +0,0 @@
{
"Set": {
"prefix": "set",
"description": "Set I guess",
"body": "\\{$1\\\\}$0"
},
"Absolute value": {
"prefix": "abs",
"description": "Absolute values",
"body": "\\abs{$1}$0"
},
"Norm": {
"prefix": "norm",
"description": "Norm of a vector",
"body": "\\norm{$1}$0"
},
"Probability function": {
"prefix": "prob",
"description": "Probability function applied to some set",
"body": "\\prob{$1}$0"
},
"Inner product": {
"prefix": "iprod",
"description": "Inner product of two vectors",
"body": "\\iprod{$1}{$2}$0"
},
"Self inner product": {
"prefix": "diprod",
"description": "Inner product of a vector with itself",
"body": "\\dprod{$1}$0"
},
"Subscript": {
"prefix": "ss",
"description": "Subscript",
"body": "_{$1}$0"
},
"Exponent": {
"prefix": "ee",
"description": "Exponent",
"body": "^{$1}$0"
},
"Nth derivative": {
"prefix": "dd",
"description": "Nth derivative",
"body": "^{($1)}$0"
},
"Overline": {
"prefix": "ol",
"description": "Overline",
"body": "\\overline{$1}$0"
},
"Z Mod": {
"prefix": "zmod",
"description": "The set of Z/nZ",
"body": "\\mathbb{Z}/$1\\mathbb{Z}$0"
},
"Sigma sum": {
"prefix": "bsum",
"description": "Create a sum using sigma notation",
"body": "\\sum_{$1 = $2}^{$3}$0"
},
"Pi product": {
"prefix": "bproduct",
"description": "Create a produt using pi notation",
"body": "\\prod_{$1 = $2}^{$3}$0"
},
"Fraction": {
"prefix": "frac",
"description": "Create a fraction",
"body": "\\frac{$1}{$2}$0"
},
"Choose": {
"prefix": "binom",
"description": "Create a (n choose k) thingy",
"body": "\\binom{$1}{$2}$0"
},
"Limit": {
"prefix": "lim",
"description": "Create a limit",
"body": "\\lim _{$1 \\to $2}$0"
},
"Limit to infinity": {
"prefix": "ilim",
"description": "Create a limit as a variable goes to infinity",
"body": "\\lim _{$1 \\to \\infty}$0"
},
"Limit to negative infinity": {
"prefix": "nlim",
"description": "Create a limit as a variable goes to negative infinity",
"body": "\\lim _{$1 \\to -\\infty}$0"
},
"Limit to zero": {
"prefix": "zlim",
"description": "Create a limit as a variable goes to 0",
"body": "\\lim _{$1 \\to 0}$0"
},
"Sqrt": {
"prefix": "sqrt",
"description": "Create a sqrt",
"body": "\\sqrt[$1]{$2}$0"
},
"Sin": {
"prefix": "sin",
"description": "Create a sin call",
"body": "\\sin($1)$0"
},
"Cos": {
"prefix": "cos",
"description": "Create a cos call",
"body": "\\cos($1)$0"
},
"Ln": {
"prefix": "ln",
"description": "Create a ln call",
"body": "\\ln($1)$0"
},
"Let": {
"prefix": "let",
"description": "Let something equal something else",
"body": "Let $$1 = $2$. $0"
},
"System of equations": {
"prefix": "eqsystem",
"description": "Create a system of equations",
"body": [
"\\left\\{",
"\t\\begin{array}{rl}",
"\t\t$0",
"\t\\end{array}",
"\\right\\\\\\}"
]
},
"Aligned equation": {
"prefix": "aleq",
"description": "Aligned equation",
"body": [
"\\\\\\ $1 &= $2",
"$0"
]
},
"2x2 matrices": {
"prefix": "mat22",
"description": "Create a 2x2 matrix",
"body": [
"\\begin{bmatrix}",
" ${1:1} & ${2:0}",
"\\\\\\ ${3:0} & ${4:1}",
"\\end{bmatrix}$0"
]
},
"3x3 matrices": {
"prefix": "mat33",
"description": "Create a 3x3 matrix",
"body": [
"\\begin{bmatrix}",
" ${1:1} & ${2:0} & ${3:0}",
"\\\\\\ ${4:0} & ${5:1} & ${6:0}",
"\\\\\\ ${7:0} & ${8:0} & ${9:1}",
"\\end{bmatrix}$0"
]
},
"3x3 determinants": {
"prefix": "det33",
"description": "Create a 3x3 determinant",
"body": [
"\\begin{vmatrix}",
" $1 & $2 & $3",
"\\\\\\ $4 & $5 & $6",
"\\\\\\ $7 & $8 & $9",
"\\end{vmatrix}$0"
]
},
"2x2 determinants": {
"prefix": "det22",
"description": "Create a 2x2 determinant",
"body": [
"\\begin{vmatrix}",
" $1 & $2",
"\\\\\\ $3 & $4",
"\\end{vmatrix}$0"
]
},
"Definite integral": {
"prefix": "dintegral",
"description": "Definite integral",
"body": "\\int_{$1}^{$2} $3 d${4:x}$0"
},
"Indefinite integral": {
"prefix": "integral",
"description": "Integral",
"body": "\\int $1 d${2:x}$0"
}
}

View file

@ -1,87 +0,0 @@
{
"Text explanation in math mode": {
"prefix": "texpl",
"description": "Explain a step using text in math mode",
"body": "&& \\text{($1)}$0"
},
"Explanation in math mode": {
"prefix": "expl",
"description": "Explain a step in math mode",
"body": "&& ($1) $0"
},
"Explain division": {
"prefix": "exdiv",
"description": "Explain a division inside an equation",
"body": "&& \\left(\\frac{\\square}{$1}\\right)$0"
},
"Explain fraction": {
"prefix": "exfract",
"description": "Explain a step which wraps both sides of an equation by a fraction",
"body": "&& \\left(\\frac{$1}{$2} \\right)$0"
},
"Explain right multiplication": {
"prefix": "exmul",
"description": "Explain a right multiplication inside an equation",
"body": "&& \\left(\\square \\cdot $1 \\right)$0"
},
"Explain left multiplication": {
"prefix": "exlmul",
"description": "Explain a left multiplication inside an equation",
"body": "&& \\left($1 \\cdot \\square\\right)$0"
},
"Explain differentiation": {
"prefix": "exdiff",
"description": "Explain a step which differentiates both sides of an equation",
"body": "&& \\left( \\frac{d \\square} {d $1} \\right)$0"
},
"Explain integration": {
"prefix": "exint",
"description": "Explain a step which integrates both sides of an equation",
"body": "&& \\left(\\int \\square d$1 \\right)$0"
},
"Explain definite integration": {
"prefix": "exdint",
"description": "Explain a step which applies a definite integral to both sides of an equation",
"body": "&& \\left(\\int _{$1} ^{$2} \\square d$3 \\right)$0"
},
"Explain addition": {
"prefix": "exadd",
"description": "Explain a step which adds to both sides of an equation",
"body": "&& \\left( \\square + $1 \\right)$0"
},
"Explain subtraction": {
"prefix": "exsub",
"description": "Explain a step which subtracts from both sides of an equation",
"body": "&& \\left( \\square - $1 \\right)$0"
},
"Explain negation": {
"prefix": "exneg",
"description": "Explain a step which negates both sides of an equation",
"body": "&& (- \\square )$0"
},
"Explain power": {
"prefix": "expow",
"description": "Explain a step which raises both sides of an equation to a given power",
"body": "&& \\left( \\square ^{$1} \\right)$0"
},
"Explain exponentiation": {
"prefix": "exexp",
"description": "Explain a step which raises a given value to both sides of an equation",
"body": "&& \\left( $1 ^{\\square} \\right)$0"
},
"Explain natural logarithm": {
"prefix": "exln",
"description": "Explain a step which applies the ln function to both sides of an equation",
"body": "&& \\left( \\ln $1 \\right)$0"
},
"Explain triangle inequality": {
"prefix": "extrin",
"description": "Explain a step using the triangle inequality in math mode",
"body": "&& \\text{(Triangle inequality on $ $1 $)}$0"
},
"Explain being bounded": {
"prefix": "exbound",
"description": "Explain that something is bounded in math mode",
"body": "&& \\text{($ $1 $ is bounded)}$0"
}
}

View file

@ -1,33 +0,0 @@
{
"Lua setup-module": {
"prefix": "msetup",
"description": "Create lua module with setup function inside",
"body": [
"local M = {}",
"",
"function M.setup()",
" $0",
"end",
"",
"return M"
]
},
"Busted describe": {
"prefix": "describe",
"description": "Create a describe call for a busted test",
"body": [
"describe(\"$1\", function ()",
"\t$0",
"end)"
]
},
"Busted it": {
"prefix": "it",
"description": "Create an it call for a busted test",
"body": [
"it(\"$1\", function ()",
"\t$0",
"end)"
]
}
}

View file

@ -1,14 +0,0 @@
{
"Fetch from GitHub": {
"prefix": "fetchFromGitHub",
"description": "Fetch a repo from github",
"body": [
"pkgs.fetchFromGitHub {",
"\towner = \"$1\";",
"\trepo = \"$2\";",
"\trev = \"\";",
"\tsha256 = \"\";",
"}$0"
]
}
}

View file

@ -1,77 +0,0 @@
{
"Derive newtype instance": {
"prefix": "gnderive",
"description": "Use newtype deriving on any typeclass",
"body": "derive newtype instance $0 $3 $2"
},
"Generate json instances": {
"prefix": "json",
"description": "Generate the deriving of the EncodeJson and DecodeJson typeclasses",
"body": [
"derive newtype instance EncodeJson $1",
"derive newtype instance DecodeJson $1"
]
},
"Generic": {
"prefix": "dgeneric",
"description": "Generate the generic instance for a type",
"body": "derive instance Generic $1 _"
},
"Generic Show": {
"prefix": "gshow",
"description": "Generate generic show instances",
"body": [
"instance Show $1 where",
" show = genericShow"
]
},
"Generic Debug": {
"prefix": "gdebug",
"description": "Generate generic debug instances",
"body": [
"instance Debug $1 where",
" debug = genericDebug"
]
},
"Generic json": {
"prefix": "gjson",
"description": "Generate generic json instances",
"body": [
"instance EncodeJson $1 where",
" encodeJson = genericEncodeJson",
"instance DecodeJson $1 where",
" decodeJson = genericDecodeJson"
]
},
"Instance": {
"prefix": "instance",
"description": "Declare typeclass instance",
"body": [
"instance $2 $3 where",
" $0"
]
},
"Functor": {
"prefix": "dfunctor",
"description": "Derive a Functor instance",
"body": "derive instance Functor $1$0"
},
"Eq": {
"prefix": "deq",
"description": "Derive an Eq instance",
"body": "derive instance Eq $1$0"
},
"Ord": {
"prefix": "dord",
"description": "Derive an Ord instance",
"body": "derive instance Ord $1$0"
},
"Eq & Ord": {
"prefix": "deqord",
"description": "Derive an Eq and an Ord instance",
"body": [
"derive instance Eq $1",
"derive instance Ord $1$0"
]
}
}

View file

@ -1,62 +0,0 @@
{
"Tuple constructors": {
"prefix": "imptuple",
"description": "Import tuple constructors",
"body": "import Data.Tuple.Nested (type (/\\), (/\\))"
},
"Map": {
"prefix": "impmap",
"description": "Import Map module",
"body": "import Data.Map as Map"
},
"HashMap": {
"prefix": "imphashmap",
"description": "Import HashMap module",
"body": "import Data.HashMap as HashMap"
},
"FRP Event": {
"prefix": "impevent",
"description": "Import FRP.Event module",
"body": "import FRP.Event as E"
},
"List": {
"prefix": "implist",
"description": "Import List module",
"body": "import Data.List as List"
},
"Array": {
"prefix": "imparray",
"description": "import Array module",
"body": "import Data.Array as Array"
},
"AVar": {
"prefix": "impavar",
"description": "import AVar module",
"body": "import Effect.Aff.AVar as AV"
},
"Object": {
"prefix": "impobject",
"description": "import Foreign.Object module",
"body": "import Foreign.Object as Object"
},
"STObject": {
"prefix": "impstobject",
"description": "import STObject module",
"body": "import Foreign.Object.ST as STObject"
},
"Ref": {
"prefix": "impref",
"description": "import Effect.Ref module",
"body": "import Effect.Ref as Ref"
},
"Int": {
"prefix": "impint",
"description": "import Data.Int module",
"body": "import Data.Int as Int"
},
"Number": {
"prefix": "impnumber",
"description": "import Data.Number module",
"body": "import Data.Number as Number"
}
}

View file

@ -1,61 +0,0 @@
{
"Definition": {
"prefix": "definition",
"description": "Basic purescript definition",
"body": ["$1 :: $2", "$1 = $3"]
},
"SProxy": {
"prefix": "sproxy",
"description": "Generate a proxy constant",
"body": ["_$1 :: Proxy \"$1\"", "_$1 = Proxy"]
},
"Proxy": {
"prefix": "proxy",
"description": "Generate a proxy constant",
"body": ["_$1 :: Proxy $1", "_$1 = Proxy"]
},
"Prop": {
"prefix": "prop",
"description": "Prop lens",
"body": ["_$1 :: Lens' $2 $3", "_$1 = prop (Proxy :: _ \"$1\")"]
},
"Variant constructor": {
"prefix": "inj",
"description": "Generate a constructor for a variant an inline sproxy",
"body": [
"$1 :: forall r a. a -> Variant ( $1 :: a | r)",
"$1 = inj (SProxy :: SProxy \"$1\")"
]
},
"Full variant constructor": {
"prefix": "injf",
"description": "Generate a constructor for a variant with an external sproxy definition",
"body": [
"$1 :: forall r a. a -> Variant ( $1 :: a | r)",
"$1 = inj _$1",
"",
"_$1 :: Proxy \"$1\"",
"_$1 = Proxy"
]
},
"Example code": {
"prefix": "ex",
"description": "Provide example usage for some piece of code",
"body": ["-- |", "-- | Ex:", "-- | ```purs", "-- | $0", "-- | ```"]
},
"Section": {
"prefix": "section",
"description": "Delimit a section using 10 dashes",
"body": "---------- $0"
},
"Typeclass instances": {
"prefix": "sinstances",
"description": "Delimit a section which declares typeclass instances",
"body": ["---------- Typeclass instances", "$0"]
},
"If": {
"prefix": "if",
"description": "If then else expression",
"body": ["if $1", "\tthen $2", "\telse $3"]
}
}

View file

@ -0,0 +1,203 @@
for thmenv <- @⟨theorem,lemma,exercise,definition,corollary,example⟩
for thmprefix <- @⟨@thmenv:thm,lem,exe,def,cor,exa⟩
block auto !math start
for env <- @⟨$1,enumerate,itemize,align*⟩
string @⟨@env:begin,olist,ulist,dm⟩
name @⟨@env:environment,ordered list,unordered list,display math⟩
snip
\begin{@env}
$0
\end{@env}
string proof
snip
\begin{proof}$?1⟨[Proof of @^⟨$1⟩]⟩
$0
\end{proof}
string ciff
name cases for ⟺
snip
\begin{enumerate}
\item[$\implies$]$1,
\item[$\impliedby$]$2,
\end{enumerate}
$0
string item
snip \item$|1⟨,[$1] $0⟩
block text
string ref
snip \ref{$1}$0
string r@thmprefix
snip \ref{@thmprefix:$1}$0
string pref
snip (\ref{$1})$0
string pr@thmprefix
snip (\ref{@thmprefix:$1})$0
string quote
snip ``$1''$0
string forcecr
snip {\ \\\\}
pattern ([Ll]et)
name definition
snip @1 \$$1 = $2\$
block auto
string im
name inline math
snip \$$1\$$0
block math
for shorthand <- @⟨sum,prod⟩
for symbol <- @⟨@shorthand:sigma,pi⟩
for operation <- @⟨@shorthand:sum,product⟩
string b@shorthand
name @symbol @operation
desc Write out a @operation using big @symbol notation
snip \\@symbol{$|1⟨$1 = $2,$1⟩}^$|2⟨{$2},\infty$2⟩ $0
for matkind <- @⟨matrix,determinant⟩
for matenv <- @⟨@matkind:bmatrix,vmatrix⟩
for shorthand <- @⟨@matkind:mat,det⟩
string 2@shorthand
name 2x2 @matkind
snip
\begin{@matenv}
$1 & $2 \\\\
$3 & $4
\end{@matenv}
string 3@shorthand
name 3x3 @matkind
snip
\begin{@matenv}
$1 & $2 & $3 \\\\
$4 & $5 & $6 \\\\
$7 & $8 & $9
\end{@matenv}
for operator <- @⟨eq,neq,leq,geq,lt,gt⟩
for symbol <- @⟨@operator:=,\neq,\leq,\geq,<,>⟩
block auto
string a@operator
name align at @operator
snip &@symbol $0
block auto start
string al@operator
name aligned @operator
snip
\\\\ $1 &@symbol $2
$0
string cr@operator
name start with @operator
snip \\\\&@symbol $0
block start
string eqsystem
name system of equations
snip
\left\{
\begin{array}{rl}
$0
\end{array}
\right\}
block end
for suffix <- @⟨add,sub,rmul,pow,inv⟩
string ex@suffix
snip
&& \lrb{\square @⟨@suffix:
+ $1,
- $1,
\cdot $1,
^{$1},
^{-1},
⟩}$0
for prefix <- @⟨neg,mul,ln⟩
string ex@prefix
snip && \lrb{@⟨@prefix:-,$1,\ln⟩ \square}$0
string exdiv
snip && \lrb{\frac \square {$1}}$0
string exint
snip && \lrb{\int\square \dif $1}$0
string exdint
snip && \lrb{\int_{$1}^{$2}\square \dif $3}$0
for kind <- @⟨texpl,extrin,exbound,exdef⟩
string @kind
snip
&& \lrb{\text{@⟨@kind:
$1,
triangle inequality on $$1$,
$$1$ is bounded,
definition of $$1$,
⟩}}$0
block auto
for constant <- @⟨star,delta,Delta,pi,tau,psi,phi,rho,sigma,alpha,beta,theta,gamma,omega,Omega⟩
string @constant
snip \\@constant
for shortconstant <- @⟨eps,lam⟩
string @shortconstant
snip \\@⟨@shortconstant:epsilon,lambda⟩
for operator <- @⟨overline,hat,abs,norm,prob,diprod,sin,cos,sqrt,ln,lrb,zmod⟩
string @operator
snip \\@operator$|1⟨{$1}, $0⟩
for bioperator <- @⟨iprod,frac,binom⟩
string @bioperator
snip \\@bioperator$|1⟨ $1,{$1}⟩$|2⟨ $2,{$2}⟩ $0
string set
desc Create a set by escaping the brackets
snip \{$1\}
pattern e([%a%d])
name auto exponent
snip ^@0
pattern s([%a%d])
name auto subscript
snip _@0
pattern (\?[%a]+)(%d)
name auto digt subscript
snip @0_@1
string ss
name subscript
snip _{$1}$0
string ee
name exponent
snip ^{$1}$0
for limtarget <- @⟨anything,zero,infinity,negative infinity⟩
for prefix <- @⟨@limtarget:,z,i,n⟩
for limtargetsymbol <- @⟨@limtarget:$2,0,\infty,-\infty⟩
string @prefix⋄lim
name limit to @limtarget
snip \lim_{$1 \to @limtargetsymbol} $0
string dint
name definite integral
snip \int_{$|1⟨$1,-\infty$1⟩}^$|2⟨{$2},\infty$2⟩ $3 \dif $0
string iint
name indefinite integral
snip \int $1 \dif $0

View file

@ -7,7 +7,7 @@ This directory contains custom module definitions used throughout my config.
| Directory | Description |
| ------------------------------ | -------------------------------------------------------------- |
| [common](./common) | Modules usable in both HM and nixos (and perhaps other places) |
| [nixos](./nixos) | Nixos specific functinality |
| [nixos](./nixos) | Nixos specific functionality |
| [home-manager](./home-manager) | Home manager specific functionality |
## Common modules

View file

@ -179,6 +179,9 @@ let
lua /* lua */ ''
D.tempest.whitelist(${encode given})
'';
# :p => expands path
# :h => returns the head of the path
notmp = lua ''vim.fn.expand("%:p:h") ~= "/tmp"'';
# }}}
# {{{ Main config generation entrypoint
generateConfig = rawConfig: