# Neovim + LanguageServer.jl

**URL:** <https://discourse.julialang.org/t/neovim-languageserver-jl/37286>\
**Category:** Tooling\
**Tags:** editors\
**Created:** [April 9, 2020, 4:13pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286 "2020-04-09T16:13:25Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![cameronperot](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cameronperot](https://discourse.julialang.org/u/cameronperot)\
**Post date:** [July 5, 2020, 10:02am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/21 "2020-07-05T10:02:18Z")

</div>

I’ve just tried to get this working, and I can successfully run the language server (from the log `"[ Info: Received new data from Julia Symbol Server.\n"`), but when using autocomplete inside of nvim it constantly says `Missing Reference: ...` next to the cursor when I’m typing and I don’t see any lsp suggestions in the autocomplete dropdown.

I’m running `NVIM v0.5.0-584-gf137307dc`. I tried my previous config, using the basic nvim config @kdheepak provided in the post above, and the aforementioned config with the additional packages `deoplete` and `deoplete-lsp`. I made sure to clear old plugins and cache files before trying this.

I also notice high CPU usage from the Julia process that runs when a `.jl` file is opened (note that this is after the first run where the packages are indexed), is that expected?

Does anyone have any suggestions to get this working?

Edit: It seems to show some lsp autocomplete suggestions when I’m editing a new file, but when editing an existing `.jl` file with a good bit of code in it I get the `Missing Reference: ...`.

---

<div class="post-metadata">

**Author:** ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Post date:** [July 5, 2020, 4:19pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/22 "2020-07-05T16:19:13Z")

</div>

If you are getting “Missing Reference: …” then LSP is working for you. Diagnostics may show missing references if LanguageServer.jl is not able to find those references. This may happen for a number of reasons. For example LanguageServer.jl will only find references in the `src` folder of a package, and will not find references in the `tests` folder. This may also be affected by whether or not you have a `Manifest.toml` file in the folder. See [@ExpandingMan’s LSPNeovim.jl package](https://github.com/ExpandingMan/LSPNeovim.jl/) for more information on this.

If you want to decrease the verbosity of the diagnostic messages, you can use something like [diagnostic-nvim](https://github.com/nvim-lua/diagnostic-nvim). See [@ExpandingMan’s dotfiles](https://github.com/ExpandingMan/dotfiles/blob/master/.config/nvim/init.vim) for an example of configuring neovim using nvim-lsp, diagnostic-nvim and deoplete and deoplete-lsp. Make sure you are using the latest versions of deoplete and deoplete-lsp.

I’m not sure why autocomplete isn’t working for you properly. If you are not wedded to deoplete, you can also try [completion-nvim](https://github.com/nvim-lua/completion-nvim). You can see [my dotfiles at this commit](https://github.com/kdheepak/dotfiles/blob/47a38e20ef4bef7a189927646eee3c91f911ffd7/vimrc) for an example on how to configure neovim, nvim-lsp, diagnostic-nvim, and completion-nvim.

Here’s the relevant pieces:

1. Install the plugins

```nohighlight
Plug 'nvim-lua/diagnostic-nvim' | " better neovim built in lsp diagnostics
Plug 'nvim-lua/completion-nvim' | " better neovim built in lsp completion

```

1. Initialize

```nohighlight
autocmd BufEnter * lua require'completion'.on_attach()

lua << EOF
    local nvim_lsp = require'nvim_lsp'
    local on_attach_vim = function()
        require'diagnostic'.on_attach()
    end
    nvim_lsp.julials.setup({on_attach=on_attach_vim})
EOF

```

1. Configure

```nohighlight
let g:diagnostic_auto_popup_while_jump = 0
let g:diagnostic_enable_virtual_text = 0
let g:diagnostic_enable_underline = 0
let g:completion_timer_cycle = 200 "default value is 80

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 5, 2020, 6:37pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/23 "2020-07-05T18:37:35Z")

</div>

really hate how lsp eco system is fragmented so thanks for having pointers here. Since I write more julia than python now I decided to abandon the deoplete and jump to your band wagon:

still several questions (I use vim as a tool so not really know about the internals):

1. your dotfile doesn’t have start language server parts such as [Vim and Neovim · julia-vscode/LanguageServer.jl Wiki · GitHub](https://github.com/julia-vscode/LanguageServer.jl/wiki/Vim-and-Neovim#languageclient-neovim) ?

2. when I ‘fix’ 1, I still don’t get completion prompt, and when I manually `:call LanguageClient_textDocument_hover()` I get a `send to disconnected channel`

---

<div class="post-metadata">

**Author:** ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Post date:** [July 5, 2020, 8:01pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/24 "2020-07-05T20:01:25Z")

</div>

I’m not using LanguageClient-neovim, I’m using the built-in LSP. It seems like currently there are four approaches: You can use LanguageClient-neovim, SpaceVim, deoplete or completion-nvim.

---

<div class="post-metadata">

**Author:** ![cameronperot](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cameronperot](https://discourse.julialang.org/u/cameronperot)\
**Post date:** [July 5, 2020, 8:38pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/25 "2020-07-05T20:38:27Z")

</div>

Thanks for the explanation, @kdheepak! I was able to get Julia lsp autocomplete to work using the completion-nvim plugin you mentioned.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 5, 2020, 10:14pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/26 "2020-07-05T22:14:36Z")

</div>

does your completion work for `export`ed functions from modules?

i.e does calling `:lua vim.lsp.buf.hover()` on `plot` produce anything if you have `using Plots`?

edit: worked after I nuked `~/.julia`

---

<div class="post-metadata">

**Author:** ![cameronperot](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cameronperot](https://discourse.julialang.org/u/cameronperot)\
**Post date:** [July 5, 2020, 11:55pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/27 "2020-07-05T23:55:29Z")

</div>

Yes, that works for me.

---

<div class="post-metadata">

**Author:** ![avonmoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avonmoll/32/17599_2.png) [@avonmoll](https://discourse.julialang.org/u/avonmoll)\
**Post date:** [August 31, 2020, 5:18pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/28 "2020-08-31T17:18:40Z")

</div>

Thanks for the tips! Are the indices supposed to be cached somewhere? If I open a Julia file that is not associated with a particular Project, the LS re-indexes every single package in my global Project.toml and it’s taking a lot of CPU each time.

---

<div class="post-metadata">

**Author:** ![qwerytyui1234](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qwerytyui1234/32/31952_2.png) [@qwerytyui1234](https://discourse.julialang.org/u/qwerytyui1234)\
**Post date:** [September 6, 2020, 10:43pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/29 "2020-09-06T22:43:19Z")

</div>

Hi thanks for the thread. I’ve followed the instructions and ended up setting everything up.

However, I have a personal package that I use, which are just collections of functions at some home directory. I don’t have an actual project.toml files or anything like that. Stuff like src set up etc. since I am not familiar with how to properly develop packages.

However, I think that is leading to having missing reference error show up when I import that package.

For example, if I just have some package called A and have “using A”, that A shows up as missing reference.

Is there any way to tell Julia to get rid of this error message? I am already using diagonstic-nvim but that didn’t seem to help, unless I messed something up.

Secondly, suppose I have some named tuple called B that consists of a and b. If I type B. in the .jl file and press tab, nothing shows up. B is defined in the REPL (and ofc works in REPL). I do not have other external autocompletion plugin. Is there any way to get tab completion working for named tuples without an additional plugin like deoplete? I prefer not to use other external plugins at the moment because I use a lot of greek letters which uses tabs.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![donquicote](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@donquicote](https://discourse.julialang.org/u/donquicote)\
**Post date:** [February 2, 2021, 4:04am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/30 "2021-02-02T04:04:37Z")

</div>

`:LspInstall` is not working anymore. How am I supposed to install `julials`?

---

<div class="post-metadata">

**Author:** ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Post date:** [February 2, 2021, 4:12am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/31 "2021-02-02T04:12:36Z")

</div>

For now, yes. Run the following:

```julia
julia -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer")'

```

I’ll plan to submit a PR to `nvim-lspconfig` to that it can be installed by the default install instructions.

For future reference, this is the location of the julia configuration.

[https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/julials.lua](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/julials.lua)

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [June 24, 2021, 7:54am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/32 "2021-06-24T07:54:55Z")

</div>

Hey, I have LanguageServer installed both globally and in my Project. `nvim-lsp` is working, but it cannot find the packages installed in the Project. Neovim working dir is the root of the project

Any advice?

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [June 24, 2021, 2:36pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/33 "2021-06-24T14:36:42Z")

</div>

Spot it, it’s because Startify moves my tab pwd but not the whole neovim pwd. I think the only solution is to make Startify move the whole pwd.

However, LanguageServer cannot recognize Flux and Random modules. Anyone with similar issue?

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [June 29, 2021, 8:45am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/34 "2021-06-29T08:45:23Z")

</div>

I’m also running this setup but for me whenever I try to start the server when I open a julia file my log shows an error.

```bash
[START] 2021-06-29T10:43:46+0200 ] LSP logging initiated
[ERROR] 2021-06-29T10:43:47+0200 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:457 ] "rpc" "julia" "stderr" "ERROR: "
[ERROR] 2021-06-29T10:43:47+0200 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:457 ] "rpc" "julia" "stderr" "StackOverflowError:"
[ERROR] 2021-06-29T10:43:47+0200 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:457 ] "rpc" "julia" "stderr" "\n"

```

I’ve pulled the latest language server and neovim as well as installed the LanguageServer and SymbolServer. How did you get your setup to work? @sapo

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [June 29, 2021, 6:29pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/35 "2021-06-29T18:29:37Z")

</div>

Hello, can you try to read the log? `:JuliaFormatterLog` does the trick.

Also, with the latest version, `:JuliaFormatterEchoCmd` on the first call shows the command used for launching the server. Just copy it and launch in a different terminal. If it fails, feel free to put here the error output…

---

<div class="post-metadata">

**Author:** ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Post date:** [June 29, 2021, 7:00pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/36 "2021-06-29T19:00:52Z")

</div>

With the latest version of `JuliaFormatter.vim` you can use `:JuliaFormatterEchoCmd` to get the command that is being executed. There’s also `:JuliaFormatterLog` that shows you the log from the server that can help for debugging purposes. This of course is not related to LSP.

---

<div class="post-metadata">

**Author:** ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Post date:** [June 29, 2021, 7:01pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/37 "2021-06-29T19:01:53Z")

</div>

@sapo you and I are racing to post the same thing 🙂

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [June 29, 2021, 7:02pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/38 "2021-06-29T19:02:19Z")

</div>

Yep, I have just corrected my message above 🙂  
Thank you a lot, it’s one of the most useful plugin when working in Julia

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [June 30, 2021, 7:00am UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/39 "2021-06-30T07:00:51Z")

</div>

Thanks for the tip with `JuliaFormatterLog`. Very useful. The juliaformatter actually works. It’s my neovim native lsp via nvim-lspconfig that doesn’t work. But I have no idea why. I just get a stackoverflow error from my `~/.cach/nvim/lsp.log` file. Weird because when I run the same commands in julia on my own it works. Maybe I’ll just post it on neovim to see if those guys knows what’s going on. I’m sure I’m doing something stupid. 🙂

---

<div class="post-metadata">

**Author:** ![ReneganRonin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reneganronin/32/21738_2.png) [@ReneganRonin](https://discourse.julialang.org/u/ReneganRonin)\
**Post date:** [July 2, 2021, 12:42pm UTC](https://discourse.julialang.org/t/neovim-languageserver-jl/37286/40 "2021-07-02T12:42:54Z")

</div>

you forgot to include `server_path` in your config. you can read more in [https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md](https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md)  
look for julials

[Previous page](https://discourse.julialang.org/t/neovim-languageserver-jl/37286.md?page=1)

[Next page](https://discourse.julialang.org/t/neovim-languageserver-jl/37286.md?page=3)
