Finally added a formatter and LSP for nix

This commit is contained in:
2024-12-26 17:21:27 +02:00
parent 3137d24a62
commit 8bb6abc6d4
3 changed files with 28 additions and 5 deletions

View File

@@ -137,4 +137,21 @@ return {
},
},
}, -- zig
nixd = {
mason = false,
cmd = { 'nixd' },
settings = {
nixd = {
nixpkgs = { expr = 'import <nixpkgs> { }' },
options = {
nixos = {
expr = '(builtins.getFlake "/home/kyren/dotfiles/flake.nix").nixosConfigurations.laptop-nixos.options',
},
home_manager = {
expr = '(builtins.getFlake "/home/kyren/dotfiles/flake.nix").homeConfigurations.laptop-nixos.options',
},
},
},
},
},
}

View File

@@ -3,10 +3,10 @@ return {
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{ '<leader>ft', '<cmd>FormatToggle<cr>', desc = '[F]ormat [T]oggle Globally' },
{ '<leader>ft', '<cmd>FormatToggle<cr>', desc = '[F]ormat [T]oggle Globally' },
{ '<leader>fT', '<cmd>FormatToggle!<cr>', desc = '[F]ormat [T]oggle Locally' },
{ '<leader>ff', '<cmd>Format<cr>', desc = '[F]ormat [F]ile' },
{ '<leader>f', '<cmd>Format<cr><esc>', desc = '[F]ormat', mode = 'v' },
{ '<leader>ff', '<cmd>Format<cr>', desc = '[F]ormat [F]ile' },
{ '<leader>f', '<cmd>Format<cr><esc>', desc = '[F]ormat', mode = 'v' },
},
---@module "conform"
---@type conform.setupOpts
@@ -24,6 +24,8 @@ return {
['css'] = { 'prettierd', 'prettier', stop_after_first = true },
['javascript'] = { 'prettierd', 'prettier', stop_after_first = true },
['typescript'] = { 'prettierd', 'prettier', stop_after_first = true },
-- ['nix'] = { 'nixfmt' },
-- ['nix'] = { 'alejandra' },
},
format_on_save = function(bufnr)
-- Disable with a global or buffer local variable

View File

@@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, pkgs, inputs, ... }:
{
home.username = "kyren";
@@ -78,8 +78,13 @@
gitleaks
rar
gomodifytags
nixfmt-rfc-style
alejandra
nixd
];
nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
@@ -114,7 +119,6 @@
};
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}