Large keymapping overhaul
This commit is contained in:
parent
11af8c9452
commit
9fb6438efa
9 changed files with 27 additions and 81 deletions
|
|
@ -1,4 +1,3 @@
|
|||
local utils = require("utils")
|
||||
local M = {}
|
||||
M.format_on_save = true
|
||||
|
||||
|
|
@ -21,16 +20,11 @@ function M.setup()
|
|||
local user_commands = {
|
||||
{ "FormatEnable", "lua require('format_handler').format_enable()" },
|
||||
{ "FormatDisable", "lua require('format_handler').format_disable()" },
|
||||
{ "Format", "lua require('format_handler').format(true)" },
|
||||
}
|
||||
for _, cmd in ipairs(user_commands) do
|
||||
vim.api.nvim_command("command! " .. cmd[1] .. " " .. cmd[2])
|
||||
end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "<leader>ff", function() M.format(true) end },
|
||||
{ "<leader>fe", function() M.format_enable() end },
|
||||
{ "<leader>fd", function() M.format_disable() end },
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ utils.foreach({
|
|||
{
|
||||
"n",
|
||||
{
|
||||
-- Using lspsaga for hover doc
|
||||
{ "K", "<Nop>", },
|
||||
-- Using lspsaga finder with gr which does references
|
||||
{ "grr", "<Nop>", },
|
||||
{ "gra", "<Nop>", },
|
||||
{ "grn", "<Nop>", },
|
||||
{ "gra", "<Nop>", },
|
||||
{ "grr", "<Nop>", },
|
||||
{ "gri", "<Nop>", },
|
||||
{ "gO", "<Nop>", },
|
||||
-- Navigation
|
||||
{ "<C-Left>", "<C-w>h", },
|
||||
{ "<C-Down>", "<C-w>j", },
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
local utils = require("utils")
|
||||
local inlay_hints_handler = require("inlay_hints_handler")
|
||||
local format_handler = require("format_handler")
|
||||
local lsplib = require("lsplib")
|
||||
|
||||
vim.lsp.config("*", {
|
||||
root_markers = { ".git" },
|
||||
|
|
@ -18,28 +17,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
local bufnr = args.buf
|
||||
assert(client, "LspAttach: client is nil")
|
||||
|
||||
inlay_hints_handler.add_buffer(bufnr)
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
format_handler.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Built-in LSP completion.
|
||||
-- Could switch to this if they just appeared automatically when typing, and didn't
|
||||
-- only rely on showing when the servers completionCharacters are typed.
|
||||
-- if client:supports_method("textDocument/completion") then
|
||||
-- vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
|
||||
-- end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
{ "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
})
|
||||
lsplib.configure_generic_client(client, bufnr)
|
||||
end
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,18 +44,6 @@ return {
|
|||
roles = {
|
||||
user = "Martin",
|
||||
},
|
||||
keymaps = {
|
||||
send = {
|
||||
modes = {
|
||||
i = { "<C-CR>", "<C-s>" },
|
||||
},
|
||||
},
|
||||
completion = {
|
||||
modes = {
|
||||
i = "<C-x>",
|
||||
},
|
||||
},
|
||||
},
|
||||
slash_commands = {
|
||||
["buffer"] = {
|
||||
opts = {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ return {
|
|||
lazy = true,
|
||||
opts = {},
|
||||
keys = {
|
||||
{ "<leader>g", function() require("neogit").open() end }
|
||||
{ "<leader>v", function() require("neogit").open() end }
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
local utils = require("utils")
|
||||
local inlay_hints_handler = require("inlay_hints_handler")
|
||||
local format_handler = require("format_handler")
|
||||
|
||||
return {
|
||||
"mrcjkb/rustaceanvim",
|
||||
version = "^5",
|
||||
|
|
@ -17,24 +13,7 @@ return {
|
|||
},
|
||||
},
|
||||
server = {
|
||||
on_attach = function(client, bufnr)
|
||||
inlay_hints_handler.add_buffer(bufnr)
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
format_handler.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
{ "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
})
|
||||
end,
|
||||
on_attach = require("lsplib").configure_generic_client,
|
||||
}
|
||||
}
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -60,17 +60,26 @@ return {
|
|||
},
|
||||
},
|
||||
keys = {
|
||||
{ "gB", function() Snacks.gitbrowse() end, },
|
||||
{ "gB", function() Snacks.gitbrowse() end, },
|
||||
|
||||
{ "<leader>z", function() Snacks.zen() end, },
|
||||
{ "<leader>z", function() Snacks.zen() end, },
|
||||
|
||||
{ "<leader>f", function() Snacks.picker.smart({ multi = { "buffers", "files" } }) end, },
|
||||
{ "<leader>g", function() Snacks.picker.grep() end, },
|
||||
{ "<leader>l", function() Snacks.picker.git_log_file() end, },
|
||||
{ "<leader>s", function() Snacks.picker.lsp_workspace_symbols() end, },
|
||||
{ "<leader>n", function() Snacks.picker.notifications() end },
|
||||
|
||||
{ "<leader>rf", function() Snacks.rename.rename_file({}) end },
|
||||
{ "<leader>f", function() Snacks.picker.smart({ multi = { "buffers", "files" } }) end, },
|
||||
{ "<leader>g", function() Snacks.picker.grep() end, },
|
||||
{ "<leader>l", function() Snacks.picker.git_log_file() end, },
|
||||
{ "<leader>s", function() Snacks.picker.lsp_workspace_symbols() end, },
|
||||
{ "<leader>o", function() Snacks.picker.lsp_symbols() end, },
|
||||
{ "<leader>n", function() Snacks.picker.notifications() end },
|
||||
{ "<leader>d", function() Snacks.picker.diagnostics() end },
|
||||
|
||||
{ "<leader>e", function() Snacks.rename.rename_file({}) end },
|
||||
|
||||
{ "gd", function() Snacks.picker.lsp_definitions() end, },
|
||||
{ "gD", function() Snacks.picker.lsp_declarations() end, },
|
||||
{ "gr", function() Snacks.picker.lsp_references() end, nowait = true, },
|
||||
{ "gi", function() Snacks.picker.lsp_implementations() end, },
|
||||
{ "gt", function() Snacks.picker.lsp_type_definitions() end, },
|
||||
},
|
||||
init = function()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ local function toggle_terminal()
|
|||
vim.api.nvim_command("startinsert")
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>h", function()
|
||||
vim.keymap.set("n", "<leader>t", function()
|
||||
toggle_terminal()
|
||||
require("window_management").autosize_windows()
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue