From 186af6d51ecfc55972def22931ced0d58708f245 Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Wed, 28 Feb 2024 11:28:06 +0530 Subject: [PATCH] [feat] Improve the nixneovim config --- config/nix/common/home.nix | 1 + config/nix/common/nvim.nix | 104 ++++++++++++++++++++++-- config/nix/flake.lock | 122 ++++++++++++++++++++++++++--- config/nix/flake.nix | 48 ++++++++---- config/nix/nixos/configuration.nix | 5 +- 5 files changed, 247 insertions(+), 33 deletions(-) diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index 48df90a8..0cd111d2 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -42,6 +42,7 @@ in { (nerdfonts.override { fonts = [ "Hasklig" ]; }) mpv ] ++ (if device.isLinux then [ + steam-run (pkgs.catppuccin-gtk.override { variant = "mocha"; size = "standard"; diff --git a/config/nix/common/nvim.nix b/config/nix/common/nvim.nix index bd02e3a4..c8d53e2a 100644 --- a/config/nix/common/nvim.nix +++ b/config/nix/common/nvim.nix @@ -2,26 +2,97 @@ imports = [ inputs.nixneovim.nixosModules.default ]; programs.nixneovim = { enable = true; - extraConfigLua = '' - vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" - vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()" - ''; options = { + foldexpr = "nvim_treesitter#foldexpr()"; + foldmethod = "expr"; number = true; relativenumber = true; + tabstop = 4; + softtabstop = 4; + shiftwidth = 4; + expandtab = true; + hidden = true; + smartcase = true; + termguicolors = true; + signcolumn = "yes"; + # "opt.list" = true; + wrap = true; + }; + + globals = { + mapleader = " "; + #copilot_no_tab_map = true; }; plugins = { lspconfig = { enable = true; servers = { - rust-analyzer.enable = true; - nil.enable = true; + nil = { + enable = true; + extraConfig = '' + settings = { + ['nil'] = { + formatting = { + command = { "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" }, + }, + nix = { + flake = { + autoArchive = true, + }, + }, + }, + }, + ''; + }; + lua-language-server = { + enable = true; + onAttachExtra = '' + local lspconfig = require 'lspconfig' + local lsp_zero = require'lsp-zero' + local lua_opts = lsp_zero.nvim_lua_ls() + lspconfig.lua_ls.setup(lua_opts) + ''; + }; }; + onAttach = '' + vim.lsp.inlay_hint.enable(bufnr, true) + ''; }; + + todo-comments.enable = true; + lualine.enable = true; + commentary.enable = true; + surround.enable = true; + treesitter = { enable = true; indent = true; }; + telescope = { + enable = true; + extensions = { + manix.enable = true; + # plenary.enable = true; + }; + }; + + nvim-cmp = { + enable = true; + completion = { + completeopt = "menu,menuone,popup,noselect"; + }; + sources = { + nvim_lsp.enable = true; + luasnip.enable = true; + buffer.enable = true; + path.enable = true; + cmdline.enable = true; + #copilot.enable = true; + git.enable = true; + }; + snippet.luasnip.enable = true; + }; + }; colorschemes = { catppuccin = { @@ -33,6 +104,7 @@ normal = { "ff" = "require'telescope.builtin'.find_files"; "gg" = "require'telescope.builtin'.live_grep"; + "mm" = "require'telescope-manix'.search"; ";" = "require'telescope.builtin'.buffers"; "" = "''"; "vff" = "'vertical Gdiffsplit'"; @@ -40,7 +112,27 @@ "gi" = "vim.lsp.buf.implementation"; "a" = "vim.lsp.buf.code_action"; "F" = "function() vim.lsp.buf.format({ async = true }) end"; + # "" = ''copilot#Accept("")''; }; }; + + extraPlugins = + let + comfortable-motion = pkgs.fetchFromGitHub { + owner = "yuttie"; + repo = "comfortable-motion.vim"; + rev = "master"; + sha256 = "sha256-S1LJXmShhpCJIg/FEPx3jFbmPpS/1U4MAQN2RY/nkI0"; + }; + in + [ + comfortable-motion + pkgs.vimExtraPlugins.rustaceanvim + pkgs.vimExtraPlugins.cmp-nvim-lsp + pkgs.vimExtraPlugins.fidget-nvim + pkgs.vimExtraPlugins.rest-nvim + pkgs.vimExtraPlugins.lsp-zero-nvim + pkgs.vimPlugins.vim-abolish + ]; }; } diff --git a/config/nix/flake.lock b/config/nix/flake.lock index dc6e161f..4f6e7465 100644 --- a/config/nix/flake.lock +++ b/config/nix/flake.lock @@ -123,11 +123,11 @@ ] }, "locked": { - "lastModified": 1707685877, - "narHash": "sha256-XoXRS+5whotelr1rHiZle5t5hDg9kpguS5yk8c8qzOc=", + "lastModified": 1708794349, + "narHash": "sha256-jX+B1VGHT0ruHHL5RwS8L21R6miBn4B6s9iVyUJsJJY=", "owner": "ipetkov", "repo": "crane", - "rev": "2c653e4478476a52c6aa3ac0495e4dea7449ea0e", + "rev": "2c94ff9a6fbeb9f3ea0107f28688edbe9c81deaa", "type": "github" }, "original": { @@ -395,6 +395,24 @@ "type": "github" } }, + "flake-utils_8": { + "inputs": { + "systems": "systems_8" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -535,11 +553,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1708388174, - "narHash": "sha256-mLROAGNyOykYwWOLga24BX05GnRE+acms0Ru10tye2o=", + "lastModified": 1709051793, + "narHash": "sha256-4FXFBq5mN1IwN18Fd2OEF1iCZV5PC40gP2L64oyq3xQ=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "73fec69386e8005911e15f3abe6bb6cee7fd9711", + "rev": "e761c7ee47b64debc687d8bff7599d702c893dcc", "type": "github" }, "original": { @@ -673,6 +691,28 @@ "type": "github" } }, + "nix-github-actions_2": { + "inputs": { + "nixpkgs": [ + "nixneovimplugins", + "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" + } + }, "nixneovim": { "inputs": { "flake-utils": "flake-utils_7", @@ -726,6 +766,28 @@ "type": "github" } }, + "nixneovimplugins_2": { + "inputs": { + "flake-utils": "flake-utils_8", + "nixpkgs": [ + "nixpkgs" + ], + "poetry2nix": "poetry2nix_2" + }, + "locked": { + "lastModified": 1708870615, + "narHash": "sha256-9GeZzoT8kxJY3OkpeOo/eJ4bqwaQTGggv3fR/5UdIkY=", + "owner": "NixNeovim", + "repo": "NixNeovimPlugins", + "rev": "eb98507f0309ddb74d81367838e742d47e9e456f", + "type": "github" + }, + "original": { + "owner": "NixNeovim", + "repo": "NixNeovimPlugins", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1706487304, @@ -898,6 +960,32 @@ "type": "github" } }, + "poetry2nix_2": { + "inputs": { + "flake-utils": [ + "nixneovimplugins", + "flake-utils" + ], + "nix-github-actions": "nix-github-actions_2", + "nixpkgs": [ + "nixneovimplugins", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1689849924, + "narHash": "sha256-d259Z2S7CS7Na04qQNQ6LYQILuI7cf4Rpe76qc4mz40=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "1d7eda9336f336392d24e9602be5cb9be7ae405c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -942,6 +1030,7 @@ "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-darwin": "nix-darwin", "nixneovim": "nixneovim", + "nixneovimplugins": "nixneovimplugins_2", "nixpkgs": "nixpkgs_5" } }, @@ -1017,11 +1106,11 @@ ] }, "locked": { - "lastModified": 1708241671, - "narHash": "sha256-zSulX9tP4R35Y8A842dGSzaHMVP91W2Ry0SXvQKD2BQ=", + "lastModified": 1708827164, + "narHash": "sha256-oBNS6pO04Y6gZBLThP3JDDgviex0+WTXz3bVBenyzms=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d500e370b26f9b14303cb39bf1509df0a920c8b0", + "rev": "e0626adabd5ea461f80b1b11390da2a6575adb30", "type": "github" }, "original": { @@ -1134,6 +1223,21 @@ "repo": "default", "type": "github" } + }, + "systems_8": { + "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", diff --git a/config/nix/flake.nix b/config/nix/flake.nix index ba755435..dfbf8ed7 100644 --- a/config/nix/flake.nix +++ b/config/nix/flake.nix @@ -52,6 +52,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nixneovimplugins = { + url = "github:NixNeovim/NixNeovimPlugins"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # { pkgs, inputs, system, ... }: # { @@ -72,9 +77,15 @@ }; - outputs = { nixpkgs, - # nixos, - home-manager, nix-darwin, flake-utils, anyrun, neovim-nightly-overlay, ... + outputs = + { nixpkgs + , # nixos, + home-manager + , nix-darwin + , flake-utils + , anyrun + , neovim-nightly-overlay + , ... }@inputs: let config_devices = [ @@ -145,21 +156,26 @@ inputs.neovim-nightly-overlay.overlay anyrun-overlay inputs.nixneovim.overlays.default + inputs.nixneovimplugins.overlays.default ]; - in { - nixosConfigurations = let devices = nixos_devices; - in import ./nixos/device.nix { - inherit devices inputs nixpkgs home-manager overlays; - }; + in + { + nixosConfigurations = + let devices = nixos_devices; + in import ./nixos/device.nix { + inherit devices inputs nixpkgs home-manager overlays; + }; - darwinConfigurations = let devices = darwin_devices; - in import ./darwin/device.nix { - inherit devices inputs nixpkgs home-manager overlays nix-darwin; - }; + darwinConfigurations = + let devices = darwin_devices; + in import ./darwin/device.nix { + inherit devices inputs nixpkgs home-manager overlays nix-darwin; + }; - homeConfigurations = let devices = linux_devices; - in import ./linux/device.nix { - inherit devices inputs nixpkgs home-manager overlays; - }; + homeConfigurations = + let devices = linux_devices; + in import ./linux/device.nix { + inherit devices inputs nixpkgs home-manager overlays; + }; }; } diff --git a/config/nix/nixos/configuration.nix b/config/nix/nixos/configuration.nix index f5c9bab4..00520042 100644 --- a/config/nix/nixos/configuration.nix +++ b/config/nix/nixos/configuration.nix @@ -1,7 +1,7 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ pkgs, ... }: { +{ pkgs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -96,7 +96,8 @@ fish nushellFull (pkgs.wrapFirefox - (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) { }) + (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) + { }) gnumake python3 (nerdfonts.override { fonts = [ "FiraCode" "Hasklig" ]; })