{ config, lib, pkgs, inputs, ... }: let inherit (lib) mkEnableOption mkIf readFile; in { home-manager.users.moritz = { programs.nixvim = lib.mkMerge [ { plugins.which-key.enable = true; } { plugins.lastplace.enable = true; } { plugins.comment.enable = true; } { plugins.ts-context-commentstring.enable = true; } { plugins.vimtex = { enable = true; settings.view_method = "zathura"; }; } { plugins.todo-comments = { enable = true; keymaps.todoTelescope.key = "fc"; }; } { plugins.conform-nvim = { enable = true; settings.formatters_by_ft = { "*" = [ "codespell" "trim_whitespace" ]; elixir = [ "mix" ]; gleam = [ "gleam" ]; go = [ "gofmt" ]; json = [ "jq" ]; lua = [ "stylua" ]; nix.__raw = ''{ "nixpkgs_fmt", "alejandra", stop_after_first=true }''; python.__raw = '' function(bufnr) return { first("ruff_organize_imports", "isort"), first("ruff_format", "black")} end ''; rust = [ "rustfmt" ]; sh = [ "shfmt" ]; tex = [ "latexindent" ]; toml = [ "taplo" ]; yaml = [ "yamlfix" ]; }; }; opts.formatexpr = "v:lua.require'conform'.formatexpr()"; extraConfigLuaPre = '' ---@param bufnr integer ---@param ... string ---@return string local function first(bufnr, ...) local conform = require("conform") for i = 1, select("#", ...) do local formatter = select(i, ...) if conform.get_formatter_info(formatter, bufnr).available then return formatter end end return select(1, ...) end vim.api.nvim_create_user_command("Format", function(opts) require("conform").format({ formatters = opts.fargs }) end, { nargs = "+", complete = function() local formatters_by_ft = require("conform").formatters_by_ft local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {} names = vim.list_extend(names, formatters_by_ft["*"] or {}) names = vim.tbl_flatten(names) local formatters = vim.tbl_map(require("conform").get_formatter_info, names) formatters = vim.tbl_filter(function(formatter) return formatter.available end, formatters) return vim.tbl_map(function(formatter_info) return formatter_info.name end, formatters) end, }) ''; performance.combinePlugins.standalonePlugins = [ "conform.nvim" ]; keymaps = [ { key = "cf"; action.__raw = ''function() require("conform").format() end''; options.desc = "Format current file"; } ]; } { keymaps = [ { key = ""; action = "noh"; options.desc = "Escape and clear hlsearch"; mode = [ "i" "n" ]; } ]; } { plugins.oil.enable = true; } { plugins.telescope = { enable = true; extensions.fzf-native.enable = true; keymaps = { "ff" = { action = "find_files"; options.desc = "Find files"; }; "fb" = { action = "buffers"; options.desc = "Find buffers"; }; "fl" = { action = "current_buffer_fuzzy_find"; options.desc = "Search lines"; }; "fg" = { action = "live_grep"; options.desc = "Live grep"; }; "fh" = { action = "help_tags"; options.desc = "Help tags"; }; "fr" = { action = "oldfiles"; options.desc = "Recent files"; }; }; }; } { plugins.nvim-autopairs.enable = true; } { plugins.surround.enable = true; } { plugins.lint.enable = true; # TODO: add linters plugins.lint.lintersByFt = { }; } { plugins.marks.enable = true; plugins.marks.defaultMappings = false; } { plugins.hmts.enable = true; performance.combinePlugins.standalonePlugins = [ "hmts.nvim" ]; } { plugins.gitsigns.enable = true; } { plugins.fugitive.enable = true; } { plugins.friendly-snippets.enable = true; } { plugins.direnv.enable = true; } { plugins.crates-nvim.enable = true; } ]; }; }