Compare commits

..

No commits in common. "0fff5154e69feb5bbb0e634e654eb65feee9c5cf" and "10253909c98a586ffdbe31f5806e96b58da01be1" have entirely different histories.

6 changed files with 104 additions and 357 deletions

View file

@ -1,23 +1,12 @@
# viminal # Neovim Configuration Flake
This is the Neovim configuration for all my NixOS and Nix enabled systems This is the Neovim configuration for all my NixOS and Nix enabled systems (such
(including macOS). It aims to be minimal and utilitarian; it forgoes many as with nix-darwin on macOS). It aims to be minimal and utilitarian; it forgoes
blingful features like sidebars or fancy UI enhancements in favor of native many blingful features like sidebars or fancy UI enhancements in favor of
(neo)Vim, while still having everything useful you'd expect, like LSPs, file native (neo)Vim, while still having everything useful you'd expect, like LSPs,
explorer (`oil.nvim`), completions, advanced language tools, and QoL file explorer (`oil.nvim`), completions, advanced language tools, and QoL
enhancements. enhancements.
The central design goal is to prefer Vim whenever possible. The Vim text editor
is already incredibly powerful, and many plugins designed to emulate features
from more bloated editors like VS Code can already be accomplished in native
Vim. To that end, plugins were selected to unobtrusively integrate with Vim.
For instance, `oil.nvim` allows you to interface with your filesystem through a
regular Vim buffer, and Git integration is done by Gitsigns and `Neogit`, which
enable a similar interface for Git. The long-term benefit of this is avoiding
lock-in to a plugin that encourages a heavily idiosyncratic workflow which may
become unmaintained in the future, while the Neovim core itself is almost
assuredly going stick around.
It uses the [Nixvim](https://nix-community.github.io/nixvim/) project under It uses the [Nixvim](https://nix-community.github.io/nixvim/) project under
the hood to declaratively configure Neovim and its plugins, and installs tools the hood to declaratively configure Neovim and its plugins, and installs tools
needed by it (like `ripgrep`, `fd`, etc). However, LSPs are not installed or needed by it (like `ripgrep`, `fd`, etc). However, LSPs are not installed or
@ -47,7 +36,7 @@ showing me how to build a Nixvim configuration as a standalone Nix package.
You can test drive my config in just one line (if you have Nix, of course): You can test drive my config in just one line (if you have Nix, of course):
```sh ```sh
nix run 'github:youwen5/viminal' --extra-experimental-features flakes --extra-experimental-features nix-command nix run 'github:youwen5/neovim-flake' --extra-experimental-features flakes --extra-experimental-features nix-command
``` ```
If for some reason, you want to install it permanently, add it to your flake If for some reason, you want to install it permanently, add it to your flake
@ -60,7 +49,7 @@ inputs, and install the package in the usual way:
inputs = { inputs = {
# -- snip -- # -- snip --
viminal.url = "github:youwen5/viminal"; custom-neovim.url = "github:youwen5/neovim-flake";
}; };
# -- snip -- # -- snip --
}; };
@ -74,7 +63,7 @@ inputs, and install the package in the usual way:
{inputs, system, ...}: {inputs, system, ...}:
{ {
environment.systemPackages = [ environment.systemPackages = [
inputs.viminal.packages.${system}.default inputs.custom-neovim.packages.${system}.default
# supported systems: x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin # supported systems: x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin
]; ];
} }

View file

@ -14,6 +14,18 @@
}; };
mode = "n"; mode = "n";
} }
{
action = "<cmd>sp<CR><C-w>j";
key = "<Leader>-";
options.silent = true;
options.desc = "Split window horizontally";
}
{
action = "<cmd>vsp<CR><c-w>l";
key = "<Leader>\\";
options.silent = true;
options.desc = "Split window vertically";
}
{ {
action = "<cmd>ZenMode<CR>"; action = "<cmd>ZenMode<CR>";
key = "<Space>wz"; key = "<Space>wz";
@ -23,6 +35,60 @@
desc = "Zen mode"; desc = "Zen mode";
}; };
} }
{
action = "<C-w>h";
key = "<C-h>";
options = {
silent = true;
noremap = true;
desc = "Move to left window";
};
}
{
action = "<C-w>j";
key = "<C-j>";
options = {
silent = true;
noremap = true;
desc = "Move to lower window";
};
}
{
action = "<C-w>k";
key = "<C-k>";
options = {
silent = true;
noremap = true;
desc = "Move to upper window";
};
}
{
action = "<C-w>l";
key = "<C-l>";
options = {
silent = true;
noremap = true;
desc = "Move to right window";
};
}
{
action = "<cmd>close<CR>";
key = "<Leader>wd";
options = {
silent = true;
noremap = true;
desc = "Close current window";
};
}
{
action = "<cmd>Bdelete!<CR><cmd>close<CR>";
key = "<Leader>wk";
options = {
silent = true;
noremap = true;
desc = "Close current window, along with the buffer open inside.";
};
}
{ {
action = "<cmd>Telescope find_files<CR>"; action = "<cmd>Telescope find_files<CR>";
key = "<Leader>ff"; key = "<Leader>ff";
@ -160,191 +226,12 @@
}; };
} }
{ {
action = ":Neogit<CR>"; action = ":LazyGit<CR>";
key = "<Leader>gg"; key = "<Leader>gg";
options = { options = {
silent = true; silent = true;
noremap = true; noremap = true;
desc = "Open Neogit"; desc = "Open LazyGit";
};
}
{
action = ":Neogit commit<CR>";
key = "<Leader>gc";
options = {
silent = true;
noremap = true;
desc = "Open commit menu";
};
}
{
mode = "n";
key = "]c";
action = {
__raw = ''
function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
require('gitsigns').nav_hunk('next')
end
end
'';
};
options = {
silent = true;
noremap = true;
desc = "Go to next hunk";
};
}
{
mode = "n";
key = "[c";
action = {
__raw = ''
function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
require('gitsigns').nav_hunk('prev')
end
end
'';
};
options = {
silent = true;
noremap = true;
desc = "Go to previous hunk";
};
}
{
mode = "n";
key = "<leader>gs";
action = ":lua require('gitsigns').stage_hunk()<CR>";
options = {
silent = true;
noremap = true;
desc = "Stage hunk";
};
}
{
mode = "n";
key = "<leader>gr";
action = ":lua require('gitsigns').reset_hunk()<CR>";
options = {
silent = true;
noremap = true;
desc = "Reset hunk";
};
}
{
mode = "v";
key = "<leader>gs";
action = ":lua require('gitsigns').stage_hunk {vim.fn.line('.'), vim.fn.line('v')}<CR>";
options = {
silent = true;
noremap = true;
desc = "Stage hunk";
};
}
{
mode = "v";
key = "<leader>gr";
action = ":lua require('gitsigns').reset_hunk {vim.fn.line('.'), vim.fn.line('v')}<CR>";
options = {
silent = true;
noremap = true;
desc = "Reset hunk";
};
}
{
mode = "n";
key = "<leader>gS";
action = ":lua require('gitsigns').stage_buffer()<CR>";
options = {
silent = true;
noremap = true;
desc = "Stage buffer";
};
}
{
mode = "n";
key = "<leader>gu";
action = ":lua require('gitsigns').undo_stage_hunk()<CR>";
options = {
silent = true;
noremap = true;
desc = "Undo stage hunk";
};
}
{
mode = "n";
key = "<leader>gR";
action = ":lua require('gitsigns').reset_buffer()<CR>";
options = {
silent = true;
noremap = true;
desc = "Reset buffer";
};
}
{
mode = "n";
key = "<leader>gp";
action = ":lua require('gitsigns').preview_hunk()<CR>";
options = {
silent = true;
noremap = true;
desc = "Preview hunk";
};
}
{
mode = "n";
key = "<leader>gb";
action = ":lua require('gitsigns').blame_line{full=true}<CR>";
options = {
silent = true;
noremap = true;
desc = "View line blame";
};
}
{
mode = "n";
key = "<leader>gB";
action = ":lua require('gitsigns').toggle_current_line_blame()<CR>";
options = {
silent = true;
noremap = true;
desc = "Toggle line blame";
};
}
{
mode = "n";
key = "<leader>gd";
action = ":lua require('gitsigns').diffthis()<CR>";
options = {
silent = true;
noremap = true;
desc = "Git diff";
};
}
{
mode = "n";
key = "<leader>gD";
action = ":lua require('gitsigns').diffthis('~')<CR>";
options = {
silent = true;
noremap = true;
desc = "Git diff";
};
}
{
mode = "n";
key = "<leader>gtd";
action = ":lua require('gitsigns').toggle_deleted()<CR>";
options = {
silent = true;
noremap = true;
desc = "Toggle git deleted";
}; };
} }
{ {
@ -498,60 +385,14 @@
silent = true; silent = true;
}; };
} }
{ # {
action = { # action = "<cmd>lua require'conform'.format({ bufnr = args.bf })<CR>";
__raw = '' # key = "<Leader>cf";
function() require('conform').format() end # options = {
''; # silent = true;
}; # noremap = true;
key = "<Leader>cf"; # desc = "Format buffer";
options = { # };
silent = true; # }
noremap = true;
desc = "Format buffer";
};
}
{
action = {
__raw = ''
function()
-- we do this instead of `not vim.g.disable_autoformat` so that we
-- can handle when `vim.g.disable_autoformat` has not yet been defined
if (vim.g.disable_autoformat) then
vim.g.disable_autoformat = false
else
vim.g.disable_autoformat = true
end
end
'';
};
key = "<Leader>ctf";
options = {
silent = true;
noremap = true;
desc = "Toggle autoformat globally";
};
}
{
action = {
__raw = ''
-- we do this instead of `not vim.g.disable_autoformat` so that we
-- can handle when `vim.g.disable_autoformat` has not yet been defined
function()
if (vim.b[0].disable_autoformat) then
vim.b[0].disable_autoformat = false
else
vim.b[0].disable_autoformat = true
end
end
'';
};
key = "<Leader>cbf";
options = {
silent = true;
noremap = true;
desc = "Toggle autoformat in buffer";
};
}
]; ];
} }

View file

@ -39,45 +39,10 @@
}); });
# package = pkgs.vimPlugins.conform-nvim; # package = pkgs.vimPlugins.conform-nvim;
settings = { settings = {
# format_on_save = { format_on_save = {
# timeoutMs = 500; timeoutMs = 500;
# lspFallback = true; lspFallback = true;
# }; };
format_on_save = # Lua
''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- if slow_format_filetypes[vim.bo[bufnr].filetype] then
-- return
-- end
--
-- local function on_format(err)
-- if err and err:match("timeout$") then
-- slow_format_filetypes[vim.bo[bufnr].filetype] = true
-- end
-- end
--
-- return { timeout_ms = 500, lsp_fallback = true }, on_format
return { timeout_ms = 500, lsp_fallback = true }
end
'';
format_after_save = # Lua
''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- if not slow_format_filetypes[vim.bo[bufnr].filetype] then
-- return
-- end
return { lsp_fallback = true }
end
'';
formatters_by_ft = { formatters_by_ft = {
lua = [ "stylua" ]; lua = [ "stylua" ];
python = [ "black" ]; python = [ "black" ];

View file

@ -1,5 +1,4 @@
# All the mini.nvim stuff # All the mini.nvim stuff
{ pkgs, ... }:
{ {
plugins.mini = { plugins.mini = {
enable = true; enable = true;
@ -14,14 +13,6 @@
trailspace = { }; trailspace = { };
cursorword = { }; cursorword = { };
bracketed = { }; bracketed = { };
starter = { };
}; };
package = pkgs.vimPlugins.mini-nvim.overrideAttrs (oldAttrs: {
postInstall =
(oldAttrs.postInstall or "")
+ ''
rm $out/doc/mini-git.txt
'';
});
}; };
} }

View file

@ -77,22 +77,18 @@
cmdToggleQuickMenu = "<Leader>hm"; cmdToggleQuickMenu = "<Leader>hm";
gotoTerminal = { gotoTerminal = {
"1" = "<Leader>ht"; "1" = "<Leader>ht";
"2" = "<Leader>h2"; "2" = "<Leader>2";
"3" = "<Leader>h3"; "3" = "<Leader>3";
"4" = "<Leader>h4"; "4" = "<Leader>4";
}; };
navFile = { navFile = {
"1" = "<C-h>"; "1" = "<Leader>ha";
"2" = "<C-j>"; "2" = "<Leader>hs";
"3" = "<C-k>"; "3" = "<Leader>hd";
"4" = "<C-l>"; "4" = "<Leader>hf";
"5" = "<Leader>1";
"6" = "<Leader>2";
"7" = "<Leader>3";
"8" = "<Leader>4";
}; };
navNext = "<Leader>]"; navNext = "<Leader>h]";
navPrev = "<Leader>["; navPrev = "<Leader>h[";
toggleQuickMenu = "<Leader>hk"; toggleQuickMenu = "<Leader>hk";
}; };
}; };

View file

@ -14,10 +14,7 @@
comment.enable = true; comment.enable = true;
vim-bbye.enable = true; vim-bbye.enable = true;
indent-blankline.enable = true; indent-blankline.enable = true;
which-key = { which-key.enable = true;
enable = true;
settings.delay = 1000;
};
nvim-autopairs.enable = true; nvim-autopairs.enable = true;
yanky = { yanky = {
enable = true; enable = true;
@ -41,47 +38,15 @@
}; };
} }
]; ];
lualine_c = [ lualine_c = [ "diff" ];
"progress"
"filetype"
];
lualine_x = [
"encoding"
"fileformat"
];
lualine_y = [
"diff"
"diagnostics"
];
lualine_z = [ "location" ];
};
options = {
globalstatus = true;
disabled_filetypes = [
"ministarter"
];
section_separators = {
left = "";
right = "";
};
}; };
options.globalstatus = true;
}; };
}; };
crates-nvim.enable = true; crates-nvim.enable = true;
# git stuff # git stuff
gitsigns = { lazygit.enable = true;
enable = true; gitsigns.enable = true;
settings = {
current_line_blame_opts = {
virt_text = true;
virt_text_pos = "eol";
};
};
};
neogit = {
enable = true;
settings.graph_style = "unicode";
};
# Language specific tools # Language specific tools
markdown-preview.enable = true; markdown-preview.enable = true;
ts-autotag.enable = true; ts-autotag.enable = true;