Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #92

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/workflows/label.yml

This file was deleted.

3 changes: 1 addition & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Copyright (C) 2024 Phạm Bình An

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Supports mermaid for rendering diagrams in markdown files

https://github.com/user-attachments/assets/865112c1-8514-4920-a531-b2204194f749


![](output.jpeg)

## Requirements

- Neovim >=0.10.0
Expand Down
12 changes: 8 additions & 4 deletions doc/live-preview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ await_term_cmd({cmd}) *live-preview.utils.await_term_cmd()*
(`table`) a table with fields code, stdout, stderr, signal

get_parent_path *live-preview.utils.get_parent_path*
Get the parent path of a subpath Example:
Get the parent path of a subpath

Example: ```lua
get_parent_path("/home/user/.config/nvim/lua/live-preview/utils.lua",
"/lua/live-preview/utils.lua") will return "/home/user/.config/nvim"
"/lua/live-preview/utils.lua") >
will return "/home/user/.config/nvim"
<

Parameters: ~
• {full_path} (`string`)
Expand Down Expand Up @@ -269,8 +273,8 @@ open_browser({path}, {browser}) *live-preview.utils.open_browser()*
• {browser} (`string`)

sha1({val}) *live-preview.utils.sha1()*
Compute the SHA1 hash of a string. Source :
https://github.com/glacambre/firenvim/blob/master/lua/firenvim/firenvim-utils.lua
Compute the SHA1 hash of a string. Copyright (C) 2007 *Free Software
Foundation, Inc*.

Parameters: ~
• {val} (`string`)
Expand Down
10 changes: 7 additions & 3 deletions lua/live-preview/server/Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ vim.api.nvim_create_autocmd("WinScrolled", {
--- Constructor
--- @param webroot string: path to the webroot
function Server:new(webroot)
self.webroot = webroot or "."
self.server = uv.new_tcp()
self.webroot = webroot or "."
return self
end

Expand Down Expand Up @@ -139,8 +139,12 @@ end

--- Stop the server
function Server:stop()
self.server:close()
self.server = uv.new_tcp()
if self.server then
self.server:close(function()
print("Server closed")
end)
self.server = nil
end
end

return Server
8 changes: 6 additions & 2 deletions lua/live-preview/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function M.get_path_lua_file()
end

--- Get the parent path of a subpath
--- Example: get_parent_path("/home/user/.config/nvim/lua/live-preview/utils.lua", "/lua/live-preview/utils.lua") will return "/home/user/.config/nvim"
---
--- Example: ```lua
--- get_parent_path("/home/user/.config/nvim/lua/live-preview/utils.lua", "/lua/live-preview/utils.lua")
--- ```
--- will return "/home/user/.config/nvim"
--- @param full_path string
--- @param subpath string
--- @return string | nil
Expand Down Expand Up @@ -136,7 +140,7 @@ function M.await_term_cmd(cmd)
end

--- Compute the SHA1 hash of a string.
--- Source : https://github.com/glacambre/firenvim/blob/master/lua/firenvim/firenvim-utils.lua
--- Copyright (C) 2007 [Free Software Foundation, Inc](https://fsf.org/).
---@param val string
---@return string: SHA1 hash
function M.sha1(val)
Expand Down
Loading