{ inputs, ... }: { perSystem = { system, pkgs, ... }: { packages.nvim = inputs.nixvim.legacyPackages.${system}.makeNixvim { vimAlias = true; colorschemes.ayu = { enable = true; settings.overrides = { EoLSpace = { bg = "#883333"; }; }; }; globals.mapleader = " "; opts = { mouse = "a"; number = true; shiftwidth = 2; clipboard = "unnamedplus"; # undo stuff undofile = { }; undolevels = 10000; undoreload = 10000; listchars = "tab:⇥ ,extends:❯,precedes:❮,nbsp:␣,trail:·,eol:↲"; }; extraConfigVim = '' set et " show special characters set list " match trailing whitespace match EoLSpace /\s\+$/ " need to use lua to expand $HOME lua vim.o.undodir = vim.fs.normalize('$HOME/.vim/undodir') ''; extraPlugins = [ pkgs.vimPlugins.vim-fetch ]; extraConfigLua = '' local null_ls = require("null-ls") local helpers = require("null-ls.helpers") local utils = require("null-ls.utils") local treefmt_nix = { method = null_ls.methods.FORMATTING, filetypes = {}, generator = helpers.formatter_factory({ command = "treefmt", args = { "--allow-missing-formatter", "--stdin", "$FILENAME" }, to_stdin = true, runtime_condition = function() return utils.is_executable("treefmt") end, }), } local treefmt_nix2 = { method = null_ls.methods.FORMATTING, filetypes = {}, generator = helpers.formatter_factory({ command = "treefmt-nix", args = { "--allow-missing-formatter", "--stdin", "$FILENAME" }, to_stdin = true, runtime_condition = function() return utils.is_executable("treefmt-nix") end, }), } null_ls.register(treefmt_nix) ''; keymaps = [ { mode = "i"; key = ""; action = ""; } { mode = "i"; key = ""; action = ""; } { mode = "n"; key = ""; action = ":q"; } { mode = "n"; key = ""; action = ""; } { mode = "n"; key = "sd"; action = ":colorscheme ayu-dark"; } { mode = "n"; key = "sw"; action = ":colorscheme ayu-light"; } { mode = [ "n" "v" ]; key = "cc"; action = ":CopilotChatOpen"; } { mode = [ "n" "v" ]; key = "ce"; action = ":CopilotChatExplain"; } { mode = [ "n" "v" ]; key = "cr"; action = ":CopilotChatReview"; } { mode = [ "n" "v" ]; key = "cf"; action = ":CopilotChatFix"; } { mode = [ "n" "v" ]; key = "cd"; action = ":CopilotChatDocs"; } { mode = [ "n" "x" ]; key = "p"; action = "(YankyPutAfter)"; } { mode = [ "n" "x" ]; key = "P"; action = "(YankyPutBefore)"; } { mode = [ "c" "i" "n" "x" ]; key = ""; action = ":lua vim.lsp.buf.code_action()"; } ]; # autoCmd = [ # { # event = "BufWritePost"; # desc = "run treefmt on save"; # # https://stackoverflow.com/questions/77466697/how-to-automatically-format-on-save # callback.__raw = '' # function() # vim.cmd("silent !treefmt %") # vim.cmd("edit") # end # ''; # } # ]; plugins.none-ls = { enable = true; # sources.formatting.treefmt = { # enable = true; # package = pkgs.emptyDirectory; # }; # package = pkgs.vimPlugins.none-ls-nvim.overrideAttrs (_old: { # src = pkgs.fetchFromGitHub { # owner = "lassulus"; # repo = "none-ls.nvim"; # rev = "292c2b5eadea0a097b9a01804aea70f5c8125200"; # sha256 = "sha256-nbzqXsxmYfxngdJH3NXMLmGgygh6reSEnruoc6l8t/s="; # }; # }); }; plugins.web-devicons.enable = true; plugins.telescope.extensions.undo.enable = true; plugins.telescope = { enable = true; keymaps = { "b" = "buffers"; "u" = "undo"; "ff" = "find_files"; "fg" = "live_grep"; "fh" = "help_tags"; "fp" = "yank_history"; }; }; plugins.lsp-format.enable = true; plugins.lsp-lines.enable = true; plugins.lsp = { enable = true; servers = { bashls.enable = true; # bash nixd = { enable = true; # nix extraOptions.offset_encoding = "utf-8"; # workaround https://github.com/nix-community/nixvim/issues/2390#issuecomment-2408101568 }; ruff_lsp.enable = true; # python harper_ls.enable = true; # comments jsonls.enable = true; # json }; }; plugins.treesitter.enable = true; plugins.copilot-cmp.enable = true; plugins.copilot-lua.panel.enabled = false; plugins.copilot-lua.suggestion.enabled = false; plugins.cmp_yanky.enable = true; plugins.cmp = { enable = true; autoEnableSources = true; settings = { experimental = { ghost_text = true; }; sources = [ { name = "nvim_lsp"; } { name = "emoji"; } { name = "buffer"; # text within current buffer option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; keywordLength = 2; } { name = "copilot"; # enable copilot } { name = "path"; # file system paths keywordLength = 3; } { name = "cmp_yanky"; } ]; mapping = { "" = "cmp.mapping.select_next_item()"; "" = "cmp.mapping.select_prev_item()"; "" = "cmp.mapping.select_next_item()"; "" = "cmp.mapping.select_prev_item()"; "" = "cmp.mapping.abort()"; "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.scroll_docs(4)"; "" = '' cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) else fallback() end end, s = cmp.mapping.confirm({ select = true }), c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), }) ''; }; }; }; plugins.bufferline.enable = true; plugins.which-key.enable = true; plugins.yanky = { enable = true; enableTelescope = true; }; plugins.comment.enable = true; plugins.copilot-chat.enable = true; plugins.undotree.enable = true; # seems to be needed for undo history in telescope plugins.leap.enable = true; }; }; }