move keybinds to plugin configs

This commit is contained in:
Noah Masur 2022-07-11 03:31:48 +00:00
parent e1ac175333
commit 24acd220fb
7 changed files with 87 additions and 101 deletions

View File

@ -35,8 +35,8 @@
# Always run packer.nvim sync # Always run packer.nvim sync
home.activation.nvimPackerSync = home.activation.nvimPackerSync =
config.home-manager.users.${config.user}.lib.dag.entryAfter config.home-manager.users.${config.user}.lib.dag.entryAfter
[ "onFilesChange" ] '' [ "writeBoundary" ] ''
$DRY_RUN_CMD nvim +PackerSync +qa $DRY_RUN_CMD nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
''; '';
}; };

View File

@ -1,4 +1,3 @@
require("packer_init") require("packer_init")
require("settings") require("settings")
require("functions")
require("keybinds") require("keybinds")

View File

@ -1,38 +0,0 @@
-- ===========================================================================
-- Custom Functions
-- ===========================================================================
grep_notes = function()
local opts = {
prompt_title = "Search Notes",
cwd = "$NOTES_PATH",
}
require("telescope.builtin").live_grep(opts)
end
find_notes = function()
local opts = {
prompt_title = "Find Notes",
cwd = "$NOTES_PATH",
}
require("telescope.builtin").find_files(opts)
end
find_downloads = function()
local opts = {
prompt_title = "Find Downloads",
cwd = "~/downloads",
}
require("telescope").extensions.file_browser.file_browser(opts)
end
command_history = function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 15,
},
},
})
require("telescope.builtin").command_history(opts)
end

View File

@ -23,60 +23,19 @@ key("n", "<CR>", ":noh<CR><CR>", { silent = true })
-- Shuffle lines around -- Shuffle lines around
key("n", "<A-j>", ":m .+1<CR>==") key("n", "<A-j>", ":m .+1<CR>==")
key("n", "<A-k>", ":m .-2<CR>==") key("n", "<A-k>", ":m .-2<CR>==")
-- key("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
-- key("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
key("v", "<A-j>", ":m '>+1<CR>gv=gv") key("v", "<A-j>", ":m '>+1<CR>gv=gv")
key("v", "<A-k>", ":m '<-2<CR>gv=gv") key("v", "<A-k>", ":m '<-2<CR>gv=gv")
-- Telescope (fuzzy finder) -- Buffer tabs
local telescope = require("telescope.builtin") key("n", "<C-L>", "gt")
local telescope_ext = require("telescope").extensions key("i", "<C-L>", "<Esc>gt")
key("n", "<Leader>k", telescope.keymaps) key("n", "<C-H>", "gT")
key("n", "<Leader>/", telescope.live_grep) key("i", "<C-H>", "<Esc>gT")
key("n", "<Leader>ff", telescope.find_files)
key("n", "<Leader>fp", telescope.git_files)
key("n", "<Leader>fN", find_notes)
key("n", "<Leader>N", grep_notes)
key("n", "<Leader>fD", find_downloads)
key("n", "<Leader>fa", telescope_ext.file_browser.file_browser)
key("n", "<Leader>fw", telescope.grep_string)
-- key("n", "<Leader>wt", ":Telescope tmux sessions<CR>")
-- key("n", "<Leader>ww", ":Telescope tmux windows<CR>")
-- key("n", "<Leader>w/", ":Telescope tmux pane_contents<CR>")
key("n", "<Leader>fz", telescope_ext.zoxide.list)
key("n", "<Leader>b", telescope.buffers)
key("n", "<Leader>hh", telescope.help_tags)
key("n", "<Leader>fr", telescope.oldfiles)
key("n", "<Leader>cc", telescope.commands)
key("n", "<Leader>cr", command_history)
key("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
key("n", "<Leader>gc", telescope.git_commits)
key("n", "<Leader>gf", telescope.git_bcommits)
key("n", "<Leader>gb", telescope.git_branches)
key("n", "<Leader>gs", telescope.git_status)
-- Buffer tabs (tmux interferes) -- Move buffers
-- key("n", "<C-L>", "gt")
-- key("i", "<C-L>", "<Esc>gt")
-- key("n", "<C-H>", "gT")
-- key("i", "<C-H>", "<Esc>gT")
-- Swap buffers
key("n", "L", ":bnext<CR>") key("n", "L", ":bnext<CR>")
key("n", "H", ":bprevious<CR>") key("n", "H", ":bprevious<CR>")
-- LSP
key("n", "gd", vim.lsp.buf.definition, { silent = true })
key("n", "gT", vim.lsp.buf.type_definition, { silent = true })
key("n", "gi", vim.lsp.buf.implementation, { silent = true })
key("n", "gh", vim.lsp.buf.hover, { silent = true })
key("n", "gr", telescope.lsp_references, { silent = true })
key("n", "<Leader>R", vim.lsp.buf.rename, { silent = true })
key("n", "]e", vim.diagnostic.goto_next, { silent = true })
key("n", "[e", vim.diagnostic.goto_prev, { silent = true })
key("n", "<Leader>e", vim.diagnostic.open_float, { silent = true })
key("n", "<Leader>E", vim.lsp.buf.code_action, { silent = true })
-- File commands -- File commands
key("n", "<Leader>q", ":quit<CR>") key("n", "<Leader>q", ":quit<CR>")
key("n", "<Leader>Q", ":quitall<CR>") key("n", "<Leader>Q", ":quitall<CR>")
@ -93,13 +52,7 @@ key("n", "<Leader>wv", ":vsplit<CR>")
key("n", "<Leader>wh", ":split<CR>") key("n", "<Leader>wh", ":split<CR>")
key("n", "<Leader>wm", ":only<CR>") key("n", "<Leader>wm", ":only<CR>")
-- Tabularize
key("", "<Leader>ta", ":Tabularize /")
key("", "<Leader>t#", ":Tabularize /#<CR>")
key("", "<Leader>tl", ":Tabularize /---<CR>")
-- Vimrc editing -- Vimrc editing
key("n", "<Leader>fv", ":edit $DOTS/nvim.configlink/init.lua<CR>")
key("n", "<Leader>rr", ":luafile $MYVIMRC<CR>") key("n", "<Leader>rr", ":luafile $MYVIMRC<CR>")
key("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:") key("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:")
key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>") key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>")

View File

@ -48,6 +48,17 @@ M.packer = function(use)
capabilities = capabilities, capabilities = capabilities,
}) })
end end
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
-- vim.keymap.set("n", "gr", telescope.lsp_references)
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float)
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)
end, end,
}) })

View File

@ -20,7 +20,14 @@ M.packer = function(use)
}) })
-- Alignment tool -- Alignment tool
use("godlygeek/tabular") use({
"godlygeek/tabular",
config = function()
vim.keymap.set("", "<Leader>ta", ":Tabularize /")
vim.keymap.set("", "<Leader>t#", ":Tabularize /#<CR>")
vim.keymap.set("", "<Leader>tl", ":Tabularize /---<CR>")
end,
})
-- Markdown renderer / wiki notes -- Markdown renderer / wiki notes
use("vimwiki/vimwiki") use("vimwiki/vimwiki")

View File

@ -28,13 +28,56 @@ M.packer = function(use)
}, },
extensions = { extensions = {
fzy_native = {}, fzy_native = {},
-- tmux = {},
zoxide = {}, zoxide = {},
project = { project = {
base_dirs = { "~/dev" }, base_dirs = { "~/dev" },
}, },
}, },
}) })
local telescope = require("telescope.builtin")
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
vim.keymap.set("n", "<Leader>b", telescope.buffers)
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
vim.keymap.set("n", "<Leader>cc", telescope.commands)
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
vim.keymap.set("n", "<Leader>N", function()
local opts = {
prompt_title = "Search Notes",
cwd = "$NOTES_PATH",
}
telescope.live_grep(opts)
end)
vim.keymap.set("n", "<Leader>fN", function()
local opts = {
prompt_title = "Find Notes",
cwd = "$NOTES_PATH",
}
telescope.find_files(opts)
end)
vim.keymap.set("n", "<Leader>cr", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 15,
},
},
})
telescope.command_history(opts)
end)
end, end,
}) })
@ -47,7 +90,10 @@ M.packer = function(use)
-- Jump directories -- Jump directories
use({ use({
"jvgrootveld/telescope-zoxide", "jvgrootveld/telescope-zoxide",
requires = { "nvim-lua/popup.nvim" }, requires = { "nvim-lua/popup.nvim", "nvim-telescope/telescope.nvim" },
config = function()
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
end,
}) })
-- Jump projects -- Jump projects
@ -57,7 +103,7 @@ M.packer = function(use)
config = function() config = function()
require("telescope").load_extension("project") require("telescope").load_extension("project")
choose_project = function() vim.keymap.set("n", "<C-p>", function()
local opts = require("telescope.themes").get_ivy({ local opts = require("telescope.themes").get_ivy({
layout_config = { layout_config = {
bottom_pane = { bottom_pane = {
@ -66,9 +112,7 @@ M.packer = function(use)
}, },
}) })
require("telescope").extensions.project.project(opts) require("telescope").extensions.project.project(opts)
end end)
vim.keymap.set("n", "<C-p>", choose_project)
end, end,
}) })
@ -78,6 +122,16 @@ M.packer = function(use)
requires = { "nvim-telescope/telescope.nvim" }, requires = { "nvim-telescope/telescope.nvim" },
config = function() config = function()
require("telescope").load_extension("file_browser") require("telescope").load_extension("file_browser")
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
vim.keymap.set("n", "<Leader>fD", function()
local opts = {
prompt_title = "Find Downloads",
cwd = "~/downloads",
}
require("telescope").extensions.file_browser.file_browser(opts)
end)
end, end,
}) })
end end