X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/d904f57127bdcc3ea9a6deec3e12e7e1430cb188..b47ffe60e244c9165f40371736079320ea2d848b:/nvim/lua/plugins/lsp.lua diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index cfb909a..d020443 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -3,63 +3,121 @@ return { { "neovim/nvim-lspconfig", ---@class PluginLspOpts - -- - init = function () + opts = function() local keys = require("lazyvim.plugins.lsp.keymaps").get() - -- TODO: setup a new mapping for this -- { "gr", "Telescope lsp_references", 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", }, + + return { + diagnostics = { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_mani", + prefix = "●", + }, + severity_sort = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.HINT] = " ", + [vim.diagnostic.severity.INFO] = " ", + }, + }, + }, + inlay_hints = { enabled = false, }, + codelens = { enabled = false, }, + document_highlight = { enabled = true, }, + capabilities = { + workspace = { + fileOperations = { + didRename = true, + willRename = true, + }, + }, + }, + format = { + formatting_options = nil, + timeout_ms = nil, + }, + -- Automatically format on save + -- autoformat = false, + -- LSP Server Settings + ---@type lspconfig.options + servers = { + lua_ls = { + settings = { + Lua = { + workspace = { checkThirdParty = false, }, + codeLens = { enable = true, }, + completion = { callSnippet = "Replace", }, + doc = { privateName = { "^_" }, }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = "Disable", + semicolon = "Disable", + arrayIndex = "Disable", + }, + diagnostics = { + disable = { "missing-fields", }, + }, }, }, }, + -- Add clangd extensions + -- https://github.com/p00f/clangd_extensions.nvim }, - -- 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, + -- 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 + 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, }, - 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 - 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, + } + end, + }, + + -- cmdline tools and lsp servers + { + + "williamboman/mason.nvim", + cmd = "Mason", + keys = { { "cm", "Mason", desc = "Mason" } }, + opts = { + ensure_installed = { + "stylua", + "shfmt", + -- "flake8", }, }, + ---@param opts MasonSettings | {ensure_installed: string[]} + config = function(_, opts) + require("mason").setup(opts) + local mr = require("mason-registry") + local function ensure_installed() + for _, tool in ipairs(opts.ensure_installed) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end + end + if mr.refresh then + mr.refresh(ensure_installed) + else + ensure_installed() + end + end, }, }