Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

feat(langs,nix): Add nix language support #399

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions doc/doom_nvim_modules.norg
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ version: 0.0.11
- {@ ../lua/doom/modules/langs/kotlin/init.lua}[`kotlin`]
- {@ ../lua/doom/modules/langs/java/init.lua}[`java`]
- {@ ../lua/doom/modules/langs/go/init.lua}[`go`]
- {@ ../lua/doom/modules/langs/nix/init.lua}[`nix`]
- {@ ../lua/doom/modules/langs/config/init.lua}[`config`] Adds JSON, YAML, TOML support
- Missing a language? Submit a feature request issue.

Expand Down
1 change: 1 addition & 0 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Modules are grouped into 3 categories:
- [`kotlin`](../lua/doom/modules/langs/kotlin)
- [`java`](../lua/doom/modules/langs/java)
- [`go`](../lua/doom/modules/langs/go)
- [`nix`](../lua/doom/modules/langs/nix/init.lua)
- [`config`](../lua/doom/modules/langs/config) Adds JSON, YAML, TOML support
- Missing a language? Submit a feature request issue.

Expand Down
55 changes: 55 additions & 0 deletions lua/doom/modules/langs/nix/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
local nix = {}

nix.settings = {
formatter = "nixpkgs_fmt",
code_actions = {
statix = true,
},
diagnostic = {
statix = true,
deadnix = true,
},
}

nix.autocmds = {
{
"BufWinEnter",
"*.nix",
function()
local utils = require("doom.utils")
local langs_utils = require("doom.modules.langs.utils")

require("nvim-treesitter.install").ensure_installed("nix")

langs_utils.use_lsp("rnix-lsp")

-- Setup null-ls
if utils.is_module_enabled("features", "linter") then
local null_ls = require("null-ls")

local null_ls_source = {}

if null_ls.builtins.formatting[nix.settings.formatter] then
table.insert(null_ls_source, null_ls.builtins.formatting[nix.settings.formatter])
end

if nix.settings.code_actions.statix then
table.insert(null_ls_source, null_ls.builtins.code_actions.statix)
end

if nix.settings.diagnostic.statix then
table.insert(null_ls_source, null_ls.builtins.diagnostics.statix)
end

if nix.settings.diagnostic.deadnix then
table.insert(null_ls_source, null_ls.builtins.diagnostics.deadnix)
end

langs_utils.use_null_ls_source(null_ls_source)
end
end,
once = true,
},
}

return nix
1 change: 1 addition & 0 deletions modules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ return {
-- "markdown",
-- "terraform", -- Terraform / hcl files support
-- "dockerfile",
-- "nix", -- Nix declarations
},
}

Expand Down