Skip to content

Commit 59a2948

Browse files
committed
update nvim config
1 parent 2ac1030 commit 59a2948

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

config/stow/nvim/.config/nvim/lua/config/keymaps.lua

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ local open_in_editor = require("utils.open_in_editor").open_in_editor
1313
local open_in_editor = require("utils.open_in_editor").open_in_editor
1414
local js_console_log = require("utils.js_console_log").js_console_log
1515

16+
-- -- Navigation
17+
-- vim.keymap.set("n", "<C-h>", "<leader>wh", { desc = "window right", remap = true })
18+
-- vim.keymap.set("n", "<C-l>", "<leader>wl", { desc = "window left", remap = true })
19+
1620
-- Clear whole page
1721
vim.keymap.set("n", "<leader>poc", "ggVGd", { desc = "Clear whole page", remap = true })
1822

@@ -52,6 +56,7 @@ end, { desc = "Next todo comment" })
5256
vim.keymap.set("n", "[t", function()
5357
require("todo-comments").jump_prev()
5458
end, { desc = "Previous todo comment" })
59+
5560
-- You can also specify a list of valid jump keywords
5661
vim.keymap.set("n", "]t", function()
5762
require("todo-comments").jump_next({ keywords = { "ERROR", "WARNING" } })
@@ -64,6 +69,26 @@ vim.keymap.set("n", "gR", "<CMD>Glance references<CR>")
6469
vim.keymap.set("n", "gY", "<CMD>Glance type_definitions<CR>")
6570
vim.keymap.set("n", "gM", "<CMD>Glance implementations<CR>")
6671

72+
-- Select all
73+
vim.keymap.set("n", "<M-a>", "ggVG")
74+
75+
-- Save
76+
vim.keymap.set("n", "<M-s>", "<CMD>write<CR>", { silent = true })
77+
vim.keymap.set("i", "<M-s>", "<CMD>write<CR>", { silent = true })
78+
79+
-- Quit
80+
vim.keymap.set("n", "<M-q>", "<CMD>quit<CR>", { silent = true })
81+
vim.keymap.set("n", "<M-Q>", "<CMD>Quit<CR>", { silent = true })
82+
83+
-- Reload file
84+
vim.keymap.set("n", "<M-r>", "<CMD>e!<CR>", {
85+
desc = "Reload file from disk",
86+
remap = true,
87+
})
88+
89+
-- Case (toggle)
90+
vim.keymap.set("i", "<leader>pcc", "~", { desc = "Toggle case" })
91+
6792
-- Open in Vscode
6893
vim.keymap.set("n", "<leader>ov", function()
6994
open_in_editor("code")
@@ -82,3 +107,71 @@ end, { desc = "Open in Kiro at line" })
82107
-- Logger
83108
-- TODO: find a better logging solution similar to turbo console_log
84109
vim.keymap.set("n", "<leader>pcl", js_console_log, { desc = "[C]onsole [L]og variable" })
110+
111+
local Snacks = require("snacks")
112+
113+
-- Toggle snacks ignored and hidden
114+
vim.keymap.set("n", "<leader>ti", function()
115+
local currentI = Snacks.config.picker.ignored
116+
local currentH = Snacks.config.picker.hidden
117+
118+
Snacks.config.picker.ignored = not currentI
119+
Snacks.config.picker.hidden = not currentH
120+
121+
msg = Snacks.config.picker.ignored and "Snacks: ignored ON" or "Snacks: ignored OFF"
122+
Snacks.notify(msg)
123+
end, { desc = "Toggle Snacks ignored files" })
124+
125+
-- Navigation
126+
-- local function ctx_move(direction)
127+
-- Snacks.notify("calling ctx_move")
128+
--
129+
-- local success = pcall(vim.cmd, "wincmd " .. direction)
130+
--
131+
-- local msg = success and "Success" or "Failed"
132+
-- -- Snacks.notify(msg)
133+
--
134+
-- Snacks.notify("success: " .. tostring(success), { title = "Success" })
135+
--
136+
-- if not success then
137+
-- Snacks.notify("wincmd failed calling tmux select-")
138+
-- vim.fn.system("tmux select-pane " .. ({
139+
-- h = "-L",
140+
-- j = "-D",
141+
-- k = "-U",
142+
-- l = "-R",
143+
-- })[direction])
144+
-- end
145+
-- end
146+
147+
local tmux_dirs = {
148+
h = "-L",
149+
j = "-D",
150+
k = "-U",
151+
l = "-R",
152+
}
153+
154+
local function ctx_move(dir)
155+
local before = vim.api.nvim_get_current_win()
156+
157+
vim.cmd("wincmd " .. dir)
158+
159+
local after = vim.api.nvim_get_current_win()
160+
161+
if before == after then
162+
vim.fn.system({ "tmux", "select-pane", tmux_dirs[dir] })
163+
end
164+
end
165+
166+
vim.keymap.set("n", "<C-h>", function()
167+
ctx_move("h")
168+
end)
169+
vim.keymap.set("n", "<C-j>", function()
170+
ctx_move("j")
171+
end)
172+
vim.keymap.set("n", "<C-k>", function()
173+
ctx_move("k")
174+
end)
175+
vim.keymap.set("n", "<C-l>", function()
176+
ctx_move("l")
177+
end)

config/stow/nvim/.config/nvim/lua/config/options.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ vim.diagnostic.enable(false)
99

1010
-- Show all content - notably in markdown
1111
vim.opt.conceallevel = 0
12+
13+
-- Reload files on save
14+
vim.opt.autoread = true

0 commit comments

Comments
 (0)