This repository has been archived by the owner on Aug 12, 2023. It is now read-only.
How to get the list of attached sources #789
Answered
by
jose-elias-alvarez
SamiAlsubhi
asked this question in
Q&A
-
I am trying to get all the attached Lsps and null-ls sources. I am able to get the attached Lsps. For null-ls active resources i am getting all the resources rather than the active ones! how can i get only the active ones? local null_ls= require('null-ls')
local lsp_info= function()
local active_clients = ''
local no_clients = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) ~= nil then
for _, client in ipairs(clients) do
if client.name ~= 'null-ls' then
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
active_clients = active_clients ..','.. client.name
end
end
end
end
local sources = null_ls.get_sources()
if next(sources) ~= nil then
for _,source in ipairs(sources) do
if null_ls.is_registered(source.name) then
active_clients = active_clients ..','.. source.name
end
end
end
--
if active_clients == '' then
return no_clients
end
return active_clients:sub(2)
end
|
Beta Was this translation helpful? Give feedback.
Answered by
jose-elias-alvarez
Apr 2, 2022
Replies: 1 comment
-
You can get a list of active sources for the current buffer using |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SamiAlsubhi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can get a list of active sources for the current buffer using
require("null-ls.sources").get_available(vim.bo.filetype)
(replace with the filetype of the buffer you want to check if you care about buffers other than the current).