Skip to content

Commit 6370a97

Browse files
Update remaps.lua
1 parent 7d32f65 commit 6370a97

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

OS/Linux/Dotfiles/nvim/lua/remaps.lua

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ function map(mode, lhs, rhs, opts)
77
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
88
end
99

10-
map("n", ",,", ":NERDTreeToggle<cr>") -- toggle nerdtree
11-
map("n", "zz", ":Prettier<cr> <ESC>:update<cr>") -- format and save file
10+
map("n", ",,", ":NvimTreeToggle<cr>") -- toggle nerdtree
11+
map("n", "zz", "<ESC>:update<cr>") -- format and save file
1212
map("n", "<C-s>","<C-^>") -- toggle last file
1313
map("n", "ff", ":Prettier<cr>") -- format file
1414
map("i", "jk", "<ESC>") --remap escape to jk
1515
map("n", "tt", ":ToggleTerm<cr>") --toggle terminal
16+
map("n", "TT", ":ToggleTermToggleAll<cr>") --toggle terminal
1617
map("n", "mm", ":Files<cr>") --search file by name
1718
map("n", "<leader>fc", ":Rg<cr>") --search word everywhere
1819
-- move between panels
@@ -21,7 +22,56 @@ map("n", "<C-k>", "<C-W>k")
2122
map("n", "<C-h>", "<C-W>h")
2223
map("n", "<C-l>", "<C-W>l")
2324

25+
map("n", ";", "<S-$>") -- Go to end of line
2426

27+
map("t", "jk", "<C-\\><C-n>") -- exit terminal mode
2528

29+
-- TERMINAL LAZYGIT
30+
local Terminal = require('toggleterm.terminal').Terminal
31+
local lazygit = Terminal:new({
32+
cmd = "lazygit",
33+
dir = "git_dir",
34+
direction = "float",
35+
float_opts = {
36+
border = "double",
37+
},
38+
-- function to run on opening the terminal
39+
on_open = function(term)
40+
vim.cmd("startinsert!")
41+
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
42+
end,
43+
-- function to run on closing the terminal
44+
on_close = function(term)
45+
vim.cmd("startinsert!")
46+
end,
47+
})
2648

49+
function _lazygit_toggle()
50+
lazygit:toggle()
51+
end
52+
53+
vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>", {noremap = true, silent = true})
54+
55+
-- TELESCOPE
56+
local builtin = require('telescope.builtin')
57+
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
58+
59+
vim.api.nvim_set_keymap("n", "<Leader><Leader>",
60+
[[<cmd>lua require('telescope').extensions.recent_files.pick()<CR>]],
61+
{noremap = true, silent = true})
62+
63+
function search_word_all()
64+
local input_string = vim.fn.input("Search For > ")
65+
if (input_string == '') then
66+
return
67+
end
68+
builtin.grep_string({
69+
search = input_string,
70+
})
71+
end
72+
vim.keymap.set('n', '<leader>fa', search_word_all, {})
73+
74+
vim.keymap.set("n", "<leader>rn", function()
75+
return ":IncRename " .. vim.fn.expand("<cword>")
76+
end, { expr = true })
2777

0 commit comments

Comments
 (0)