From cb5a6aa05c7cd32fdd1f6134672629f43877f5aa Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 22 May 2025 08:53:04 +0100 Subject: [PATCH] Configure lua-language-server and nixd --- .nvim.lua | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 3 ++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/.nvim.lua b/.nvim.lua index 75c9c505..2f839b98 100644 --- a/.nvim.lua +++ b/.nvim.lua @@ -3,3 +3,65 @@ vim.keymap.set("n", "fn", function() cwd = "modules/home-manager/coding/neovim/config" }) end) + +require("conform").setup { + formatters_by_ft = { + lua = { "stylua" }, + nix = { "nixfmt" }, + }, +} + +require("lint").linters_by_ft = { + lua = { "luacheck" }, + nix = { "nix" }, +} + +local lspconfig = require "lspconfig" + +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + +lspconfig.lua_ls.setup { + capabilities = capabilities, + + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + + diagnostics = { + globals = { "vim" }, + }, + + runtime = { + version = "LuaJIT", + }, + + telemetry = { + enabled = false, + }, + + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + }, + }, +} + +lspconfig.nixd.setup { + capabilities = capabilities, + + cmd = { "nixd" }, + + settings = { + nixd = { + nixpkgs = { + expr = "import { }", + }, + + formatting = { + command = "nix fmt", + }, + }, + }, +} diff --git a/flake.nix b/flake.nix index 5a17ef04..f45828db 100644 --- a/flake.nix +++ b/flake.nix @@ -54,8 +54,9 @@ { devShells.${system}.default = pkgs.mkShell { packages = with pkgs; [ - lua54Packages.luacheck just + lua-language-server + lua54Packages.luacheck nixd ]; };