Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Dynamic setup per filetype #45

Closed
ChristianChiarulli opened this issue Jul 23, 2021 · 2 comments
Closed

Dynamic setup per filetype #45

ChristianChiarulli opened this issue Jul 23, 2021 · 2 comments

Comments

@ChristianChiarulli
Copy link

I'm not sure if this is possible but I figured I would ask.

What I am looking for is for null-ls to only configure what it needs for the filetype that it's looking at. Or append configuration as it sees filetypes.

For example:

  • filetype js: eslint and prettier are configured
  • filetype py: flake8 and black are configured
  • etc..

What I'm trying to avoid is instantiating null-ls with all of my configuration up front. I would like to wait until it's absolutely necessary to pass that config.

There may be an inherent limitations with how lsp-config or the language servers work in general. If that's the case it's not that big of a deal, but if something can be done to support this I would appreciate it.

@jose-elias-alvarez
Copy link
Owner

jose-elias-alvarez commented Jul 23, 2021

I actually spun null-ls off from a TypeScript-/JavaScript-specific plugin which sets up its null-ls integrations dynamically in an LSP on_attach callback. As long as you've set up the nvim-lspconfig integration somewhere, you should be able to use require("null-ls").register({ sources = ... }) pretty much anywhere that makes sense (LSP callbacks, autocommands) and everything should work as expected, but feel free to open an issue if you run into any weird behavior.

I'm curious – are you seeing any specific issues with startup time?

@ChristianChiarulli
Copy link
Author

The register function was exactly what I was looking for. Also I don't seem to have any noticeable startup issues.

I think this issue can be closed, null-ls seems to check all the boxes for my needs. I will also put in some other issues for supporting more builtins, if I have time I will add them myself. Thanks for the response.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants