{ lib, config, ... }:
{
  options = {
    custom.neovim.enable = lib.mkEnableOption "My neovim config";
  };
  config = lib.mkIf config.custom.neovim.enable {
    home = {
      sessionVariables = {
        EDITOR = "nvim";
      };
    };
    programs.nixvim = {
      enable = true;
      plugins = {
        dropbar.enable = true;
        lspconfig.enable = true;
        guess-indent.enable = true;
        oil.enable = true;
        mini-statusline.enable = true;
        mini-pairs.enable = true;
        mini-pick.enable = true;
        mini-diff.enable = true;
        mini-indentscope.enable = true;
        mini-surround.enable = true;
        ts-autotag.enable = true;
        blink-cmp = {
          enable = true;
          settings = {
            signature = {
              enabled = true;
            };
          };
        };
        treesitter = {
          enable = true;
          highlight.enable = true;
          indent.enable = true;
        };
        harpoon.enable = true;
        dap.enable = true;
        dap-virtual-text.enable = true;
        dap-view = {
          enable = true;
          settings = {
            winbar = {
              default_section = "scopes";
            };
          };
        };
        dap-python.enable = true;
        hydra = {
          enable = true;
          hydras = [
            {
              body = "<leader>d";
              config = {
                color = "pink";
                hint = {
                  hide_on_load = true;
                };
                on_enter = ''
                  function()
                    require("dap-view").open()
                  end
                '';
                on_exit = ''
                  function()
                    require("dap-view").close()
                  end
                '';
              };
              heads = [
                [
                  "o"
                  ""
                ]
                [
                  "c"
                  "<cmd>DapContinue<CR>"
                ]
                [
                  "b"
                  "<cmd>DapToggleBreakpoint<CR>"
                ]
                [
                  "n"
                  "<cmd>DapStepOver<CR>"
                ]
                [
                  "i"
                  "<cmd>DapStepInto<CR>"
                ]
                [
                  "x"
                  "<cmd>DapDisconnect<CR>"
                ]
                [
                  "t"
                  {
                    __raw = ''
                      function()
                        test_method()
                      end
                    '';
                  }
                ]
              ];
            }
          ];
        };
      };
      keymaps = [
        {
          action = "<cmd>Oil<CR>";
          key = "<leader>o";
        }
        {
          action = "<cmd>lua require('mini.pick').builtin.files()<CR>";
          key = "<leader>f";
        }
        {
          action = "<cmd>lua require('mini.pick').builtin.grep_live()<CR>";
          key = "<leader>g";
        }
        {
          action = "<cmd>lua require('mini.pick').builtin.help()<CR>";
          key = "<leader>h";
        }
        {
          action = "<cmd>lua require('mini.pick').builtin.resume()<CR>";
          key = "<leader>r";
        }
        {
          action = "<cmd>lua vim.lsp.buf.format()<CR>";
          key = "<leader>i";
        }
        {
          action = "<cmd>lua vim.lsp.buf.code_action()<CR>";
          key = "<leader>a";
        }
        {
          action = "<cmd>lua vim.diagnostic.goto_prev({ float = true })<CR>";
          key = "[d";
        }
        {
          action = "<cmd>lua vim.diagnostic.goto_next({ float = true })<CR>";
          key = "]d";
        }
        {
          action = "<cmd>lua vim.diagnostic.setqflist()<CR>";
          key = "<leader>q";
        }
        {
          action = "<cmd>lua require('harpoon'):list():add()<CR>";
          key = "<leader>k";
        }
        {
          action = "<cmd>lua require('harpoon'):list():select(1)<CR>";
          key = "<M-q>";
        }
        {
          action = "<cmd>lua require('harpoon'):list():select(2)<CR>";
          key = "<M-w>";
        }
        {
          action = "<cmd>lua require('harpoon'):list():select(3)<CR>";
          key = "<M-e>";
        }
        {
          action = "<cmd>lua require('harpoon'):list():select(4)<CR>";
          key = "<M-r>";
        }
        {
          action = "<cmd>lua require('harpoon').ui:toggle_quick_menu(require('harpoon'):list())<CR>";
          key = "<leader>j";
        }
        {
          action = "<cmd>CopyRelativePath<CR>";
          key = "<leader>p";
        }
      ];
      globals.mapleader = " ";
      opts = {
        number = true;
        relativenumber = true;
        ignorecase = true;
        smartcase = true;
        swapfile = false;
        exrc = true;
      };
      colorschemes.catppuccin.enable = true;
      clipboard.register = "unnamedplus";
      userCommands = {
        CopyRelativePath = {
          command = "call setreg('+', expand('%'))";
        };
      };
      lsp.servers = {
        basedpyright.enable = true;
        gopls.enable = true;
        nil_ls.enable = true;
        rust_analyzer.enable = true;
        html.enable = true;
        jsonls.enable = true;
        yamlls.enable = true;
        cssls.enable = true;
        tailwindcss.enable = true;
        vtsls.enable = true;
      };
    };
  };
}
