Change mappings, better lazy loading

This commit is contained in:
Jiří Štefka 2023-03-10 19:08:40 +01:00
parent 74f9b467fa
commit 8d6d4c1894

View file

@ -155,6 +155,8 @@ local config = {
mappings = { mappings = {
-- first key is the mode -- first key is the mode
n = { n = {
["<leader>ft"] = false,
["<leader>fT"] = { function() require("telescope.builtin").colorscheme { enable_preview = true } end, desc = "Find themes" },
-- second key is the lefthand side of the map -- second key is the lefthand side of the map
-- mappings seen under group name "Buffer" -- mappings seen under group name "Buffer"
["<leader>bb"] = { "<cmd>tabnew<cr>", desc = "New tab" }, ["<leader>bb"] = { "<cmd>tabnew<cr>", desc = "New tab" },
@ -210,6 +212,7 @@ local config = {
["<leader>du"] = { function() require("dapui").toggle() end, desc = "Toggle Debugger UI" }, ["<leader>du"] = { function() require("dapui").toggle() end, desc = "Toggle Debugger UI" },
["<leader>dh"] = { function() require("dap.ui.widgets").hover() end, desc = "Debugger Hover" }, ["<leader>dh"] = { function() require("dap.ui.widgets").hover() end, desc = "Debugger Hover" },
-- Mardown preview -- Mardown preview
["<leader>m"] = { name = "Markdown" },
["<leader>mp"] = { "<cmd>MarkdownPreview<cr>", desc = "Markdown preview" }, ["<leader>mp"] = { "<cmd>MarkdownPreview<cr>", desc = "Markdown preview" },
["<leader>ms"] = { "<cmd>MarkdownPreviewStop<cr>", desc = "Markdown preview stop" }, ["<leader>ms"] = { "<cmd>MarkdownPreviewStop<cr>", desc = "Markdown preview stop" },
["<leader>mt"] = { "<cmd>MarkdownPreviewToggle<cr>", desc = "Markdown preview toggle" }, ["<leader>mt"] = { "<cmd>MarkdownPreviewToggle<cr>", desc = "Markdown preview toggle" },
@ -237,10 +240,11 @@ local config = {
["<leader>xX"] = { "<cmd>VimtexReloadState<cr>", desc = "Reload the state for the current buffer" }, ["<leader>xX"] = { "<cmd>VimtexReloadState<cr>", desc = "Reload the state for the current buffer" },
["<leader>xs"] = { "<cmd>VimtexToggleMain<cr>", desc = "Set current file as 'current project'" }, ["<leader>xs"] = { "<cmd>VimtexToggleMain<cr>", desc = "Set current file as 'current project'" },
["<leader>xa"] = { "<cmd>VimtexContextMenu<cr>", desc = "Show context menu" }, ["<leader>xa"] = { "<cmd>VimtexContextMenu<cr>", desc = "Show context menu" },
["<leader>ft"] = { name = "Trouble, Tagbar" },
-- Taglist -- Taglist
["<leader>fT"] = { "<cmd>TlistToggle<cr>", desc = "Tagbar toggle " }, ["<leader>ftT"] = { "<cmd>TlistToggle<cr>", desc = "Tagbar toggle " },
-- Trouble -- Trouble
-- ["<leader>ft"] = { name = "Trouble" },
["<leader>ftx"] = { "<cmd>TroubleToggle<cr>", desc = "Toggle Trouble" }, ["<leader>ftx"] = { "<cmd>TroubleToggle<cr>", desc = "Toggle Trouble" },
["<leader>ftw"] = { "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace diagnostics" }, ["<leader>ftw"] = { "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace diagnostics" },
["<leader>ftd"] = { "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document diagnostics" }, ["<leader>ftd"] = { "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document diagnostics" },
@ -248,11 +252,12 @@ local config = {
["<leader>ftl"] = { "<cmd>TroubleToggle loclist<cr>", desc = "Loc List" }, ["<leader>ftl"] = { "<cmd>TroubleToggle loclist<cr>", desc = "Loc List" },
["<leader>ftR"] = { "<cmd>TroubleToggle lsp_references<cr>", desc = "Lsp references" }, ["<leader>ftR"] = { "<cmd>TroubleToggle lsp_references<cr>", desc = "Lsp references" },
-- ["<leader>ftt"] = { "<cmd>TodoTrouble<cr>", desc = "Todo Trouble" }, -- ["<leader>ftt"] = { "<cmd>TodoTrouble<cr>", desc = "Todo Trouble" },
--
-- Autosave -- Autosave
["<C-s>"] = { "<cmd>ASToggle<cr>", desc = "Toggle autosave" }, ["<C-s>"] = { "<cmd>ASToggle<cr>", desc = "Toggle autosave" },
["<leader>fs"] = { "<cmd>ASToggle<cr>", desc = "Toggle autosave" }, ["<leader>fs"] = { "<cmd>ASToggle<cr>", desc = "Toggle autosave" },
-- Carbon code sharing -- Carbon code sharing
["<leader>S"] = { "CarbonNow", desc = "Share code on Carbon", silent = true }, ["<leader>s"] = { "CarbonNow", desc = "Share code on Carbon", silent = true },
}, },
v = { v = {
-- Carbon code sharing -- Carbon code sharing
@ -331,20 +336,20 @@ local config = {
-- end, -- end,
-- }, -- },
-- By adding to the which-key config and using our helper function you can add more which-key registered bindings -- By adding to the which-key config and using our helper function you can add more which-key registered bindings
{ -- {
"folke/which-key.nvim", -- "folke/which-key.nvim",
config = function(plugin, opts) -- config = function(plugin, opts)
require "plugins.configs.which-key" (plugin, opts) -- require "plugins.configs.which-key" (plugin, opts)
-- Add bindings which show up as group name -- -- Add bindings which show up as group name
local wk = require "which-key" -- local wk = require "which-key"
wk.register({ -- wk.register({
m = { name = "Markdown" }, -- m = { name = "Markdown" },
ft = { name = "Trouble" }, -- ft = { name = "Trouble" },
b = { name = "Buffers" }, -- b = { name = "Buffers" },
}, { mode = "n", prefix = "<leader>" }) -- }, { mode = "n", prefix = "<leader>" })
end, -- end,
}, -- },
--
{ {
-- override nvim-cmp plugin -- override nvim-cmp plugin
@ -378,7 +383,7 @@ local config = {
-- Editorconfig -- Editorconfig
{ {
"editorconfig/editorconfig-vim", "editorconfig/editorconfig-vim",
event = "BufRead" event = "User AstroFile"
}, },
-- You can also add new plugins here as well: -- You can also add new plugins here as well:
@ -421,7 +426,7 @@ local config = {
-- Comments -- Comments
{ {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
event = "BufEnter", event = "User AstroFile",
}, },
-- Show todo comments, warnings, errors, ... -- Show todo comments, warnings, errors, ...
{ {
@ -473,7 +478,7 @@ local config = {
-- Basic editor functionality -- Basic editor functionality
{ {
"Pocco81/auto-save.nvim", "Pocco81/auto-save.nvim",
event = "UIEnter", event = "User AstroFile",
config = function() config = function()
require("auto-save").setup() require("auto-save").setup()
end, end,