From c436fe66fd0afadcfdb4cc8e106ef87f7cc390ed Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 23 Aug 2025 12:38:45 +0200 Subject: [PATCH] nvim: Always determine correct wrapping for wiki text files For any files under my WIKIROOT directory I am sure that they are textual (if they fall into the wrapping.nvim allowlist). So we do not need to undertake the 'nontextual' file heuristic that uses the capabilities of the language server connected. Especially since our ZK lsp, or markdown lsp would always return the capability. Unfortunately wrapping.nvim does not currently have the ability to provide your own 'nontextual' heuristic, so I instead use a fork which does and provide the correct function in the options. --- nvim/.config/nvim/lazy-lock.json | 2 +- nvim/.config/nvim/lua/plugins/prose.lua | 37 +++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 08406de..372427c 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -100,7 +100,7 @@ "vim-spellsync": { "branch": "master", "commit": "ea9f431483ceb40ede8bd5b126a03eccd49b1bc0" }, "wezterm.nvim": { "branch": "main", "commit": "f73bba23ab4becd146fa2d0a3a16a84b987eeaca" }, "which-key.nvim": { "branch": "main", "commit": "fcbf4eea17cb299c02557d576f0d568878e354a4" }, - "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, + "wrapping.nvim": { "branch": "feat/nontextual-detection-option", "commit": "f3eb5d36e518b62430fd705086bc83cf2b1e7ac2" }, "zen-mode.nvim": { "branch": "main", "commit": "04b52674b8c800f8b7d4609e8bd8d0212e3ffa79" }, "zk-nvim": { "branch": "main", "commit": "fd1ab2239ed85ca51051c094a49a280f4ed76bb2" } } diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 2e57fac..98a49b9 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -1,7 +1,7 @@ -- append t2 to t1 -- happens in-place, so it CHANGES t1 local function concat(t1, t2) - local tbl = {} + local tbl = {} for i = 1, #t1 do tbl[#tbl + 1] = t1[i] end @@ -85,14 +85,41 @@ local prose_plugs = { }, }, { - "andrewferrier/wrapping.nvim", + "marty-oehme/wrapping.nvim", + branch = "feat/nontextual-detection-option", opts = { create_keymaps = false, notify_on_switch = false, - -- softener = { quarto = true, markdown = true, text = true, asciidoc = true }, auto_set_mode_filetype_allowlist = prose_ft, + softener = { quarto = 2.0, markdown = 2.0, djot = 2.0 }, + nontextual_heuristic = function() + local nb = vim.tbl_get(vim.env, "ZK_NOTEBOOK_DIR") or vim.tbl_get(vim.env, "WIKIROOT") + if nb then + if vim.fn.expand("%:p:h"):find(nb) then + return false + end + return true + end + local get_clients + + if vim.fn.has("nvim-0.10") == 1 then + get_clients = vim.lsp.get_clients + else + get_clients = vim.lsp.get_active_clients + end + + for _, client in pairs(get_clients({ bufnr = 0 })) do + if + client.server_capabilities.definitionProvider + or client.server_capabilities.signatureHelpProvider + then + return true + end + end + + return false + end, }, - -- event = { "BufReadPre", "BufNewFile" }, ft = prose_ft, keys = { { @@ -114,7 +141,7 @@ local prose_plugs = { }, }, { - -- displays prettier md rendering + -- displays prettier md rendering "MeanderingProgrammer/render-markdown.nvim", opts = { file_types = md_like,