mirror of https://github.com/tiyn/dotfiles
parent
5541ec87b9
commit
d4a1d0622c
@ -1,198 +1,108 @@
|
|||||||
-- setup keymap function
|
-- setup keymap function
|
||||||
local m = require("mapx").setup({ global = true, whichkey = true })
|
local wk = require("which-key")
|
||||||
|
local lazygit = require("FTerm"):new({ cmd = "lazygit" })
|
||||||
|
|
||||||
|
wk.add({
|
||||||
-- setup keymap groups
|
-- setup keymap groups
|
||||||
m.nname("g", "LSP: goto")
|
{mode = "n", "g", desc = "LSP: goto"},
|
||||||
m.nname("gp", "LSP: preview")
|
{mode = "n", "gp", desc = "LSP: preview"},
|
||||||
m.cname("w", "Write")
|
{mode = "c", "w", desc = "Write"},
|
||||||
m.cname("w!", "Write: overwrite")
|
{mode = "c", "w!", desc = "Write: overwrite"},
|
||||||
m.nname("<leader>g", "Git")
|
{mode = "n", "<leader>g", desc = "Git"},
|
||||||
m.nname("<leader>f", "Telescope: find ...")
|
{mode = "n", "<leader>f", desc = "Telescope: find"},
|
||||||
m.nname("<leader>gd", "Git: diff")
|
{mode = "n", "<leader>gd", desc = "Git: diff"},
|
||||||
m.nname("<leader>s", "Substitute")
|
{mode = "n", "<leader>s", desc = "Substitute"},
|
||||||
m.nname("<leader>t", "Terminal")
|
{mode = "n", "<leader>t", desc = "Terminal"},
|
||||||
m.nname("<C-W>", "Navigation")
|
{mode = "n", "<C-W>", desc = "Navigation"},
|
||||||
|
|
||||||
-- unmap unwanted commands
|
-- unmap unwanted commands
|
||||||
m.nnoremap("Zt", "<NOP>")
|
{mode = "n", "Zt", "<NOP>", noremap = true},
|
||||||
m.nnoremap("ZT", "<NOP>")
|
{mode = "n", "ZT", "<NOP>", noremap = true},
|
||||||
m.nnoremap("<Space>", "<NOP>")
|
{mode = "n", "<Space>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F2>", "<NOP>")
|
{mode = "n", "<F2>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F3>", "<NOP>")
|
{mode = "n", "<F3>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F4>", "<NOP>")
|
{mode = "n", "<F4>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F5>", "<NOP>")
|
{mode = "n", "<F5>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F6>", "<NOP>")
|
{mode = "n", "<F6>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F8>", "<NOP>")
|
{mode = "n", "<F8>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F9>", "<NOP>")
|
{mode = "n", "<F9>", "<NOP>", noremap = true},
|
||||||
m.nnoremap("<F9>", "<NOP>")
|
{mode = "n", "<F9>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F10>", "<NOP>")
|
{mode = "n", "<F10>", "<NOP>", noremap = true},
|
||||||
m.nnoremap("<F10>", "<NOP>")
|
{mode = "n", "<F10>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F11>", "<NOP>")
|
{mode = "n", "<F11>", "<NOP>", noremap = true},
|
||||||
m.nnoremap("<F11>", "<NOP>")
|
{mode = "n", "<F11>", "<NOP>", noremap = true},
|
||||||
m.inoremap("<F12>", "<NOP>")
|
{mode = "n", "<F12>", "<NOP>", noremap = true},
|
||||||
m.nnoremap("<F12>", "<NOP>")
|
{mode = "n", "<F12>", "<NOP>", noremap = true},
|
||||||
|
|
||||||
-- spell
|
-- spell
|
||||||
m.nmap("<F6>s", "z=", "Spell: display suggestions")
|
{mode = "n", "<F6>s", "z=", desc = "Spell: display suggestions"},
|
||||||
|
|
||||||
-- shortcuts for quitting
|
-- shortcuts for quitting
|
||||||
m.nnoremap("ZA", ":xa<CR>", "Exit: write and quit all buffers")
|
{mode = "n", "ZA", ":xa<CR>", desc = "Exit: write and quit all buffers", noremap = true},
|
||||||
m.nnoremap("ZQ", ":conf q<CR>", "Exit: quit current buffer")
|
{mode = "n", "ZQ", ":conf q<CR>", desc = "Exit: quit current buffer", noremap = true},
|
||||||
m.nnoremap("ZZ", ":x<CR>", "Exit: write and quit current buffer")
|
{mode = "n", "ZZ", ":x<CR>", desc = "Exit: write and quit current buffer", noremap = true},
|
||||||
|
|
||||||
-- shortcut for split navigation
|
-- shortcut for split navigation
|
||||||
m.nnoremap("<C-h>", "<C-w>h", "Navigation: go to left window")
|
{mode = "n", "<C-h>", "<C-w>h", desc = "Navigation: go to left window", noremap = true},
|
||||||
m.nnoremap("<C-j>", "<C-w>j", "Navigation: go to lower window")
|
{mode = "n", "<C-j>", "<C-w>j", desc = "Navigation: go to lower window", noremap = true},
|
||||||
m.nnoremap("<C-k>", "<C-w>k", "Navigation: go to upper window")
|
{mode = "n", "<C-k>", "<C-w>k", desc = "Navigation: go to upper window", noremap = true},
|
||||||
m.nnoremap("<C-l>", "<C-w>l", "Navigation: go to right window")
|
{mode = "n", "<C-l>", "<C-w>l", desc = "Navigation: go to right window", noremap = true},
|
||||||
|
|
||||||
-- remap for dealing with word wrap
|
-- remap for dealing with word wrap
|
||||||
m.nmap(
|
{mode = "n", "j", "gj", desc = "Navigation: go down in wrapped lines", silent = true},
|
||||||
"j",
|
{mode = "n", "k", "gk", desc = "Navigation: go up in wrapped lines", silent = true},
|
||||||
"v:count == 0 ? 'gj' : 'j'",
|
|
||||||
{ "expr", "silent" },
|
|
||||||
"Navigation: go down in wrapped lines"
|
|
||||||
)
|
|
||||||
m.nmap("k", "v:count == 0 ? 'gk' : 'k'", { "expr", "silent" }, "Navigation: go up in wrapped lines")
|
|
||||||
|
|
||||||
-- compiler for languages
|
-- compiler for languages
|
||||||
m.nnoremap("<leader>c", ":w! | !compiler <c-r>%<CR>", "Compile: current file")
|
{mode = "n", "<leader>c", ":w! | !compiler <c-r>%<CR>", desc = "Compile: current file", noremap = true},
|
||||||
|
{mode = "n", "w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!', desc = "Write: overwrite file over with sudo", noremap = true},
|
||||||
-- save file as sudo on files that require root permission
|
|
||||||
m.cnoremap(
|
|
||||||
"w!!",
|
|
||||||
'execute "silent! write !sudo tee % >/dev/null" <bar> edit!',
|
|
||||||
"Write: overwrite file over with sudo"
|
|
||||||
)
|
|
||||||
|
|
||||||
-- tpope/vim-abolish
|
-- tpope/vim-abolish
|
||||||
m.nnoremap("<leader>sa", ":%S//g<Left><Left>", "Substitute: free form")
|
{mode = "n", "<leader>sa", ":%S//g<Left><Left>", desc = "Substitute: free form", noremap = true},
|
||||||
m.nnoremap("<leader>ss", ":%S/\\<<C-r><C-w>\\>//g<Left><Left>", "Substitute: word under cursor")
|
{mode = "n", "<leader>ss", ":%S/\\<<C-r><C-w>\\>//g<Left><Left>", desc = "Substitute: word under cursor", noremap = true},
|
||||||
|
|
||||||
-- simrat39/symbols-outline.nvim
|
-- simrat39/symbols-outline.nvim
|
||||||
m.nmap("<F3>", ":SymbolsOutline<CR>", "CTags: toggle")
|
{mode = "n", "<F3>", ":SymbolsOutline<CR>", desc = "CTags: toggle"},
|
||||||
|
|
||||||
-- nvim-tree/nvim-tree.lua
|
-- nvim-tree/nvim-tree.lua
|
||||||
m.nmap("<F2>", ":NvimTreeToggle toggle<CR>", "File tree: toggle")
|
{mode = "n", "<F2>", ":NvimTreeToggle toggle<CR>", desc = "File tree: toggle"},
|
||||||
|
|
||||||
-- mbbill/undotree
|
-- mbbill/undotree
|
||||||
m.nmap("<F1>", ":UndotreeToggle<CR>", "Undo tree: toggle")
|
{mode = "n", "<F1>", ":UndotreeToggle<CR>", desc = "Undo tree: toggle"},
|
||||||
|
|
||||||
-- amrbashir/nvim-docs-view
|
-- amrbashir/nvim-docs-view
|
||||||
m.nnoremap("go", ":DocsViewToggle<CR>", "LSP: toggle documentation window")
|
{mode = "n", "go", ":DocsViewToggle<CR>", desc = "LSP: toggle documentation window", noremap = true},
|
||||||
|
|
||||||
-- numtostr/fterm.nvim
|
-- numtostr/fterm.nvim
|
||||||
m.nnoremap("<leader>tt", require("FTerm").toggle, "Terminal: open")
|
{mode = "n", "<leader>tt", require("FTerm").toggle, desc = "Terminal: open", noremap = true},
|
||||||
m.tnoremap("<leader>tt", require("FTerm").toggle, "Terminal: open")
|
{mode = "n", "<leader>gt", function() lazygit:toggle() end, desc = "Git: open lazygit", noremap = true},
|
||||||
local lazygit = require("FTerm"):new({
|
{mode = "n", "<leader>tg", function() lazygit:toggle() end, desc = "Terminal: open lazygit", noremap = true},
|
||||||
cmd = "lazygit",
|
{mode = "n", "<leader>tg", function() lazygit:toggle() end, desc = "Terminal: open lazygit", noremap = true},
|
||||||
})
|
|
||||||
m.nnoremap("<leader>gt", function()
|
|
||||||
lazygit:toggle()
|
|
||||||
end, "Git: open lazygit")
|
|
||||||
m.tnoremap("<leader>gt", function()
|
|
||||||
lazygit:toggle()
|
|
||||||
end, "Git: open lazygit")
|
|
||||||
m.nnoremap("<leader>tg", function()
|
|
||||||
lazygit:toggle()
|
|
||||||
end, "Terminal: open lazygit")
|
|
||||||
m.tnoremap("<leader>tg", function()
|
|
||||||
lazygit:toggle()
|
|
||||||
end, "Terminal: open lazygit")
|
|
||||||
|
|
||||||
-- sindrets/diffview.nvim
|
-- sindrets/diffview.nvim
|
||||||
m.nmap("<leader>gdo", ":DiffviewOpen<CR>", "Git: open diff")
|
{mode = "n", "<leader>gdo", ":DiffviewOpen<CR>", desc = "Git: open diff"},
|
||||||
m.nmap("<leader>gdc", ":DiffviewClose<CR>", "Git: close diff")
|
{mode = "n", "<leader>gdc", ":DiffviewClose<CR>", desc = "Git: close diff"},
|
||||||
|
|
||||||
-- folke/trouble.nvim
|
-- folke/trouble.nvim
|
||||||
m.nmap("<leader>x", ":TroubleToggle<CR>", "LSP: toggle error list")
|
{mode = "n", "<leader>x", ":TroubleToggle<CR>", desc = "LSP: toggle error list"},
|
||||||
|
|
||||||
-- hrsh7th/nvim-cmp
|
-- hrsh7th/nvim-cmp
|
||||||
m.nnoremap("gd", vim.lsp.buf.definition(), "LSP: goto definition")
|
{mode = "n", "gd", vim.lsp.buf.definition(), desc = "LSP: goto definition", noremap = true},
|
||||||
m.nnoremap("gD", vim.lsp.buf.declaration(), "LSP: goto declaration")
|
{mode = "n", "gD", vim.lsp.buf.declaration(), desc = "LSP: goto declaration", noremap = true},
|
||||||
m.nnoremap("gi", vim.lsp.buf.implementation(), "LSP: list implementation")
|
{mode = "n", "gi", vim.lsp.buf.implementation(), desc = "LSP: list implementation", noremap = true},
|
||||||
m.nnoremap("gr", function()
|
{mode = "n", "gr", function() vim.lsp.buf.references() end, desc = "LSP: list references", noremap = true},
|
||||||
vim.lsp.buf.references()
|
{mode = "n", "K", vim.lsp.buf.hover(), desc = "LSP: show documentation", noremap = true},
|
||||||
end, "LSP: list references")
|
{mode = "n", "<F8>", function() require("conform").format({ async = true, lsp_fallback = true }) end, desc = "LSP: format", noremap = true},
|
||||||
m.nnoremap("gy", vim.lsp.buf.type_definition(), "LSP: goto type definition")
|
|
||||||
m.nnoremap("K", vim.lsp.buf.hover(), "LSP: show documentation")
|
|
||||||
m.nnoremap("<F8>", function()
|
|
||||||
require("conform").format({ async = true, lsp_fallback = true })
|
|
||||||
end, "LSP: format")
|
|
||||||
|
|
||||||
-- rmagatti/goto-preview
|
-- rmagatti/goto-preview
|
||||||
m.nnoremap("gpd", function()
|
{mode = "n", "gpd", function() require("goto-preview").goto_preview_definition() end, desc = "LSP: preview definition", noremap = true},
|
||||||
require("goto-preview").goto_preview_definition()
|
{mode = "n", "gpy", function() require("goto-preview").goto_preview_type_definition() end, desc = "LSP: preview type definition", noremap = true},
|
||||||
end, "LSP: preview definition")
|
{mode = "n", "gpi", function() require("goto-preview").goto_preview_implementation() end, desc = "LSP: list preview implementation", noremap = true},
|
||||||
m.nnoremap("gpy", function()
|
{mode = "n", "gpD", function() require("goto-preview").goto_preview_declaration() end, desc = "LSP: preview declaration", noremap = true},
|
||||||
require("goto-preview").goto_preview_type_definition()
|
{mode = "n", "gpr", function() require("goto-preview").goto_preview_references() end, desc = "LSP: list preview references", noremap = true},
|
||||||
end, "LSP: preview type definition")
|
{mode = "n", "gpc", function() require("goto-preview").close_all_win() end, desc = "LSP: close all preview windows", noremap = true},
|
||||||
m.nnoremap("gpi", function()
|
|
||||||
require("goto-preview").goto_preview_implementation()
|
|
||||||
end, "LSP: list preview implementation")
|
|
||||||
m.nnoremap("gpD", function()
|
|
||||||
require("goto-preview").goto_preview_declaration()
|
|
||||||
end, "LSP: preview declaration")
|
|
||||||
m.nnoremap("gpr", function()
|
|
||||||
require("goto-preview").goto_preview_references()
|
|
||||||
end, "LSP: list preview references")
|
|
||||||
m.nnoremap("gpc", function()
|
|
||||||
require("goto-preview").close_all_win()
|
|
||||||
end, "LSP: close all preview windows")
|
|
||||||
|
|
||||||
-- filipdutescu/renamer.nvim
|
-- filipdutescu/renamer.nvim
|
||||||
m.nnoremap("<F5>", function()
|
{mode = "n", "<F5>", function() require("renamer").rename() end, desc = "LSP: rename", noremap = true},
|
||||||
require("renamer").rename()
|
|
||||||
end, "LSP: rename")
|
|
||||||
|
|
||||||
-- nvim-telescope/telescope.nvim
|
-- nvim-telescope/telescope.nvim
|
||||||
m.nnoremap("<F4>", ":Telescope find_files<CR>", "Telescope: find files")
|
{mode = "n", "<F4>", ":Telescope find_files<CR>", desc = "Telescope: find files", noremap = true},
|
||||||
m.nnoremap("<leader>ff", ":Telescope find_files<CR>", "Telescope: find files")
|
{mode = "n", "<leader>ff", ":Telescope find_files<CR>", desc = "Telescope: find files", noremap = true},
|
||||||
|
|
||||||
-- kamykn/spelunker.vim
|
-- kamykn/spelunker.vim
|
||||||
m.nnoremap("<F6>t", ":call spelunker#toggle()<CR>", "Spelunker: toggle spell check")
|
{mode = "n", "<F6>t", ":call spelunker#toggle()<CR>", desc = "Spelunker: toggle spell check", noremap = true},
|
||||||
m.nnoremap("<F6>l", function()
|
{mode = "n", "<F6>l", function() if vim.opt.spelllang._value == "de_de" then vim.opt.spelllang = "en_us" print("Spell language set to en_us") else vim.opt.spelllang = "de_de" print("Spell language set to de_de") end vim.opt.spell = false end, desc = "Spell: toggle spell language", noremap = true},
|
||||||
if vim.opt.spelllang._value == "de_de" then
|
|
||||||
vim.opt.spelllang = "en_us"
|
|
||||||
print("Spell language set to en_us")
|
|
||||||
else
|
|
||||||
vim.opt.spelllang = "de_de"
|
|
||||||
print("Spell language set to de_de")
|
|
||||||
end
|
|
||||||
vim.opt.spell = false
|
|
||||||
end, "Spell: toggle spell language")
|
|
||||||
|
|
||||||
-- kevinhwang91/nvim-ufo
|
-- kevinhwang91/nvim-ufo
|
||||||
m.nnoremap("K", function()
|
{mode = "n", "K", function() local winid = require("ufo").peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end, desc = "LSP: peek folded section", noremap = true},
|
||||||
local winid = require("ufo").peekFoldedLinesUnderCursor()
|
|
||||||
if not winid then
|
|
||||||
vim.lsp.buf.hover()
|
|
||||||
end
|
|
||||||
end, "LSP: peek folded section")
|
|
||||||
|
|
||||||
-- kevinhwang91/nvim-hlslens
|
-- kevinhwang91/nvim-hlslens
|
||||||
m.nnoremap(
|
{mode = "n", "n", [[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Search: search forward", noremap = true, silent = true},
|
||||||
"n",
|
{mode = "n", "N", [[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Search: search backwards", noremap = true, silent = true},
|
||||||
[[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
|
|
||||||
"silent",
|
|
||||||
"Search: search forward"
|
|
||||||
)
|
|
||||||
m.nnoremap(
|
|
||||||
"N",
|
|
||||||
[[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
|
|
||||||
"silent",
|
|
||||||
"Search: search backwards"
|
|
||||||
)
|
|
||||||
|
|
||||||
-- sindrets/winshift.nvim
|
-- sindrets/winshift.nvim
|
||||||
m.nnoremap("<C-W>m", ":WinShift<CR>", "Navigation: enter window shift mode")
|
{mode = "n", "<C-W>m", ":WinShift<CR>", desc = "Navigation: enter window shift mode", noremap = true},
|
||||||
|
|
||||||
-- ggandor/leap.nvim
|
-- ggandor/leap.nvim
|
||||||
m.nnoremap("f", "<Plug>(leap-forward)", "Navigation: enter leap mode for forward movement")
|
{mode = "n", "f", "<Plug>(leap-forward)", desc = "Navigation: enter leap mode for forward movement", noremap = true},
|
||||||
m.nnoremap("F", "<Plug>(leap-backward)", "Navigation: enter leap mode for backwards movement")
|
{mode = "n", "F", "<Plug>(leap-backward)", desc = "Navigation: enter leap mode for backwards movement", noremap = true},
|
||||||
m.nnoremap("gf", "<Plug>(leap-from-window)", "Navigation: enter leap mode for other windows")
|
{mode = "n", "gf", "<Plug>(leap-from-window)", desc = "Navigation: enter leap mode for other windows", noremap = true},
|
||||||
|
|
||||||
-- gnikdroy/projections.nvim
|
-- gnikdroy/projections.nvim
|
||||||
m.nnoremap("<leader>fp", function()
|
{mode = "n", "<leader>fp", function() vim.cmd("Telescope projections") end, desc = "Telescope: find projects", noremap = true},
|
||||||
vim.cmd("Telescope projections")
|
})
|
||||||
end, "Telescope: find projects")
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
return {
|
|
||||||
-- improved keybindings, previewing them
|
|
||||||
{
|
|
||||||
"b0o/mapx.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"folke/which-key.nvim",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
-- improved keybindings, previewing them
|
||||||
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue