From feaebcc0812bd1cc02fc7437c3c20f0c884eb6ee Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 4 Jun 2023 10:20:19 +0530 Subject: [PATCH] use home manager modules for nvim --- flake.lock | 112 ++------------ flake.nix | 10 +- home/programs/neovim.nix | 319 +++++++++++++++++++++++---------------- 3 files changed, 209 insertions(+), 232 deletions(-) diff --git a/flake.lock b/flake.lock index 901d448..5038a1c 100644 --- a/flake.lock +++ b/flake.lock @@ -202,60 +202,20 @@ "type": "github" } }, - "nix-flake-tests": { - "locked": { - "lastModified": 1677844186, - "narHash": "sha256-ErJZ/Gs1rxh561CJeWP5bohA2IcTq1rDneu1WT6CVII=", - "owner": "antifuchs", - "repo": "nix-flake-tests", - "rev": "bbd9216bd0f6495bb961a8eb8392b7ef55c67afb", - "type": "github" - }, - "original": { - "owner": "antifuchs", - "repo": "nix-flake-tests", - "type": "github" - } - }, - "nixneovim": { - "inputs": { - "home-manager": [ - "home-manager" - ], - "nix-flake-tests": "nix-flake-tests", - "nixneovimplugins": "nixneovimplugins", - "nixpkgs": [ - "nixpkgs" - ], - "nmd": "nmd", - "nmt": "nmt" - }, - "locked": { - "lastModified": 1685738568, - "narHash": "sha256-79ztyBK2cQPFn8FTQxUf2S6CbbrpzXKqwWSzCtiYspY=", - "owner": "nixneovim", - "repo": "nixneovim", - "rev": "1d01235b5b1bcee85cd26b8f1cec4345d57ca07c", - "type": "github" - }, - "original": { - "owner": "nixneovim", - "repo": "nixneovim", - "type": "github" - } - }, "nixneovimplugins": { "inputs": { "flake-compat": "flake-compat_2", "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1685629088, - "narHash": "sha256-sISQDPrGhUHoiu8aGkMoAn+DjM2LXHUJu5C+1WTxHGw=", + "lastModified": 1685737234, + "narHash": "sha256-pNKT/LB0lS9nufIgMlZB0wQqZzRLr8zs4Ssg2aftSQs=", "owner": "nixneovim", "repo": "nixneovimplugins", - "rev": "0536aa939392cd48e6ed95c807b2391c59b54963", + "rev": "4e954a890f9e8bc1481bcf78895ec456b16de827", "type": "github" }, "original": { @@ -266,16 +226,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1659190188, - "narHash": "sha256-LudYrDFPFaQMW0l68TYkPWRPKmqpxIFU1nWfylIp9AQ=", + "lastModified": 1685655444, + "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a3fddd46a7f3418d7e3940ded94701aba569161d", + "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -296,54 +256,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1685655444, - "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nmd": { - "flake": false, - "locked": { - "lastModified": 1680213367, - "narHash": "sha256-NbSXxpFAK5IMcsQTK0vSGy099HExx3SEagqW4Lpc+X8=", - "owner": "rycee", - "repo": "nmd", - "rev": "abb15317ebd17e5a0a7dd105e2ce52f2700185a8", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, - "nmt": { - "flake": false, - "locked": { - "lastModified": 1683843030, - "narHash": "sha256-2K9tFpypgSORyUTRAL7MFRKCXU4GykmhIDrrIydtPdI=", - "owner": "jooooscha", - "repo": "nmt", - "rev": "f30b96093eb056f1bcc60199545344b4e4a72c5a", - "type": "github" - }, - "original": { - "owner": "jooooscha", - "repo": "nmt", - "type": "github" - } - }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -380,8 +292,8 @@ "home-manager": "home-manager", "impermanence": "impermanence", "lanzaboote": "lanzaboote", - "nixneovim": "nixneovim", - "nixpkgs": "nixpkgs_2" + "nixneovimplugins": "nixneovimplugins", + "nixpkgs": "nixpkgs" } }, "rust-overlay": { diff --git a/flake.nix b/flake.nix index b8ad570..d3e2a38 100644 --- a/flake.nix +++ b/flake.nix @@ -20,10 +20,9 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - nixneovim = { - url = "github:nixneovim/nixneovim"; + nixneovimplugins = { + url = "github:nixneovim/nixneovimplugins"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.home-manager.follows = "home-manager"; }; }; @@ -33,7 +32,7 @@ home-manager, impermanence, lanzaboote, - nixneovim, + nixneovimplugins, } @ inputs: { formatter."x86_64-linux" = nixpkgs.legacyPackages."x86_64-linux".alejandra; nixosConfigurations = let @@ -44,7 +43,7 @@ pkgs = import nixpkgs { inherit system; config = {allowUnfree = true;}; - overlays = [(import ./packages) nixneovim.overlays.default]; + overlays = [(import ./packages) nixneovimplugins.overlays.default]; }; specialArgs = inputs; modules = [ @@ -66,7 +65,6 @@ users.${user.primary.userName} = {pkgs, ...}: { imports = [ impermanence.nixosModules.home-manager.impermanence - nixneovim.nixosModules.default ./home ]; }; diff --git a/home/programs/neovim.nix b/home/programs/neovim.nix index e9f265c..73a7c5e 100644 --- a/home/programs/neovim.nix +++ b/home/programs/neovim.nix @@ -1,131 +1,198 @@ {pkgs, ...}: { - programs.nixneovim = { + programs.neovim = { enable = true; - extraLuaPreConfig = '' - vim.g.gitblame_date_format = '%r' - vim.g.gitblame_message_when_not_committed = ''' - - vim.opt.list = true - vim.opt.listchars:append "space:⋅" - vim.opt.listchars:append "eol:↴" - ''; - extraPlugins = with pkgs.vimExtraPlugins; [dracula-vim git-blame-nvim]; - colorscheme = "dracula"; - options = { - autowrite = true; - background = "dark"; - clipboard = "unnamedplus"; - expandtab = true; - laststatus = 2; - list = true; - showmode = false; - swapfile = false; - number = true; - relativenumber = true; - shiftwidth = 2; - signcolumn = "yes"; - smartindent = true; - tabstop = 2; - termguicolors = true; - updatetime = 100; - wrap = true; - splitright = true; - splitbelow = true; - }; - mappings = { - normal = { - "" = "'bp'"; - "" = "'bn'"; - "" = { - silent = true; - action = "'noh'"; - }; - "w" = { - silent = true; - action = "'bdeletebnext'"; - }; - "1" = { - silent = true; - action = "'NvimTreeToggle'"; - }; - "`" = { - silent = true; - action = "'split term://zsh'"; - }; - "ff" = { - silent = true; - action = "'Telescope find_files'"; - }; - "fg" = { - silent = true; - action = "'Telescope live_grep'"; - }; - "fb" = { - silent = true; - action = "'Telescope buffers'"; - }; - }; - }; - plugins = { - comment.enable = true; - fugitive.enable = true; - gitsigns.enable = true; - indent-blankline = { - enable = true; - showEndOfLine = true; - }; - telescope.enable = true; - nvim-tree = { - enable = true; - diagnostics.enable = true; - disableNetrw = true; - git.enable = true; - }; - bufferline = { - enable = true; - alwaysShowBufferline = true; - diagnostics = "nvim_lsp"; - separatorStyle = "slant"; - offsets = [ - { - filetype = "NvimTree"; - text = "File Explorer"; - separator = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + withNodeJs = true; + withPython3 = true; + withRuby = true; + defaultEditor = true; + extraPackages = with pkgs; [ + fd + ripgrep + tree-sitter + nil + ]; + plugins = with pkgs.vimExtraPlugins; [ + { + plugin = nvim-web-devicons; + type = "lua"; + config = '' + require('nvim-web-devicons').setup { + default = true } - ]; - }; - lualine = { - enable = true; - globalstatus = true; - }; - nvim-cmp = { - enable = true; - snippet.luasnip.enable = true; - sources = { - buffer.enable = true; - nvim_lsp.enable = true; - nvim_lsp_document_symbol.enable = true; - nvim_lsp_signature_help.enable = true; - treesitter.enable = true; - luasnip.enable = true; - }; - }; - luasnip.enable = true; - treesitter = { - enable = true; - installAllGrammars = true; - indent = true; - incrementalSelection.enable = true; - }; - treesitter-context.enable = true; - lsp = { - enable = true; - servers = { - gopls.enable = true; - nil.enable = true; - rust-analyzer.enable = true; - }; - }; - }; + ''; + } + { + plugin = dracula-nvim; + type = "lua"; + config = '' + require("dracula").setup({ + show_end_of_buffer = true, + transparent_bg = true, + italic_comment = true + }) + vim.cmd[[colorscheme dracula]] + ''; + } + { + plugin = nvim-tree-lua; + type = "lua"; + config = '' + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + require('nvim-tree').setup { + diagnostics = { + enable = true + } + } + ''; + } + { + plugin = git-blame-nvim; + type = "lua"; + config = '' + vim.g.gitblame_date_format = '%r' + vim.g.gitblame_message_when_not_committed = ''' + ''; + } + { + plugin = gitsigns-nvim; + type = "lua"; + config = '' + require('gitsigns').setup() + ''; + } + { + plugin = indent-blankline-nvim; + type = "lua"; + config = '' + vim.opt.list = true + vim.opt.listchars:append "space:⋅" + vim.opt.listchars:append "eol:↴" + require("indent_blankline").setup { + show_end_of_line = true + } + ''; + } + { + plugin = lualine-nvim; + type = "lua"; + config = '' + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'dracula-nvim', + globalstatus = true + } + } + ''; + } + { + plugin = nvim-lastplace; + type = "lua"; + config = '' + require('nvim-lastplace').setup {} + ''; + } + { + plugin = toggleterm-nvim; + type = "lua"; + config = '' + require('toggleterm').setup{} + ''; + } + { + plugin = nvim-treesitter-context; + type = "lua"; + config = '' + require('treesitter-context').setup { + enable = true + } + ''; + } + {plugin = nvim-treesitter-refactor;} + { + plugin = pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: + with plugins; [ + bash + dockerfile + gitattributes + gitcommit + gitignore + git_config + git_rebase + go + gomod + gosum + ini + json + markdown + markdown_inline + nix + toml + yaml + ]); + type = "lua"; + config = '' + require('nvim-treesitter.configs').setup { + auto_install = false, + highlight = true, + refactor = { + highlight_definitions = { + enable = true, + clear_on_cursor_move = false + } + } + } + ''; + } + { + plugin = nvim-lspconfig; + type = "lua"; + config = '' + require('lspconfig').bashls.setup{} + require('lspconfig').dockerls.setup{} + require('lspconfig').docker_compose_language_service.setup{} + require('lspconfig').gopls.setup{} + require('lspconfig').jsonls.setup{} + require('lspconfig').marksman.setup{} + require('lspconfig').nil_ls.setup{} + require('lspconfig').rust_analyzer.setup{} + ''; + } + ]; + extraConfig = '' + set autowrite + set background=dark + set clipboard+=unnamedplus + set expandtab + set laststatus=2 + set noshowmode + set noswapfile + set number + set relativenumber + set shiftwidth=2 + set signcolumn=yes + set smartindent + set tabstop=2 + set termguicolors + set updatetime=100 + set wrap + set splitright + set splitbelow + + nmap bp + nmap bn + nnoremap noh + nnoremap w bdeletebnext + nnoremap ` ToggleTerm + nnoremap 1 NvimTreeToggle + nnoremap ff Telescope find_files + nnoremap fg Telescope live_grep + nnoremap fb Telescope buffers + nnoremap fh Telescope help_tags + ''; }; }