nix-config

My personal nixos and home-manager configuration
Log | Files | Refs | README

default.nix (2780B)


      1 { config, pkgs, lib, ... }:
      2 
      3 with builtins;
      4 with lib;
      5 
      6 let
      7   luaConfig = file: ''
      8     lua << EOF
      9     ${readFile file}
     10     EOF
     11   '';
     12 in
     13 {
     14   options.neovim = {
     15     enable = mkEnableOption "Neovim";
     16 
     17     colourSchemePackage = mkOption {
     18       type = types.package;
     19       default = pkgs.vimPlugins.gruvbox;
     20       example = pkgs.vimPlugins.dracula-vim;
     21       description = "Package of the vim colour scheme used.";
     22     };
     23 
     24     colourScheme = mkOption {
     25       type = types.str;
     26       default = "gruvbox";
     27       example = "blue";
     28       description = "What you would type in the colorscheme vim command (e.g. `colorscheme gruvbox`).";
     29     };
     30   };
     31 
     32   config = mkIf config.neovim.enable {
     33     programs.neovim = {
     34       enable = true;
     35       package = pkgs.neovim;
     36       extraConfig = ''
     37         ${readFile ./syntax.vim}
     38 
     39         lua << EOF
     40           ${readFile ./init.lua}
     41 
     42           function asm()
     43             vim.bo.ft = 'nasm'
     44           end
     45           function c()
     46             ${readFile ./c.lua}
     47           end
     48           function cpp()
     49             ${readFile ./cpp.lua}
     50           end
     51           function lua()
     52             ${readFile ./lua.lua}
     53           end
     54           function tex()
     55             ${readFile ./tex.lua}
     56           end
     57         EOF
     58         au BufEnter *.asm lua asm()
     59         au BufEnter *.c lua c()
     60         au BufEnter *.cpp lua cpp()
     61         au BufEnter *.lua lua lua()
     62         au BufEnter *.tex lua tex()
     63       '';
     64       plugins = with pkgs.vimPlugins; with pkgs.vitalityVimPlugins; [
     65         { plugin = config.neovim.colourSchemePackage; config = "colorscheme ${config.neovim.colourScheme}"; }
     66         { plugin = fugitive; }
     67         { plugin = fzfWrapper; }
     68         { plugin = LuaSnip; }
     69         { plugin = mattn-calendar-vim; }
     70         { plugin = nvim-compe; config = luaConfig ./compe.lua; }
     71         { plugin = nvim-lspconfig; }
     72         { plugin = pkgs.vimPlugins.nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars); config = luaConfig ./treesitter.lua; }
     73         { plugin = telescope-nvim; config = luaConfig ./telescope.lua; }
     74         { plugin = telescope-bibtex-nvim; }
     75         { plugin = telescope-cheat-nvim; }
     76         { plugin = telescope-frecency-nvim; }
     77         { plugin = telescope-symbols-nvim; }
     78         { plugin = telescope-fzy-native-nvim; }
     79         { plugin = plenary-nvim; }
     80         { plugin = popup-nvim; }
     81         { plugin = vim-dispatch; }
     82         { plugin = vim-nix; }
     83         { plugin = vim-polyglot; }
     84         { plugin = vim-startify; }
     85         { plugin = vim-surround; }
     86         { plugin = vimwiki; }
     87 
     88         # Language specific plugins
     89         (mkIf config.haskell.enable { plugin = haskell-vim; })
     90         (mkIf config.idris2.enable { plugin = idris2-vim; })
     91         (mkIf config.latex.enable { plugin = vimtex; })
     92       ];
     93     };
     94   };
     95 }