Skip to content

Commit 3ae5940

Browse files
committed
make server_path work headless and in clean mode
1 parent 4c59602 commit 3ae5940

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

lua/eca/api.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ local M = {}
1111
function M.chat(opts)
1212
opts = opts or {}
1313
local eca = require("eca")
14+
15+
if not M.is_server_running() then
16+
M.start_server()
17+
end
18+
1419
eca.open_sidebar(opts)
1520
end
1621

lua/eca/server.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ function M:start(opts)
103103
local this_file = debug.getinfo(1, "S").source:sub(2)
104104
local proj_root = vim.fn.fnamemodify(this_file, ":p:h:h:h")
105105
local script_path = proj_root .. "/scripts/server_path.lua"
106-
local logger_path = proj_root .. "/lua/eca/logger.lua"
107-
local utils_path = proj_root .. "/lua/eca/utils.lua"
108106

109107
local nvim_exe = vim.fn.exepath("nvim")
110108

@@ -114,7 +112,7 @@ function M:start(opts)
114112

115113
local lua_cmd = string.format("lua ServerPath.run(%s)", Utils.lua_quote(Config.server_path) or "")
116114

117-
local cmd = { nvim_exe, "--headless", "--noplugin", "-u", utils_path, "-u", logger_path, "-u", script_path, "-c", lua_cmd }
115+
local cmd = { nvim_exe, "--headless", "--noplugin", "--clean", "-u", script_path, "-c", lua_cmd }
118116

119117
vim.system(cmd, { text = true }, function(out)
120118
if out.code ~= 0 then

scripts/server_path.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
local ServerPath = {}
22

3-
-- Export module
4-
_G.ServerPath = ServerPath
3+
-- Setup if headless
4+
if #vim.api.nvim_list_uis() == 0 then
5+
_G.ServerPath = ServerPath
6+
vim.cmd([[let &rtp.=','.getcwd()]])
7+
vim.cmd('set rtp+=deps/nui.nvim')
8+
vim.cmd('set rtp+=deps/eca-nvim')
9+
vim.o.swapfile = false
10+
vim.o.backup = false
11+
vim.o.writebackup = false
12+
require("eca").setup({})
13+
end
514

615
ServerPath.run = function(custom_path)
716
local path_finder = require("eca.path_finder"):new()

0 commit comments

Comments
 (0)