fix keymaps, lazy load pass trying to reduce startup time, shaved ~35ms
This commit is contained in:
parent
8b38a13192
commit
f5efed19c7
11 changed files with 295 additions and 218 deletions
|
|
@ -35,7 +35,8 @@ local function toggle_terminal()
|
|||
vim.api.nvim_command("startinsert")
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>t", function()
|
||||
|
||||
utils.set_keymap_list({{ "<leader>t", function()
|
||||
toggle_terminal()
|
||||
require("window_management").autosize_windows()
|
||||
end)
|
||||
end }})
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@
|
|||
"rev": "8b54c59bcb23366645ae10edca6edfb9d3a0853e",
|
||||
"src": "https://github.com/b0o/incline.nvim"
|
||||
},
|
||||
"live-rename.nvim": {
|
||||
"rev": "3a3cddf23b89a17992f9ca67afc5858077769462",
|
||||
"src": "https://github.com/saecki/live-rename.nvim"
|
||||
},
|
||||
"logger.nvim": {
|
||||
"rev": "63dd10c9b9a159fd6cfe08435d9606384ff103c5",
|
||||
"src": "https://github.com/rmagatti/logger.nvim"
|
||||
|
|
@ -63,7 +59,7 @@
|
|||
"src": "https://github.com/MunifTanjim/nui.nvim"
|
||||
},
|
||||
"nvim-dap": {
|
||||
"rev": "2a8799ad91a1495c6bdf753f9b2179b3ff0f5bba",
|
||||
"rev": "45a69eba683a2c448dd9ecfc4de89511f0646b5f",
|
||||
"src": "https://github.com/mfussenegger/nvim-dap"
|
||||
},
|
||||
"nvim-dap-go": {
|
||||
|
|
@ -75,7 +71,7 @@
|
|||
"src": "https://github.com/LiadOz/nvim-dap-repl-highlights"
|
||||
},
|
||||
"nvim-dap-ui": {
|
||||
"rev": "f5b6673f374626515401c5bc51b005f784a4f252",
|
||||
"rev": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49",
|
||||
"src": "https://github.com/rcarriga/nvim-dap-ui"
|
||||
},
|
||||
"nvim-dap-virtual-text": {
|
||||
|
|
@ -94,6 +90,10 @@
|
|||
"rev": "57e1fa7638e753efbd62e5aa53b82b08a80fed7e",
|
||||
"src": "https://github.com/LarssonMartin1998/nvim-norrsken"
|
||||
},
|
||||
"nvim-rephrase": {
|
||||
"rev": "3391726e2768fd241e89d032f8523ea053099387",
|
||||
"src": "git@github.com:LarssonMartin1998/nvim-rephrase"
|
||||
},
|
||||
"nvim-treesitter": {
|
||||
"rev": "7caec274fd19c12b55902a5b795100d21531391f",
|
||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
|
||||
|
|
|
|||
|
|
@ -3,47 +3,27 @@ local function gh(repo)
|
|||
end
|
||||
|
||||
vim.pack.add({
|
||||
-- Mini suite
|
||||
-- Foundational
|
||||
gh("LarssonMartin1998/mini.nvim"),
|
||||
{ src = gh("nvim-treesitter/nvim-treesitter"), version = "main" },
|
||||
|
||||
-- Colorscheme
|
||||
gh("rktjmp/lush.nvim"),
|
||||
gh("LarssonMartin1998/nvim-norrsken"),
|
||||
|
||||
-- Treesitter
|
||||
{ src = gh("nvim-treesitter/nvim-treesitter"), version = "main" },
|
||||
gh("nvim-treesitter/nvim-treesitter-context"),
|
||||
gh("nvim-treesitter/nvim-treesitter-textobjects"),
|
||||
|
||||
-- Completion
|
||||
gh("rafamadriz/friendly-snippets"),
|
||||
{ src = gh("L3MON4D3/LuaSnip"), version = vim.version.range("2.x") },
|
||||
{ src = gh("saghen/blink.cmp"), version = vim.version.range("1.x") },
|
||||
|
||||
-- UI
|
||||
gh("nvim-lualine/lualine.nvim"),
|
||||
gh("b0o/incline.nvim"),
|
||||
gh("kosayoda/nvim-lightbulb"),
|
||||
gh("rachartier/tiny-glimmer.nvim"),
|
||||
gh("rachartier/tiny-inline-diagnostic.nvim"),
|
||||
|
||||
-- DAP
|
||||
gh("mfussenegger/nvim-dap"),
|
||||
gh("rcarriga/nvim-dap-ui"),
|
||||
gh("nvim-neotest/nvim-nio"),
|
||||
gh("LiadOz/nvim-dap-repl-highlights"),
|
||||
gh("theHamsta/nvim-dap-virtual-text"),
|
||||
gh("Weissle/persistent-breakpoints.nvim"),
|
||||
gh("leoluz/nvim-dap-go"),
|
||||
-- Motions
|
||||
gh("mawkler/demicolon.nvim"),
|
||||
gh("nvim-treesitter/nvim-treesitter-textobjects"),
|
||||
|
||||
-- Misc
|
||||
gh("OXY2DEV/markview.nvim"),
|
||||
gh("MunifTanjim/nui.nvim"),
|
||||
gh("xzbdmw/colorful-menu.nvim"),
|
||||
})
|
||||
|
||||
require("colorful-menu").setup({})
|
||||
|
||||
vim.cmd.packadd("nvim.undotree")
|
||||
|
||||
vim.api.nvim_create_user_command("VimPackClean", function()
|
||||
|
|
|
|||
|
|
@ -45,10 +45,16 @@ vim.schedule(function()
|
|||
})
|
||||
end)
|
||||
|
||||
require("treesitter-context").setup({
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter-context" })
|
||||
require("treesitter-context").setup({
|
||||
max_lines = 2,
|
||||
multiline_threshold = 3,
|
||||
trim_scope = "inner",
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Textobject helpers
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
local ls = require("luasnip")
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
ls.filetype_extend("typescriptreact", { "html" })
|
||||
ls.filetype_extend("javascriptreact", { "html" })
|
||||
ls.config.set_config({
|
||||
enable_autosnippets = false,
|
||||
store_selection_keys = false,
|
||||
})
|
||||
local function gh(repo)
|
||||
return "https://github.com/" .. repo
|
||||
end
|
||||
|
||||
require("blink.cmp").setup({
|
||||
vim.api.nvim_create_autocmd("ModeChanged", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({
|
||||
gh("rafamadriz/friendly-snippets"),
|
||||
{ src = gh("L3MON4D3/LuaSnip"), version = vim.version.range("2.x") },
|
||||
{ src = gh("saghen/blink.cmp"), version = vim.version.range("1.x") },
|
||||
gh("xzbdmw/colorful-menu.nvim"),
|
||||
})
|
||||
|
||||
require("blink.cmp").setup({
|
||||
keymap = { preset = "super-tab" },
|
||||
appearance = {
|
||||
nerd_font_variant = "mono",
|
||||
|
|
@ -40,4 +45,16 @@ require("blink.cmp").setup({
|
|||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
},
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||
})
|
||||
require("colorful-menu").setup({})
|
||||
end,
|
||||
})
|
||||
|
||||
local ls = require("luasnip")
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
ls.filetype_extend("typescriptreact", { "html" })
|
||||
ls.filetype_extend("javascriptreact", { "html" })
|
||||
ls.config.set_config({
|
||||
enable_autosnippets = false,
|
||||
store_selection_keys = false,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
vim.schedule(function()
|
||||
vim.pack.add({ "https://github.com/mawkler/demicolon.nvim" })
|
||||
require("demicolon").setup({
|
||||
require("demicolon").setup({
|
||||
keymaps = {
|
||||
repeat_motions = "stateful",
|
||||
},
|
||||
})
|
||||
end)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
vim.schedule(function()
|
||||
vim.pack.add({
|
||||
"https://github.com/rmagatti/logger.nvim",
|
||||
"https://github.com/rmagatti/goto-preview",
|
||||
})
|
||||
local function gh(repo)
|
||||
return "https://github.com/" .. repo
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({
|
||||
gh("https://github.com/rmagatti/goto-preview"),
|
||||
gh("rmagatti/logger.nvim")
|
||||
})
|
||||
require("goto-preview").setup({
|
||||
border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" },
|
||||
focus_on_open = true,
|
||||
|
|
@ -12,10 +17,10 @@ vim.schedule(function()
|
|||
vim_ui_input = false,
|
||||
})
|
||||
|
||||
local utils = require("utils")
|
||||
utils.set_keymap_list({
|
||||
require("utils").set_keymap_list({
|
||||
{ "gp", function() require("goto-preview").goto_preview_definition() end },
|
||||
{ "gy", function() require("goto-preview").goto_preview_type_definition() end },
|
||||
{ "<Leader>q", function() require("goto-preview").close_all_win() end },
|
||||
})
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,12 +3,37 @@ local inlay_hints_handler = require("inlay_hints_handler")
|
|||
|
||||
local is_debug_mode_active = false
|
||||
|
||||
local dap = require("dap")
|
||||
local function gh(repo)
|
||||
return "https://github.com/" .. repo
|
||||
end
|
||||
|
||||
require("nvim-dap-repl-highlights").setup({})
|
||||
require("nvim-dap-virtual-text").setup({})
|
||||
require("persistent-breakpoints").setup({ load_breakpoints_event = { "BufReadPost" } })
|
||||
require("dapui").setup({
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({
|
||||
gh("Weissle/persistent-breakpoints.nvim"),
|
||||
})
|
||||
require("persistent-breakpoints").setup({
|
||||
load_breakpoints_event = { "BufReadPost" },
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
local function setup_dap()
|
||||
vim.pack.add({
|
||||
gh("mfussenegger/nvim-dap"),
|
||||
gh("rcarriga/nvim-dap-ui"),
|
||||
gh("nvim-neotest/nvim-nio"),
|
||||
gh("LiadOz/nvim-dap-repl-highlights"),
|
||||
gh("theHamsta/nvim-dap-virtual-text"),
|
||||
gh("leoluz/nvim-dap-go"),
|
||||
})
|
||||
|
||||
local dap = require("dap")
|
||||
|
||||
require("nvim-dap-repl-highlights").setup({})
|
||||
require("nvim-dap-virtual-text").setup({})
|
||||
require("dapui").setup({
|
||||
controls = { enabled = false },
|
||||
layouts = {
|
||||
{
|
||||
|
|
@ -20,15 +45,22 @@ require("dapui").setup({
|
|||
size = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("dap-go").setup({})
|
||||
})
|
||||
require("dap-go").setup({})
|
||||
|
||||
dap.adapters.codelldb = require("dap.codelldb")
|
||||
dap.adapters.codelldb = require("dap.codelldb")
|
||||
|
||||
local virtual_text = require("nvim-dap-virtual-text/virtual_text")
|
||||
local breakpoint_api = require("persistent-breakpoints.api")
|
||||
for _, sign in ipairs({
|
||||
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
|
||||
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
|
||||
{ "DapBreakpointCondition", { text = "🟥", texthl = "", linehl = "", numhl = "" } },
|
||||
}) do
|
||||
vim.fn.sign_define(unpack(sign))
|
||||
end
|
||||
|
||||
local stepping_keymaps = {
|
||||
local virtual_text = require("nvim-dap-virtual-text/virtual_text")
|
||||
|
||||
local stepping_keymaps = {
|
||||
{ "<F10>", function() dap.step_over() end },
|
||||
{ "<F11>", function() dap.step_into() end },
|
||||
{ "<F12>", function() dap.step_out() end },
|
||||
|
|
@ -45,53 +77,74 @@ local stepping_keymaps = {
|
|||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for _, sign in ipairs({
|
||||
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
|
||||
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
|
||||
{ "DapBreakpointCondition", { text = "🟥", texthl = "", linehl = "", numhl = "" } },
|
||||
}) do
|
||||
vim.fn.sign_define(unpack(sign))
|
||||
end
|
||||
|
||||
local function enter_debug_mode()
|
||||
local function enter_debug_mode()
|
||||
if is_debug_mode_active then return end
|
||||
utils.set_keymap_list(stepping_keymaps)
|
||||
is_debug_mode_active = true
|
||||
inlay_hints_handler.disable()
|
||||
require("dapui").open()
|
||||
end
|
||||
end
|
||||
|
||||
local function exit_debug_mode()
|
||||
local function exit_debug_mode()
|
||||
if not is_debug_mode_active then return end
|
||||
utils.del_keymap_list(stepping_keymaps)
|
||||
is_debug_mode_active = false
|
||||
inlay_hints_handler.restore()
|
||||
virtual_text.clear_virtual_text()
|
||||
require("dapui").close()
|
||||
end
|
||||
end
|
||||
|
||||
for _, request in ipairs({ "attach", "launch" }) do
|
||||
for _, request in ipairs({ "attach", "launch" }) do
|
||||
dap.listeners.before[request]["dapui_config"] = enter_debug_mode
|
||||
end
|
||||
end
|
||||
|
||||
for _, event in ipairs({ "event_terminated", "event_exited" }) do
|
||||
for _, event in ipairs({ "event_terminated", "event_exited" }) do
|
||||
dap.listeners.after[event]["dapui_config"] = exit_debug_mode
|
||||
end
|
||||
end
|
||||
|
||||
local function dap_stop()
|
||||
dap.terminate()
|
||||
dap.close()
|
||||
exit_debug_mode()
|
||||
local function with_dap(fn)
|
||||
return function(...)
|
||||
setup_dap()
|
||||
return fn(...)
|
||||
end
|
||||
end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "<leader>dr", dap.continue },
|
||||
{ "<leader>bt", breakpoint_api.toggle_breakpoint },
|
||||
{ "<leader>bc", breakpoint_api.set_conditional_breakpoint },
|
||||
{ "<leader>br", breakpoint_api.clear_all_breakpoints },
|
||||
{ "<leader>ds", dap_stop },
|
||||
{
|
||||
"<leader>dr",
|
||||
with_dap(function()
|
||||
require("dap").continue()
|
||||
end),
|
||||
},
|
||||
{
|
||||
"<leader>bt",
|
||||
function()
|
||||
require("persistent-breakpoints.api").toggle_breakpoint()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"<leader>bc",
|
||||
function()
|
||||
require("persistent-breakpoints.api").set_conditional_breakpoint()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"<leader>br",
|
||||
function()
|
||||
require("persistent-breakpoints.api").clear_all_breakpoints()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"<leader>ds",
|
||||
with_dap(function()
|
||||
local dap = require("dap")
|
||||
dap.terminate()
|
||||
dap.close()
|
||||
end),
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("LaunchTemplate", function()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
require("nvim-lightbulb").setup({
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({ "https://github.com/kosayoda/nvim-lightbulb" })
|
||||
require("nvim-lightbulb").setup({
|
||||
hide_in_unfocused_buffer = true,
|
||||
code_lenses = false, -- 0.12 shows code lenses as virtual lines natively
|
||||
sign = { enabled = true },
|
||||
|
|
@ -6,4 +10,6 @@ require("nvim-lightbulb").setup({
|
|||
float = { enabled = false },
|
||||
status_text = { enabled = false },
|
||||
autocmd = { enabled = true, updatetime = 25 },
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
require("tiny-glimmer").setup({
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({ "https://github.com/rachartier/tiny-glimmer.nvim" })
|
||||
require("tiny-glimmer").setup({
|
||||
refresh_interval_ms = 6,
|
||||
overwrite = {
|
||||
auto_map = true,
|
||||
|
|
@ -21,4 +25,6 @@ require("tiny-glimmer").setup({
|
|||
to_color = "Folded",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
require("tiny-inline-diagnostic").setup({
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.pack.add({ "https://github.com/rachartier/tiny-inline-diagnostic.nvim" })
|
||||
require("tiny-inline-diagnostic").setup({
|
||||
preset = "modern",
|
||||
transparent_bg = false,
|
||||
transparent_cursorline = false,
|
||||
|
|
@ -8,4 +12,6 @@ require("tiny-inline-diagnostic").setup({
|
|||
always_show = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue