refactor(config): auto-import config files

This commit is contained in:
Nicolas Goudry 2024-05-27 09:39:25 +02:00
parent 1c12503ebf
commit 465916d5c1
No known key found for this signature in database
GPG key ID: 5FC434D9FFD1DF44
5 changed files with 126 additions and 109 deletions

View file

@ -1,13 +1,14 @@
# Use catppuccin mocha variant
{
catppuccin = {
enable = true;
colorschemes = {
catppuccin = {
enable = true;
settings = {
flavour = "mocha";
settings = {
flavour = "mocha";
# Needed to keep terminal transparency, if any
transparent_background = true;
# Needed to keep terminal transparency, if any
transparent_background = true;
};
};
};
}

13
config/default.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib, ... }@args:
let
definitions = lib.attrNames (
lib.filterAttrs
(filename: kind:
filename != "default.nix"
&& (kind == "regular" || kind == "directory")
)
(builtins.readDir ./.)
);
in
lib.mkMerge (map (file: import ./${file}) definitions)

View file

@ -4,30 +4,32 @@ let
options.desc = "Force write";
};
in
[
{
key = "<leader>n";
action = "<cmd>enew<cr>";
options.desc = "New file";
}
{
inherit (forceWrite) action options;
key = "<c-s>";
}
{
inherit (forceWrite) options;
mode = [ "i" "x" ];
key = "<c-s>";
action = "<esc>${forceWrite.action}";
}
{
key = "|";
action = "<cmd>vsplit<cr>";
options.desc = "Split vertically";
}
{
key = "\\";
action = "<cmd>split<cr>";
options.desc = "Split horizontally";
}
]
{
keymaps = [
{
key = "<leader>n";
action = "<cmd>enew<cr>";
options.desc = "New file";
}
{
inherit (forceWrite) action options;
key = "<c-s>";
}
{
inherit (forceWrite) options;
mode = [ "i" "x" ];
key = "<c-s>";
action = "<esc>${forceWrite.action}";
}
{
key = "|";
action = "<cmd>vsplit<cr>";
options.desc = "Split vertically";
}
{
key = "\\";
action = "<cmd>split<cr>";
options.desc = "Split horizontally";
}
];
}

View file

@ -2,102 +2,104 @@
# Use :options to get the list of all options
# Use :h <option> to load help for given <option>
{
# Hide command line unless needed
cmdheight = 0;
opts = {
# Hide command line unless needed
cmdheight = 0;
# Insert mode completion options
completeopt = [ "menu" "menuone" "noselect" ];
# Insert mode completion options
completeopt = [ "menu" "menuone" "noselect" ];
# Copy previous indentation on autoindenting
copyindent = true;
# Copy previous indentation on autoindenting
copyindent = true;
# Highlight current line
cursorline = true;
# Highlight current line
cursorline = true;
# Expand <Tab> to spaces
expandtab = true;
# Expand <Tab> to spaces
expandtab = true;
# Enable fold with all code unfolded
foldcolumn = "1";
foldenable = true;
foldlevel = 99;
foldlevelstart = 99;
# Enable fold with all code unfolded
foldcolumn = "1";
foldenable = true;
foldlevel = 99;
foldlevelstart = 99;
# Ignore case in search patterns
ignorecase = true;
# Ignore case in search patterns
ignorecase = true;
# Show substitution preview in split window
inccommand = "split";
# Show substitution preview in split window
inccommand = "split";
# Infer casing on word completion
infercase = true;
# Infer casing on word completion
infercase = true;
# Enable list mode
list = true;
# Enable list mode
list = true;
# Set custom strings for list mode
# - tabulations are shown as ‒▶
# - trailing spaces are shown as ·
# - multiple non-leading consecutive spaces are shown as bullets (·)
# - non-breakable spaces are shown as ⎕
listchars = "tab:,trail:·,multispace:·,lead: ,nbsp:";
# Set custom strings for list mode
# - tabulations are shown as ‒▶
# - trailing spaces are shown as ·
# - multiple non-leading consecutive spaces are shown as bullets (·)
# - non-breakable spaces are shown as ⎕
listchars = "tab:,trail:·,multispace:·,lead: ,nbsp:";
# Show line numbers
number = true;
# Show line numbers
number = true;
# Preserve indentation as much as possible
preserveindent = true;
# Preserve indentation as much as possible
preserveindent = true;
# Height of the popup menu
pumheight = 10;
# Height of the popup menu
pumheight = 10;
# Display line numbers relative to current line
relativenumber = true;
# Display line numbers relative to current line
relativenumber = true;
# Minimal number of lines to keep around the cursor
# This has the effect to move the view along with current line
#scrolloff = 999;
# Minimal number of lines to keep around the cursor
# This has the effect to move the view along with current line
#scrolloff = 999;
# Number of spaces to use for indentation
shiftwidth = 2;
# Number of spaces to use for indentation
shiftwidth = 2;
# Always show tabline (TODO: use with heirline?)
#showtabline = 2;
# Always show tabline (TODO: use with heirline?)
#showtabline = 2;
# Show signs instead of number in gutter
signcolumn = "number";
# Show signs instead of number in gutter
signcolumn = "number";
# Override ignorecase if search pattern contains uppercase characters
smartcase = true;
# Override ignorecase if search pattern contains uppercase characters
smartcase = true;
# Number of spaces input on <Tab>
softtabstop = 2;
# Number of spaces input on <Tab>
softtabstop = 2;
# Open horizontal split below (:split)
splitbelow = true;
# Open horizontal split below (:split)
splitbelow = true;
# Open vertical split to the right (:vsplit)
splitright = true;
# Open vertical split to the right (:vsplit)
splitright = true;
# Number of spaces to represent a <Tab>
tabstop = 2;
# Number of spaces to represent a <Tab>
tabstop = 2;
# Enables 24-bit RGB color
termguicolors = true;
# Enables 24-bit RGB color
termguicolors = true;
# Shorter timeout duration
timeoutlen = 500;
# Shorter timeout duration
timeoutlen = 500;
# Set window title to the filename
title = true;
# Set window title to the filename
title = true;
# Save undo history to undo file (in $XDG_STATE_HOME/nvim/undo)
undofile = true;
# Save undo history to undo file (in $XDG_STATE_HOME/nvim/undo)
undofile = true;
# Enable virtual edit in visual block mode
# This has the effect of selecting empty cells beyond lines boundaries
virtualedit = "block";
# Enable virtual edit in visual block mode
# This has the effect of selecting empty cells beyond lines boundaries
virtualedit = "block";
# Disable line wrapping
wrap = false;
# Disable line wrapping
wrap = false;
};
}