fix(formatters): always select null-ls by default (#1810)

This commit is contained in:
kylo252 2021-10-20 20:01:51 +02:00 committed by GitHub
parent cfdd5e61f9
commit 03e5760e59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View file

@ -19,7 +19,7 @@ end
local function make_formatters_info(ft)
local null_formatters = require "lvim.lsp.null-ls.formatters"
local registered_formatters = null_formatters.list_supported_names(ft)
local registered_formatters = null_formatters.list_registered_providers(ft)
local supported_formatters = null_formatters.list_available(ft)
local section = {
"Formatters info",
@ -37,7 +37,7 @@ end
local function make_linters_info(ft)
local null_linters = require "lvim.lsp.null-ls.linters"
local supported_linters = null_linters.list_available(ft)
local registered_linters = null_linters.list_supported_names(ft)
local registered_linters = null_linters.list_registered_providers(ft)
local section = {
"Linters info",
fmt(
@ -151,6 +151,7 @@ function M.toggle_popup(ft)
vim.cmd('let m=matchadd("LvimInfoIdentifier", " ' .. ft .. '$")')
vim.cmd 'let m=matchadd("string", "true")'
vim.cmd 'let m=matchadd("string", "active")'
vim.cmd 'let m=matchadd("boolean", "inactive")'
vim.cmd 'let m=matchadd("string", "")'
vim.cmd 'let m=matchadd("error", "false")'
-- tbl_set_highlight(registered_providers, "LvimInfoIdentifier")

View file

@ -104,12 +104,12 @@ return {
-- add formatter
local formatters = require "lvim.lsp.null-ls.formatters"
local supported_formatters = formatters.list_supported_names(buf_ft)
local supported_formatters = formatters.list_registered_providers(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local linters = require "lvim.lsp.null-ls.linters"
local supported_linters = linters.list_supported_names(buf_ft)
local supported_linters = linters.list_registered_providers(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
return table.concat(buf_client_names, ", ")

View file

@ -86,15 +86,14 @@ function M.common_capabilities()
end
local function select_default_formater(client)
local client_formatting = client.resolved_capabilities.document_formatting
or client.resolved_capabilities.document_range_formatting
if client.name == "null-ls" or not client_formatting then
if client.name == "null-ls" or not client.resolved_capabilities.document_formatting then
return
end
Log:debug("Checking for formatter overriding for " .. client.name)
local formatters = require "lvim.lsp.null-ls.formatters"
local client_filetypes = client.config.filetypes or {}
for _, filetype in ipairs(client_filetypes) do
if lvim.lang[filetype] and #vim.tbl_keys(lvim.lang[filetype].formatters) > 0 then
if #vim.tbl_keys(formatters.list_registered_providers(filetype)) > 0 then
Log:debug("Formatter overriding detected. Disabling formatting capabilities for " .. client.name)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false

View file

@ -4,7 +4,7 @@ local null_ls = require "null-ls"
local services = require "lvim.lsp.null-ls.services"
local Log = require "lvim.core.log"
function M.list_supported_names(filetype)
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
local formatter_method = null_ls_methods.internal["FORMATTING"]
local registered_providers = services.list_registered_providers_names(filetype)

View file

@ -4,7 +4,7 @@ local null_ls = require "null-ls"
local services = require "lvim.lsp.null-ls.services"
local Log = require "lvim.core.log"
function M.list_supported_names(filetype)
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
local linter_method = null_ls_methods.internal["DIAGNOSTICS"]
local registered_providers = services.list_registered_providers_names(filetype)