Skip to content

Commit

Permalink
feat(nix): Add LSP documentation on nixpkgs and flake
Browse files Browse the repository at this point in the history
  • Loading branch information
sbulav committed Oct 24, 2024
1 parent c03c90d commit a281e35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion nix/modules/darwin/tools/lsp/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
options,
inputs,
config,
lib,
pkgs,
Expand All @@ -14,6 +14,7 @@ in {
};

config = mkIf cfg.enable {
nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
environment.systemPackages = with pkgs; [
lua-language-server # LSP for lua
marksman # LSP for markdown
Expand Down
2 changes: 2 additions & 0 deletions nix/modules/nixos/tools/lsp/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
inputs,
options,
config,
lib,
Expand All @@ -14,6 +15,7 @@ in {
};

config = mkIf cfg.enable {
nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
environment.systemPackages = with pkgs; [
lua-language-server # LSP for lua
marksman # LSP for markdown
Expand Down
28 changes: 19 additions & 9 deletions nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,33 @@ return {
end,
-- manually configured servers
require("lspconfig")["helm_ls"].setup {},

require("lspconfig").nixd.setup {
cmd = { "nixd" },
settings = {
nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }",
-- For flake.
-- This expression will be interpreted as "nixpkgs" toplevel
-- Nixd provides package, lib completion/information from it.
-- Resource Usage: Entries are lazily evaluated, entire nixpkgs takes 200~300MB for just "names".
-- Package documentation, versions, are evaluated by-need.
expr = "import (builtins.getFlake(toString ./.)).inputs.nixpkgs { }",
},
formatting = {
command = { "alejandra" }, -- or nixfmt or nixpkgs-fmt
},
-- options = {
-- nixos = {
-- expr = '(builtins.getFlake "/PATH/TO/FLAKE").nixosConfigurations.CONFIGNAME.options',
-- },
-- home_manager = {
-- expr = '(builtins.getFlake "/PATH/TO/FLAKE").homeConfigurations.CONFIGNAME.options',
-- },
-- },
options = {
nixos = {
expr = "let flake = builtins.getFlake(toString ./.); in flake.nixosConfigurations.nz.options",
},
home_manager = {
expr = 'let flake = builtins.getFlake(toString ./.); in flake.homeConfigurations."sab@mbp16".options',
},
darwin = {
expr = "let flake = builtins.getFlake(toString ./.); in flake.darwinConfigurations.mbp16.options",
},
},
},
},
},
Expand Down Expand Up @@ -196,6 +205,7 @@ return {
-- "pyright",
-- "black",
-- "marksman",
-- "nixd"
"lua-language-server",
},
},
Expand Down

0 comments on commit a281e35

Please sign in to comment.