fix alignment and add basic nvim config

This commit is contained in:
Noa Aarts 2024-02-28 12:39:47 +01:00
parent 3a71fb8ce2
commit 2bc79f165e
3 changed files with 293 additions and 164 deletions

18
flake.lock generated
View file

@ -155,17 +155,17 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1708976249, "lastModified": 1708984720,
"narHash": "sha256-bA0rrmxj5K1W/EWgzpk1NUvEIyAk1hqsmxcRCmmXFuw=", "narHash": "sha256-gJctErLbXx4QZBBbGp78PxtOOzsDaQ+yw1ylNQBuSUY=",
"owner": "NixOS", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d8e0944e6d2ce0f326040e654c07a410e2617d47", "rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d8e0944e6d2ce0f326040e654c07a410e2617d47",
"type": "github" "type": "github"
} }
}, },
@ -181,11 +181,11 @@
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
}, },
"locked": { "locked": {
"lastModified": 1709054170, "lastModified": 1709109026,
"narHash": "sha256-er3hOsSa6nOiOYHpCUukLZcbaORSdifxpzAmMBLT1HM=", "narHash": "sha256-gW1UIlzNnk9F6M04GAqF9sctGAz0CZrGlIPy7IDqAQI=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixvim", "repo": "nixvim",
"rev": "81f20bd2f5f53883d4fb386752196ea0a3ddd053", "rev": "bb9d56087dda932274e25702ce32b725295d926d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -2,9 +2,9 @@
description = "Nixos config flake"; description = "Nixos config flake";
inputs = { inputs = {
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/d8e0944e6d2ce0f326040e654c07a410e2617d47"; # nixpkgs.url = "github:NixOS/nixpkgs/d8e0944e6d2ce0f326040e654c07a410e2617d47";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";

View file

@ -23,30 +23,31 @@
# The home.packages option allows you to install Nix packages into your # The home.packages option allows you to install Nix packages into your
# environment. # environment.
home.packages = [ home.packages = with pkgs; [
pkgs.file file
pkgs.unzip unzip
pkgs.zip zip
pkgs.dig dig
pkgs.mtr mtr
pkgs.firefox firefox
(pkgs.writeShellScriptBin "spotify" '' (writeShellScriptBin "spotify" ''
exec ${pkgs.spotify}/bin/spotify --enable-features=UseOzonePlatform --ozone-platform=wayland exec ${pkgs.spotify}/bin/spotify --enable-features=UseOzonePlatform --ozone-platform=wayland
'') '')
pkgs.hyprland hyprland
pkgs.dunst dunst
pkgs.waybar waybar
wl-clipboard
(pkgs.writeShellScriptBin "discord" '' (writeShellScriptBin "discord" ''
exec ${pkgs.discord}/bin/discord --enable-features=UseOzonePlatform --ozone-platform=wayland exec ${pkgs.discord}/bin/discord --enable-features=UseOzonePlatform --ozone-platform=wayland
'') '')
pkgs.kitty kitty
pkgs.wofi wofi
pkgs.pipewire pipewire
pkgs.lsd lsd
]; ];
@ -96,7 +97,8 @@
enable=true; enable=true;
shellAliases = { shellAliases = {
ll = "lsd -l"; ll = "lsd -l";
update = "sudo nixos-rebuild switch --flake /etc/nixos#default"; lt = "lsd -l --tree";
update = "sudo nixos-rebuild switch --flake $HOME/nixos#default";
}; };
history = { history = {
path = "${config.xdg.dataHome}/zsh/history"; path = "${config.xdg.dataHome}/zsh/history";
@ -197,68 +199,184 @@
}; };
# TODO move to seperate file # TODO move to seperate file
# TODO create neovim config
programs.nixvim = { programs.nixvim = {
enable = true; enable = true;
vimAlias = true; vimAlias = true;
globals = {
mapleader = " ";
maplocalleader = " ";
};
colorschemes.catppuccin.enable = true;
# Configure neovim options... # Configure neovim options...
options = { options = {
tabstop = 4;
shiftwidth = 4;
relativenumber = true; relativenumber = true;
incsearch = true; incsearch = true;
hlsearch = true;
number = true;
mouse = "a";
showmode = false;
breakindent = true;
undofile = true;
ignorecase = true;
smartcase = true;
signcolumn = "yes";
updatetime = 250;
timeoutlen = 300;
splitright = true;
splitbelow = true;
list = true;
listchars = {
tab = "> ";
trail = ".";
nbsp = "_";
};
inccommand = "nosplit";
cursorline = true;
scrolloff = 8;
}; };
# ...mappings... # ...mappings...
keymaps = [ keymaps = [
{ {
mode = "n"; mode = "n";
key = "<C-s>"; key = "<Esc>";
action = ":w<CR>"; action = "<cmd>nohlsearch<CR>";
options.desc = "Remove search highlights";
}
{
mode = "t";
key = "<Esc><Esc>";
action = "<C-\\><C-n>";
options.desc = "Exit terminal mode";
} }
{ {
mode = "n"; mode = "n";
key = "<esc>"; key = "<C-h>";
action = ":noh<CR>"; action = "<C-w><C-h>";
options.silent = true; options.desc = "Move focus to the left window";
} }
{ {
mode = "v"; mode = "n";
key = ">"; key = "<C-l>";
action = ">gv"; action = "<C-w><C-l>";
options.desc = "Move focus to the right window";
} }
{ {
mode = "v"; mode = "n";
key = "<"; key = "<C-j>";
action = "<gv"; action = "<C-w><C-j>";
options.desc = "Move focus to the lower window";
}
{
mode = "n";
key = "<C-k>";
action = "<C-w><C-k>";
options.desc = "Move focus to the upper window";
}
{
mode = "n";
key = "<leader>pv";
lua = true;
action = "vim.cmd.Ex";
options.desc = "Open the integrated file explorer";
} }
]; ];
plugins = { plugins = {
telescope.enable = true; fugitive.enable = true;
comment-nvim.enable = true;
nvim-colorizer.enable = true;
telescope = {
enable = true;
keymaps = {
"<leader>sh" = {
action = "help_tags";
desc = "[S]earch [H]elp";
};
"<leader>sk" = {
action = "keymaps";
desc = "[S]earch [K]eymaps";
};
"<leader>sf" = {
action = "find_files";
desc = "[S]earch [F]iles";
};
"<leader>ss" = {
action = "builtin";
desc = "[S]earch [S]elect Telescope";
};
"<leader>sw" = {
action = "grep_string";
desc = "[S]earch current [W]ord";
};
"<leader>sg" = {
action = "live_grep";
desc = "[S]earch by [G]rep";
};
"<leader>sd" = {
action = "diagnostics";
desc = "[S]earch [D]iagnostics";
};
"<leader>sr" = {
action = "resume";
desc = "[S]earch [R]esume";
};
"<leader>s." = {
action = "oldfiles";
desc = "[S]earch recent files (\".\" for repeat)";
};
"<leader><leader>" = {
action = "buffers";
desc = "[ ] Find existing buffers";
};
};
};
treesitter = {
enable = true;
indent = true;
};
lsp = { lsp = {
enable = true;
enabledServers = [
"lua_ls"
];
keymaps = { keymaps = {
silent = true; silent = true;
diagnostic = { diagnostic = {
"<leader>k" = "goto_prev"; "[d" = {
"<leader>j" = "goto_next"; action = "goto_prev";
desc = "Go to previous [D]iagnostic message";
}; };
"]d" = {
lspBuf = { action = "goto_next";
gd = "definition"; desc = "Go to next [D]iagnostic message";
K = "hover";
}; };
"<leader>e" = {
action = "open_float";
desc = "Show diagnostic [E]rror messages";
}; };
servers = { "<leader>q" = {
bashls.enable = true; action = "setloclist";
clangd.enable = true; desc = "Open diagnostic [Q]uickfix list";
nil_ls.enable = true; };
};
};
};
gitsigns = {
enable = true;
signs = {
add = { text = "+"; };
change = { text = "~"; };
delete = { text = "_"; };
topdelete = { text = "T"; };
changedelete = { text = "~"; };
}; };
}; };
}; };
# ... and even highlights and autocommands !
highlight.ExtraWhitespace.bg = "red";
match.ExtraWhitespace = "\\s\\+$"; match.ExtraWhitespace = "\\s\\+$";
autoCmd = [ autoCmd = [
{ {
@ -266,6 +384,17 @@
pattern = "nix"; pattern = "nix";
command = "setlocal tabstop=2 shiftwidth=2"; command = "setlocal tabstop=2 shiftwidth=2";
} }
{
event = "LspAttach";
callback = ''
function (event)
local map = function(keys, func, desc)
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end
'';
}
];
extraPlugins = with pkgs.vimPlugins; [
]; ];
}; };