Neovim: Getting LSP running for Julia using Coc-Plugin

so I’m trying to get LSP working for Julia using the CoC Plugin. It works for python or HTML. So I’m using:

Coc-Plugin: /neoclide/coc.nvim @ github
CoC-Extension (coc-julia): /neoclide/coc.nvim/wiki/Language-servers#julia @github
LSP-Server: (recommended by the Coc-extension)

I also did:

julia> using Pkg
julia> Pkg.add("LanguageServer")
julia> Pkg.add("SymbolServer")
julia> Pkg.add("StaticLint")

Doesn’t really work. I don’t get any definitions. If I write “a” I just get a bunch of possible functions starting with a. Also jump to definition doesn’t seem to work. Either the server is just useless or I’m doing something wrong. Chances are way higher on the later.

I then uninstalled the coc extension and added the server config manually to my coc-settings.json - of course I first tried if the arguments in the config worked. They didn’t, might be a bug in the docs in the git of Coc. Anyway, I got this now: which should work according to

    "python.jediEnabled": false,
    "languageserver": {
        "julia": {
            "command": "/usr/bin/julia",
            "args" : ["--startup-file=no", "--history-file=no", "-e",
           "using LanguageServer; using Pkg; import StaticLint; import SymbolServer; en
            "filetypes": ["julia"]

but same result. Now I’m having kind of a hard time debugging it since I’m new to Neovim and Coc but ps aux | grep -i julia shows that

/usr/bin/julia --startup-file=no --history-file=no --depwarn=no --eval using LanguageServer; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, "/home/<user>/.julia/environments/v1.5"); server.runlinter = true; run(server);

is running. (The command also works just fine or at least doesn’t throw an error.) So the server should run. And journalctl -n 40 also doesn’t show anything.

CocOpenLog also shows
1 2020-09-15T17:16:14.568 INFO (pid:5526) [services] - registered service "languageserver.julia"

So I assume that Neovim/Coc has a connection to my server. I’m unsure it’s actually using it though. Again, maybe the server just doesn’t really do much?

Any input is appreciated.

This didn’t work for me a while back, but I just tried coc-julia again a few days ago, and it seems to work now. Popups displaying function definitions and autocompletions do, at least. Not sure about jumping to definitions.

It may take a little while for the LS to start up.

Also, CocInfo reports the error IOError: bind: name too long (ENAMETOOLONG) from Julia, but I’m not really sure how that error has affected anything, as things are working just as I expect them to.

Any news? I tried to use it and I don’t get anything at all, like if my .jl file is not even recognized as a Julia file.
Coc works flawlessly with Rust on the same machine, so I really think its a problem with coc-julia

Back then there was a bug in the Julia Language Server. It might have been fixed. I tried fixing it by myself and I think I ws able to but it didn’t really work anyway. Never tried it again.

coc-julia is working very well for me. Do you have julia-vim installed? If not, then your vim will probably think your .jl files are lisp files (unless you set the ft yourself some other way). That might be why the LS isn’t working for you.

Edit: Fixed a typo, in bold.

Yeah I removed julia-vim but I still get nothing, not even syntax highlighting. There’s something I should add to mi init.vim file in order to make coc-julia work?

I forgot to mention: I effortlessly got CoC to work for Rust, simply installing the corresponding module with CocInstall. For Julia, I followed the same steps but it simply does nothing

Sorry, there was a typo in my last post. You want to keep julia-vim installed. (Or, otherwise, set ft=julia for .jl files by an autocmd.)

I’m not sure if LanguageServer.jl supports syntax highlighting yet. But, other than that, coc-julia worked for me without having to do anything other than installing it. What exactly isn’t working with coc-julia for you? Other than syntax highlighting, because I don’t think that’s available (or, at least, hasn’t worked for me yet either).

Can you add coc#status() to your statusline (or you could call it manually too I guess) to see what coc does when you open a .jl file? You can also try :CocInfo and :CocOpenLog to see if coc starts the Julia language server.

If I take julia-vim installed together with coc-julia I get errors, so I think the two of them goes in conflict. I could stand (for now) to be without the syntax highlighting provided from julia-vim, I would really like to get coc-julia to work with autocompletion. At the actual state, I only get completion for reserved words and words that I already used in the same file, but no autocompletion for modules or their imported methods and functions

coc-julia and julia-vim work fine for me, so perhaps there is something else wrong with your configuration.

The way coc-julia works (but I think this might be how it is implemented in LanguageServer.jl, I’m not sure) is that it checks your cwd for a Manifest.toml file so that it can index the modules you’re importing from elsewhere. If you generate that file in your working directory, then coc-julia will do what you want.


I tried to use the sample init.vim file present on the github page of COC. I tried without it (“blank” init.vim file with only COC and Julia module installed) but it still doesn’t work and I get the same error message:

[coc.nvim]: Some plugin change completeopt on insert mode: Last set from ~/.config/nvim/plugged/julia-vim/autoload/LaT
eXtoUnicode.vim line 404!

Ho did you configured julia-vim and COC in your init.vim file? Did you just installed both and it simply worked out of the box? Which version of neovim or vim are you using?

Do you mean the configuration found in this section?

It should work out of the box, but coc does like to complain when another plugin does automatic completion in your buffer. The error you see should appear whenever you try to use julia-vim’s LaTeX-to-Unicode substitution (e.g. when you type \mu, it converts it automatically to µ, perhaps after pressing <Tab>). However, as far as I can tell, the error doesn’t really have any impact other than being annoying.

To avoid the error, I’ve turned off julia-vim’s LaTeX-to-Unicode substitution by putting this in my init.vim / .vimrc:

let g:latex_to_unicode_file_types = '$^'
let g:latex_to_unicode_file_types_blacklist = '.*'

One probably really only needs the first line, but I haven’t gotten around to testing it fully. The language server can also do the same substitutions, so I haven’t noticed any loss in functionality from disabling the julia-vim-L2U plugin. (See :help julia-vim-L2U, :help g:latex_to_unicode_file_types, etc.)

julia-vim-L2U also allows you to customise the behaviour of its substitutions. If you want to keep using it, but don’t like the error coc gives you, you can try reading :help julia-vim-L2U-keymap. I’ve found that turning this on and turning off tab/automatic completion avoids the error from coc. (However, you should not include the init.vim config I’ve shown you above to use it.)

Note that the configuration above will deactivate LaTeX-to-Unicode substitutions for all filetypes, so you’ll want to modify it appropriately if you want to use it for some non-Julia filetypes.

I am using Neovim built from the master branch. That is, NVIM v0.5.0-a22fe09, so I might be a few commits behind the current master branch.

I have been struggling too. Here is a minimal init.vim for neovim with only coc and julia-vim. I have also installed coc-julia. Latex-to-unicode substitution then happens like this:

  1. I type the characters \mu
  2. I type the tab key
  3. I type the backspace key
  4. I type the tab key again, and this time the substitution is made. The 404 error message may or may not appear. If I keep alternating tab and backspace, no further substitution is made, but sometimes the 404 message appears.
call plug#begin('/home/nacnudus/.config/nvim/plugged')  
Plug 'neoclide/coc.nvim', {'branch': 'release'}"
Plug 'JuliaEditorSupport/julia-vim'
call plug#end()
filetype plugin indent on

Hi @nacnudus, did you get the chance to read this part of my previous post?

Hi @chisquared, thank you for replying. Yes I did read your full post. Using those two lines disables LaTeX-to-Unicode substitution altogether for me, and I would like to retain it. Without using those two lines, the substitution is only made at the second attempt, and I would prefer it to be made at the first attempt, which is what julia-vim does on its own (when coc.vim and coc-julia aren’t installed).

The language server should be able to do L2U-substitution, though I’m not quite sure what you mean by first and second attempt. (Edit: Ok, now I understand. See further edit below.) L2U-substitution using julia-vim vs using the language server are practically indistinguishable for me, aside from julia-vim being perhaps a split second faster while the language server is still starting up.

One way to keep using coc for completion while also using julia-vim without errors is described in the second part of my previous post, though I don’t find the experience ideal. (It’s hard to describe. You can try it out for yourself to see.)

I guess your other alternative is to turn off coc completion for .jl files and just rely on julia-vim, but that’ll be much more limited.

Finally, I suppose you could also try the other language server plugins available for vim:

Edit: Ok, I think I now understand what you mean. That’s because your init.vim contains no keybindings for coc completion. I don’t think it should even work at all the second time, but perhaps I am missing something.

If you want to use tab-completion with coc, you’ll need to use some of the configuration given here (along with deactivating julia-vim-L2U). For example:

" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

function! s:check_back_space() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'

I should mention that I’ve found this piece of the config a little finicky when it comes to working with other plugins (e.g. UltiSnips), but you may wish to try it.

I’m not using this particular suggested configuration. Instead, I patterned mine off the coc keybindings I found here:

Thanks again, I have now tried that chunk of tab completion configuration, and also the relevant parts of lervag/dotvim. The L2U substitution by the language server still doesn’t work either way. This is in a completely clean init.vim, and the only coc extension installed is coc-julia. It seems the only option now is to try other language server plugins, unless there is an example init.vim somewhere that has been confirmed to work.

That is very strange. Sorry it hasn’t worked for you.

I think you’ll want to try the built-in LS plugin described in the blogpost I shared (it’s also in the second half of the wiki page on vim at the LanguageServer.jl repo); I believe the way that completion is implemented there is a bit friendlier to how julia-vim does L2U-substitution.

If you’d like to keep trying with coc, send me a PM and I can send my init.vim.

With help from @chisquared I have got LatTeX-to-unicode substitution working from the language server instead of the vim-julia package. However, it only replaces the backslash, not the rest of the text already written, so the result is muμ instead of μ.

There is a setting to control whether the existing text is replaced, suggest.fixInsertedWord, which defaults to true. I have also tried manually setting that in the coc config, to no avail.

Huh, this happens to me now too. This isn’t how coc used to work, and I think is a bug either in coc.nvim or coc-julia.