add nix lsp and formatter

This commit is contained in:
2025-03-28 02:47:53 +01:00
parent 3a6258ccf0
commit fbead62967
5 changed files with 87 additions and 26 deletions

59
lua/config/lsp/nix.lua Normal file
View File

@@ -0,0 +1,59 @@
local ok, lspconfig, conform, lint = pcall(function()
return
require("lspconfig"),
require("conform"),
require("lint")
end)
if not ok then
return
end
lspconfig.nixd.setup({
-- capabilities = cmp_nvim_lsp.default_capabilities()
capabilities = require("config/lsp/lsp-capabilities"),
on_attach = require("config/lsp/lsp-attach"),
settings = {
nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }",
},
-- formatting = {
-- command = { "nixfmt" },
-- },
},
},
})
-- conform.setup({
-- formatters_by_ft = {
-- nix = { "nixfmt" },
-- },
-- format_on_save = {
-- async = false,
-- timeout_ms = 500,
-- lsp_format = "fallback",
-- },
-- })
--
-- vim.keymap.set({ "n", "v" }, "<leader>lf", function()
-- conform.format({
-- async = false,
-- timeout_ms = 500,
-- lsp_format = "fallback",
-- })
-- end, { desc = "Format" })
-- lint.linters_by_ft = {
-- lua = { "luacheck" },
-- }
--
-- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
-- callback = function()
-- lint.try_lint()
-- end,
-- })
--
-- vim.keymap.set("n", "<leader>ll", function()
-- lint.try_lint()
-- end, { desc = "Lint" })