{ config, pkgs, lib, ... }: with lib; let cfg = config.custom.neovim; in { options.custom.neovim = { enable = mkEnableOption "Custom Neovim"; colorscheme = mkOption { type = types.str; default = "unokai"; }; hostname = mkOption { type = types.str; }; }; config = mkIf cfg.enable { programs.neovim = { enable = true; defaultEditor = true; viAlias = true; vimAlias = false; vimdiffAlias = true; plugins = with pkgs.vimPlugins; [ { plugin = auto-session; type = "lua"; config = '' require("auto-session").setup({ cwd_change_handling = true, suppressed_dirs = { "$HOME", "/etc/nixos", "$HOME/tmp" }, }) ''; } { plugin = blink-cmp; type = "lua"; config = '' require("blink.cmp").setup({ completion = { documentation = { auto_show = true }, }, keymap = { preset = "default", [""] = { "snippet_forward", "fallback" }, [""] = { "select_and_accept", "snippet_forward", "fallback" }, [""] = { "snippet_backward", "fallback" }, }, }) ''; } { plugin = comment-nvim; type = "lua"; config = '' require('Comment').setup() ''; } { plugin = conform-nvim; type = "lua"; config = '' require("conform").setup({ formatters_by_ft = { c = { "clang-format" }, cpp = { "clang-format" }, lua = { "stylua" }, javascript = { "prettierd" }, nix = { "nixfmt" }, python = { "black" }, php = { "php_cs_fixer" }, zig = { "zigfmt" }, css = { "prettierd" }, scss = { "prettierd" }, less = { "prettierd" }, blade = { "blade-formatter" }, go = { "gofmt" }, wgsl = { "wgsl_fmt" }, }, }) vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*", callback = function(args) require("conform").format({ bufnr = args.buf }) end, }) vim.keymap.set("n", "rf", function() require("conform").format({ lsp_fallback = true, async = true, timeout_ms = 500, }) end, { desc = "conform format" }) ''; } leap-nvim { plugin = lsp_lines-nvim; type = "lua"; config = '' require("lsp_lines").setup() vim.keymap.set("n", "i", require("lsp_lines").toggle, { desc = "Toggle LSP lines" }) ''; } { plugin = mini-icons; type = "lua"; config = ''require("mini.icons").setup()''; } { plugin = neotest; type = "lua"; config = '' require('neotest').setup({ output = { open_on_run = true }, adapters = { require('neotest-pest'), } }) vim.keymap.set('n', 'pn', function() require('neotest').run.run() end, { desc = "test nearest" }) vim.keymap.set('n', 'pe', function() require('neotest').run.run(vim.fn.expand('%')) end, { desc = "test file" }) ''; } { plugin = neotest-pest; type = "lua"; } # { # plugin = nvim-autopairs; # type = "lua"; # config = '' # require('nvim-autopairs').setup() # ''; # } { plugin = nvim-dap; type = "lua"; config = '' local dap = require("dap") dap.adapters.php = { type = 'executable', command = '${pkgs.nodejs}/bin/node', args = { '${pkgs.vscode-extensions.xdebug.php-debug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js' }, } dap.configurations.php = { { type = 'php', request = 'launch', name = 'listen for xdebug', port = 9003, } } ''; } { plugin = nvim-dap-ui; type = "lua"; config = '' local dapui = require("dapui") dapui.setup() dap.listeners.before.attach.dapui_config = function() dapui.open() end dap.listeners.before.launch.dapui_config = function() dapui.open() end dap.listeners.before.event_terminated.dapui_config = function() dapui.close() end dap.listeners.before.event_exited.dapui_config = function() dapui.close() end ''; } nvim-nio { plugin = nvim-treesitter.withAllGrammars; type = "lua"; config = '' local treesitter = require("nvim-treesitter") treesitter.setup() vim.api.nvim_create_autocmd('FileType', { pattern = { 'c', 'lua', 'vim', 'vimdoc', 'query', 'elixir', 'heex', 'javascript', 'typescript', 'html', 'yaml', 'blade', 'php', 'scss', 'comment', 'cmake' , 'dockerfile', 'fish', 'fsharp', 'git_config', 'git_rebase', 'gitignore', 'glsl', 'go', 'gomod', 'graphql', 'haskell', 'hlsl', 'http', 'ini', 'javadoc', 'jq', 'jsdoc', 'json', 'json5', 'kitty', 'latex', 'markdown', 'nginx', 'nix', 'php', 'php_only', 'phpdoc', 'regex', 'rust', 'sql', 'ssh_config', 'tmux', 'vim', 'wgsl', 'yaml', 'zig', 'ols', }, callback = function() vim.treesitter.start() end, }) ''; } { plugin = nvim-treesitter-context; type = "lua"; config = ''require("treesitter-context").setup()''; } # { # plugin = nvim-treesitter-textobjectse # type = "lua"; # config = '' # vim.g.no_plugin_maps = true # require("treesitter-textobjects").setup() # ''; # } nvim-lspconfig nvim-nio { plugin = nvim-surround; type = "lua"; config = ''require("nvim-surround").setup()''; } { plugin = nvim-web-devicons; type = "lua"; config = ''require("nvim-web-devicons").setup()''; } { plugin = oil-nvim; type = "lua"; config = '' require("oil").setup() vim.keymap.set("n", "o", "Oil", { desc = "Oil" }) ''; } { plugin = opencode-nvim; type = "lua"; config = '' vim.o.autoread = true -- Recommended/example keymaps. vim.keymap.set({ "n", "x" }, "", function() require("opencode").ask("@this: ", { submit = true }) end, { desc = "Ask opencode…" }) vim.keymap.set({ "n", "x" }, "", function() require("opencode").select() end, { desc = "Execute opencode action…" }) vim.keymap.set({ "n", "t" }, "", function() require("opencode").toggle() end, { desc = "Toggle opencode" }) vim.keymap.set({ "n", "x" }, "go", function() return require("opencode").operator("@this ") end, { desc = "Add range to opencode", expr = true }) vim.keymap.set("n", "goo", function() return require("opencode").operator("@this ") .. "_" end, { desc = "Add line to opencode", expr = true }) vim.keymap.set("n", "", function() require("opencode").command("session.half.page.up") end, { desc = "Scroll opencode up" }) vim.keymap.set("n", "", function() require("opencode").command("session.half.page.down") end, { desc = "Scroll opencode down" }) -- You may want these if you stick with the opinionated "" and "" above — otherwise consider "o…". vim.keymap.set("n", "+", "", { desc = "Increment under cursor", noremap = true }) vim.keymap.set("n", "-", "", { desc = "Decrement under cursor", noremap = true }) ''; } phpactor plenary-nvim { plugin = render-markdown-nvim; type = "lua"; config = ''require("render-markdown").setup()''; } { plugin = snacks-nvim; type = "lua"; config = '' local snacks = require("snacks") snacks.setup({ bigfile = {}, dim = {}, image = {}, indent = {}, lazygit = {}, picker = { win = { input = { keys = { [""] = { "close", mode = { "n", "i" } }, }, }, }, }, quickfile = {}, notifier = {}, }) vim.keymap.set({ "n" }, "t", snacks.picker.grep, { desc = "grep picker" }) vim.keymap.set({ "n" }, "r", snacks.picker.buffers, { desc = "buffer picker" }) vim.keymap.set({ "n" }, "s", snacks.picker.files, { desc = "file picker" }) vim.keymap.set({ "n" }, "ln", snacks.picker.lsp_references, { desc = "lsp references" }) vim.keymap.set("n", "le", snacks.picker.lsp_implementations, { desc = "lsp implementations" }) -- vim.keymap.set("n", "lg", function() snacks.lazygit() end , { desc = "lazygit" }) ''; } rose-pine { plugin = rustaceanvim; type = "lua"; config = '' vim.keymap.set("n", "da", function() vim.cmd.RustLsp('codeAction') end, { silent = true, buffer = bufnr }) vim.keymap.set("n", "K", function() vim.cmd.RustLsp({'hover', 'actions'}) end, { silent = true, buffer = bufnr }) ''; } { plugin = tabby-nvim; type = "lua"; config = '' require("tabby").setup({ preset = "active_wins_at_tail", options = { theme = { fill = "TabLineFill", head = "TabLine", current_tab = "TabLineSel", tab = "TabLine", win = "TabLine", tail = "TabLine", }, nerdfont = true, lualine_theme = nil, tab_name = { name_fallback = function(tabid) return tabid end, }, buf_name = { mode = "unique", }, }, }) vim.keymap.set("n", "to", "Tabby jump_to_tab", { desc = "Jump to tab" }) vim.keymap.set("n", "tf", "Tabby pick_window", { desc = "Search tab" }) ''; } { plugin = ts-autotag-nvim; type = "lua"; config = '' require("ts-autotag").setup() ''; } # { # plugin = toggleterm-nvim; # type = "lua"; # config = '' # require("toggleterm").setup() # vim.keymap.set("n", "nt", "ToggleTerm size=120 direction=tab name=ttermh", { desc = "Toggle tterm tab" }) # vim.keymap.set("n", "ns", "ToggleTerm direction=vertical name=ttermv", { desc = "Toggle tterm vertical" }) # vim.keymap.set("n", "", "ToggleTerm direction=float name=ttermf", { desc = "Toggle tterm float" }) # ''; # } { plugin = trouble-nvim; type = "lua"; config = '' require("trouble").setup({}) vim.keymap.set("n", "id", "Trouble diagnostics toggle", { desc = "Trouble project" }) -- vim.keymap.set("n", "io", "Trouble diagnostics toggle filter.buf=0", { desc = "Trouble buffer" }) ''; } { plugin = undotree; type = "lua"; config = ''vim.keymap.set("n", "u", vim.cmd.UndotreeToggle, { desc = "undotree" })''; } vim-repeat { plugin = vimtex; type = "lua"; config = '' vim.g.vimtex_view_method = "zathura" vim.g.vimtex_compiler_method = "latexmk" ''; } { plugin = which-key-nvim; type = "lua"; config = '' local wk = require("which-key") wk.setup({ preset = "helix", win = { row = 0, col = 0.5 }, triggers = { { "", mode = { "n", "v" } }, { "", mode = { "n", "v" } }, } }) wk.add({ { "s", group = "Search..." }, { "l", group = "Launch..." }, { "t", group = "Tab..." }, { "g", group = "Go..." }, { "r", group = "Run..." }, { "n", group = "term..." }, }) -- vim.keymap.set({"t"}, "", wk.show, { desc = "Show which key in terminal mode" }) ''; } vim-fugitive ]; extraConfig = '' colorscheme ${cfg.colorscheme} ''; extraLuaConfig = '' ${builtins.readFile ./settings.lua} ${builtins.replaceStrings [ "@HOSTNAME@" ] [ cfg.hostname ] (builtins.readFile ./plugins.lua)} require("custom") ''; }; }; }