]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lsp.lua
Merge branch 'lazyvim'
[dotfiles.git] / nvim / lua / plugins / lsp.lua
1 return {
2 -- lspconfig
3 {
4 "neovim/nvim-lspconfig",
5 ---@class PluginLspOpts
6 --
7 init = function ()
8 local keys = require("lazyvim.plugins.lsp.keymaps").get()
9
10 -- TODO: setup a new mapping for this
11 -- { "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" },
12 keys[#keys+1] = { "gr", false }
13 end,
14 opts = {
15 -- Automatically format on save
16 -- autoformat = false,
17 -- LSP Server Settings
18 ---@type lspconfig.options
19 servers = {
20 lua_ls = {
21 settings = {
22 Lua = {
23 diagnostics = {
24 disable = { "missing-fields", },
25 },
26 },
27 },
28 },
29 -- Add clangd extensions
30 -- https://github.com/p00f/clangd_extensions.nvim
31 ruff_lsp = {
32 root_dir = function(fname)
33 return require("lspconfig.util").root_pattern("pyproject.toml", "setup.cfg", "ruff.toml")(fname)
34 end,
35 },
36 pylsp = {
37 settings = {
38 pylsp = {
39 plugins = {
40 autopep8 = { enabled = false },
41 flake8 = { enabled = false },
42 mccabe = { enabled = false },
43 pycodestyle = { enabled = false },
44 pydocstyle = { enabled = false },
45 pyflakes = { enabled = false }, -- covered by flake8
46 }
47 }
48 }
49 }
50 },
51 -- you can do any additional lsp server setup here
52 -- return true if you don't want this server to be setup with lspconfig
53 ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
54 setup = {
55 -- example to setup with typescript.nvim
56 -- tsserver = function(_, opts)
57 -- require("typescript").setup({ server = opts })
58 -- return true
59 -- end,
60 -- Specify * to use this function as a fallback for any server
61 -- ["*"] = function(server, opts) end,
62 },
63 },
64 },
65
66 -- cmdline tools and lsp servers
67 {
68
69 "williamboman/mason.nvim",
70 cmd = "Mason",
71 keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
72 opts = {
73 ensure_installed = {
74 "stylua",
75 "shfmt",
76 -- "flake8",
77 },
78 },
79 ---@param opts MasonSettings | {ensure_installed: string[]}
80 config = function(_, opts)
81 require("mason").setup(opts)
82 local mr = require("mason-registry")
83 local function ensure_installed()
84 for _, tool in ipairs(opts.ensure_installed) do
85 local p = mr.get_package(tool)
86 if not p:is_installed() then
87 p:install()
88 end
89 end
90 end
91 if mr.refresh then
92 mr.refresh(ensure_installed)
93 else
94 ensure_installed()
95 end
96 end,
97 },
98 }