Skip to content

Doesn't support installing mlp with for example pipx install markdown_live_preview #1

@tuurep

Description

@tuurep

I think the plugin is needlessly strict on how the main program is installed, my first instinct was to use:

pipx install markdown_live_preview

(https://github.com/pypa/pipx)

I tried a quick hack like this:

diff --git a/lua/mdpreview/init.lua b/lua/mdpreview/init.lua
index 5a73b19..45c65b0 100644
--- a/lua/mdpreview/init.lua
+++ b/lua/mdpreview/init.lua
@@ -43,15 +43,9 @@ local function find_suitable_port()
 end

 M.preview_open = function(bufnr)
-    local python = get_python()
-    if python == nil then
-        vim.notify("mdpreview: Python installation not found", vim.log.levels.ERROR)
-        return
-    end
-
-    vim.fn.system({python, "-m", "markdown_live_preview", "-h"})
-    if vim.v.shell_error ~= 0 then
-        vim.notify("mdpreview: mlp not installed. Try ':lua require('mdpreview').install_mlp()'", vim.log.levels.WARN)
+    vim.fn.system({ "mlp", "-h" })
+    if vim.v.shell_error ~= 0 then
+        vim.notify("mdpreview: mlp not installed. Try 'pipx install markdown_live_preview'", vim.log.levels.WARN)
         return
     end

@@ -62,7 +56,7 @@ M.preview_open = function(bufnr)
         end
     end

-    local opts = { python, "-m", "markdown_live_preview"}
+    local opts = { "mlp" }
     if not M.config.follow then table.insert(opts, "--no-follow") end
     if not M.config.browser then table.insert(opts, "--no-browser") end
     if not M.config.localhost_only then opts:append(opts, "--open") end

And looks like that about does the trick. Let me know if you're interested in getting this implemented more properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions