Setting up a more optimal Julia LSP in neovim

Hello everyone! I have an LSP for Julia in neovim that just doesn’t seem to be performing well. It is unable to do “go to definition” and some of the more rudimentary things that an LSP should do (expose symbols, etc.). It basically just looks like it is highlighting similar words and doing some background processing.

Has anyone here set up an LSP for julia in neovim? How has your experience been and can I get suggestions on how I can go about fixing the issue?

Did you try:
https://aviatesk.github.io/JETLS.jl/release/#neovim

This is a work-in-progress, but it might already work better than the old language server.

1 Like

Thank you @ufechner7 ! JetLS is working n my neovim system! It does take a while to spin up (around 30-45 seconds) but it is well worth it! I appreciate the suggestion!

1 Like

Have you figured out a good configuration here? When I’m developing a package locally and then open a file in a folder say examples under that package that depends on the package itself, i.e., it has its own project.toml with its own dependencies, jetls does not know my package exists and cannot find the functions. In Julia itself this works fine though. It’s just inside neovim it doesn’t work.

The functions are recognized developing the package when editing files inside src though.

FYI I’m on my phone and writing swiftly so I hope my question is coming through. :joy:

To be honest, that is too difficult for me to understand. It would be better if you, for example, provided a GitHub repo with example code and documented the steps you are taking, so others can reproduce the issue.

Perhaps you’re missing this feature, which isn’t implemented yet?

  • Recursive analysis for dependencies

I’ll make an asciinema illustrating the issue. :blush:

1 Like

I think I “may” know what the problem is. I would need to see your neovim configuration, but you need to instantiate jetls FROM your project root and ensure that it can find your base project. I do believe that your development package needs to be registered in the julia depot though, so you would need to manually add it as a package first. The issue is that I don’t believe you can changes to the LSP source of the package that you are developing while you are currently in the package changing the code (you would need to update/recompile the package in the Julia package depot. Try this configuration (it is a Lazy.nvim lua file) and see if it works

vim.api.nvim_create_autocmd("FileType", {
  pattern = "julia",
  callback = function()
    vim.lsp.start({
      name = "/home/firebat/.julia/bin/jetls",
      cmd = {
        "/home/firebat/.julia/bin/jetls",
        "--threads=auto",
        "--",
      },
      root_dir = vim.fs.root(0, { "Project.toml", ".git" }),
      settings = {
        -- You can add specific JET.jl settings here if needed
      },
    })
  end,
})

1 Like

Thanks for the replies and sorry for high jacking the thread but I hope it’s useful for everyone. I made a small recording of the problem. Sorry that it’s a bit long but it’s because the lsp takes a while to initialize each time. You can view it here: untitled - asciinema.org

Code is organized like this:

.
├── Manifest-v1.12.toml
├── nvimjetls.cas
├── Project.toml
├── src
│   ├── Hello.jl
│   └── utils.jl
└── test
    ├── Manifest.toml
    ├── Manifest-v1.12.toml
    ├── Project.toml
    └── runtests.jl

My jetls config is this:

      vim.lsp.config('jetls', {
        cmd = {
          '/home/mike/.julia/bin/jetls',
          '--threads=auto',
          '--',
        },
        filetypes = { 'julia' },
        root_markers = { 'Project.toml', 'JuliaProject.toml' },
        settings = {},
      })
      vim.lsp.enable 'jetls'

I’m using nvim-lspconfig as I have several language servers.

1 Like