mirror of
https://github.com/youwen5/neovim-flake.git
synced 2024-11-25 03:03:49 -08:00
Compare commits
No commits in common. "0fff5154e69feb5bbb0e634e654eb65feee9c5cf" and "10253909c98a586ffdbe31f5806e96b58da01be1" have entirely different histories.
0fff5154e6
...
10253909c9
6 changed files with 104 additions and 357 deletions
29
README.md
29
README.md
|
@ -1,23 +1,12 @@
|
|||
# viminal
|
||||
# Neovim Configuration Flake
|
||||
|
||||
This is the Neovim configuration for all my NixOS and Nix enabled systems
|
||||
(including macOS). It aims to be minimal and utilitarian; it forgoes many
|
||||
blingful features like sidebars or fancy UI enhancements in favor of native
|
||||
(neo)Vim, while still having everything useful you'd expect, like LSPs, file
|
||||
explorer (`oil.nvim`), completions, advanced language tools, and QoL
|
||||
This is the Neovim configuration for all my NixOS and Nix enabled systems (such
|
||||
as with nix-darwin on macOS). It aims to be minimal and utilitarian; it forgoes
|
||||
many blingful features like sidebars or fancy UI enhancements in favor of
|
||||
native (neo)Vim, while still having everything useful you'd expect, like LSPs,
|
||||
file explorer (`oil.nvim`), completions, advanced language tools, and QoL
|
||||
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
|
||||
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
|
||||
|
@ -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):
|
||||
|
||||
```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
|
||||
|
@ -60,7 +49,7 @@ inputs, and install the package in the usual way:
|
|||
|
||||
inputs = {
|
||||
# -- snip --
|
||||
viminal.url = "github:youwen5/viminal";
|
||||
custom-neovim.url = "github:youwen5/neovim-flake";
|
||||
};
|
||||
# -- snip --
|
||||
};
|
||||
|
@ -74,7 +63,7 @@ inputs, and install the package in the usual way:
|
|||
{inputs, system, ...}:
|
||||
{
|
||||
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
|
||||
];
|
||||
}
|
||||
|
|
|
@ -14,6 +14,18 @@
|
|||
};
|
||||
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>";
|
||||
key = "<Space>wz";
|
||||
|
@ -23,6 +35,60 @@
|
|||
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>";
|
||||
key = "<Leader>ff";
|
||||
|
@ -160,191 +226,12 @@
|
|||
};
|
||||
}
|
||||
{
|
||||
action = ":Neogit<CR>";
|
||||
action = ":LazyGit<CR>";
|
||||
key = "<Leader>gg";
|
||||
options = {
|
||||
silent = true;
|
||||
noremap = true;
|
||||
desc = "Open Neogit";
|
||||
};
|
||||
}
|
||||
{
|
||||
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";
|
||||
desc = "Open LazyGit";
|
||||
};
|
||||
}
|
||||
{
|
||||
|
@ -498,60 +385,14 @@
|
|||
silent = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
action = {
|
||||
__raw = ''
|
||||
function() require('conform').format() end
|
||||
'';
|
||||
};
|
||||
key = "<Leader>cf";
|
||||
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";
|
||||
};
|
||||
}
|
||||
# {
|
||||
# action = "<cmd>lua require'conform'.format({ bufnr = args.bf })<CR>";
|
||||
# key = "<Leader>cf";
|
||||
# options = {
|
||||
# silent = true;
|
||||
# noremap = true;
|
||||
# desc = "Format buffer";
|
||||
# };
|
||||
# }
|
||||
];
|
||||
}
|
||||
|
|
|
@ -39,45 +39,10 @@
|
|||
});
|
||||
# package = pkgs.vimPlugins.conform-nvim;
|
||||
settings = {
|
||||
# format_on_save = {
|
||||
# timeoutMs = 500;
|
||||
# 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
|
||||
'';
|
||||
format_on_save = {
|
||||
timeoutMs = 500;
|
||||
lspFallback = true;
|
||||
};
|
||||
formatters_by_ft = {
|
||||
lua = [ "stylua" ];
|
||||
python = [ "black" ];
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# All the mini.nvim stuff
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
plugins.mini = {
|
||||
enable = true;
|
||||
|
@ -14,14 +13,6 @@
|
|||
trailspace = { };
|
||||
cursorword = { };
|
||||
bracketed = { };
|
||||
starter = { };
|
||||
};
|
||||
package = pkgs.vimPlugins.mini-nvim.overrideAttrs (oldAttrs: {
|
||||
postInstall =
|
||||
(oldAttrs.postInstall or "")
|
||||
+ ''
|
||||
rm $out/doc/mini-git.txt
|
||||
'';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -77,22 +77,18 @@
|
|||
cmdToggleQuickMenu = "<Leader>hm";
|
||||
gotoTerminal = {
|
||||
"1" = "<Leader>ht";
|
||||
"2" = "<Leader>h2";
|
||||
"3" = "<Leader>h3";
|
||||
"4" = "<Leader>h4";
|
||||
"2" = "<Leader>2";
|
||||
"3" = "<Leader>3";
|
||||
"4" = "<Leader>4";
|
||||
};
|
||||
navFile = {
|
||||
"1" = "<C-h>";
|
||||
"2" = "<C-j>";
|
||||
"3" = "<C-k>";
|
||||
"4" = "<C-l>";
|
||||
"5" = "<Leader>1";
|
||||
"6" = "<Leader>2";
|
||||
"7" = "<Leader>3";
|
||||
"8" = "<Leader>4";
|
||||
"1" = "<Leader>ha";
|
||||
"2" = "<Leader>hs";
|
||||
"3" = "<Leader>hd";
|
||||
"4" = "<Leader>hf";
|
||||
};
|
||||
navNext = "<Leader>]";
|
||||
navPrev = "<Leader>[";
|
||||
navNext = "<Leader>h]";
|
||||
navPrev = "<Leader>h[";
|
||||
toggleQuickMenu = "<Leader>hk";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -14,10 +14,7 @@
|
|||
comment.enable = true;
|
||||
vim-bbye.enable = true;
|
||||
indent-blankline.enable = true;
|
||||
which-key = {
|
||||
enable = true;
|
||||
settings.delay = 1000;
|
||||
};
|
||||
which-key.enable = true;
|
||||
nvim-autopairs.enable = true;
|
||||
yanky = {
|
||||
enable = true;
|
||||
|
@ -41,47 +38,15 @@
|
|||
};
|
||||
}
|
||||
];
|
||||
lualine_c = [
|
||||
"progress"
|
||||
"filetype"
|
||||
];
|
||||
lualine_x = [
|
||||
"encoding"
|
||||
"fileformat"
|
||||
];
|
||||
lualine_y = [
|
||||
"diff"
|
||||
"diagnostics"
|
||||
];
|
||||
lualine_z = [ "location" ];
|
||||
};
|
||||
options = {
|
||||
globalstatus = true;
|
||||
disabled_filetypes = [
|
||||
"ministarter"
|
||||
];
|
||||
section_separators = {
|
||||
left = "";
|
||||
right = "";
|
||||
};
|
||||
lualine_c = [ "diff" ];
|
||||
};
|
||||
options.globalstatus = true;
|
||||
};
|
||||
};
|
||||
crates-nvim.enable = true;
|
||||
# git stuff
|
||||
gitsigns = {
|
||||
enable = true;
|
||||
settings = {
|
||||
current_line_blame_opts = {
|
||||
virt_text = true;
|
||||
virt_text_pos = "eol";
|
||||
};
|
||||
};
|
||||
};
|
||||
neogit = {
|
||||
enable = true;
|
||||
settings.graph_style = "unicode";
|
||||
};
|
||||
lazygit.enable = true;
|
||||
gitsigns.enable = true;
|
||||
# Language specific tools
|
||||
markdown-preview.enable = true;
|
||||
ts-autotag.enable = true;
|
||||
|
|
Loading…
Reference in a new issue