Skip to content

Commit

Permalink
feat(lsp_attach): Increase performance + lsp_attach check
Browse files Browse the repository at this point in the history
updated startup events, added check to enable keymaps only when LSP has been attached
  • Loading branch information
daUnknownCoder committed Feb 17, 2024
1 parent b50125c commit 8e78a17
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions lua/NeutronVim/plugins/LSP/lspconfig.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
return {
{
"neovim/nvim-lspconfig",
event = "BufReadPre",
event = { "BufEnter", "BufNewFile" },
lazy = true,
dependencies = {
{
"hrsh7th/cmp-nvim-lsp",
event = { "BufReadPost", "BufNewFile" },
lazy = true,
},
{
Expand All @@ -30,39 +31,40 @@ return {
local keymap = vim.keymap.set
-- luacheck: ignore 212
local on_attach = function(client, bufnr)
print("LSP Attached to buffer.")
keymap(
"n",
"\\f",
"<cmd>Lspsaga finder ref+def+imp+tyd<CR>",
{ noremap = true, silent = true, desc = "LSP Finder [Ref, Def, Imp, Tyd] " }
)
keymap(
"n",
"[d",
"<cmd>Lspsaga diagnostic_jump_prev<CR>",
{ noremap = true, silent = true, desc = "Diagnostic Jump Prev" }
)
keymap(
"n",
"]d",
"<cmd>Lspsaga diagnostic_jump_next<CR>",
{ noremap = true, silent = true, desc = "Diagnostic Jump Next" }
)
require("lsp_signature").on_attach({
bind = true,
debug = true,
floating_window = true,
floating_window_above_cur_line = true,
hint_enable = true,
fix_pos = false,
-- floating_window_above_first = true,
log_path = vim.fn.expand("$HOME") .. "/tmp/sig.log",
padding = " ",
handler_opts = {
border = "rounded",
},
}, bufnr)
if client then
keymap(
"n",
"\\f",
"<cmd>Lspsaga finder ref+def+imp+tyd<CR>",
{ noremap = true, silent = true, desc = "LSP Finder [Ref, Def, Imp, Tyd] " }
)
keymap(
"n",
"[d",
"<cmd>Lspsaga diagnostic_jump_prev<CR>",
{ noremap = true, silent = true, desc = "Diagnostic Jump Prev" }
)
keymap(
"n",
"]d",
"<cmd>Lspsaga diagnostic_jump_next<CR>",
{ noremap = true, silent = true, desc = "Diagnostic Jump Next" }
)
require("lsp_signature").on_attach({
bind = true,
debug = true,
floating_window = true,
floating_window_above_cur_line = true,
hint_enable = true,
fix_pos = false,
-- floating_window_above_first = true,
log_path = vim.fn.expand("$HOME") .. "/tmp/sig.log",
padding = " ",
handler_opts = {
border = "rounded",
},
}, bufnr)
end
end
local capabilities = cmp_nvim_lsp.default_capabilities()
local signs = {
Expand Down

0 comments on commit 8e78a17

Please sign in to comment.