]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/lsp/init.lua
systemd: add bugwarrior sync timer service
[dotfiles.git] / nvim / lua / plugins / lsp / init.lua
index 351f0606ae2dd9b748f0817e15d080318f3615e3..99fab99a5ce55fb459230f2df627a08eef45a612 100644 (file)
@@ -1,6 +1,6 @@
 return {
   { "neovim/nvim-lspconfig",
 return {
   { "neovim/nvim-lspconfig",
-    event = "LazyFile",
+    event = { "BufReadPost", "BufNewFile", "BufWritePre" },
     dependencies = {
       "mason.nvim",
       { "williamboman/mason-lspconfig.nvim", config = function() end }, -- don't configure yet
     dependencies = {
       "mason.nvim",
       { "williamboman/mason-lspconfig.nvim", config = function() end }, -- don't configure yet
@@ -83,7 +83,6 @@ return {
     },
     ---@param opts PluginLspOpts
     config = function(_, opts)
     },
     ---@param opts PluginLspOpts
     config = function(_, opts)
-      local lspconfig = require('lspconfig')
       for server, config in pairs(opts.servers) do
         local capabilities = vim.tbl_deep_extend("force",
           vim.lsp.protocol.make_client_capabilities() or {},
       for server, config in pairs(opts.servers) do
         local capabilities = vim.tbl_deep_extend("force",
           vim.lsp.protocol.make_client_capabilities() or {},
@@ -91,25 +90,23 @@ return {
           config.capabilities or {}
         )
         config.capabilities = capabilities
           config.capabilities or {}
         )
         config.capabilities = capabilities
-        lspconfig[server].setup(config)
+        vim.lsp.config(server, config)
       end
 
       -- setup keymaps
       end
 
       -- setup keymaps
-      LazyVim.lsp.on_attach(function(client, buffer)
+      rmz.lsp.on_attach(function(client, buffer)
         require("plugins.lsp.keymaps").on_attach(client, buffer)
       end)
 
         require("plugins.lsp.keymaps").on_attach(client, buffer)
       end)
 
-      LazyVim.lsp.setup()
-      LazyVim.lsp.on_dynamic_capability(require("plugins.lsp.keymaps").on_attach)
+      rmz.lsp.setup()
+      rmz.lsp.on_dynamic_capability(require("plugins.lsp.keymaps").on_attach)
       -- TODO: should vim.diagnostics be condigured directly?
       vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
 
       -- get all the servers that are available through mason-lspconfig
       -- TODO: should vim.diagnostics be condigured directly?
       vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
 
       -- get all the servers that are available through mason-lspconfig
-      local have_mason, mlsp = pcall(require, "mason-lspconfig")
-      local all_mslp_servers = {}
-      if have_mason then
-        all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
-      end
+      local mlsp = require("mason-lspconfig")
+      -- TODO: use mason-lspconfig.get_available_servers()?
+      local all_mslp_servers = require("mason-lspconfig").get_mappings().lspconfig_to_package
 
       local ensure_installed = {} ---@type string[]
       for server, server_opts in pairs(opts.servers) do
 
       local ensure_installed = {} ---@type string[]
       for server, server_opts in pairs(opts.servers) do
@@ -118,7 +115,7 @@ return {
           if server_opts.enabled ~= false then
             -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
             if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
           if server_opts.enabled ~= false then
             -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
             if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
-              require("lspconfig")[server].setup(server_opts)
+              vim.lsp.config(server, server_opts)
             else
               ensure_installed[#ensure_installed + 1] = server
             end
             else
               ensure_installed[#ensure_installed + 1] = server
             end
@@ -126,16 +123,14 @@ return {
         end
       end
 
         end
       end
 
-      if have_mason then
-        mlsp.setup({
-          ensure_installed = vim.tbl_deep_extend(
-            "force",
-            ensure_installed,
-            LazyVim.opts("mason-lspconfig.nvim").ensure_installed or {}
-          ),
-          handlers = { setup },
-        })
-      end
+      mlsp.setup({
+        ensure_installed = vim.tbl_deep_extend(
+          "force",
+          ensure_installed,
+          rmz.lazy.opts("mason-lspconfig.nvim").ensure_installed or {}
+        ),
+        handlers = { setup },
+      })
     end
   },
   { "williamboman/mason.nvim",
     end
   },
   { "williamboman/mason.nvim",