From f5efb7cb66ff81acfb87e7b16f658f1b877f1637 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 22 Oct 2024 18:27:36 +0900 Subject: [PATCH] refactor(julials): update docs & remove unused shell scripts --- bin/neovim/readme.md | 17 +++++++---------- bin/neovim/setup_julials.jl | 12 +++--------- bin/neovim/setup_julials.sh | 2 -- bin/neovim/update_julials.jl | 25 +++++++++++++------------ bin/neovim/update_julials.sh | 7 ------- 5 files changed, 23 insertions(+), 40 deletions(-) delete mode 100755 bin/neovim/setup_julials.sh delete mode 100755 bin/neovim/update_julials.sh diff --git a/bin/neovim/readme.md b/bin/neovim/readme.md index b94f686..ba69a49 100644 --- a/bin/neovim/readme.md +++ b/bin/neovim/readme.md @@ -1,27 +1,24 @@ # How to manage Julia Language Server -This config use sysimage built with PackageCompiler to make language server startup faster. -Scripts in this directory is for management of sysimage. +This config use sysimage built with PackageCompiler to make language server starts faster. +Scripts in this directory are for management of the sysimage. # description all related process is done in project at `~/.julia/environments/nvim-lspconfig/`. -## startup +## install (or minor update of Julia) ```sh -$ ./setup_julials.sh +julia ./setup_julials.jl ``` -which executes `add_dependencies.jl` internally. +Run Language Server with `--tracecompile` option from any editor. ## update ```sh -$ ./update_julials.sh +julia ./update_julials.sh ``` which updates project, compile sysimage, then do precompile. +To use the sysimage, run Language Server with `-J ~/.julia/environments/nvim-lspconfig/` option. # effect Start up got about x3 - x4 faster. It still takes some time to load packages though. -# TODO -- [ ] Not sure all necessary packages are listed in add_dependencies.jl -- [ ] Maybe it's better to set up different sysimages for each projects - diff --git a/bin/neovim/setup_julials.jl b/bin/neovim/setup_julials.jl index f357963..f6107bd 100644 --- a/bin/neovim/setup_julials.jl +++ b/bin/neovim/setup_julials.jl @@ -1,15 +1,9 @@ #!/usr/bin/julia project_path = joinpath(homedir(), ".julia", "environments", "nvim-lspconfig") if !ispath(project_path) - try - mkdir(project_path) - @info "Created $(project_path)" - touch(joinpath(project_path, "tracecompile.jl")) - catch e - @error e - @error dump(e) - throw(e) - end + mkdir(project_path) + @info "Created $(project_path)" + touch(joinpath(project_path, "tracecompile.jl")) end cmd = `julia --project=$(project_path) $(@__DIR__)/add_dependencies.jl` @info cmd diff --git a/bin/neovim/setup_julials.sh b/bin/neovim/setup_julials.sh deleted file mode 100755 index f1aa150..0000000 --- a/bin/neovim/setup_julials.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/bash -x -julia --project=~/.julia/environments/nvim-lspconfig ./add_dependencies.jl diff --git a/bin/neovim/update_julials.jl b/bin/neovim/update_julials.jl index 08e1f36..713c00b 100644 --- a/bin/neovim/update_julials.jl +++ b/bin/neovim/update_julials.jl @@ -1,15 +1,16 @@ #!/usr/bin/julia project_path = joinpath(homedir(), ".julia", "environments", "nvim-lspconfig") -cd(project_path) -@info "now at " pwd() -run(`julia --project=. -e 'using Pkg; Pkg.update()'`) -compile_traces = Iterators.filter(eachline("tracecompile.jl")) do line - # Remove anonymous functions from compile trace - !startswith(line, '#') && !occursin(r"\#\d+\#\d+", line) && !occursin(r"\#\#printstyled\#", line) -end |> join -read("precompile_exec_head.jl", String) * compile_traces |> (b -> write("precompile_exec.jl", b)) -@info "compiling sysimage..." -run(`julia --project=. -e 'using PackageCompiler; create_sysimage(["LanguageServer"], sysimage_path = "sys-ls.so", precompile_execution_file = ["precompile_exec.jl"])'`) -@info "post precompile" -run(`julia --project=. -J sys-ls.so -e 'using Pkg; Pkg.precompile()'`) +cd(project_path) do + @info "now at " pwd() + run(`julia --project=. -e 'using Pkg; Pkg.update()'`) + compile_traces = Iterators.filter(eachline("tracecompile.jl")) do line + # Remove anonymous functions from compile trace + !startswith(line, '#') && !occursin(r"\#\d+\#\d+", line) && !occursin(r"\#\#printstyled\#", line) + end |> join + read("precompile_exec_head.jl", String) * compile_traces |> (b -> write("precompile_exec.jl", b)) + @info "compiling sysimage..." + run(`julia --project=. -e 'using PackageCompiler; create_sysimage(["LanguageServer"], sysimage_path = "sys-ls.so", precompile_execution_file = ["precompile_exec.jl"])'`) + @info "post precompile" + run(`julia --project=. -J sys-ls.so -e 'using Pkg; Pkg.precompile()'`) +end diff --git a/bin/neovim/update_julials.sh b/bin/neovim/update_julials.sh deleted file mode 100755 index 8dd5a78..0000000 --- a/bin/neovim/update_julials.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/bash -x -cd ~/.julia/environments/nvim-lspconfig/ || return 1 -julia --project=. -e 'using Pkg; Pkg.update()' -cat precompile_exec_head.jl tracecompile.jl > precompile_exec.jl -julia --project=. -e 'using PackageCompiler; create_sysimage(["LanguageServer"], sysimage_path="sys-ls.so", precompile_execution_file=["precompile_exec.jl"])' -julia --project=. -J sys-ls.so -e 'using Pkg; Pkg.precompile()' -