Set up Nix LSP and auto-formatting in VSCode

wip
Bo Jeanes 2024-07-19 15:59:27 +10:00
parent 8e31752f8a
commit c292c57e32
No known key found for this signature in database
4 changed files with 87 additions and 0 deletions

7
.vscode/extensions.json vendored 100644
View File

@ -0,0 +1,7 @@
{
"recommendations": [
"jeff-hykin.better-nix-syntax",
"pinage404.nix-extension-pack",
"mkhl.direnv"
]
}

14
.vscode/settings.json vendored 100644
View File

@ -0,0 +1,14 @@
{
"nix.enableLanguageServer": true,
"nix.formatterPath": "nixpkgs-fmt",
"nix.serverSettings": {
"nil": {
"formatting": {
"command": [
"nixpkgs-fmt"
],
}
}
},
"direnv.restart.automatic": true,
}

View File

@ -169,6 +169,32 @@
"type": "github" "type": "github"
} }
}, },
"nil": {
"inputs": {
"flake-utils": [
"nixvim",
"devshell",
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1717086091,
"narHash": "sha256-GmsEQa4HZeMfec37LZnwG/Lt/XmqFLXsjv5QWojeNiM=",
"owner": "oxalica",
"repo": "nil",
"rev": "ab3ddb8f063774cf7e22eb610f5ecfdb77309f3c",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "nil",
"type": "github"
}
},
"nix-darwin": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -293,6 +319,7 @@
"_1password-shell-plugins": "_1password-shell-plugins", "_1password-shell-plugins": "_1password-shell-plugins",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"nil": "nil",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nixos-flake": "nixos-flake", "nixos-flake": "nixos-flake",
@ -301,6 +328,31 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
} }
}, },
"rust-overlay": {
"inputs": {
"flake-utils": [
"nil",
"flake-utils"
],
"nixpkgs": [
"nil",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717035469,
"narHash": "sha256-MzH+yjKULH3HCRj9QCTwBvqq4LZkR0ZqRE/QfGOGC2E=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "095702e63a40e86f339d11864da9dc965b70a01e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": { "systems": {
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1681028828,

View File

@ -36,6 +36,12 @@
treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
nil = {
url = "github:oxalica/nil";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "nixvim/devshell/flake-utils";
};
}; };
outputs = inputs@{ self, ... }: outputs = inputs@{ self, ... }:
@ -383,6 +389,14 @@
treefmt.config = { treefmt.config = {
projectRootFile = "flake.lock"; projectRootFile = "flake.lock";
programs.nixpkgs-fmt.enable = true; programs.nixpkgs-fmt.enable = true;
programs.nixpkgs-fmt.package = pkgs.nixpkgs-fmt;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
inputs.nil.packages.${system}.nil
nixpkgs-fmt
];
}; };
}; };
} }