From 480d221ee419c2f5db409ad84a330f0263f258cd Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Tue, 30 Apr 2024 01:43:00 +0530 Subject: [PATCH] feat: Update neovim --- common/home.nix | 2 + flake.lock | 119 +++++++++++++++++++++++++++++++------------- flake.nix | 2 +- neovim/flake.lock | 29 ++++++----- neovim/flake.nix | 14 +++++- neovim/nvim.nix | 11 ++++ neovim/overlays.nix | 113 ++++++++++++++++++++--------------------- 7 files changed, 179 insertions(+), 111 deletions(-) diff --git a/common/home.nix b/common/home.nix index 4e0afcb0..205340a0 100644 --- a/common/home.nix +++ b/common/home.nix @@ -69,6 +69,8 @@ in { pkg-config devenv sleek + d2 + jujutsu # openapi-tui # Misc diff --git a/flake.lock b/flake.lock index e7fc730e..5b83ac5a 100644 --- a/flake.lock +++ b/flake.lock @@ -298,6 +298,22 @@ "type": "github" } }, + "d2": { + "flake": false, + "locked": { + "lastModified": 1675176182, + "narHash": "sha256-+mT4pEbtq7f9ZXhOop3Jnjr7ulxU32VtahffIwQqYF4=", + "owner": "terrastruct", + "repo": "d2-vim", + "rev": "981c87dccb63df2887cc41b96e84bf550f736c57", + "type": "github" + }, + "original": { + "owner": "terrastruct", + "repo": "d2-vim", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": "nixpkgs_3" @@ -1267,11 +1283,11 @@ ] }, "locked": { - "lastModified": 1713732794, - "narHash": "sha256-AYCofb8Zu4Mbc1lHDtju/uxeARawRijmOueAqEMEfMU=", + "lastModified": 1713992342, + "narHash": "sha256-bW7K4WPo6jhYMo4ZUGoJfog6xJV0XZh8adXqZKunRoc=", "owner": "nix-community", "repo": "home-manager", - "rev": "670d9ecc3e46a6e3265c203c2d136031a3d3548e", + "rev": "2f072c127c041eec36621b8e38a531fe0fe07961", "type": "github" }, "original": { @@ -1288,11 +1304,11 @@ ] }, "locked": { - "lastModified": 1713732794, - "narHash": "sha256-AYCofb8Zu4Mbc1lHDtju/uxeARawRijmOueAqEMEfMU=", + "lastModified": 1713992342, + "narHash": "sha256-bW7K4WPo6jhYMo4ZUGoJfog6xJV0XZh8adXqZKunRoc=", "owner": "nix-community", "repo": "home-manager", - "rev": "670d9ecc3e46a6e3265c203c2d136031a3d3548e", + "rev": "2f072c127c041eec36621b8e38a531fe0fe07961", "type": "github" }, "original": { @@ -1488,6 +1504,7 @@ }, "neovim": { "inputs": { + "d2": "d2", "gp-nvim": "gp-nvim", "neogit": "neogit", "neorg": "neorg", @@ -1500,11 +1517,13 @@ "nvim-devdocs": "nvim-devdocs", "pets": "pets", "rest-nvim": "rest-nvim", - "systems": "systems_14" + "systems": "systems_14", + "tree-sitter-d2": "tree-sitter-d2", + "tree-sitter-just": "tree-sitter-just" }, "locked": { "lastModified": 1, - "narHash": "sha256-gCukuAUllTFxqnRuhUvSapyMCWHd1sSD96SSI9518ow=", + "narHash": "sha256-pmGkwZxQ9+lSOJX5Q7+hdxI9tkY+Jfl8yolBymPOUgc=", "path": "./neovim", "type": "path" }, @@ -1595,11 +1614,11 @@ ] }, "locked": { - "lastModified": 1713543876, - "narHash": "sha256-olEWxacm1xZhAtpq+ZkEyQgR4zgfE7ddpNtZNvubi3g=", + "lastModified": 1713946171, + "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "9e7c20ffd056e406ddd0276ee9d89f09c5e5f4ed", + "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", "type": "github" }, "original": { @@ -1615,11 +1634,11 @@ ] }, "locked": { - "lastModified": 1713543876, - "narHash": "sha256-olEWxacm1xZhAtpq+ZkEyQgR4zgfE7ddpNtZNvubi3g=", + "lastModified": 1713946171, + "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "9e7c20ffd056e406ddd0276ee9d89f09c5e5f4ed", + "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", "type": "github" }, "original": { @@ -1636,11 +1655,11 @@ ] }, "locked": { - "lastModified": 1713543876, - "narHash": "sha256-olEWxacm1xZhAtpq+ZkEyQgR4zgfE7ddpNtZNvubi3g=", + "lastModified": 1713946171, + "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "9e7c20ffd056e406ddd0276ee9d89f09c5e5f4ed", + "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", "type": "github" }, "original": { @@ -1908,16 +1927,15 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1714124569, - "narHash": "sha256-v8DjUedj2WB0cyeOlZtM88Xm2sfrhlgcqqoEFFr8myc=", - "owner": "GaetanLepage", + "lastModified": 1714368997, + "narHash": "sha256-NYAi9WSwFab1S3hDFWos3sk+o34TY1wwreIxHTchzSs=", + "owner": "nix-community", "repo": "nixvim", - "rev": "aa696d6fb70d7a68a010a18f844ded267cfcb80a", + "rev": "b12d81c69a7328256ce52eb640b5682bc108df78", "type": "github" }, "original": { - "owner": "GaetanLepage", - "ref": "ast-grep", + "owner": "nix-community", "repo": "nixvim", "type": "github" } @@ -1935,16 +1953,15 @@ "pre-commit-hooks": "pre-commit-hooks_2" }, "locked": { - "lastModified": 1714124569, - "narHash": "sha256-v8DjUedj2WB0cyeOlZtM88Xm2sfrhlgcqqoEFFr8myc=", - "owner": "GaetanLepage", + "lastModified": 1714368997, + "narHash": "sha256-NYAi9WSwFab1S3hDFWos3sk+o34TY1wwreIxHTchzSs=", + "owner": "nix-community", "repo": "nixvim", - "rev": "aa696d6fb70d7a68a010a18f844ded267cfcb80a", + "rev": "b12d81c69a7328256ce52eb640b5682bc108df78", "type": "github" }, "original": { - "owner": "GaetanLepage", - "ref": "ast-grep", + "owner": "nix-community", "repo": "nixvim", "type": "github" } @@ -2059,11 +2076,11 @@ ] }, "locked": { - "lastModified": 1713775815, - "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "lastModified": 1713954846, + "narHash": "sha256-RWFafuSb5nkWGu8dDbW7gVb8FOQOPqmX/9MlxUUDguw=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "rev": "6fb82e44254d6a0ece014ec423cb62d92435336f", "type": "github" }, "original": { @@ -2118,11 +2135,11 @@ ] }, "locked": { - "lastModified": 1713775815, - "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "lastModified": 1713954846, + "narHash": "sha256-RWFafuSb5nkWGu8dDbW7gVb8FOQOPqmX/9MlxUUDguw=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "rev": "6fb82e44254d6a0ece014ec423cb62d92435336f", "type": "github" }, "original": { @@ -2698,6 +2715,38 @@ "type": "github" } }, + "tree-sitter-d2": { + "flake": false, + "locked": { + "lastModified": 1694985317, + "narHash": "sha256-Auap3+yBBxv4RyiSaQ1sHKsSfzgrKdq0F1ethWnM+pE=", + "owner": "ravsii", + "repo": "tree-sitter-d2", + "rev": "c21126b5ee97b0dffe4b2f982932739f0a772743", + "type": "github" + }, + "original": { + "owner": "ravsii", + "repo": "tree-sitter-d2", + "type": "github" + } + }, + "tree-sitter-just": { + "flake": false, + "locked": { + "lastModified": 1711142481, + "narHash": "sha256-EnU0IpBr9i3+RFLzg7g6XuDSiuMBLGQ0eCJNPKeDohw=", + "owner": "IndianBoy42", + "repo": "tree-sitter-just", + "rev": "6c2f018ab1d90946c0ce029bb2f7d57f56895dff", + "type": "github" + }, + "original": { + "owner": "IndianBoy42", + "repo": "tree-sitter-just", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index c1db416b..4ed7fda0 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nixvim = { - url = "github:GaetanLepage/nixvim/ast-grep"; + url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; }; nix-index-database.url = "github:Mic92/nix-index-database"; diff --git a/neovim/flake.lock b/neovim/flake.lock index 94d7d550..96f71789 100644 --- a/neovim/flake.lock +++ b/neovim/flake.lock @@ -253,11 +253,11 @@ ] }, "locked": { - "lastModified": 1713732794, - "narHash": "sha256-AYCofb8Zu4Mbc1lHDtju/uxeARawRijmOueAqEMEfMU=", + "lastModified": 1713992342, + "narHash": "sha256-bW7K4WPo6jhYMo4ZUGoJfog6xJV0XZh8adXqZKunRoc=", "owner": "nix-community", "repo": "home-manager", - "rev": "670d9ecc3e46a6e3265c203c2d136031a3d3548e", + "rev": "2f072c127c041eec36621b8e38a531fe0fe07961", "type": "github" }, "original": { @@ -348,11 +348,11 @@ ] }, "locked": { - "lastModified": 1713543876, - "narHash": "sha256-olEWxacm1xZhAtpq+ZkEyQgR4zgfE7ddpNtZNvubi3g=", + "lastModified": 1713946171, + "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "9e7c20ffd056e406ddd0276ee9d89f09c5e5f4ed", + "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", "type": "github" }, "original": { @@ -390,16 +390,15 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1714124569, - "narHash": "sha256-v8DjUedj2WB0cyeOlZtM88Xm2sfrhlgcqqoEFFr8myc=", - "owner": "GaetanLepage", + "lastModified": 1714368997, + "narHash": "sha256-NYAi9WSwFab1S3hDFWos3sk+o34TY1wwreIxHTchzSs=", + "owner": "nix-community", "repo": "nixvim", - "rev": "aa696d6fb70d7a68a010a18f844ded267cfcb80a", + "rev": "b12d81c69a7328256ce52eb640b5682bc108df78", "type": "github" }, "original": { - "owner": "GaetanLepage", - "ref": "ast-grep", + "owner": "nix-community", "repo": "nixvim", "type": "github" } @@ -475,11 +474,11 @@ ] }, "locked": { - "lastModified": 1713775815, - "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "lastModified": 1713954846, + "narHash": "sha256-RWFafuSb5nkWGu8dDbW7gVb8FOQOPqmX/9MlxUUDguw=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "rev": "6fb82e44254d6a0ece014ec423cb62d92435336f", "type": "github" }, "original": { diff --git a/neovim/flake.nix b/neovim/flake.nix index 473a2d1a..b5857c80 100644 --- a/neovim/flake.nix +++ b/neovim/flake.nix @@ -3,7 +3,7 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default"; nixvim = { - url = "github:GaetanLepage/nixvim/ast-grep"; + url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; }; nnn = { @@ -38,6 +38,18 @@ url = "github:NeogitOrg/neogit/nightly"; flake = false; }; + tree-sitter-d2 = { + url = "github:ravsii/tree-sitter-d2"; + flake = false; + }; + tree-sitter-just = { + url = "github:IndianBoy42/tree-sitter-just"; + flake = false; + }; + d2 = { + url = "github:terrastruct/d2-vim"; + flake = false; + }; }; outputs = { diff --git a/neovim/nvim.nix b/neovim/nvim.nix index eac6c57d..9fabb2ba 100644 --- a/neovim/nvim.nix +++ b/neovim/nvim.nix @@ -114,6 +114,7 @@ in rec { ++ (with pkgs.tree-sitter-grammars; [ tree-sitter-just tree-sitter-nu + tree-sitter-d2 tree-sitter-norg-meta ]); }; @@ -321,6 +322,7 @@ in rec { "mm" = "[[Neorg]]"; "vff" = "[[vertical Gdiffsplit]]"; + "rr" = "vim.lsp.buf.rename"; "" = "vim.lsp.buf.definition"; "" = "require('FTerm').toggle"; "F" = "function() vim.lsp.buf.format({ async = true }) end"; @@ -333,6 +335,7 @@ in rec { "gg" = "require'telescope.builtin'.live_grep"; ";" = "require'telescope.builtin'.buffers"; + # Emulate tmux bindings with prefix and tabs "" = "[[g]]"; "c" = "[[tabnew]]"; "x" = "[[tabclose]]"; @@ -618,6 +621,13 @@ in rec { }, ignore_blank_lines = true, -- ignore blank lines when sending visual select lines }) + + vim.filetype.add({ + extension = { + http = "http", + }, + }) + ''; package = pkgs.neovim-nightly; opts = { @@ -689,6 +699,7 @@ in rec { nvim-devdocs iron-nvim + d2 pkgs.tree-sitter-grammars.tree-sitter-just pkgs.tree-sitter-grammars.tree-sitter-nu diff --git a/neovim/overlays.nix b/neovim/overlays.nix index 209afab9..06ce50b6 100644 --- a/neovim/overlays.nix +++ b/neovim/overlays.nix @@ -3,6 +3,11 @@ vimPlugins = prev.vimPlugins // { + d2 = final.pkgs.vimUtils.buildVimPlugin { + name = "d2"; + version = "1"; + src = inputs.d2; + }; gp-nvim = final.pkgs.vimUtils.buildVimPlugin { name = "gp.nvim"; src = inputs.gp-nvim; @@ -13,16 +18,7 @@ src = inputs.neogit; dependencies = with final.vimPlugins; [plenary-nvim diffview-nvim fzf-lua]; }; - # comfortable-motion = final.pkgs.vimUtils.buildVimPlugin { - # name = "comfortable-motion"; - # # TODO: Move to subflake - # src = final.pkgs.fetchFromGitHub { - # owner = "yuttie"; - # repo = "comfortable-motion.vim"; - # rev = "master"; - # sha256 = "sha256-S1LJXmShhpCJIg/FEPx3jFbmPpS/1U4MAQN2RY/nkI0"; - # }; - # }; + nvim-dap-rr = final.pkgs.vimUtils.buildVimPlugin { name = "nvim-dap-rr"; # TODO: Move to subflake @@ -86,13 +82,12 @@ tree-sitter-just = final.pkgs.tree-sitter.buildGrammar { language = "just"; version = "1"; - # TODO: Move to subflake - src = final.pkgs.fetchFromGitHub { - owner = "IndianBoy42"; - repo = "tree-sitter-just"; - rev = "613b3fd39183bec94bc741addc5beb6e6f17969f"; - sha256 = "sha256-OBlXwWriE6cdGn0dhpfSMnJ6Rx1Z7KcXehaamdi/TxQ"; - }; + src = inputs.tree-sitter-just; + }; + tree-sitter-d2 = final.pkgs.tree-sitter.buildGrammar { + language = "d2"; + version = "1"; + src = inputs.tree-sitter-d2; }; tree-sitter-nu = final.pkgs.tree-sitter.buildGrammar { language = "nu"; @@ -107,51 +102,51 @@ }; }; }; - rest-nvim-overlay = final: prev: let - rest-nvim-src = inputs.rest-nvim; - rest-nvim-luaPackage-override = luaself: luaprev: { - rest-nvim = luaself.callPackage ( - { - luaOlder, - buildLuarocksPackage, - lua, - nvim-nio, - luarocks-nix, - lua-curl, - mimetypes, - xml2lua, - }: - buildLuarocksPackage { - pname = "rest.nvim"; - version = "scm-1"; - knownRockspec = "${rest-nvim-src}/rest.nvim-scm-1.rockspec"; - src = rest-nvim-src; - propagatedBuildInputs = [lua luarocks-nix nvim-nio lua-curl mimetypes xml2lua]; - disable = luaOlder "5.1"; - } - ) {}; - }; - lua5_1 = prev.lua5_1.override { - packageOverrides = rest-nvim-luaPackage-override; - }; - lua51Packages = final.lua5_1.pkgs; - in { - inherit lua5_1 lua51Packages; - # vimPlugins = - # prev.vimPlugins - # // { - # rest-nvim = final.neovimUtils.buildNeovimPlugin { - # pname = "rest.nvim"; - # version = "scm-1"; - # src = rest-nvim-src; - # }; - # }; - # rest-nvim = final.vimPlugins.rest-nvim; - }; + # rest-nvim-overlay = final: prev: let + # rest-nvim-src = inputs.rest-nvim; + # rest-nvim-luaPackage-override = luaself: luaprev: { + # rest-nvim = luaself.callPackage ( + # { + # luaOlder, + # buildLuarocksPackage, + # lua, + # nvim-nio, + # luarocks-nix, + # lua-curl, + # mimetypes, + # xml2lua, + # }: + # buildLuarocksPackage { + # pname = "rest.nvim"; + # version = "scm-1"; + # knownRockspec = "${rest-nvim-src}/rest.nvim-scm-1.rockspec"; + # src = rest-nvim-src; + # propagatedBuildInputs = [lua luarocks-nix nvim-nio lua-curl mimetypes xml2lua]; + # disable = luaOlder "5.1"; + # } + # ) {}; + # }; + # lua5_1 = prev.lua5_1.override { + # packageOverrides = rest-nvim-luaPackage-override; + # }; + # lua51Packages = final.lua5_1.pkgs; + # in { + # inherit lua5_1 lua51Packages; + # # vimPlugins = + # # prev.vimPlugins + # # // { + # # rest-nvim = final.neovimUtils.buildNeovimPlugin { + # # pname = "rest.nvim"; + # # version = "scm-1"; + # # src = rest-nvim-src; + # # }; + # # }; + # # rest-nvim = final.vimPlugins.rest-nvim; + # }; in [ inputs.nnn.overlay inputs.nixvim.overlays.default vimPlugins tree-sitter-grammars - rest-nvim-overlay + # rest-nvim-overlay ]