Neovim + LanguageServer.jl

Could be worth doing a :checkhealth if you’ve not already to see whether there’s anything obvious that’s causing it. Do any other language servers work in your setup?

I struggled with the default settings for a while before just customising it enough to work for me with (the relevant parts):

local util = require "lspconfig/util"

local cmd = {
  "julia",
  "--startup-file=no",
  "--history-file=no",
  "/home/mike/.config/nvim/lua/mike/lsp.jl"
}

require"lspconfig".julials.setup {
    cmd = cmd,
    on_new_config = function(new_config, _)
        local server_path = vim.fn.system "julia --startup-file=no -q -e 'print(dirname(dirname(Base.find_package(\"LanguageServer\"))))'"
        local new_cmd = vim.deepcopy(cmd)
        table.insert(new_cmd, 2, "--project=" .. server_path)
        new_config.cmd = new_cmd
    end,
    filetypes = {"julia"},
    root_dir = function(fname)
        return util.find_git_ancestor(fname) or vim.fn.getcwd()
    end
}

and lsp.jl (since I didn’t like passing it all as an argument):

using LanguageServer
using LanguageServer.SymbolServer

let env = Base.load_path(),
    dir = pwd(),
    depot_path = get(ENV, "JULIA_DEPOT_PATH", ""),
    project_path = dirname(something(Base.current_project(pwd()), Base.load_path_expand(LOAD_PATH[2])))

    @info env dir project_path depot_path

    server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
    server.runlinter = true
    run(server)
end

(Hopefully that might help you out a bit.)

2 Likes