From 5b83bd79c04fa9728acf1a4d819a58bfff61c728 Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Wed, 13 Mar 2024 00:00:55 +0530 Subject: [PATCH] [feat] Use nix-index-database --- config/nix/common/home.nix | 13 ++- config/nix/common/nvim/default.nix | 164 ++++++++++++++++++++++++++++- config/nix/flake.lock | 41 +++++++- config/nix/flake.nix | 2 + config/nix/overlays.nix | 9 ++ 5 files changed, 220 insertions(+), 9 deletions(-) diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index fb015922..da24fc02 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -14,7 +14,8 @@ in home.packages = with pkgs; [ - psst + gnupg + gpg-tui comma neovide sqls @@ -32,7 +33,6 @@ in bottom qmk nodejs - nix-index macchina ripgrep fd @@ -50,6 +50,7 @@ in (nerdfonts.override { fonts = [ "Hasklig" ]; }) mpv ] ++ lib.optionals device.isLinux [ + psst gnome.seahorse gnome.nautilus nextcloud-client @@ -110,7 +111,10 @@ in userName = "uttarayan21"; userEmail = "email@uttarayan.me"; }; - nix-index.enableFishIntegration = true; + nix-index = { + enable = true; + enableFishIntegration = true; + }; fish = { enable = true; shellAbbrs = { @@ -228,9 +232,8 @@ in file = { ".config/tmux/sessions".source = ../../tmux/sessions; ".config/macchina".source = ../../macchina; - # catppuccin themes for fish ".config/fish/themes".source = pkgs.catppuccinThemes.fish + "/themes"; - + ".cache/nix-index".source = pkgs.nix-index-database; } // (if lazy then { ".config/nvim/lua".source = ../../nvim/lua; ".config/nvim/init.lua".source = ../../nvim/init.lua; diff --git a/config/nix/common/nvim/default.nix b/config/nix/common/nvim/default.nix index 2c1c3593..eee0d50b 100644 --- a/config/nix/common/nvim/default.nix +++ b/config/nix/common/nvim/default.nix @@ -177,6 +177,18 @@ trouble-nvim crates-nvim sqls-nvim + # (nvim-treesitter.withPlugins (_: nvim-treesitter.allGrammars ++ [ + # (pkgs.tree-sitter.buildGrammar { + # language = "just"; + # version = "8af0aab"; + # src = pkgs.fetchFromGitHub { + # owner = "IndianBoy42"; + # repo = "tree-sitter-just"; + # rev = "8af0aab79854aaf25b620a52c39485849922f766"; + # sha256 = "sha256-hYKFidN3LHJg2NLM1EiJFki+0nqi1URnoLLPknUbFJY="; + # }; + # }) + # ])) # No more postman rest-nvim @@ -188,9 +200,159 @@ # Utils FTerm-nvim plenary-nvim + nix-develop-nvim ]; - extraConfigLua = builtins.readFile ./extraConfig.lua; + extraConfigLua = /* lua */ '' + require('rest-nvim').setup() + require('telescope').setup { + defaults = { + initial_mode = 'insert', + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + } + } + } + + require('telescope').load_extension("ui-select") + require('telescope').load_extension("dap") + require('telescope').load_extension("fzf") + require('telescope').load_extension("file_browser") + require('telescope').load_extension("rest") + + vim.g.rustaceanvim = { + tools = { + enable_clippy = false, + }, + server = { + capabilities = require 'lsp-zero'.get_capabilities(), + on_attach = function(client, bufnr) + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(bufnr, true) + end + end, + }, + dap = { + autoload_configurations = false + }, + } + + require("copilot").setup({ + suggestion = { + enabled = true, + auto_trigger = true, + keymap = { + accept = "", + } + }, + panel = { enabled = true }, + }) + + require 'fidget'.setup() + + + -- ======================================================================= + -- nvim-cmp + -- ======================================================================= + + local cmp = require("cmp") + cmp.setup({ + view = { + entries = { name = 'custom', selection_order = 'near_cursor' } + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + sources = cmp.config.sources({ + { name = "copilot", }, + { name = 'buffer' }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'treesitter' }, + { name = 'path' }, + { name = 'git' }, + { name = 'tmux' } + }), + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm(), + [''] = cmp.mapping.complete(), + -- [''] = cmp.mapping.complete(), + [''] = cmp.config.next, + [''] = cmp.config.prev, + }) + }) + + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline { + [''] = cmp.config.disable, + [''] = cmp.config.disable, + }, + sources = { + { name = 'buffer' } + } + }) + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline { + [''] = cmp.config.disable, + [''] = cmp.config.disable, + }, + -- mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }) + }) + require('crates').setup() + require('outline').setup() + require("noice").setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = true, -- add a border to hover docs and signature help + }, + }) + + require 'FTerm'.setup({ + border = 'double', + dimensions = { + height = 0.95, + width = 0.95, + }, + cmd = "fish", + blend = 10, + }) + ''; + # builtins.readFile ./extraConfig.lua; package = pkgs.neovim-nightly; }; } diff --git a/config/nix/flake.lock b/config/nix/flake.lock index 6468efab..384ccad2 100644 --- a/config/nix/flake.lock +++ b/config/nix/flake.lock @@ -419,7 +419,7 @@ }, "haumea": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1685133229, @@ -672,6 +672,24 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1710120787, + "narHash": "sha256-tlLuB73OCOKtU2j83bQzSYFyzjJo3rjpITZE5MoofG8=", + "owner": "Mic92", + "repo": "nix-index-database", + "rev": "e76ff2df6bfd2abe06abd8e7b9f217df941c1b07", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "nix-index-database", + "type": "github" + } + }, "nixneovim": { "inputs": { "flake-utils": "flake-utils_7", @@ -806,6 +824,22 @@ } }, "nixpkgs_4": { + "locked": { + "lastModified": 1709703039, + "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1681001314, "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=", @@ -820,7 +854,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1709703039, "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", @@ -955,8 +989,9 @@ "lanzaboote": "lanzaboote", "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-darwin": "nix-darwin", + "nix-index-database": "nix-index-database", "nixneovim": "nixneovim", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_6", "nur": "nur" } }, diff --git a/config/nix/flake.nix b/config/nix/flake.nix index af7939fc..dfaa4e45 100644 --- a/config/nix/flake.nix +++ b/config/nix/flake.nix @@ -47,6 +47,8 @@ # nixneovimplugins = { # url = "github:NixNeovim/NixNeovimPlugins"; # inputs.nixpkgs.follows = "nixpkgs"; + # } + nix-index-database.url = "github:Mic92/nix-index-database"; nur.url = "github:nix-community/nur"; diff --git a/config/nix/overlays.nix b/config/nix/overlays.nix index a2c5de65..dbd52be6 100644 --- a/config/nix/overlays.nix +++ b/config/nix/overlays.nix @@ -9,6 +9,7 @@ let }; vimPlugins = final: prev: { vimPlugins = prev.vimPlugins // { + # nvim-treesitter comfortable-motion = final.pkgs.vimUtils.buildVimPlugin { name = "comfortable-motion"; src = final.pkgs.fetchFromGitHub { @@ -66,6 +67,13 @@ let catppuccinThemes = import ./themes/catppuccin.nix { pkgs = final.pkgs; }; }; + + nix-index-db = (final: prev: { + nix-index-database = final.runCommandLocal "nix-index-database" { } '' + mkdir -p $out + ln -s ${inputs.nix-index-database.legacyPackages.${prev.system}.database} $out/files + ''; + }); in [ catppuccinThemes @@ -76,4 +84,5 @@ in inputs.nixneovim.overlays.default # inputs.nixneovimplugins.overlays.default inputs.nur.overlay + nix-index-db ]