Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
deps/
deps/
.eca/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why excluding a local eca folder, I believe most of config could just go at ~/.config/eca/config.json?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a local .eca configuration file

5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ require("eca").setup({
| `:EcaServerStart` | Starts ECA server manually | `:EcaServerStart` |
| `:EcaServerStop` | Stops ECA server | `:EcaServerStop` |
| `:EcaServerRestart` | Restarts ECA server | `:EcaServerRestart` |
| `:EcaServerStatus` | Shows detailed server status | `:EcaServerStatus` |
| `:EcaSend <message>` | Sends message directly | `:EcaSend Explain this function` |

## ⌨️ Keyboard Shortcuts
Expand Down Expand Up @@ -459,9 +458,6 @@ Consider readability and maintainability.
#### Server Management

```vim
" Check status
:EcaServerStatus

" Restart if there are issues
:EcaServerRestart

Expand Down Expand Up @@ -515,7 +511,6 @@ Consider readability and maintainability.

- Check if `curl` and `unzip` are installed
- Try setting `server_path` manually with absolute path
- Run `:EcaServerStatus` for diagnostics
- Check logs with `debug = true` in configuration
- Try `:EcaServerRestart`

Expand Down
30 changes: 0 additions & 30 deletions lua/eca/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,6 @@ function M.setup()
desc = "Restart ECA server",
})

vim.api.nvim_create_user_command("EcaServerStatus", function()
local eca = require("eca")
local status = eca.server and eca.server:status() or "Not initialized"
local status_icon = "○"

if status == "Running" then
status_icon = "✓"
elseif status == "Starting" then
status_icon = "⋯"
elseif status == "Failed" then
status_icon = "✗"
end

Logger.notify("ECA Server Status: " .. status .. " " .. status_icon, vim.log.levels.INFO)

-- Also show path info if available
if eca.server and eca.server._path_finder then
local config = require("eca.config")
if config.server_path and config.server_path ~= "" then
Logger.notify("Server path: " .. config.server_path .. " (custom)", vim.log.levels.INFO)
else
Logger.notify("Server path: auto-detected/downloaded", vim.log.levels.INFO)
end
end
end, {
desc = "Show ECA server status with details",
})

vim.api.nvim_create_user_command("EcaLogs", function(opts)
local Api = require("eca.api")
local subcommand = opts.args and opts.args:match("%S+") or "show"
Expand Down Expand Up @@ -293,8 +265,6 @@ function M.setup()
desc = "Emergency stop for infinite loops or runaway responses",
})



vim.api.nvim_create_user_command("EcaFixTreesitter", function()
local Utils = require("eca.utils")

Expand Down
19 changes: 1 addition & 18 deletions lua/eca/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local Logger = require("eca.logger")
local Sidebar = require("eca.sidebar")
local Config = require("eca.config")
local Server = require("eca.server")
local StatusBar = require("eca.status_bar")

---@class Eca
local M = {
Expand All @@ -16,8 +15,6 @@ local M = {
current = { sidebar = nil },
---@type eca.Server
server = nil,
---@type eca.StatusBar
status_bar = nil,
}

M.did_setup = false
Expand Down Expand Up @@ -245,23 +242,9 @@ function M.setup(opts)
H.signs()

-- Initialize status bar
M.status_bar = StatusBar:new()

-- Initialize the ECA server with callbacks
M.server = Server:new({
on_started = function(connection)
M.status_bar:update("Running")
Logger.debug("ECA server started and ready!")
end,
on_status_changed = function(status)
M.status_bar:update(status)
if status == "Failed" then
Logger.notify("ECA server failed to start. Check :messages for details.", vim.log.levels.ERROR)
elseif status == "Starting" then
Logger.debug("Starting ECA server...")
end
end,
})
M.server = Server.new()

-- Start server automatically in background
vim.defer_fn(function()
Expand Down
7 changes: 7 additions & 0 deletions lua/eca/logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ end
---@param message string
---@param level integer
function M.log(message, level)
if vim.in_fast_event() then
return vim.schedule(function()
M.log(message, level)
end)
end

if not M.config then
return
end
Expand All @@ -98,6 +104,7 @@ function M.log(message, level)
end

local log_path = M.get_log_path()

vim.fn.mkdir(vim.fn.fnamemodify(log_path, ":h"), "p")

local timestamp = os.date("%Y-%m-%d %H:%M:%S")
Expand Down
21 changes: 21 additions & 0 deletions lua/eca/message_handler.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local M = {}

--- Parse raw messages coming from the ECA server
---@param data string
---@return {content_length: integer, content: string}[]
function M.parse_raw_messages(data)
local messages = {}
local seek_head = 1
while true do
local first, last, capture = string.find(data, "Content%-Length: (%d+)[\r\n]+", seek_head)
if not first then
break
end
capture = tonumber(capture)
seek_head = last + capture
table.insert(messages, { content_length = capture, content = string.sub(data, last + 1, seek_head) })
end
return messages
end

return M
186 changes: 0 additions & 186 deletions lua/eca/rpc.lua

This file was deleted.

Loading