diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index e81bcf8..8db3f25 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -65,11 +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', - opts = {}, + lazy = false, }, }, }) 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 diff --git a/lua/live-server/init.lua b/lua/live-server/init.lua index 3a8ea4b..ff84dc2 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 @@ -156,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