]> git.rmz.io Git - dotfiles.git/commitdiff
nvim: configure lsp servers (pylsp, ruff_lsp, lua_ls)
authorSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:15:19 +0000 (17:15 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:23:08 +0000 (17:23 +0000)
nvim/lua/plugins/lsp.lua

index 7fd027497dc74794e6b4488576f246d89e8e71b9..cfb909a6b32cc12340f88e91bf4d44a5ae007210 100644 (file)
@@ -11,5 +11,55 @@ return {
       -- { "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" },
       keys[#keys+1] = { "gr", false }
     end,
       -- { "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" },
       keys[#keys+1] = { "gr", false }
     end,
-  }
+    opts = {
+      -- Automatically format on save
+      -- autoformat = false,
+      -- LSP Server Settings
+      ---@type lspconfig.options
+      servers = {
+        lua_ls = {
+          settings = {
+            Lua = {
+              diagnostics = {
+                disable = { "missing-fields", },
+              },
+            },
+          },
+        },
+        -- Add clangd extensions
+        -- https://github.com/p00f/clangd_extensions.nvim
+        ruff_lsp = {
+          root_dir = function(fname)
+            return require("lspconfig.util").root_pattern("pyproject.toml", "setup.cfg", "ruff.toml")(fname)
+          end,
+        },
+        pylsp = {
+          settings = {
+            pylsp = {
+              plugins = {
+                autopep8 = { enabled = false },
+                flake8 = { enabled = false },
+                mccabe = { enabled = false },
+                pycodestyle = { enabled = false },
+                pydocstyle = { enabled = false },
+                pyflakes = { enabled = false },  -- covered by flake8
+              }
+            }
+          }
+        }
+      },
+      -- you can do any additional lsp server setup here
+      -- return true if you don't want this server to be setup with lspconfig
+      ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
+      setup = {
+        -- example to setup with typescript.nvim
+        -- tsserver = function(_, opts)
+        --   require("typescript").setup({ server = opts })
+        --   return true
+        -- end,
+        -- Specify * to use this function as a fallback for any server
+        -- ["*"] = function(server, opts) end,
+      },
+    },
+  },
 }
 }