Skip to content

Commit d65f3c2

Browse files
committed
refactor: customize nixvim
1 parent d5e3372 commit d65f3c2

File tree

11 files changed

+254
-4
lines changed

11 files changed

+254
-4
lines changed

home-manager/common/default.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{ pkgs, ... }:
22
{
3+
imports = [ ./nixvim ];
4+
35
home.packages = with pkgs; [
46
fd
57
fnm
@@ -73,9 +75,6 @@
7375
programs.gpg.enable = true;
7476
programs.lazygit.enable = true;
7577
programs.lsd.enable = true;
76-
programs.nixvim = {
77-
enable = true;
78-
};
7978
programs.password-store = {
8079
enable = true;
8180
settings = {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
programs.nixvim = {
3+
colorschemes = {
4+
base16 = {
5+
enable = true;
6+
colorscheme = "dracula";
7+
};
8+
};
9+
};
10+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
programs.nixvim = {
3+
plugins.bufferline.enable = true;
4+
keymaps = [
5+
{
6+
key = "<leader>bo";
7+
action = "<Cmd>BufferLineCloseOthers<CR>";
8+
}
9+
{
10+
key = "[B";
11+
action = "<cmd>BufferLineMovePrev<cr>";
12+
}
13+
{
14+
key = "[b";
15+
action = "<cmd>BufferLineCyclePrev<cr>";
16+
}
17+
{
18+
key = "]B";
19+
action = "<cmd>BufferLineMoveNext<cr>";
20+
}
21+
{
22+
key = "]b";
23+
action = "<cmd>BufferLineCycleNext<cr>";
24+
}
25+
];
26+
plugins.which-key = {
27+
registrations = {
28+
"<leader>bo" = "Delete Other Buffers";
29+
"[B" = "Move buffer prev";
30+
"[b" = "Prev Buffer";
31+
"]B" = "Move buffer next";
32+
"]b" = "Next Buffer";
33+
};
34+
};
35+
};
36+
}

home-manager/common/nixvim/cmp.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
programs.nixvim = {
3+
plugins.cmp = {
4+
enable = true;
5+
settings = {
6+
autoEnableSources = true;
7+
sources = [
8+
{ name = "nvim_lsp"; }
9+
{ name = "path"; }
10+
{ name = "buffer"; }
11+
{
12+
name = "luasnip";
13+
keywordLength = 3;
14+
}
15+
];
16+
};
17+
};
18+
};
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
imports = [
3+
./appearance.nix
4+
./bufferline.nix
5+
./cmp.nix
6+
./keymaps.nix
7+
./lsp.nix
8+
./neo-tree.nix
9+
./plugins.nix
10+
./telescope.nix
11+
];
12+
programs.nixvim = {
13+
enable = true;
14+
globals.mapleader = " ";
15+
opts = {
16+
# highlight current line
17+
cursorline = true;
18+
# line numbers
19+
number = true;
20+
relativenumber = true;
21+
# search
22+
ignorecase = true;
23+
smartcase = true;
24+
ruler = true; # show line and column when search
25+
# tabs
26+
tabstop = 2;
27+
shiftwidth = 2;
28+
expandtab = true;
29+
smarttab = true;
30+
# always show the signcolumn, otherwise text would be shifted when displaying error icons
31+
# https://github.com/Ahwxorg/nixvim-config/blob/d90d75bd7c69637e08cbd3969ec0373d6db7ffdc/config/options.nix
32+
signcolumn = "yes";
33+
};
34+
};
35+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
programs.nixvim = {
3+
keymaps = [
4+
{
5+
key = "<C-s>";
6+
action = "<cmd>w<cr><esc>";
7+
mode = [
8+
"i"
9+
"n"
10+
"s"
11+
"x"
12+
];
13+
options = {
14+
silent = true;
15+
};
16+
}
17+
{
18+
key = "<leader>bd";
19+
action = "<cmd>bd<cr>";
20+
}
21+
{
22+
key = "<leader>qq";
23+
action = "<cmd>qa<cr>";
24+
mode = [ "n" ];
25+
options = {
26+
silent = true;
27+
};
28+
}
29+
];
30+
plugins.which-key = {
31+
registrations = {
32+
"<C-s>" = "Save file";
33+
"<leader>bd" = "Delete buffer";
34+
"<leader>qq" = "Quit all";
35+
};
36+
};
37+
};
38+
}

home-manager/common/nixvim/lsp.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ pkgs, ... }:
2+
{
3+
programs.nixvim = {
4+
plugins.lsp = {
5+
enable = true;
6+
servers = {
7+
nil-ls.enable = true;
8+
rust-analyzer = {
9+
enable = true;
10+
installCargo = false;
11+
installRustc = false;
12+
};
13+
tsserver.enable = true;
14+
volar.enable = true;
15+
};
16+
};
17+
plugins.lsp-format = {
18+
enable = true;
19+
};
20+
plugins.none-ls = {
21+
enable = true;
22+
sources.formatting = {
23+
nixfmt = {
24+
enable = true;
25+
package = pkgs.nixfmt-rfc-style;
26+
};
27+
};
28+
};
29+
};
30+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
programs.nixvim = {
3+
plugins.neo-tree = {
4+
enable = true;
5+
closeIfLastWindow = true;
6+
};
7+
keymaps = [
8+
{
9+
key = "<leader>e";
10+
action = "<cmd>Neotree toggle<cr>";
11+
options = {
12+
remap = true;
13+
};
14+
}
15+
];
16+
plugins.which-key = {
17+
registrations = {
18+
"<leader>e" = "Explorer NeoTree (Root Dir)";
19+
};
20+
};
21+
};
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
programs.nixvim = {
3+
plugins = {
4+
lualine.enable = true; # bottom status line
5+
6+
cursorline.enable = true;
7+
fidget.enable = true;
8+
gitsigns.enable = true;
9+
nix.enable = true;
10+
which-key.enable = true;
11+
};
12+
};
13+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
programs.nixvim = {
3+
plugins.telescope = {
4+
enable = true;
5+
extensions = {
6+
fzf-native = {
7+
enable = true;
8+
};
9+
};
10+
};
11+
keymaps = [
12+
{
13+
key = "<leader>fb";
14+
action = "<cmd>Telescope buffers<CR>";
15+
options = {
16+
silent = true;
17+
};
18+
}
19+
20+
{
21+
key = "<leader>ff";
22+
action = "<cmd>Telescope find_files<CR>";
23+
options = {
24+
silent = true;
25+
};
26+
}
27+
{
28+
key = "<leader>fg";
29+
action = "<cmd>Telescope live_grep<CR>";
30+
options = {
31+
silent = true;
32+
};
33+
}
34+
];
35+
plugins.which-key = {
36+
registrations = {
37+
"<leader>fb" = "Buffers";
38+
"<leader>ff" = "Find files with telescope";
39+
"<leader>fg" = "Live grep";
40+
};
41+
};
42+
};
43+
}

home-manager/linux/default.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# This is your home-manager configuration file
22
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
3-
{ inputs, outputs, pkgs, ... }:
3+
{
4+
inputs,
5+
outputs,
6+
pkgs,
7+
...
8+
}:
49
{
510
# You can import other home-manager modules here
611
imports = [

0 commit comments

Comments
 (0)