Skip to content

Commit ebf86c4

Browse files
committed
chore: Update toggleterm.nix configuration
This commit updates the toggleterm.nix configuration file. Changes include: - Setting the direction to "float" for the toggleterm plugin - Adding float options with a rounded border - Adjusting the shading factor to 2 - Changing the size to 10 - Updating the highlights for various elements - Modifying the on_create Lua callback function These changes enhance the functionality and appearance of the toggleterm plugin.
1 parent 9f1333a commit ebf86c4

File tree

2 files changed

+100
-17
lines changed

2 files changed

+100
-17
lines changed

config/plugins/utils/toggleterm.nix

+86-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
1+
# TODO: Error executing Lua callback: /nix/store/wx63jbhbmsccs6ksh8x5fqgza6lmn1vv-init.lua:251: attempt to call global 'rndname' (a nil value)
2+
# homepage: https://github.com/akinsho/toggleterm.nvim
3+
# nixvim doc: https://nix-community.github.io/nixvim/plugins/toggleterm/index.html
4+
15
_: {
26
plugins.toggleterm = {
37
enable = true;
48
settings = {
5-
size = 20;
9+
direction = "float";
10+
float_opts = {
11+
border = "rounded";
12+
};
13+
shadding_factor = 2;
14+
size = 10;
15+
16+
highlights = {
17+
Normal.link = "Normal";
18+
NormalNC.link = "NormalNC";
19+
NormalFloat.link = "NormalFloat";
20+
FloatBorder.link = "FloatBorder";
21+
StatusLine.link = "StatusLine";
22+
StatusLineNC.link = "StatusLineNC";
23+
WinBar.link = "WinBar";
24+
WinBarNC.link = "WinBarNC";
25+
};
26+
27+
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/toggleterm.lua#L66-L74
28+
on_create = ''
29+
function(t)
30+
vim.opt_local.foldcolumn = "0"
31+
vim.opt_local.signcolumn = "no"
32+
if t.hidden then
33+
vim.keymap.set({ "n", "t", "i" }, "<F7>", function() t:toggle() end, { desc = "Toggle terminal", buffer = t.bufnr })
34+
end
35+
local term_name = rndname()
36+
vim.cmd(t.id .. "ToggleTermSetName " .. term_name)
37+
end
38+
'';
639
};
740
};
841
keymaps = [
9-
{
10-
mode = "n";
11-
key = "<leader>t";
12-
action = "<cmd>ToggleTerm<cr>";
13-
options = {
14-
desc = "Toggle Terminal Window";
15-
};
16-
}
42+
# {
43+
# mode = "n";
44+
# key = "<leader>t";
45+
# action = "<cmd>ToggleTerm<cr>";
46+
# options = {
47+
# desc = "Toggle Terminal Window";
48+
# };
49+
# }
1750
{
1851
mode = "n";
1952
key = "<leader>tv";
@@ -38,5 +71,49 @@ _: {
3871
desc = "Toggle Floating Terminal Window";
3972
};
4073
}
74+
{
75+
mode = "n";
76+
key = "<F7>";
77+
action = "<Cmd>execute v:count . 'ToggleTerm'<CR>";
78+
options.desc = "Toggle terminal";
79+
}
80+
{
81+
mode = "t";
82+
key = "<F7>";
83+
action = "<Cmd>ToggleTerm<CR>";
84+
options.desc = "Toggle terminal";
85+
}
86+
{
87+
mode = "i";
88+
key = "<F7>";
89+
action = "<Esc><Cmd>ToggleTerm<CR>";
90+
options.desc = "Toggle terminal";
91+
}
92+
{
93+
mode = "t";
94+
key = "<Esc><Esc>";
95+
action = "<C-\\><C-n>";
96+
options.desc = "Switch to normal mode";
97+
}
98+
{
99+
mode = [ "n" "t" ];
100+
key = "<Leader>tn";
101+
action.__raw = ''
102+
function()
103+
local curterm = require("toggleterm.terminal").get_focused_id()
104+
105+
if curterm ~= nil then
106+
vim.cmd(curterm .. "ToggleTermSetName")
107+
end
108+
end
109+
'';
110+
options.desc = "Rename current terminal";
111+
}
112+
{
113+
mode = [ "n" "t" ];
114+
key = "<Leader>tl";
115+
action = "<cmd>TermSelect<cr>";
116+
options.desc = "List terminals";
117+
}
41118
];
42119
}

config/plugins/utils/whichkey.nix

+14-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ _: {
33
enable = true;
44

55
settings = {
6+
67
spec = [
78
{
89
__unkeyed = "<leader>b";
@@ -34,13 +35,19 @@ _: {
3435
}
3536
];
3637

38+
disable.ft = [
39+
"TelescopePrompt"
40+
"neo-tree"
41+
"neo-tree-popup"
42+
];
43+
3744
replace = {
38-
# key = [
39-
# [
40-
# "<Space>"
41-
# "SPC"
42-
# ]
43-
# ];
45+
key = [
46+
[
47+
"<Space>"
48+
"SPC"
49+
]
50+
];
4451

4552
desc = [
4653
[
@@ -65,11 +72,10 @@ _: {
6572
]
6673
];
6774
};
75+
6876
win = {
6977
border = "single";
7078
};
71-
72-
# preset = "helix";
7379
};
7480
};
7581
}

0 commit comments

Comments
 (0)