From fde21e3dc4f0349dfe2bd527d1562df5dcf497aa Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 14 Jul 2024 19:55:52 -0500 Subject: [PATCH] feat: resolve directories correctly --- index.html | 11 +++++++++++ lua/live-server.lua | 13 ++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..1fdf1f3 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + Document + + + + + diff --git a/lua/live-server.lua b/lua/live-server.lua index d956de7..9d875b0 100644 --- a/lua/live-server.lua +++ b/lua/live-server.lua @@ -53,17 +53,20 @@ M.setup = function(user_config) return end + local function find_dir(args) + local dir = args ~= '' and args or '%:p:h' + return vim.fn.expand(vim.fn.fnamemodify(dir, ':p')) + end + vim.api.nvim_create_user_command('LiveServerStart', function(opts) - local dir = opts.args ~= '' and opts.args or '%:p:h' - M.start(vim.fn.expand(dir)) + M.start(find_dir(opts.args)) end, { nargs = '?' }) vim.api.nvim_create_user_command('LiveServerStop', function(opts) - local dir = opts.args ~= '' and opts.args or '%:p:h' - M.stop(vim.fn.expand(dir)) + M.stop(find_dir(opts.args)) end, { nargs = '?' }) vim.api.nvim_create_user_command('LiveServerToggle', function(opts) local dir = opts.args ~= '' and opts.args or '%:p:h' - M.toggle(vim.fn.expand(dir)) + M.toggle(find_dir(opts.args)) end, { nargs = '?' }) end