From 98c86a57f098bd3939e1e5af8203605f86e953fd Mon Sep 17 00:00:00 2001 From: Nicole Dresselhaus Date: Wed, 8 Oct 2025 10:12:22 +0200 Subject: [PATCH] hls etc. --- nvim-config/lazyvim.json | 1 - nvim-config/lua/plugins/haskell.lua | 58 +++++++++------------ nvim-config/lua/plugins/nvim-treesitter.lua | 23 ++++++-- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/nvim-config/lazyvim.json b/nvim-config/lazyvim.json index 84fd487..deb8394 100644 --- a/nvim-config/lazyvim.json +++ b/nvim-config/lazyvim.json @@ -15,7 +15,6 @@ "lazyvim.plugins.extras.editor.snacks_picker", "lazyvim.plugins.extras.editor.telescope", "lazyvim.plugins.extras.formatting.prettier", - "lazyvim.plugins.extras.lang.haskell", "lazyvim.plugins.extras.lang.json", "lazyvim.plugins.extras.lang.markdown", "lazyvim.plugins.extras.lang.nix", diff --git a/nvim-config/lua/plugins/haskell.lua b/nvim-config/lua/plugins/haskell.lua index cdb4245..55a188e 100644 --- a/nvim-config/lua/plugins/haskell.lua +++ b/nvim-config/lua/plugins/haskell.lua @@ -1,40 +1,32 @@ return { - "mrcjkb/haskell-tools.nvim", - ft = { "haskell", "lhaskell", "cabal" }, - dependencies = { "L3MON4D3/LuaSnip", "nvim-treesitter/nvim-treesitter" }, - opts = { + { + "mrcjkb/haskell-tools.nvim", + -- WICHTIG: expliziter Modulname; Lazy soll NICHT raten + main = "haskell-tools", + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, - hls = { - cmd = { "haskell-language-server-wrapper", "--lsp" }, - settings = { - haskell = { - formattingProvider = "fourmolu", - -- wir nutzen das interne Plugin, kein externes Binary nötig: - plugin = { fourmolu = { config = { external = false } } }, + -- Gib Lazy NICHT die Chance, sein Auto-setup zu machen: + -- Wir liefern EINE eigene config-Funktion und rufen setup() selbst. + config = function(_, _) + local ok, ht = pcall(require, "haskell-tools") + if not ok or type(ht.setup) ~= "function" then + vim.notify("[haskell-tools] setup() nicht gefunden – wird übersprungen", vim.log.levels.ERROR) + return + end - -- .cabal-Formatting komplett deaktivieren (sonst verlangt HLS cabal-fmt) - cabalFormattingProvider = "none", + ht.setup({ + hls = { + -- Dein Nix-HLS, damit Mason außen vor bleibt + cmd = { "haskell-language-server-wrapper", "--lsp" }, + settings = { + haskell = { + formattingProvider = "fourmolu", + cabalFormattingProvider = "none", + plugin = { fourmolu = { config = { external = false } } }, + }, + }, }, - }, - }, - -- optional: Safety im on_attach - on_attach = function(client, bufnr) - if vim.bo[bufnr].filetype == "cabal" then - client.server_capabilities.documentFormattingProvider = false - end - end, - -- falls Lazy mal falsch cached: lade LuaSnip aktiv vorher - init = function() - if not package.loaded["luasnip"] then - local ok, lazy = pcall(require, "lazy") - if ok then - lazy.load({ plugins = { "LuaSnip" } }) - end - end - end, - -- lade nur, wenn require("luasnip") wirklich klappt - cond = function() - return package.loaded["luasnip"] or pcall(require, "luasnip") + }) end, }, } diff --git a/nvim-config/lua/plugins/nvim-treesitter.lua b/nvim-config/lua/plugins/nvim-treesitter.lua index e56af8c..06ee50a 100644 --- a/nvim-config/lua/plugins/nvim-treesitter.lua +++ b/nvim-config/lua/plugins/nvim-treesitter.lua @@ -2,10 +2,12 @@ return { { "nvim-treesitter/nvim-treesitter", version = false, - lazy = false, -- <- wichtig: vor FileType-Kram geladen - priority = 1000, -- <- noch davor build = ":TSUpdate", - main = "nvim-treesiter.configs", + + -- Lazy ruft automatisch: require(main).setup(opts) + -- => Wir brauchen KEIN require('nvim-treesitter.configs') mehr. + main = "nvim-treesitter.configs", + opts = function(_, opts) opts = opts or {} opts.ensure_installed = vim.tbl_extend("force", opts.ensure_installed or {}, { @@ -23,5 +25,20 @@ return { opts.highlight.enable = true return opts end, + + -- Nur der Shim; KEIN require('nvim-treesitter.configs') hier! + config = function() + local ok, parsers = pcall(require, "nvim-treesitter.parsers") + if ok and parsers and parsers.ft_to_lang == nil then + local langmod = vim.treesitter.language + if langmod and type(langmod.get_lang) == "function" then + parsers.ft_to_lang = function(ft) + return langmod.get_lang(ft) or ft + end + elseif type(parsers.filetype_to_parsername) == "function" then + parsers.ft_to_lang = parsers.filetype_to_parsername + end + end + end, }, }