summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/essentials/nvim/lua/user/init.lua1
-rw-r--r--config/essentials/nvim/lua/user/live-server.lua53
-rw-r--r--config/essentials/nvim/lua/user/packer.lua1
-rw-r--r--config/essentials/zsh/aliases.zsh6
4 files changed, 57 insertions, 4 deletions
diff --git a/config/essentials/nvim/lua/user/init.lua b/config/essentials/nvim/lua/user/init.lua
index a9ba9c4..2f29b87 100644
--- a/config/essentials/nvim/lua/user/init.lua
+++ b/config/essentials/nvim/lua/user/init.lua
@@ -3,4 +3,5 @@ require("user.remap")
require("user.set")
require("user.cmp")
require("user.zk")
+require("user.live-server")
vim.cmd.source(vim.fn.stdpath("config") .. "/lua/user/aucommands.vim")
diff --git a/config/essentials/nvim/lua/user/live-server.lua b/config/essentials/nvim/lua/user/live-server.lua
new file mode 100644
index 0000000..c98729c
--- /dev/null
+++ b/config/essentials/nvim/lua/user/live-server.lua
@@ -0,0 +1,53 @@
+local M = {}
+-- keep track of jobs
+local live_servers = {}
+
+function M.start_live_server()
+ -- Search for available port and use it
+ local port = 5500
+ local running = true
+ while running do
+ local output = vim.fn.systemlist('lsof -i :' .. port)
+ if #output == 0 then
+ running = false
+ else
+ port = port + 1
+ end
+ end
+
+ local command = "live-server --no-browser --port=" .. port .. " " .. vim.fn.expand("%:p:h")
+ -- run
+ local job_id = vim.fn.jobstart(command, {
+ on_exit = function(_, _, _) end
+ })
+ -- save
+ live_servers[port] = job_id
+
+ print("Started live-server on :" .. port .. ".")
+end
+
+function M.stop_live_servers()
+ for port, job_id in pairs(live_servers) do
+ local output = vim.fn.systemlist('lsof -i :' .. port)
+ if #output > 0 then
+ vim.fn.jobstop(job_id)
+ print("Killed live-server on :" .. port .. ".")
+ end
+ live_servers[port] = nil
+ end
+end
+
+vim.api.nvim_create_user_command("LiveServer", function(opts)
+ local opt = string.format(opts.args)
+ if #opts.args == 0 then
+ M.start_live_server()
+ elseif opt == "start" then
+ M.start_live_server()
+ elseif opt == "stop" then
+ M.stop_live_servers()
+ else
+ print("Invalid argument. Usage: LiveServer [start|stop]")
+ end
+end, { nargs = '*' })
+
+return M
diff --git a/config/essentials/nvim/lua/user/packer.lua b/config/essentials/nvim/lua/user/packer.lua
index a66dab4..86a70ed 100644
--- a/config/essentials/nvim/lua/user/packer.lua
+++ b/config/essentials/nvim/lua/user/packer.lua
@@ -34,7 +34,6 @@ return require('packer').startup(function(use)
-- utils
use('godlygeek/tabular')
use('renerocksai/calendar-vim')
- use('LordTlasT/live-server')
use('ojroques/vim-oscyank', {branch = "main"})
use("potamides/pantran.nvim")
diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh
index 9b8ef3d..3861467 100644
--- a/config/essentials/zsh/aliases.zsh
+++ b/config/essentials/zsh/aliases.zsh
@@ -94,9 +94,9 @@ alias srcgd='
for dir in ~/src/*
do
cd $dir
- test "$(git status --short 2>/dev/null | grep -v "^??")" && pwd
-done
-'
+ test "$(git status --short 2>/dev/null | head -1)" && echo "$PWD \e[1;31m*changes\e[0m"
+ test "$(parse_git_remote)" && echo "$PWD \e[0;32m*push/pull\e[0m" ;
+done'
# Python
alias penv='python -m venv env'