From da3222028172b11779460c5f847d6a01fdd7a739 Mon Sep 17 00:00:00 2001 From: Uzair Mohammed Date: Sat, 21 Dec 2024 16:13:19 -0800 Subject: [PATCH] Replacing neovim config with nixvim --- flake.lock | 286 +++++++++++++++++++++++- flake.nix | 11 + home/home.nix | 1 - home/modules/devStuff.nix | 97 +------- home/modules/nvimPlugins/cmp.lua | 46 ---- home/modules/nvimPlugins/lsp.lua | 49 ---- home/modules/nvimPlugins/lualine.lua | 41 ---- home/modules/nvimPlugins/other.lua | 18 -- home/modules/nvimPlugins/telescope.lua | 16 -- home/modules/nvimPlugins/tree.lua | 25 --- home/modules/nvimPlugins/treesitter.lua | 9 - home/modules/nvimPlugins/trouble.lua | 37 --- system/modules/default.nix | 1 + system/modules/neovim.nix | 5 + 14 files changed, 303 insertions(+), 339 deletions(-) delete mode 100644 home/modules/nvimPlugins/cmp.lua delete mode 100644 home/modules/nvimPlugins/lsp.lua delete mode 100644 home/modules/nvimPlugins/lualine.lua delete mode 100644 home/modules/nvimPlugins/other.lua delete mode 100644 home/modules/nvimPlugins/telescope.lua delete mode 100644 home/modules/nvimPlugins/tree.lua delete mode 100644 home/modules/nvimPlugins/treesitter.lua delete mode 100644 home/modules/nvimPlugins/trouble.lua create mode 100644 system/modules/neovim.nix diff --git a/flake.lock b/flake.lock index 5ccb70a..26ef1e5 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,27 @@ "type": "github" } }, + "devshell": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", + "owner": "numtide", + "repo": "devshell", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -54,6 +75,20 @@ } }, "flake-compat_3": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_4": { "flake": false, "locked": { "lastModified": 1733328505, @@ -126,6 +161,27 @@ "type": "github" } }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -144,6 +200,54 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore_2", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734425854, + "narHash": "sha256-nzE5UbJ41aPEKf8R2ZFYtLkqPmF7EIUbNEdHMBLg0Ig=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "0ddd26d0925f618c3a5d85a4fa5eb1e23a09491d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -166,6 +270,28 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "git-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" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -187,6 +313,55 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734622215, + "narHash": "sha256-OOfI0XhSJGHblfdNDhfnn8QnZxng63rWk9eeJ2tCbiI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1395379a7a36e40f2a76e7b9936cc52950baa1be", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729958008, + "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.6", + "repo": "ixx", + "type": "github" + } + }, "lanzaboote": { "inputs": { "crane": "crane", @@ -214,6 +389,27 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733570843, + "narHash": "sha256-sQJAxY1TYWD1UyibN/FnN97paTFuwBw3Vp3DNCyKsMk=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "a35b08d09efda83625bef267eb24347b446c80b8", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nixos-cli": { "inputs": { "flake-compat": "flake-compat_2", @@ -339,6 +535,57 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts_4", + "git-hooks": "git-hooks", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1734798432, + "narHash": "sha256-JVU+WjrRZUJnUKQ/iXP9O8eQ0L3YkqV1DpFMS4kLZog=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "6a4b4221c4ebf1140f73f8df769e97f1828d90fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils_2", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733773348, + "narHash": "sha256-Y47y+LesOCkJaLvj+dI/Oa6FAKj/T9sKVKDXLNsViPw=", + "owner": "NuschtOS", + "repo": "search", + "rev": "3051be7f403bff1d1d380e4612f0c70675b44fc9", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -373,6 +620,7 @@ "nixos-cli": "nixos-cli", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_3", + "nixvim": "nixvim", "spicetify-nix": "spicetify-nix" } }, @@ -403,7 +651,7 @@ }, "spicetify-nix": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "nixpkgs": [ "nixpkgs" ] @@ -437,6 +685,42 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734704479, + "narHash": "sha256-MMi74+WckoyEWBRcg/oaGRvXC9BVVxDZNRMpL+72wBI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "65712f5af67234dad91a5a4baee986a8b62dbf8f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "zig-deps-fod": { "inputs": { "flake-parts": "flake-parts_3", diff --git a/flake.nix b/flake.nix index ab6b923..d1ccd27 100644 --- a/flake.nix +++ b/flake.nix @@ -34,6 +34,14 @@ # Optional but recommended to limit the size of your system closure. inputs.nixpkgs.follows = "nixpkgs"; }; + + nixvim = { + url = "github:nix-community/nixvim"; + # If you are not running an unstable channel of nixpkgs, select the corresponding branch of nixvim. + # url = "github:nix-community/nixvim/nixos-24.11"; + + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { @@ -44,6 +52,7 @@ nixos-hardware, nixos-cli, lanzaboote, + nixvim, ... } @ inputs: let lib = nixpkgs.lib; @@ -74,6 +83,8 @@ lanzaboote.nixosModules.lanzaboote + inputs.nixvim.nixosModules.nixvim + ./system ]; }; diff --git a/home/home.nix b/home/home.nix index eb0bc73..a4b951a 100644 --- a/home/home.nix +++ b/home/home.nix @@ -1,5 +1,4 @@ { config, pkgs, ... }: - { imports = [ ./modules/default.nix diff --git a/home/modules/devStuff.nix b/home/modules/devStuff.nix index c7b5ea6..46004ce 100644 --- a/home/modules/devStuff.nix +++ b/home/modules/devStuff.nix @@ -1,105 +1,10 @@ {pkgs, ...}: { home.sessionVariables = { - EDITOR = "hx"; + EDITOR = "nvim"; ELECTRON_OZONE_PLATFORM_HINT = "wayland"; NIXOS_CONFIG = "/home/uzair/Documents/nixos-config"; }; - programs.neovim = let - toLua = str: "lua << EOF\n${str}\nEOF\n"; - toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; - in { - enable = true; - plugins = with pkgs.vimPlugins; [ - nvim-cmp - neoformat - rustaceanvim - telescope-fzf-native-nvim - cmp_luasnip - cmp-nvim-lsp - luasnip - friendly-snippets - nvim-web-devicons - vim-nix - copilot-vim - - { - plugin = nvim-lspconfig; - config = toLuaFile ./nvimPlugins/lsp.lua; - } - - { - plugin = comment-nvim; - config = toLua "require(\"Comment\").setup()"; - } - - { - plugin = catppuccin-nvim; - config = "colorscheme catppuccin-mocha"; - } - - { - plugin = telescope-nvim; - config = toLuaFile ./nvimPlugins/telescope.lua; - } - - { - plugin = nvim-cmp; - config = toLuaFile ./nvimPlugins/cmp.lua; - } - - { - plugin = lualine-nvim; - config = toLuaFile ./nvimPlugins/lualine.lua; - } - - { - plugin = trouble-nvim; - # config = toLuaFile ./nvimPlugins/trouble.lua; - } - - { - plugin = nvim-tree-lua; - config = toLuaFile ./nvimPlugins/tree.lua; - } - - { - plugin = nvim-treesitter.withPlugins (p: [ - p.tree-sitter-nix - p.tree-sitter-vim - p.tree-sitter-bash - p.tree-sitter-json - p.tree-sitter-yaml - p.tree-sitter-typescript - p.tree-sitter-toml - p.tree-sitter-sql - p.tree-sitter-rust - p.tree-sitter-markdown - p.tree-sitter-make - p.tree-sitter-java - p.tree-sitter-kotlin - p.tree-sitter-html - p.tree-sitter-fish - p.tree-sitter-css - p.tree-sitter-cpp - p.tree-sitter-cmake - p.tree-sitter-c-sharp - p.tree-sitter-c - ]); - config = toLuaFile ./nvimPlugins/treesitter.lua; - } - ]; - - extraLuaConfig = '' - ${builtins.readFile ./nvimPlugins/other.lua} - ''; - - extraPackages = with pkgs; [ - wl-clipboard - ripgrep - ]; - }; - programs.helix = { enable = true; }; diff --git a/home/modules/nvimPlugins/cmp.lua b/home/modules/nvimPlugins/cmp.lua deleted file mode 100644 index cf2b7a7..0000000 --- a/home/modules/nvimPlugins/cmp.lua +++ /dev/null @@ -1,46 +0,0 @@ -local cmp = require('cmp') -local luasnip = require('luasnip') - -require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, -} diff --git a/home/modules/nvimPlugins/lsp.lua b/home/modules/nvimPlugins/lsp.lua deleted file mode 100644 index 3297e12..0000000 --- a/home/modules/nvimPlugins/lsp.lua +++ /dev/null @@ -1,49 +0,0 @@ -local on_attach = function(_, bufnr) - - local bufmap = function(keys, func) - vim.keymap.set('n', keys, func, { buffer = bufnr }) - end - - bufmap('r', vim.lsp.buf.rename) - bufmap('a', vim.lsp.buf.code_action) - - bufmap('gd', vim.lsp.buf.definition) - bufmap('gD', vim.lsp.buf.declaration) - bufmap('gI', vim.lsp.buf.implementation) - bufmap('D', vim.lsp.buf.type_definition) - - bufmap('gr', require('telescope.builtin').lsp_references) - bufmap('s', require('telescope.builtin').lsp_document_symbols) - bufmap('S', require('telescope.builtin').lsp_dynamic_workspace_symbols) - - bufmap('K', vim.lsp.buf.hover) - - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, {}) -end - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - -require('lspconfig').lua_ls.setup { - on_attach = on_attach, - capabilities = capabilities, - root_dir = function() - return vim.loop.cwd() - end, - cmd = { "lua-lsp" }, - settings = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - } -} - -require('lspconfig').nixd.setup { - on_attach = on_attach, - capabilities = capabilities, - cmd = { "nixd" }, - filetypes = { "nix" } -} diff --git a/home/modules/nvimPlugins/lualine.lua b/home/modules/nvimPlugins/lualine.lua deleted file mode 100644 index fe2f701..0000000 --- a/home/modules/nvimPlugins/lualine.lua +++ /dev/null @@ -1,41 +0,0 @@ -require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - always_show_tabline = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} -} diff --git a/home/modules/nvimPlugins/other.lua b/home/modules/nvimPlugins/other.lua deleted file mode 100644 index afe9cbb..0000000 --- a/home/modules/nvimPlugins/other.lua +++ /dev/null @@ -1,18 +0,0 @@ --- Change leader key to space -vim.g.mapleader = ' ' - -vim.o.clipboard = 'unnamedplus' - -vim.o.tabstop = 4 -vim.o.shiftwidth = 4 - -vim.o.termguicolors = true - --- vim.cmd.colorscheme "catppuccin" -require("Comment").setup() - -local builtin = require('telescope.builtin') -vim.keymap.set('n', ' ', builtin.find_files, { desc = 'Telescope find files' }) -vim.keymap.set('n', '/', builtin.live_grep, { desc = 'Telescope live grep' }) -vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) -vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) diff --git a/home/modules/nvimPlugins/telescope.lua b/home/modules/nvimPlugins/telescope.lua deleted file mode 100644 index 28eb998..0000000 --- a/home/modules/nvimPlugins/telescope.lua +++ /dev/null @@ -1,16 +0,0 @@ -require("telescope").setup( - { - 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" - -- the default case_mode is "smart_case" - } - } - } -) - -require("telescope").load_extension("fzf") - diff --git a/home/modules/nvimPlugins/tree.lua b/home/modules/nvimPlugins/tree.lua deleted file mode 100644 index bc49de0..0000000 --- a/home/modules/nvimPlugins/tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- disable netrw at the very start of your init.lua -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - --- optionally enable 24-bit colour -vim.opt.termguicolors = true - --- empty setup using defaults --- require("nvim-tree").setup() - --- OR setup with some options -require("nvim-tree").setup({ - sort = { - sorter = "case_sensitive", - }, - view = { - width = 30, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = true, - }, -}) diff --git a/home/modules/nvimPlugins/treesitter.lua b/home/modules/nvimPlugins/treesitter.lua deleted file mode 100644 index 2edb953..0000000 --- a/home/modules/nvimPlugins/treesitter.lua +++ /dev/null @@ -1,9 +0,0 @@ -require('nvim-treesitter.configs').setup { - ensure_installed = {}, - - auto_install = false, - - highlight = { enable = true }, - - indent = { enable = true }, -} diff --git a/home/modules/nvimPlugins/trouble.lua b/home/modules/nvimPlugins/trouble.lua deleted file mode 100644 index 3741f30..0000000 --- a/home/modules/nvimPlugins/trouble.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, -} diff --git a/system/modules/default.nix b/system/modules/default.nix index 6a73753..5cf131e 100644 --- a/system/modules/default.nix +++ b/system/modules/default.nix @@ -21,5 +21,6 @@ ./gaming.nix ./printing.nix ./yubikey.nix + ./neovim.nix ]; } diff --git a/system/modules/neovim.nix b/system/modules/neovim.nix new file mode 100644 index 0000000..857e677 --- /dev/null +++ b/system/modules/neovim.nix @@ -0,0 +1,5 @@ +{ + programs.nixvim = { + enable = true; + }; +}