From 3933feefd467aa4cf2307b11bc31f1f4ee080f05 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:48:08 -0500 Subject: [PATCH 1/5] fix: prevent infinite loop in `find_cached_dir` for non-filesystem buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: calling `:LiveServerStart` from a buffer whose name is a non-filesystem URI (e.g. oil.nvim's `oil:///path/to/dir`) causes `find_cached_dir` to spin forever. `fnamemodify(cur, ':h')` eventually degenerates to `.`, which maps back to itself, so the loop never terminates — freezing Neovim and pegging the CPU. Solution: store the result of `fnamemodify(cur, ':h')` and bail out if it equals `cur`, indicating the path cannot be traversed further. --- lua/live-server/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/live-server/init.lua b/lua/live-server/init.lua index 3a8ea4b..4a6c6b7 100644 --- a/lua/live-server/init.lua +++ b/lua/live-server/init.lua @@ -140,7 +140,11 @@ local function find_cached_dir(dir) if cur == '/' or cur:match('^[A-Z]:\\$') then return nil end - cur = vim.fn.fnamemodify(cur, ':h') + local parent = vim.fn.fnamemodify(cur, ':h') + if parent == cur then + return nil + end + cur = parent end return cur end From 128f31c04a5d319d3a071b2d84e65846da1dad4d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:49:04 -0500 Subject: [PATCH 2/5] fix(bug-report): add `lazy = false` to repro template so healthcheck works --- .github/ISSUE_TEMPLATE/bug_report.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index e81bcf8..73ccfab 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -69,6 +69,7 @@ body: spec = { { 'barrett-ruth/live-server.nvim', + lazy = false, opts = {}, }, }, From 14b584f8fcb6c418a6e6e8a452e841eedc003aef Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:55:11 -0500 Subject: [PATCH 3/5] fix(bug-report): correct repro template module name and remove deprecated `opts` --- .github/ISSUE_TEMPLATE/bug_report.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 73ccfab..8db3f25 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -65,12 +65,11 @@ body: value: | vim.env.LAZY_STDPATH = '.repro' load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() - require('lazy.nvim').setup({ + require('lazy').setup({ spec = { { 'barrett-ruth/live-server.nvim', lazy = false, - opts = {}, }, }, }) From d2c4f4161c769b095fded797ca928144ca61a469 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:57:43 -0500 Subject: [PATCH 4/5] fix: serve correct directory when started from a URI-scheme buffer Problem: buffers like oil.nvim use URI-scheme names (e.g. `oil:///path/to/dir`) instead of plain filesystem paths. `resolve_dir` fell back to `%:p:h`, which expanded the URI literally rather than the directory being browsed, causing the server to fail or error. Solution: when no explicit dir is given, check the current buffer name for a URI scheme and extract the real path from it. Falls back to `%:p:h` for normal file buffers. --- lua/live-server/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/live-server/init.lua b/lua/live-server/init.lua index 4a6c6b7..ff84dc2 100644 --- a/lua/live-server/init.lua +++ b/lua/live-server/init.lua @@ -160,7 +160,9 @@ end ---@return string local function resolve_dir(dir) if not dir or dir == '' then - dir = '%:p:h' + local bufname = vim.api.nvim_buf_get_name(0) + local uri_path = bufname:match('^%a+://(/.*)') + dir = uri_path or '%:p:h' end return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ':p')) end From 11560e0c60d4dca1e8a962a14e990334836c15e3 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:58:11 -0500 Subject: [PATCH 5/5] chore: ignore `repro.lua` --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2722ae6..c7b0274 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ node_modules/ .envrc .direnv + +.repro +repro.lua