Configure nixvim

This commit is contained in:
Isshi0417 2024-07-19 14:52:30 +09:00
parent 9c937006e9
commit 415f123c45
7 changed files with 312 additions and 17 deletions

View File

@ -1,34 +1,178 @@
{ ... }: { pkgs, ... }:
{ {
imports = [
./plugins
];
programs.nixvim = { programs.nixvim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
vimdiffAlias = true; vimdiffAlias = true;
enableMan = true;
colorschemes.gruvbox.enable = true; colorschemes.gruvbox.enable = true;
globals = {
mapleader = " ";
maplocalleader = " ";
have_nerd_font = true;
};
opts = { opts = {
# Show line numbers
number = true; number = true;
relativenumber = true; relativenumber = true;
# Enable mouse mode
mouse = "a";
# Don't show the mode
showmode = false;
# Sync clipboard with OS
clipboard = "unnamedplus";
# Enable break indent
breakindent = true;
# Save undo history
undofile = true;
# Case-insensitive searching unless stated otherwise
ignorecase = true;
smartcase = true;
# Keep isgncolumn on by default
signcolumn = "yes";
# Decrease update time
updatetime = 250;
# Decrease mapped sequence wait time
timeoutlen = 300;
# Configure split behavior
splitright = true;
splitbelow = true;
# Set how neovim displays whitespace characters
list = true;
listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '' }";
# Preview substitutions live
inccommand = "split";
# Show which line the cursor is on
cursorline = true;
# Minimal number of screen lines to keep above and below the cursor
scrolloff = 20;
# Set highlight on search but clear on pressing <Esc> in normal mode
hlsearch = true;
}; };
keymaps = [
{
mode = "n";
key = "<Esc>";
action = "<cmd>nohlsearch<CR>";
}
{
mode = "t";
key = "<Esc><Esc>";
action = "<C-\\><C-n>";
options = {
desc = "Exit terminal mode";
};
}
{
mode = "n";
key = "<C-h>";
action = "<C-w><C-h>";
options = {
desc = "Move focus to the left window";
};
}
{
mode = "n";
key = "<C-l>";
action = "<C-w><C-l>";
options = {
desc = "Move focus to the right window";
};
}
{
mode = "n";
key = "<C-j>";
action = "<C-w><C-l>";
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";
};
}
];
autoGroups = {
kickstart-highlight-yank = {
clear = true;
};
};
# Basic autocommands
autoCmd = [
{
event = ["TextYankPost"];
desc = "Highlight when yanking (copying) text";
group = "kickstart-highlight-yank";
callback.__raw = ''
function()
vim.highlight.on_yank()
end
'';
}
];
plugins = { plugins = {
lualine.enable = true; sleuth = {
treesitter.enable = true; enable = true;
telescope.enable = true; };
lazygit.enable = true;
cmp.enable = true; comment = {
sleuth.enable = true; enable = true;
nvim-autopairs.enable = true; };
neoscroll.enable = true;
indent-blankline.enable = true; todo-comments = {
bufferline.enable = true; enable = true;
which-key.enable = true; signs = true;
comment.enable = true; };
dashboard.enable = true; };
};
extraPlugins = with pkgs.vimPlugins; [
nvim-web-devicons
];
extraConfigLuaPre = ''
if vim.g.have_nerd_font then
require('nvim-web-devicons').setup {}
end
'';
extraConfigLuaPost = ''
-- vim: ts=2 sts=2 sw=2 et
'';
}; };
} }

View File

@ -0,0 +1,11 @@
{ ... }:
{
imports = [
./mini.nix
./lualine.nix
./treesitter.nix
./telescope.nix
./lazygit.nix
];
}

View File

@ -0,0 +1,7 @@
{ ... }:
{
programs.nixvim.plugins.lazygit = {
enable = true;
};
}

View File

@ -0,0 +1,9 @@
{ ... }:
{
programs.nixvim.plugins.lualine = {
enable = true;
globalstatus = true;
iconsEnabled = true;
};
}

View File

@ -0,0 +1,16 @@
{ config, pkgs, inputs, ... }:
{
programs.nixvim.plugins.mini = {
enable = true;
modules = {
ai = {
n_lines = 500;
};
surround = {
};
};
};
}

View File

@ -0,0 +1,99 @@
{ config, pkgs, inputs, ... }:
{
programs.nixvim.plugins.telescope = {
enable = true;
# Enable telescope extensions
extensions = {
fzf-native.enable = true;
ui-select.enable = true;
};
keymaps = {
"<leader>sh" = {
mode = "n";
action = "help_tags";
options = {
desc = "[S]earch [H]elp";
};
};
"<leader>sk" = {
mode = "n";
action = "keymaps";
options = {
desc = "[S]earch [K]eymaps";
};
};
"<leader>sf" = {
mode = "n";
action = "find_files";
options = {
desc = "[S]earch [F]iles";
};
};
"<leader>ss" = {
mode = "n";
action = "builtin";
options = {
desc = "[S]earch [S]elect Telescope";
};
};
"<leader>sw" = {
mode = "n";
action = "grep_string";
options = {
desc = "[S]earch by [G]rep";
};
};
"<leader>sg" = {
mode = "n";
action = "live_grep";
options = {
desc = "[S]earch by [G]rep";
};
};
"<leader>sd" = {
mode = "n";
action = "diagnostics";
options = {
desc = "[S]earch [D]iagnostics";
};
};
"<leader>sr" = {
mode = "n";
action = "resume";
options = {
desc = "[S]earch [R]esume";
};
};
"<leader>s" = {
mode = "n";
action = "oldfiles";
options = {
desc = "[S]earch Recent Files ('.' for repeat)";
};
};
"<leader><leader>" = {
mode = "n";
action = "buffers";
options = {
desc = "[ ] Find existing buffers";
};
};
};
settings = {
extensions.__raw = "{ ['ui-select'] = { require('telescope.themes').get_dropdown() } }";
};
};
}

View File

@ -0,0 +1,9 @@
{ config, pkgs, inputs, ... }:
{
programs.nixvim.plugins.treesitter = {
enable = true;
indent = true;
};
}