summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chaussé <Benjamin.Chausse@goto.com>2024-07-17 18:01:57 -0400
committerBenjamin Chaussé <Benjamin.Chausse@goto.com>2024-07-17 18:01:57 -0400
commitd2ab7879342f25db8e7728cd30a95364909f3f2b (patch)
tree4bb0cb9397324687adf84611a817ec72fbebff1a
parent664cccd1902a7eca54e06aad20a67f17be4fbc84 (diff)
Optimize startup time
-rw-r--r--lua/core/init.lua18
-rw-r--r--lua/plugins/cmp.lua1
-rw-r--r--lua/plugins/colorscheme.lua2
-rw-r--r--lua/plugins/dadbod.lua4
-rw-r--r--lua/plugins/harpoon.lua130
-rw-r--r--lua/plugins/lsp.lua27
6 files changed, 116 insertions, 66 deletions
diff --git a/lua/core/init.lua b/lua/core/init.lua
index 5326e40..f9caf4a 100644
--- a/lua/core/init.lua
+++ b/lua/core/init.lua
@@ -44,6 +44,24 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
end,
})
+-- Auto cd to git root of project (good for harpoon)
+local function is_git_repo()
+ local git_dir = vim.fn.systemlist("git rev-parse --show-toplevel")
+ if vim.v.shell_error ~= 0 then
+ return false
+ end
+ return git_dir[1]
+end
+
+local function cd_to_git_root()
+ local git_root = is_git_repo()
+ if git_root then
+ vim.cmd("tcd " .. git_root)
+ end
+end
+
+cd_to_git_root()
+
-- Quickly compile and preview files
vim.keymap.set("n", "<leader>c", "<cmd>make<cr>")
vim.keymap.set("n", "<leader>o", "<cmd>!opout %<cr>")
diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua
index e079910..fc296fa 100644
--- a/lua/plugins/cmp.lua
+++ b/lua/plugins/cmp.lua
@@ -1,5 +1,6 @@
return {
"hrsh7th/nvim-cmp",
+ event = "InsertEnter",
dependencies = {
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-buffer" },
diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua
index 5aeec35..60e4fbf 100644
--- a/lua/plugins/colorscheme.lua
+++ b/lua/plugins/colorscheme.lua
@@ -76,7 +76,7 @@ return {
{
"neanias/everforest-nvim",
version = false,
- priority = 1000,
+ enable = false,
config = function()
require("everforest").setup({
background = "hard",
diff --git a/lua/plugins/dadbod.lua b/lua/plugins/dadbod.lua
index 2e71f4a..f3ef317 100644
--- a/lua/plugins/dadbod.lua
+++ b/lua/plugins/dadbod.lua
@@ -4,4 +4,8 @@ return {
"kristijanhusak/vim-dadbod-ui",
"kristijanhusak/vim-dadbod-completion",
},
+ cmd = {
+ "DBUI",
+ "DBUIToggle",
+ },
}
diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua
index 3fb4661..52d91ba 100644
--- a/lua/plugins/harpoon.lua
+++ b/lua/plugins/harpoon.lua
@@ -5,59 +5,79 @@ return {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
- config = function()
- -- Cd to git root on startup to retain harpoons wherever vim starts
- local function is_git_repo()
- local git_dir = vim.fn.systemlist("git rev-parse --show-toplevel")
- if vim.v.shell_error ~= 0 then
- return false
- end
- return git_dir[1]
- end
-
- local function cd_to_git_root()
- local git_root = is_git_repo()
- if git_root then
- vim.cmd("tcd " .. git_root)
- end
- end
-
- cd_to_git_root()
-
- local harpoon = require("harpoon")
-
- harpoon:setup()
-
- -- harpoon keybindings
- vim.keymap.set("n", "<leader>a", function()
- harpoon:list():add()
- end)
- -- vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon:list()) end, {desc = "Open harpoon window"} )
- vim.keymap.set("n", "<C-e>", function()
- harpoon.ui:toggle_quick_menu(harpoon:list())
- end)
-
- vim.keymap.set("n", "<C-h>", function()
- harpoon:list():select(1)
- end)
- vim.keymap.set("n", "<C-j>", function()
- harpoon:list():select(2)
- end)
- vim.keymap.set("n", "<C-k>", function()
- harpoon:list():select(3)
- end)
- vim.keymap.set("n", "<C-l>", function()
- harpoon:list():select(4)
- end)
- vim.keymap.set("n", "<C-;>", function()
- harpoon:list():select(5)
- end)
-
- vim.keymap.set("n", "<C-S-P>", function()
- harpoon:list():prev()
- end)
- vim.keymap.set("n", "<C-S-N>", function()
- harpoon:list():next()
- end)
- end,
+ opts = {},
+ keys = {
+ { -- Add Harpoon
+ "<leader>a",
+ function()
+ require("harpoon"):list():add()
+ end,
+ mode = "n",
+ desc = "Add Harpoon",
+ },
+ { -- Edit Harpoons
+ "<C-e>",
+ function()
+ require("harpoon").ui:toggle_quick_menu(require("harpoon"):list())
+ end,
+ mode = "n",
+ desc = "Edit Harpoons",
+ },
+ { -- Select Harpoon 1
+ "<C-h>",
+ function()
+ require("harpoon"):list():select(1)
+ end,
+ mode = "n",
+ desc = "Select Harpoon 1",
+ },
+ { -- Select Harpoon 2
+ "<C-j>",
+ function()
+ require("harpoon"):list():select(2)
+ end,
+ mode = "n",
+ desc = "Select Harpoon 2",
+ },
+ { -- Select Harpoon 3
+ "<C-k>",
+ function()
+ require("harpoon"):list():select(3)
+ end,
+ mode = "n",
+ desc = "Select Harpoon 3",
+ },
+ { -- Select Harpoon 4
+ "<C-l>",
+ function()
+ require("harpoon"):list():select(4)
+ end,
+ mode = "n",
+ desc = "Select Harpoon 4",
+ },
+ { -- Select Harpoon 5
+ "<C-;>",
+ function()
+ require("harpoon"):list():select(5)
+ end,
+ mode = "n",
+ desc = "Select Harpoon 5",
+ },
+ { -- Select Previous Harpoon
+ "<C-S-P>",
+ function()
+ require("harpoon"):list():prev()
+ end,
+ mode = "n",
+ desc = "Select Previous Harpoon",
+ },
+ { -- Select Next Harpoon
+ "<C-S-N>",
+ function()
+ require("harpoon"):list():next()
+ end,
+ mode = "n",
+ desc = "Select Next Harpoon",
+ },
+ },
}
diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua
index 5dc67cb..4a5e6b9 100644
--- a/lua/plugins/lsp.lua
+++ b/lua/plugins/lsp.lua
@@ -1,9 +1,14 @@
return {
{
- "williamboman/mason.nvim",
+ "williamboman/mason-lspconfig.nvim",
dependencies = {
- "williamboman/mason-lspconfig.nvim",
+ "williamboman/mason.nvim",
},
+ event = { "BufReadPre", "BufNewFile" },
+ },
+ {
+ "williamboman/mason.nvim",
+ cmd = "Mason",
config = function()
local mason = require("mason")
local mlsp = require("mason-lspconfig")
@@ -40,23 +45,24 @@ return {
},
{
"neovim/nvim-lspconfig",
- veryLazy = true,
+ event = { "BufReadPre", "BufNewFile" },
dependencies = {
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"nvim-telescope/telescope.nvim",
},
config = function()
- -- Use icons in the sidebar
- local signs = { Error = "", Warn = "", Hint = "󰈈", Info = "" }
- for type, icon in pairs(signs) do
- local hl = "DiagnosticSign" .. type
- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
- end
-- Hide inline virtual text and use only the icons for debbuging/tips
vim.diagnostic.config({
virtual_text = false,
- signs = true,
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = "",
+ [vim.diagnostic.severity.WARN] = "",
+ [vim.diagnostic.severity.HINT] = "󰈈",
+ [vim.diagnostic.severity.INFO] = "",
+ },
+ },
underline = true,
})
@@ -220,6 +226,7 @@ return {
},
{
"zapling/mason-conform.nvim",
+ event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"stevearc/conform.nvim",