From 953a671de533080e1077e41e91d19bbc5ddffd41 Mon Sep 17 00:00:00 2001 From: workflow <4farlion@gmail.com> Date: Mon, 15 Jan 2024 17:34:32 +0000 Subject: [PATCH] feat(nvim): add base config for nil and nixpkgs-fmt Still has problem: Your LSP client doesn't support confimration. You can enable autoArchive in lsp configuration. --- flake.lock | 107 +++++++++++++++++++++++++++++++++++++--- flake.nix | 3 +- home/neovim/default.nix | 6 ++- home/neovim/lsp.lua | 15 +++++- 4 files changed, 121 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index e2bcdf41..5fa6b804 100644 --- a/flake.lock +++ b/flake.lock @@ -57,6 +57,24 @@ "inputs": { "systems": "systems" }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_2" + }, "locked": { "lastModified": 1694529238, "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", @@ -130,6 +148,26 @@ "type": "github" } }, + "nil": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1704611696, + "narHash": "sha256-4ZCgV5oHdEc3q+XaIzy//gh20uC/aSuAtMU9bsfgLZk=", + "owner": "oxalica", + "repo": "nil", + "rev": "059d33a24bb76d2048740bcce936362bf54b5bc9", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "nil", + "type": "github" + } + }, "nix": { "inputs": { "lowdown-src": "lowdown-src", @@ -251,6 +289,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1702346276, "narHash": "sha256-eAQgwIWApFQ40ipeOjVSoK4TEHVd6nbSd9fApiHIw5A=", @@ -266,7 +320,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1694593561, "narHash": "sha256-WSaIQZ5s9N9bDFkEMTw6P9eaZ9bv39ZhsiW12GtTNM0=", @@ -312,8 +366,8 @@ }, "rmob": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1694731476, @@ -332,14 +386,40 @@ "inputs": { "devenv": "devenv", "home-manager": "home-manager", + "nil": "nil", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-vim-enmasse-branch": "nixpkgs-vim-enmasse-branch", "rmob": "rmob", "secrets": "secrets" } }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "nil", + "flake-utils" + ], + "nixpkgs": [ + "nil", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704593904, + "narHash": "sha256-nDoXZDTRdgF3b4n3m011y99nYFewvOl9UpzFvP8Rb3c=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c36fd70a99decfa6e110c86f296a97613034a680", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "secrets": { "inputs": { "nixpkgs": [ @@ -347,8 +427,8 @@ ] }, "locked": { - "lastModified": 1704913002, - "narHash": "sha256-faWxrXdy5bgpNttHSYe5RNTzRfcLmUHWGk73n6NAbCI=", + "lastModified": 1705103708, + "narHash": "sha256-oyGixmxGLY9PnUt+/Ay1IO6n1/17TqsgQRBfTCZOyfg=", "path": "/home/farlion/code/nixos-secrets", "type": "path" }, @@ -371,6 +451,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f18d284c..db7c89a4 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; @@ -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 { diff --git a/home/neovim/default.nix b/home/neovim/default.nix index 2eb0d096..79aee9d3 100644 --- a/home/neovim/default.nix +++ b/home/neovim/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, inputs, ... }: let vim-enmasse-branch = pkgs.nixpkgs-vim-enmasse-branch; @@ -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; [ @@ -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"; } { diff --git a/home/neovim/lsp.lua b/home/neovim/lsp.lua index dca83358..19f5a416 100644 --- a/home/neovim/lsp.lua +++ b/home/neovim/lsp.lua @@ -124,7 +124,6 @@ local servers = { -- diagnostics = { disable = { 'missing-fields', 'undefined-global' } }, }, }, - -- nil_ls = {}, -- nix julials = {}, pyright = {}, rust_analyzer = { @@ -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" }, + }, + }, + }, +}