1
0
Fork 0

lsp: unconditionally load setup

This commit is contained in:
Felipe 2024-06-24 12:00:54 -04:00
parent 5076180f27
commit 6d72a4c713
Signed by: pitbuster
SSH key fingerprint: SHA256:OM3HeVSA96adfy2Gi8OhZkQBY67P88LoJUwkeVoTArQ

View file

@ -282,38 +282,14 @@ cmp.setup({
}), }),
}) })
---- LSP ---- ---- LSP ----
vim.g.lsp_loaded = false vim.cmd("packadd nvim-lspconfig")
vim.api.nvim_create_autocmd({ "FileType" }, { vim.cmd("packadd lsp_lines.nvim")
pattern = { -- vim.cmd("packadd lsp-timeout.nvim")
"c",
"cpp",
"dot",
"go",
"javascript",
"json",
"latex",
"lua",
"python",
"rust",
"terraform",
"tex",
"toml",
"typescript",
"typst",
},
callback = function()
if vim.g.lsp_loaded == true then
return
end
vim.g.lsp_loaded = true
vim.cmd("packadd nvim-lspconfig")
vim.cmd("packadd lsp_lines.nvim")
-- vim.cmd("packadd lsp-timeout.nvim")
local lsp = require("lspconfig") local lsp = require("lspconfig")
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_lsp_attach = function(_client, _bufnr) local on_lsp_attach = function(_client, _bufnr)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration) vim.keymap.set("n", "gD", vim.lsp.buf.declaration)
vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "K", vim.lsp.buf.hover) vim.keymap.set("n", "K", vim.lsp.buf.hover)
@ -330,11 +306,11 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
-- vim.keymap.segcjk("n", "<F3>", function() -- vim.keymap.segcjk("n", "<F3>", function()
-- vim.lsp.buf.format({ async = true }) -- vim.lsp.buf.format({ async = true })
-- end) -- end)
end end
-- Use a loop to conveniently call 'setup' on multiple servers and -- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches -- map buffer local keybindings when the language server attaches
local servers = { local servers = {
clangd = { clangd = {
filetypes = { "c", "cpp" } filetypes = { "c", "cpp" }
}, },
@ -377,11 +353,11 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
cmd = { "pnpm", "exec", "biome", "lsp-proxy" } cmd = { "pnpm", "exec", "biome", "lsp-proxy" }
}, },
typst_lsp = {}, typst_lsp = {},
} }
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
lsp.util.default_config = vim.tbl_deep_extend("force", lsp.util.default_config, { capabilities = capabilities }) lsp.util.default_config = vim.tbl_deep_extend("force", lsp.util.default_config, { capabilities = capabilities })
for server, add_to_config in pairs(servers) do for server, add_to_config in pairs(servers) do
local config = { local config = {
on_attach = on_lsp_attach, on_attach = on_lsp_attach,
flags = { flags = {
@ -392,25 +368,23 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
config[k] = v config[k] = v
end end
lsp[server].setup(config) lsp[server].setup(config)
end end
vim.cmd("LspStart") vim.cmd("LspStart")
---- lsp_lines ---- lsp_lines
require("lsp_lines").setup() require("lsp_lines").setup()
-- Disable virtual_text since it's redundant due to lsp_lines. -- Disable virtual_text since it's redundant due to lsp_lines.
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = false, virtual_text = false,
})
---- lsp-timeout
-- vim.g["lsp-timeout-config"] = {
-- stopTimeout = 1000 * 60 * 5, -- ms, timeout before stopping all LSP servers
-- startTimeout = 1000 * 2, -- ms, timeout before restart
-- silent = false -- true to suppress notifications
-- }
end,
}) })
---- lsp-timeout
-- vim.g["lsp-timeout-config"] = {
-- stopTimeout = 1000 * 60 * 5, -- ms, timeout before stopping all LSP servers
-- startTimeout = 1000 * 2, -- ms, timeout before restart
-- silent = false -- true to suppress notifications
-- }
-- -- Auto format on save -- -- Auto format on save
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, { -- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
-- callback = function() -- callback = function()