Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lua/null-ls/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,24 @@ M.setup = function(user_config)
vim.api.nvim_create_user_command("NullLsInfo", function()
require("null-ls.info").show_window()
end, {})

vim.api.nvim_create_user_command("NullLsLog", function()
vim.cmd(string.format("edit %s", require("null-ls.logger"):get_path()))
end, {})

vim.api.nvim_create_user_command("NullLsToggle", function(opts)
M.toggle(opts.args)
end, {
nargs = 1,
complete = function()
local list = {}
for _, source in ipairs(M.get_sources()) do
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this complete with sources active for the current filetype?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it for all registered sources for the current filetype, since it needs to re-enable them again.

list[#list + 1] = source.name
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a possibility of duplicate sources here, e.g. if the user has eslint registered for both formatting and diagnostics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will depend on how source.toggle() should behave, and since it's only eslint, I think it's probably fine to leave it like this?
otherwise, we'd need something similar to how LspStop handles nargs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just pass eslint to source.toggle() it'll toggle all sources matching the given query, which in this case means it'll toggle all sources named eslint. I think this would be the least surprising behavior for users, and there's at least a few other sources that share names, so I think we should deduplicate them.

end
return list
end,
})

local augroup = vim.api.nvim_create_augroup("NullLs", {})
vim.api.nvim_create_autocmd("FileType", {
group = augroup,
Expand Down