Skip to content

Commit f2b57ef

Browse files
committed
update nvim config
1 parent 9b54859 commit f2b57ef

File tree

22 files changed

+583
-568
lines changed

22 files changed

+583
-568
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
{flake, ...}: {
1+
{
2+
flake,
3+
inputs,
4+
...
5+
}: {
26
imports = [
37
flake.homeModules.common
48
flake.homeModules.class-server
9+
inputs.agenix.homeManagerModules.default
510
];
611
}

hosts/lusus/users/danieln/home-configuration.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
flake.homeModules.common
88
flake.homeModules.class-laptop
99
inputs.gridx.home-module
10+
inputs.agenix.homeManagerModules.default
1011
];
1112
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
{flake, ...}: {
1+
{
2+
flake,
3+
inputs,
4+
...
5+
}: {
26
imports = [
37
flake.homeModules.common
48
flake.homeModules.class-laptop
9+
inputs.agenix.homeManagerModules.default
510
];
611
}

modules/home/class-laptop/kitty.nix

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
'';
107107
keybindings = {
108108
# os windows
109-
"alt+n" = "launch --type=os-window --cwd=current";
110-
"alt+r" = "set_window_title";
109+
"ctrl+shift+n" = "launch --type=os-window --cwd=current";
110+
"ctrl+shift+r" = "set_window_title";
111111

112112
# clipboard
113113
"ctrl+shift+c" = "copy_to_clipboard";
@@ -116,30 +116,30 @@
116116
# scrolling
117117
"shift+page_up" = "scroll_page_up";
118118
"shift+page_down" = "scroll_page_down";
119-
"alt+page_up" = "scroll_to_prompt -1";
120-
"alt+page_down" = "scroll_to_prompt +1";
119+
"ctrl+shift+page_up" = "scroll_to_prompt -1";
120+
"ctrl+shift+page_down" = "scroll_to_prompt +1";
121121

122122
# font size
123-
"alt+plus" = "change_font_size current +2.0";
124-
"alt+equal" = "change_font_size current +2.0";
125-
"alt+minus" = "change_font_size current -2.0";
126-
"alt+0" = "change_font_size current 0";
123+
"ctrl+shift+plus" = "change_font_size current +2.0";
124+
"ctrl+shift+equal" = "change_font_size current 0";
125+
"ctrl+shift+minus" = "change_font_size current -2.0";
126+
"ctrl+shift+0" = "change_font_size current 0";
127127

128128
# dump output to vim
129-
"alt+h" = "show_scrollback";
129+
"ctrl+shift+h" = "show_scrollback";
130130

131131
# paste things
132-
"alt+g" = "kitten hints --hints-text-color=red --type hash --program -";
133-
"alt+w" = "kitten hints --hints-text-color=red --type word --program -";
134-
"alt+f" = "kitten hints --hints-text-color=red --type path --program -";
132+
"ctrl+shift+g" = "kitten hints --alphabet=arstgmneiowfpluyxcdh,.bjvkqz --hints-text-color=red --type hash --program -";
133+
"ctrl+shift+w" = "kitten hints --alphabet=arstgmneiowfpluyxcdh,.bjvkqz --hints-text-color=red --type word --program -";
134+
"ctrl+shift+f" = "kitten hints --alphabet=arstgmneiowfpluyxcdh,.bjvkqz --hints-text-color=red --type path --program -";
135135

136136
# urls
137-
"alt+e" = "kitten hints --hints-text-color=red --type url --program default";
138-
"alt+u" = "kitten hints --hints-text-color=red --type url --program default";
137+
"ctrl+shift+e" = "kitten hints --alphabet=arstgmneiowfpluyxcdh,.bjvkqz --hints-text-color=red --type url --program default";
138+
"ctrl+shift+u" = "kitten hints --alphabet=arstgmneiowfpluyxcdh,.bjvkqz --hints-text-color=red --type url --program default";
139139

140140
# markers
141-
"alt+m" = "create_marker";
142-
"alt+shift+m" = "remove_marker";
141+
"ctrl+shift+m" = "create_marker";
142+
"ctrl+shift+shift+m" = "remove_marker";
143143
};
144144
};
145145
}

modules/home/common/cloud.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
{pkgs, ...}: {
1+
{
2+
pkgs,
3+
config,
4+
...
5+
}: {
26
home.packages = with pkgs; [
37
awscli2
48
gmailctl
59
ssm-session-manager-plugin
610
yt-dlp
711
];
812

13+
age.secrets.gh-token.file = ../../../secrets/gh-token.age;
14+
915
programs = {
1016
rbw.enable = true;
11-
tmate.enable = true;
12-
granted.enable = true;
1317
gh = {
1418
enable = true;
19+
package = let
20+
gh-wrapped = pkgs.writeShellScriptBin "gh" ''
21+
export GITHUB_TOKEN="$(cat ${config.age.secrets.gh-token.path})"
22+
${pkgs.gh}/bin/gh "''${@}"
23+
'';
24+
in
25+
gh-wrapped;
1526
settings = {
1627
version = 1;
1728
git_protocol = "ssh";

modules/home/common/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
./starship.nix
1818
];
1919

20+
age.identityPaths = ["/home/danieln/.ssh/agenix"];
21+
2022
home = {
2123
username = "danieln";
2224
homeDirectory = "/home/danieln";

modules/home/common/fish.nix

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
'';
4444
shellAbbrs = {
4545
g = "git";
46-
v = "vim";
46+
h = "history --show-time='%F %T ' search";
47+
e = "vim";
4748
d = "dlv --headless -l 'localhost:2345' debug";
4849
};
4950
functions = {
@@ -86,6 +87,30 @@
8687
commandline -f repaint'
8788
'';
8889
};
90+
down-or-search = {
91+
body = ''
92+
if commandline --search-mode
93+
commandline -f history-search-forward
94+
return
95+
end
96+
97+
if commandline --paging-mode
98+
commandline -f down-line
99+
return
100+
end
101+
102+
set -l lineno (commandline -L)
103+
set -l line_count (count (commandline))
104+
105+
switch $lineno
106+
case $line_count
107+
commandline -f history-search-forward or complete
108+
109+
case \'*\'
110+
commandline -f down-line
111+
end
112+
'';
113+
};
89114
};
90115
shellAliases = {
91116
ag = "rg";
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
;; extends
22

3-
; standalone variadic parameter
4-
(parameter_list
5-
("," @_start
6-
.)?
7-
(variadic_parameter_declaration) @parameter.inner
8-
(#make-range! "parameter.outer" @_start @parameter.inner))
3+
; ; standalone variadic parameter
4+
; (parameter_list
5+
; ("," @_start
6+
; .)?
7+
; (variadic_parameter_declaration) @parameter.inner
8+
; (#make-range! "parameter.outer" @_start @parameter.inner))
99

1010
(function_declaration (identifier) @function.name)
1111
(method_declaration (field_identifier) @function.name)
@@ -15,3 +15,9 @@
1515
.
1616
(method_declaration) @def
1717
) @function.all
18+
19+
(
20+
((comment)*) @doc
21+
.
22+
(function_declaration) @def
23+
) @function.all

modules/home/common/nvim/default.nix

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@
1616
MANPAGER = "nvim +Man!";
1717
};
1818

19-
xdg.configFile = let
20-
treesitterParsers = pkgs.symlinkJoin {
21-
name = "treesitter-parsers";
22-
paths = pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
23-
# paths = builtins.filter
24-
# (x: (builtins.parseDrvName x.name).name != "vimplugin-treesitter-grammar-javascript")
25-
# pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
26-
};
27-
in {
19+
xdg.configFile = {
2820
# "nvim/init.lua".source = ./init.lua;
2921
# "nvim/lua".source = ./lua;
3022
# "nvim/ftplugin".source = ./ftplugin;
@@ -34,16 +26,13 @@
3426
"nvim/lua".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/modules/home/common/nvim/lua";
3527
"nvim/ftplugin".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/modules/home/common/nvim/ftplugin";
3628
"nvim/after".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/modules/home/common/nvim/after";
37-
38-
"nvim/parser".source = "${treesitterParsers}/parser"; # treesitter master only
3929
};
4030

4131
xdg.dataFile = let
4232
vimPlugins = builtins.listToAttrs (
4333
lib.lists.forEach [
4434
"blink-cmp"
4535
"conform-nvim"
46-
"diffview-nvim"
4736
"friendly-snippets"
4837
"kanagawa-nvim"
4938
"lazy-nvim"
@@ -53,14 +42,6 @@
5342
"nvim-dap"
5443
# "nvim-dap-view" # not in nixpkgs
5544
"nvim-lint"
56-
"nvim-treesitter" # uses master
57-
"nvim-treesitter-context"
58-
"nvim-treesitter-textobjects" # uses master
59-
"quicker-nvim"
60-
"snacks-nvim"
61-
# "amp-nvim"
62-
"copilot-lua"
63-
"claudecode-nvim"
6445
]
6546
(
6647
name: {
@@ -104,35 +85,38 @@
10485
}
10586
)
10687
);
88+
treesitterParsers = pkgs.symlinkJoin {
89+
name = "treesitter-parsers";
90+
paths = pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
91+
# paths = builtins.filter
92+
# (x: (builtins.parseDrvName x.name).name != "vimplugin-treesitter-grammar-javascript")
93+
# pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
94+
};
95+
treesitter = pkgs.fetchFromGitHub {
96+
owner = "nvim-treesitter";
97+
repo = "nvim-treesitter";
98+
rev = "main";
99+
sha256 = "sha256-kPB4KyhE0+mNfanTIzc4O+4wvw/u8lyHTHoQ368KWXI=";
100+
};
107101
in
108102
{
109-
"nvim/nixpkgs/fzf" = {
110-
source = "${pkgs.fzf}/share/vim-plugins/fzf";
111-
};
112-
113103
# treesitter main parsers:
114-
# "nvim/site/queries" = {
115-
# source = "${pkgs.vimPlugins.nvim-treesitter.withAllGrammars}/queries";
116-
# };
117-
# "nvim/site/parser".source = "${treesitterParsers}/parser";
104+
"nvim/site/queries" = {
105+
source = "${treesitter}/runtime/queries";
106+
};
107+
"nvim/site/parser".source = "${treesitterParsers}/parser";
118108

119-
# for switching to treesitter main:
120-
# "nvim/nixpkgs/nvim-treesitter-textobjects" = {
121-
# source = pkgs.fetchFromGitHub {
122-
# owner = "nvim-treesitter";
123-
# repo = "nvim-treesitter-textobjects";
124-
# rev = "main";
125-
# sha256 = "sha256-sJdKVaGNXW4HEi6NXEqUhelr8T7/M216m7bPKHAd1do=";
126-
# };
127-
# };
128-
# "nvim/nixpkgs/nvim-treesitter" = {
129-
# source = pkgs.fetchFromGitHub {
130-
# owner = "nvim-treesitter";
131-
# repo = "nvim-treesitter";
132-
# rev = "main";
133-
# sha256 = "sha256-m3ShsTug4wSee89K+GaTKodC1cWsskR35y9SjDtVRgU=";
134-
# };
135-
# };
109+
"nvim/nixpkgs/nvim-treesitter-textobjects" = {
110+
source = pkgs.fetchFromGitHub {
111+
owner = "nvim-treesitter";
112+
repo = "nvim-treesitter-textobjects";
113+
rev = "main";
114+
sha256 = "sha256-jjKT3bZHwZIVDsTw4m7cJm9G2JW8lUXasKTaiGzT0Ag=";
115+
};
116+
};
117+
"nvim/nixpkgs/nvim-treesitter" = {
118+
source = treesitter;
119+
};
136120
}
137121
// vimPlugins // miniPlugins;
138122
}

modules/home/common/nvim/lua/aucmd.lua

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
4343
pattern = "*",
4444
callback = function()
4545
vim.cmd("clearjumps")
46+
if vim.fn.argc() > 1 then
47+
vim.cmd.blast()
48+
vim.cmd.bfirst()
49+
end
4650
end,
4751
})
4852

@@ -104,34 +108,34 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
104108
vim.api.nvim_create_autocmd({ "BufRead" }, {
105109
group = vim.api.nvim_create_augroup("add_autocmd_on_buf_enter", { clear = true }),
106110
pattern = { "*" },
107-
callback = function(_)
111+
callback = function(openEvent)
108112
if vim.o.filetype == "gitcommit" then
109113
vim.cmd.normal("1G0") -- discard any position there might be on file
110114
return -- skip the usual things
111115
end
112116
-- mark as persisted
113117
vim.api.nvim_create_autocmd({ "InsertEnter", "BufModifiedSet" }, {
114-
buffer = 0,
115-
once = true,
116-
callback = function(_)
117-
vim.fn.setbufvar(0, "bufpersist", 1)
118-
end,
119-
})
120-
-- go to last loc when focusing a buffer the first time
121-
vim.api.nvim_create_autocmd("BufWinEnter", {
122-
buffer = 0,
118+
buffer = openEvent.buf,
123119
once = true,
124-
callback = function(_)
125-
local mark = vim.api.nvim_buf_get_mark(0, '"')
126-
local lcount = vim.api.nvim_buf_line_count(0)
127-
if mark[1] > 0 and mark[1] < lcount then
128-
pcall(vim.api.nvim_win_set_cursor, 0, mark)
129-
end
120+
callback = function(event)
121+
vim.fn.setbufvar(event.buf, "bufpersist", 1)
130122
end,
131123
})
132124
end,
133125
})
134126

127+
-- go to last loc when focusing a buffer the first time
128+
vim.api.nvim_create_autocmd("BufReadPost", {
129+
group = vim.api.nvim_create_augroup("restore_position", { clear = true }),
130+
callback = function(event)
131+
local mark = vim.api.nvim_buf_get_mark(event.buf, '"')
132+
local lcount = vim.api.nvim_buf_line_count(event.buf)
133+
if mark[1] > 0 and mark[1] < lcount then
134+
pcall(vim.api.nvim_win_set_cursor, 0, mark)
135+
end
136+
end,
137+
})
138+
135139
-- terminals
136140
vim.api.nvim_create_autocmd("TermOpen", {
137141
group = vim.api.nvim_create_augroup("on_term_open", { clear = true }),

0 commit comments

Comments
 (0)