added formatter for nix, nixd was not working.

Welcome to the config, conform.nvim!
This commit is contained in:
Gabe Venberg 2026-03-15 18:05:50 +01:00
parent 46208d9102
commit 35fb7ffcb1
4 changed files with 34 additions and 45 deletions

24
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1773231277,
"narHash": "sha256-Xy3WEpUAbpsz8ydgvVAQAGGB/WB+8cNA5cshiL0McTI=",
"lastModified": 1773507054,
"narHash": "sha256-Q8U5VXgrcxmCxPtCCJCIZkcAX3FCZwGh1GNVIXxMND0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "75690239f08f885ca9b0267580101f60d10fbe62",
"rev": "e80236013dc8b77aa49ca90e7a12d86f5d8d64c9",
"type": "github"
},
"original": {
@ -19,11 +19,11 @@
"plugins-lze": {
"flake": false,
"locked": {
"lastModified": 1772949858,
"narHash": "sha256-skLhmn/MvxOZbrBiceF/xiLRRmmEs6ZQS2sGrBrUyLU=",
"lastModified": 1773555725,
"narHash": "sha256-Ii/mrCHw8kw1IN0GIROm7O0NSz1jtDligb/qDNq1P3U=",
"owner": "BirdeeHub",
"repo": "lze",
"rev": "a3ba1a2d469d4ab26acb629aba8c7d70a6cbe558",
"rev": "1d05835370e841c1605ec88d0541195c9410c34e",
"type": "github"
},
"original": {
@ -35,11 +35,11 @@
"plugins-lzextras": {
"flake": false,
"locked": {
"lastModified": 1772949841,
"narHash": "sha256-MQ1h2R5axM3u6mLNTDzXF/40o8+U0JOWb48UTQO9jfc=",
"lastModified": 1773555737,
"narHash": "sha256-fG8glvgoeFRHU6fgfBTb5GUxY+2YY3QfqzVYERa7ogs=",
"owner": "BirdeeHub",
"repo": "lzextras",
"rev": "a6ac9a7bee380881af2dfbfd238ccb1697d677d7",
"rev": "88f70fe95e3a6c4dc841ebed3b23c1f92c5cde42",
"type": "github"
},
"original": {
@ -63,11 +63,11 @@
]
},
"locked": {
"lastModified": 1773360496,
"narHash": "sha256-AQN5UhIc2WHvELT4TWIsD1W05ksLXWRkS5NjPm3jkc0=",
"lastModified": 1773553469,
"narHash": "sha256-DY3xNV1kgPEHX8X9HG7Uix5OIt0MQri8i7X+BqGM4DI=",
"owner": "BirdeeHub",
"repo": "nix-wrapper-modules",
"rev": "8f1770c6d58a89a4757849713c0e6d9ace7b4ac3",
"rev": "c53fd67dbf1cccec37b8216128e5b647e70bd149",
"type": "github"
},
"original": {

View file

@ -12,7 +12,6 @@ if lspEnabled then
vim.keymap.set("n", "<leader>lt", vim.lsp.buf.type_definition, { desc = "Type [D]efinition" })
vim.keymap.set({ "n", "v", }, "<leader>la", vim.lsp.buf.code_action, { desc = "[C]ode Action" })
vim.keymap.set("n", "<leader>ld", vim.lsp.buf.definition, { desc = "Goto [D]efinition" })
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "Format buffer" })
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Hover Documentation" })
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "[R]ename" })
vim.keymap.set("n", "<leader>ls", vim.lsp.buf.signature_help, { desc = "Signature Documentation" })
@ -81,10 +80,29 @@ require('lze').load {
vim.lsp.enable(plugin.name)
end,
},
{
"conform.nvim",
for_cat = "lsp",
on_require = { "conform" },
cmd = { "ConformInfo" },
keys = { { "<leader>lf", function() require("conform").format({async=true}) end, mode = { "" }, desc = "Format buffer" }, },
after = function()
require("conform").setup({
default_format_opts = {
lsp_format = "fallback",
},
formatters_by_ft = {
nix = { "alejandra" }
}
})
end,
},
{ import = "lsp.lua" },
{ import = "lsp.python" },
{ import = "lsp.C" },
{ import = "lsp.nix" },
{ import = "lsp.typst" },
{ import = "lsp.bash" },
{ import = "lsp.zk" },

View file

@ -1,27 +0,0 @@
return {
{
"nixd",
enabled = nixInfo.isNix, -- mason doesn't have nixd
for_cat = "nix",
lsp = {
filetypes = { "nix" },
settings = {
nixd = {
nixpkgs = {
expr = [[import <nixpkgs> {}]],
},
options = {
},
formatting = {
command = { "nixfmt" }
},
diagnostic = {
suppress = {
"sema-escaping-with"
}
}
}
},
},
},
}

View file

@ -115,7 +115,6 @@ inputs: {
config.specs.completion = {
after = ["lze"];
lazy = true;
enable = lib.mkIf config.settings.minimal false;
data = with pkgs.vimPlugins; [
luasnip
friendly-snippets
@ -129,7 +128,6 @@ inputs: {
config.specs.markdown = {
after = ["general" "lazy"];
enable = lib.mkIf config.settings.minimal false;
lazy = true;
data = with pkgs.vimPlugins; [
markdown-preview-nvim
@ -142,7 +140,6 @@ inputs: {
};
config.specs.lsp = {
enable = lib.mkIf config.settings.minimal false;
after = ["general" "lazy"];
lazy = true;
@ -150,9 +147,11 @@ inputs: {
trouble-nvim
lualine-lsp-progress
nvim-lspconfig
conform-nvim
];
};
config.specs.zk = {
after = ["general" "lazy"];
data = with pkgs.vimPlugins; [
@ -180,7 +179,6 @@ inputs: {
after = ["general" "lazy"];
data = null;
extraPackages = with pkgs; [
nixd
alejandra
];
};