summaryrefslogtreecommitdiff
path: root/lua/core/galaxyline.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-07-31 06:06:08 +0200
committerGitHub <[email protected]>2021-07-31 00:06:08 -0400
commit9d89929d9bb47d1f78c2d3945b761da2f24a5643 (patch)
tree7f5d281ddb4bbdcecffe01c0234d02be32ede1f7 /lua/core/galaxyline.lua
parent6f4dd8471b24f71ed6712fb6b9acc0ac79b9137a (diff)
Enable querying lang-server formatting capabilities (#1078)
Diffstat (limited to 'lua/core/galaxyline.lua')
-rw-r--r--lua/core/galaxyline.lua30
1 files changed, 9 insertions, 21 deletions
diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua
index cf7d35d0..2aae0242 100644
--- a/lua/core/galaxyline.lua
+++ b/lua/core/galaxyline.lua
@@ -6,6 +6,8 @@ if not status_ok then
return
end
+local utils = require "utils"
+
-- NOTE: if someone defines colors but doesn't have them then this will break
local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette")
if not palette_status_ok then
@@ -200,36 +202,22 @@ table.insert(gls.right, {
},
})
--- TODO: this function doesn't need to be this complicated
local function get_attached_provider_name(msg)
msg = msg or "LSP Inactive"
- local buf_ft = vim.bo.filetype
local buf_clients = vim.lsp.buf_get_clients()
if next(buf_clients) == nil then
return msg
end
-
- local utils = require "utils"
- local config = require("null-ls.config").get()
- local builtins = require "null-ls.builtins"
- -- concat all the builtin formatters and linters from null-ls
- local all_things = builtins.formatting
- for k, v in pairs(builtins.diagnostics) do
- all_things[k] = v
- end
-
- -- if we open multiple filetypes in the same session
- -- null-ls will register multiple formatter/linters
- -- but only use the ones that support vim.bo.filetype
- -- so we need to filter them
+ local buf_ft = vim.bo.filetype
local buf_client_names = {}
+ local null_ls_providers = require("lsp.null-ls").requested_providers
for _, client in pairs(buf_clients) do
if client.name == "null-ls" then
- -- for every registered formatter/linter in the current buffer
- for _, v in pairs(config._names) do
- -- show only the ones that are being used for the current filetype
- if utils.has_value(all_things[v].filetypes, buf_ft) then
- table.insert(buf_client_names, v)
+ for _, provider in pairs(null_ls_providers) do
+ if vim.tbl_contains(provider.filetypes, buf_ft) then
+ if not vim.tbl_contains(buf_client_names, provider.name) then
+ table.insert(buf_client_names, provider.name)
+ end
end
end
else