X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/b99dee25318e48024313b76e075a24afccd0c10b..11b9e4b2c7692dd5b3f645f2257057c676063cdf:/nvim/lua/rmz/util/lsp.lua?ds=inline diff --git a/nvim/lua/rmz/util/lsp.lua b/nvim/lua/rmz/util/lsp.lua index 7424803..662781c 100644 --- a/nvim/lua/rmz/util/lsp.lua +++ b/nvim/lua/rmz/util/lsp.lua @@ -189,58 +189,6 @@ function M.disable(server, cond) end) end ----@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)} -function M.formatter(opts) - opts = opts or {} - local filter = opts.filter or {} - filter = type(filter) == "string" and { name = filter } or filter - ---@cast filter lsp.Client.filter - ---@type LazyFormatter - local ret = { - name = "LSP", - primary = true, - priority = 1, - format = function(buf) - M.format(LazyVim.merge({}, filter, { bufnr = buf })) - end, - sources = function(buf) - local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf })) - ---@param client vim.lsp.Client - local ret = vim.tbl_filter(function(client) - return client.supports_method("textDocument/formatting") - or client.supports_method("textDocument/rangeFormatting") - end, clients) - ---@param client vim.lsp.Client - return vim.tbl_map(function(client) - return client.name - end, ret) - end, - } - return LazyVim.merge(ret, opts) --[[@as LazyFormatter]] -end - ----@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter - ----@param opts? lsp.Client.format -function M.format(opts) - opts = vim.tbl_deep_extend( - "force", - {}, - opts or {}, - LazyVim.opts("nvim-lspconfig").format or {}, - LazyVim.opts("conform.nvim").format or {} - ) - local ok, conform = pcall(require, "conform") - -- use conform for formatting with LSP when available, - -- since it has better format diffing - if ok then - opts.formatters = {} - conform.format(opts) - else - vim.lsp.buf.format(opts) - end -end - M.action = setmetatable({}, { __index = function(_, action) return function()