From 35fb7ffcb12097c637ce7a95b57c233575f8b2d5 Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Sun, 15 Mar 2026 18:05:50 +0100 Subject: [PATCH] added formatter for nix, nixd was not working. Welcome to the config, conform.nvim! --- flake.lock | 24 ++++++++++++------------ lua/lsp/init.lua | 22 ++++++++++++++++++++-- lua/lsp/nix.lua | 27 --------------------------- module.nix | 6 ++---- 4 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 lua/lsp/nix.lua diff --git a/flake.lock b/flake.lock index 6836d9d..6e5ed33 100644 --- a/flake.lock +++ b/flake.lock @@ -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": { diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 66d1e61..d7f6291 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -12,7 +12,6 @@ if lspEnabled then vim.keymap.set("n", "lt", vim.lsp.buf.type_definition, { desc = "Type [D]efinition" }) vim.keymap.set({ "n", "v", }, "la", vim.lsp.buf.code_action, { desc = "[C]ode Action" }) vim.keymap.set("n", "ld", vim.lsp.buf.definition, { desc = "Goto [D]efinition" }) - vim.keymap.set("n", "lf", vim.lsp.buf.format, { desc = "Format buffer" }) vim.keymap.set("n", "lh", vim.lsp.buf.hover, { desc = "Hover Documentation" }) vim.keymap.set("n", "lr", vim.lsp.buf.rename, { desc = "[R]ename" }) vim.keymap.set("n", "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 = { { "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" }, diff --git a/lua/lsp/nix.lua b/lua/lsp/nix.lua deleted file mode 100644 index 4463427..0000000 --- a/lua/lsp/nix.lua +++ /dev/null @@ -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 {}]], - }, - options = { - }, - formatting = { - command = { "nixfmt" } - }, - diagnostic = { - suppress = { - "sema-escaping-with" - } - } - } - }, - }, - }, -} diff --git a/module.nix b/module.nix index 58498c5..9f9e25a 100644 --- a/module.nix +++ b/module.nix @@ -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 ]; };