dotfiles/programs/nvim/default.nix
2024-12-30 09:41:46 +01:00

123 lines
3 KiB
Nix

{ pkgs, ... }:
let
map = mode: key: action: {
inherit mode key action;
};
in
{
home = { sessionVariables = { EDITOR = "nvim"; }; };
imports = [
./options.nix
./plugins.nix
];
programs.nixvim = {
enable = true;
globals.mapleader = " ";
globals.maplocalleader = " ";
viAlias = true;
vimAlias = true;
# Highlight and remove extra white spaces
# same color as cursorline as per
# https://github.com/joshdick/onedark.vim/blob/390b893d361c356ac1b00778d849815f2aa44ae4/autoload/onedark.vim
highlight.ExtraWhitespace.bg = "#2C323C";
match.ExtraWhitespace = "\\s\\+$";
clipboard.providers.wl-copy.enable = true;
performance = {
byteCompileLua.enable = true;
combinePlugins = {
enable = true;
standalonePlugins = [
# clashes with lualine
"onedark.nvim"
];
};
};
# package = pkgs.neovim-unwrapped;
package = (pkgs.neovim-unwrapped.override { lua = pkgs.luajit; }).overrideAttrs (_: {
version = "git";
src = pkgs.fetchFromGitHub {
owner = "neovim";
repo = "neovim";
rev = "76dcc7029b200e1d85024d7ba4a34c602e730dbe";
hash = "sha256-y3LmGebXuQhLz9w1IzkDU8b464WvMvPCbIImpVvxmcI=";
};
buildInputs = [
(pkgs.utf8proc.overrideAttrs (_: {
version = "git";
src = pkgs.fetchFromGitHub
{
owner = "JuliaStrings";
repo = "utf8proc";
rev = "3de4596fbe28956855df2ecb3c11c0bbc3535838";
hash = "sha256-DNnrKLwks3hP83K56Yjh9P3cVbivzssblKIx4M/RKqw=";
};
}))
] ++ pkgs.neovim-unwrapped.buildInputs ++ pkgs.neovim-unwrapped.nativeBuildInputs;
});
keymaps = [
{
key = "<f2>";
action = "<cmd>Lspsaga rename<cr>";
}
{
key = "<leader>o";
action = "<cmd>Lspsaga outline<cr>";
}
{
key = "<leader>.";
action = "<cmd>Lspsaga code_action<cr>";
}
# {
# key = "/";
# action = "<cmd>lua require('spectre').open_file_search({select_word=true})<CR>";
# }
(map "n" "t" "<cmd>Neotree toggle<cr>")
# tab for indent/dedent
(map "n" "<tab>" ">>_")
(map "n" "<S-tab>" "<<_")
(map "i" "<S-tab>" "<c-d>")
(map "v" "<tab>" ">gv")
(map "v" "<S-tab>" "<gv")
];
colorschemes.onedark = {
enable = true;
settings = {
style = "deep";
highlights = {
# bright green doccomments
"@lsp.type.comment".fg = "#77B767";
"@comment.documentation.rust".fg = "#77B767";
"@comment.documentation".fg = "#77B767";
"@comment".fg = "#426639";
};
};
};
extraConfigLuaPre = ''
require("neoconf").setup({})
'';
extraConfigLua = ''
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
'' + (builtins.readFile ./config.lua);
};
}