Skip to content

Commit

Permalink
feat(nvim): add base config for nil and nixpkgs-fmt
Browse files Browse the repository at this point in the history
Still has problem: Your LSP client doesn't support confimration. You can
enable autoArchive in lsp configuration.
  • Loading branch information
workflow committed Jan 15, 2024
1 parent 4a74a2d commit 953a671
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 10 deletions.
107 changes: 101 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nil.url = "github:oxalica/nil";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs-vim-enmasse-branch.url = "github:workflow/nixpkgs/vimplugins-enmasse";
Expand All @@ -20,7 +21,7 @@
};
};

outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-vim-enmasse-branch, nixos-hardware, home-manager, secrets, ... }@inputs:
outputs = { self, nil, nixpkgs, nixpkgs-unstable, nixpkgs-vim-enmasse-branch, nixos-hardware, home-manager, secrets, ... }@inputs:
let
overlays = {
nixpkgs-vim-enmasse-branch = import nixpkgs-vim-enmasse-branch {
Expand Down
6 changes: 4 additions & 2 deletions home/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, inputs, ... }:
let
vim-enmasse-branch = pkgs.nixpkgs-vim-enmasse-branch;

Expand Down Expand Up @@ -406,6 +406,8 @@ in
extraPackages = [
pkgs.shellcheck
pkgs.shfmt
pkgs.nixpkgs-fmt
inputs.nil.packages.x86_64-linux.default # Nix Language Server by Oxalica
];

plugins = with pkgs.vimPlugins; [
Expand Down Expand Up @@ -648,7 +650,7 @@ in
vim-numbertoggle
{
plugin = mason-nvim; # Automatically install LSP servers
config = builtins.readFile ./lsp.lua;
config = builtins.replaceStrings ["LSP_PATH"] ["${inputs.nil.packages.x86_64-linux.default}/bin/nil"] (builtins.readFile ./lsp.lua);
type = "lua";
}
{
Expand Down
15 changes: 14 additions & 1 deletion home/neovim/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ local servers = {
-- diagnostics = { disable = { 'missing-fields', 'undefined-global' } },
},
},
-- nil_ls = {}, -- nix
julials = {},
pyright = {},
rust_analyzer = {
Expand Down Expand Up @@ -156,3 +155,17 @@ mason_lspconfig.setup_handlers {
}
end,
}

local lsp_path = 'LSP_PATH'
require('lspconfig').nil_ls.setup {
autostart = true,
capabilities = capabilities,
cmd = { lsp_path },
settings = {
['nil'] = {
formatting = {
command = { "nixpkgs-fmt" },
},
},
},
}

0 comments on commit 953a671

Please sign in to comment.