mirror of
https://github.com/youwen5/neovim-flake.git
synced 2024-11-28 12:13:51 -08:00
Compare commits
15 commits
10253909c9
...
0fff5154e6
Author | SHA1 | Date | |
---|---|---|---|
0fff5154e6 | |||
62b25e1c4b | |||
309bc9a1eb | |||
f297d5116e | |||
859e91ada2 | |||
8a9c7c25a7 | |||
e7125bd862 | |||
9aea792f09 | |||
721d145307 | |||
eab8fed9d1 | |||
21a2247842 | |||
fbc52d72d7 | |||
8a6de619e6 | |||
115b7d6b98 | |||
b00ce44c64 |
6 changed files with 357 additions and 104 deletions
29
README.md
29
README.md
|
@ -1,12 +1,23 @@
|
|||
# Neovim Configuration Flake
|
||||
# viminal
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -36,7 +47,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/neovim-flake' --extra-experimental-features flakes --extra-experimental-features nix-command
|
||||
nix run 'github:youwen5/viminal' --extra-experimental-features flakes --extra-experimental-features nix-command
|
||||
```
|
||||
|
||||
If for some reason, you want to install it permanently, add it to your flake
|
||||
|
@ -49,7 +60,7 @@ inputs, and install the package in the usual way:
|
|||
|
||||
inputs = {
|
||||
# -- snip --
|
||||
custom-neovim.url = "github:youwen5/neovim-flake";
|
||||
viminal.url = "github:youwen5/viminal";
|
||||
};
|
||||
# -- snip --
|
||||
};
|
||||
|
@ -63,7 +74,7 @@ inputs, and install the package in the usual way:
|
|||
{inputs, system, ...}:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
inputs.custom-neovim.packages.${system}.default
|
||||
inputs.viminal.packages.${system}.default
|
||||
# supported systems: x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin
|
||||
];
|
||||
}
|
||||
|
|
|
@ -14,18 +14,6 @@
|
|||
};
|
||||
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";
|
||||
|
@ -35,60 +23,6 @@
|
|||
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";
|
||||
|
@ -226,12 +160,191 @@
|
|||
};
|
||||
}
|
||||
{
|
||||
action = ":LazyGit<CR>";
|
||||
action = ":Neogit<CR>";
|
||||
key = "<Leader>gg";
|
||||
options = {
|
||||
silent = true;
|
||||
noremap = true;
|
||||
desc = "Open LazyGit";
|
||||
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";
|
||||
};
|
||||
}
|
||||
{
|
||||
|
@ -385,14 +498,60 @@
|
|||
silent = true;
|
||||
};
|
||||
}
|
||||
# {
|
||||
# action = "<cmd>lua require'conform'.format({ bufnr = args.bf })<CR>";
|
||||
# key = "<Leader>cf";
|
||||
# options = {
|
||||
# silent = true;
|
||||
# noremap = true;
|
||||
# desc = "Format buffer";
|
||||
# };
|
||||
# }
|
||||
{
|
||||
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";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
|
@ -39,10 +39,45 @@
|
|||
});
|
||||
# package = pkgs.vimPlugins.conform-nvim;
|
||||
settings = {
|
||||
format_on_save = {
|
||||
timeoutMs = 500;
|
||||
lspFallback = true;
|
||||
};
|
||||
# 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
|
||||
'';
|
||||
formatters_by_ft = {
|
||||
lua = [ "stylua" ];
|
||||
python = [ "black" ];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# All the mini.nvim stuff
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
plugins.mini = {
|
||||
enable = true;
|
||||
|
@ -13,6 +14,14 @@
|
|||
trailspace = { };
|
||||
cursorword = { };
|
||||
bracketed = { };
|
||||
starter = { };
|
||||
};
|
||||
package = pkgs.vimPlugins.mini-nvim.overrideAttrs (oldAttrs: {
|
||||
postInstall =
|
||||
(oldAttrs.postInstall or "")
|
||||
+ ''
|
||||
rm $out/doc/mini-git.txt
|
||||
'';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -77,18 +77,22 @@
|
|||
cmdToggleQuickMenu = "<Leader>hm";
|
||||
gotoTerminal = {
|
||||
"1" = "<Leader>ht";
|
||||
"2" = "<Leader>2";
|
||||
"3" = "<Leader>3";
|
||||
"4" = "<Leader>4";
|
||||
"2" = "<Leader>h2";
|
||||
"3" = "<Leader>h3";
|
||||
"4" = "<Leader>h4";
|
||||
};
|
||||
navFile = {
|
||||
"1" = "<Leader>ha";
|
||||
"2" = "<Leader>hs";
|
||||
"3" = "<Leader>hd";
|
||||
"4" = "<Leader>hf";
|
||||
"1" = "<C-h>";
|
||||
"2" = "<C-j>";
|
||||
"3" = "<C-k>";
|
||||
"4" = "<C-l>";
|
||||
"5" = "<Leader>1";
|
||||
"6" = "<Leader>2";
|
||||
"7" = "<Leader>3";
|
||||
"8" = "<Leader>4";
|
||||
};
|
||||
navNext = "<Leader>h]";
|
||||
navPrev = "<Leader>h[";
|
||||
navNext = "<Leader>]";
|
||||
navPrev = "<Leader>[";
|
||||
toggleQuickMenu = "<Leader>hk";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
comment.enable = true;
|
||||
vim-bbye.enable = true;
|
||||
indent-blankline.enable = true;
|
||||
which-key.enable = true;
|
||||
which-key = {
|
||||
enable = true;
|
||||
settings.delay = 1000;
|
||||
};
|
||||
nvim-autopairs.enable = true;
|
||||
yanky = {
|
||||
enable = true;
|
||||
|
@ -38,15 +41,47 @@
|
|||
};
|
||||
}
|
||||
];
|
||||
lualine_c = [ "diff" ];
|
||||
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 = "";
|
||||
};
|
||||
};
|
||||
options.globalstatus = true;
|
||||
};
|
||||
};
|
||||
crates-nvim.enable = true;
|
||||
# git stuff
|
||||
lazygit.enable = true;
|
||||
gitsigns.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
|
||||
markdown-preview.enable = true;
|
||||
ts-autotag.enable = true;
|
||||
|
|
Loading…
Reference in a new issue