Skip to content

Commit 4d8d634

Browse files
authored
refactor(julia): JuliaActivateEnv merged upstream (#1353)
1 parent 10dce6c commit 4d8d634

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

lua/astrocommunity/pack/julia/init.lua

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -44,77 +44,6 @@ return {
4444
opts = function(_, opts)
4545
local astrocore = require "astrocore"
4646
opts = astrocore.extend_tbl(opts, {
47-
commands = {
48-
JuliaActivateEnv = {
49-
cond = function(client) return client.name == "julials" end,
50-
function(args)
51-
local bufnr = vim.api.nvim_get_current_buf()
52-
local julials_clients = (vim.lsp.get_clients or vim.lsp.get_active_clients) {
53-
bufnr = bufnr,
54-
name = "julials",
55-
}
56-
if #julials_clients == 0 then
57-
vim.notify(
58-
"method julia/activateenvironment is not supported by any servers active on the current buffer",
59-
vim.log.levels.WARN
60-
)
61-
return
62-
end
63-
local julia_project_files = { "Project.toml", "JuliaProject.toml" }
64-
local function _activate_env(environment)
65-
if environment then
66-
for _, julials_client in ipairs(julials_clients) do
67-
julials_client.notify("julia/activateenvironment", { envPath = environment })
68-
end
69-
vim.notify("Julia environment activated: \n`" .. environment .. "`", vim.log.levels.INFO)
70-
end
71-
end
72-
if args.args ~= "" then
73-
local path = vim.fs.normalize(require("plenary.path"):new(args.args):expand())
74-
local found_env = false
75-
for _, project_file in ipairs(julia_project_files) do
76-
local file = (vim.uv or vim.loop).fs_stat(vim.fs.joinpath(path, project_file))
77-
if file and file.type then
78-
found_env = true
79-
break
80-
end
81-
end
82-
if not found_env then
83-
vim.notify("Path is not a julia environment: \n`" .. path .. "`", vim.log.levels.WARN)
84-
return
85-
end
86-
_activate_env(path)
87-
else
88-
local depot_paths = vim.env.JULIA_DEPOT_PATH
89-
and vim.split(vim.env.JULIA_DEPOT_PATH, vim.fn.has "win32" == 1 and ";" or ":")
90-
or { vim.fn.expand "~/.julia" }
91-
local environments = {}
92-
vim.list_extend(
93-
environments,
94-
vim.fs.find(julia_project_files, { type = "file", upward = true, limit = math.huge })
95-
)
96-
for _, depot_path in ipairs(depot_paths) do
97-
local depot_env = vim.fs.joinpath(vim.fs.normalize(depot_path), "environments")
98-
vim.list_extend(
99-
environments,
100-
vim.fs.find(
101-
function(name, env_path)
102-
return vim.tbl_contains(julia_project_files, name)
103-
and string.sub(env_path, #depot_env + 1):match "^/[^/]*$"
104-
end,
105-
{ path = depot_env, type = "file", limit = math.huge }
106-
)
107-
)
108-
end
109-
environments = vim.tbl_map(vim.fs.dirname, environments)
110-
vim.ui.select(environments, { prompt = "Select a Julia environment" }, _activate_env)
111-
end
112-
end,
113-
desc = "Activate a julia environment",
114-
nargs = "?",
115-
complete = "file",
116-
},
117-
},
11847
config = {
11948
julials = {
12049
settings = {

0 commit comments

Comments
 (0)