Skip to content

Commit

Permalink
fix(language): add nix language support with my own config
Browse files Browse the repository at this point in the history
  • Loading branch information
roeybenarieh committed Sep 7, 2024
1 parent 1456ce5 commit b391813
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/plugins/all_imports.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
import = "plugins.languages.nix",
}
35 changes: 35 additions & 0 deletions lua/plugins/languages/nix/nil_nix_lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- nix lsp client named nil
return {
-- tell mason to install nil
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed or {}, { "nil" })
end,
},
-- add nil to nvim-lspconfig

{
"neovim/nvim-lspconfig",
opts = {
servers = { nil_ls = {} },
setup = {
["nil_ls"] = function()
LazyVim.lsp.on_attach(function(client, _)
if client.name == "nil_ls" then
client.settings = {
["nil"] = {
testSetting = 42,
formatting = {
command = { "nixpkgs-fmt" },
},
},
}
end
end)
end,
},
},
},
-- added nix to telescope languages
}
28 changes: 28 additions & 0 deletions lua/plugins/languages/nix/nixpkgs_fmt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- nix formatter named nixpkgs_fmt
return {
-- tell mason to install nixpkgs_fmt
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed or {}, { "nixpkgs-fmt" })
end,
},
-- add alejandra to null-ls
{
"nvimtools/none-ls.nvim",
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.nixpkgs_fmt)
end,
},
-- tell conform to use alejandra
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["nix"] = { "nixpkgs-fmt " },
},
},
},
}

0 comments on commit b391813

Please sign in to comment.