Browse Source

[nvim] Update precompile generation for LSP sysimage.

master
Fredrik Ekre 4 years ago
parent
commit
b46172db3f
  1. 51
      .julia/environments/nvim-lspconfig/Example.jl
  2. 23
      .julia/environments/nvim-lspconfig/Makefile

51
.julia/environments/nvim-lspconfig/Example.jl

@ -0,0 +1,51 @@
# This file is opened in Neovim with a LanguageServer.jl process that records Julia
# compilation statements for creating a custom sysimage.
#
# This file has a bunch of linter errors which will exercise the linter and record
# statements for that. When the diagnostic messages corresponding to those errors show up in
# the buffer the language server should be ready to accept other commands (note: this may
# take a while -- be patient). Here are some suggestions for various LSP functionality that
# can be exercised (your regular keybindings should work):
#
# - :lua vim.lsp.buf.hover()
# - :lua vim.lsp.buf.definition()
# - :lua vim.lsp.buf.references()
# - :lua vim.lsp.buf.rename()
# - :lua vim.lsp.buf.formatting()
# - :lua vim.lsp.buf.formatting_sync()
# - :lua vim.lsp.buf.code_action()
# - Tab completion (if you have set this up using LSP)
# - ...
#
# When you are finished, simply exit neovim and PackageCompiler.jl will use all the recorded
# statements to create a custom sysimage. This sysimage will be used for the language server
# process in the future, and should result in almost instant response.
module Example
import JSON
import fzf_jll
using Random
using Zlib_jll
function hello(who, notused)
println("hello", who)
shuffle([1, 2, 3])
shoffle([1, 2, 3])
fzzf = fzf_jll.fzzf()
fzf = fzf_jll.fzf(1)
JSON.print(stdout, Dict("hello" => [1, 2, 3]), 2, 123)
JSON.print(stdout, Dict("hello" => [1, 2, 3]))
hi(who)
return Zlib_jll.libz
end
function world(s)
if s == nothing
hello(s)
else
hello(s)
end
end
end # module

23
.julia/environments/nvim-lspconfig/Makefile

@ -1,10 +1,12 @@
JULIA=$(shell which julia) JULIA=$(shell which julia)
JULIA_PROJECT= JULIA_PROJECT=
SRCDIR:=$(shell dirname $(abspath $(firstword $(MAKEFILE_LIST))))
ifeq ($(shell uname -s),Linux) ifeq ($(shell uname -s),Linux)
SYSIMAGE=languageserver.so SYSIMAGE=languageserver.so
else else
SYSIMAGE=languageserver.dylib SYSIMAGE=languageserver.dylib
endif endif
default: $(SYSIMAGE) default: $(SYSIMAGE)
$(SYSIMAGE): Manifest.toml packagecompiler/Manifest.toml packagecompiler/precompile_statements.jl $(SYSIMAGE): Manifest.toml packagecompiler/Manifest.toml packagecompiler/precompile_statements.jl
@ -30,26 +32,7 @@ packagecompiler/precompile_statements.jl: Manifest.toml bin/julia
cd Example && \ cd Example && \
JULIA_LOAD_PATH=$${PWD}:@stdlib ${JULIA} -e 'using Pkg; Pkg.add(["JSON", "fzf_jll", "Random", "Zlib_jll"])' 2> /dev/null && \ JULIA_LOAD_PATH=$${PWD}:@stdlib ${JULIA} -e 'using Pkg; Pkg.add(["JSON", "fzf_jll", "Random", "Zlib_jll"])' 2> /dev/null && \
JULIA_LOAD_PATH=$${PWD}:@stdlib ${JULIA} -e 'using Pkg; Pkg.precompile()' 2> /dev/null && \ JULIA_LOAD_PATH=$${PWD}:@stdlib ${JULIA} -e 'using Pkg; Pkg.precompile()' 2> /dev/null && \
echo "module Example" > src/Example.jl && \ cat ${SRCDIR}/Example.jl > src/Example.jl && \
echo "" >> src/Example.jl && \
echo "import JSON" >> src/Example.jl && \
echo "import fzf_jll" >> src/Example.jl && \
echo "using Random" >> src/Example.jl && \
echo "using Zlib_jll" >> src/Example.jl && \
echo "" >> src/Example.jl && \
echo "function hello(who, notused)" >> src/Example.jl && \
echo " println(\"hello\", who)" >> src/Example.jl && \
echo " shuffle([1, 2, 3])" >> src/Example.jl && \
echo " shoffle([1, 2, 3])" >> src/Example.jl && \
echo " fzzf = fzf_jll.fzzf()" >> src/Example.jl && \
echo " fzf = fzf_jll.fzf(1)" >> src/Example.jl && \
echo " JSON.print(stdout, Dict(\"hello\" => [1, 2, 3]), 2, 123)" >> src/Example.jl && \
echo " JSON.print(stdout, Dict(\"hello\" => [1, 2, 3]))" >> src/Example.jl && \
echo " hi(who)" >> src/Example.jl && \
echo " return Zlib_jll.libz" >> src/Example.jl && \
echo "end" >> src/Example.jl && \
echo "" >> src/Example.jl && \
echo "end # module" >> src/Example.jl && \
JULIA_TRACE_COMPILE=1 nvim src/Example.jl && \ JULIA_TRACE_COMPILE=1 nvim src/Example.jl && \
rm -rf $${TMPDIR} rm -rf $${TMPDIR}

Loading…
Cancel
Save