# My Julia setup for vim with YCM on Linux

**URL:** https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485
**Category:** Tooling
**Tags:** vim
**Created:** [August 25, 2020, 5:57am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485 "2020-08-25T05:57:44Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [August 25, 2020, 5:57am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/1 "2020-08-25T05:57:44Z")

</div>

## Installation

```julia-auto
$ pip install jill --user -U

```

```julia-auto
$ jill install 1.3

```

## lsp

```julia-auto
Plug 'ycm-core/YouCompleteMe'
Plug 'ycm-core/lsp-examples'
Plug 'JuliaEditorSupport/julia-vim', {'for': 'julia'}

let g:ycm_language_server = [
			\ { 
			\ 'name': 'julia',
			\ 'filetypes': ['julia'],
			\ 'project_root_files': ['Project.toml'],
			\	'cmdline': ['julia', '--startup-file=no', '--history-file=no', '-e', '
			\ using LanguageServer;
			\ using Pkg;
			\ import StaticLint;
			\ import SymbolServer;
			\ env_path = dirname(Pkg.Types.Context().env.project_file);
			\       
			\ server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, "");
			\ server.runlinter = true;
			\ run(server);
			\ ']
			\ },
			\ ]

```

```julia-auto
$ cd $HOME/.vim/plugged/lsp-examples
$ ./install.py --enable-julia

```

## Ctags and Gtags

```julia-auto
# ~/.ctags.d/julia.ctags
--langdef=julia
--langmap=julia:.jl
--regex-julia=/^[\t]*(([^ \t.({[]+\.)*@[^ \t({[]+[\t]+)*(function|macro|abstract type|primitive type|struct|mutable struct|module)[\t]+([^ \t({[]+).*$/\4/f,function/
--regex-julia=/^[\t]*(([^ \t.({[]+\.)*@[^ \t({[]+[\t]+)*(([^@#$ \t({[]+)|\(([^@#$ \t({[]+)\))[\t]*[\t]*\([^#]*\)([\t]+where[\t]+\{.*\})?[\t]*=([^=].*)?$/\4\5/f,function/
--regex-julia=/^(([^ \t.({[]+\.)*@[^ \t({[]+[\t]+)*(const[\t]+)?(([^ \t.({[]+\.)*@[^ \t({[]+[\t]+)*([^@#$ \t({[]+)[\t]*=([^=].*)?$/\6/v,variable/

```

```julia-auto
$ ctags -R --totals=yes --exclude=`.*` --exclude=.git --languages=julia 
$ gtags

```

## jupyter

```julia-auto
Plug 'jupyter-vim/jupyter-vim', {'for': ['python', 'julia']}

```

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [August 25, 2020, 6:06am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/2 "2020-08-25T06:06:19Z")

</div>

YouCompleteMe Hover:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/b/dba21e94e6c2bbed0f383e443c4c97c7f5167346.png)

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [August 25, 2020, 6:28am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/3 "2020-08-25T06:28:19Z")

</div>

GNU global for ref:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/8/88ce7bc3579f8c0547bf0271ab1b8053df59013b.png)

---

<div class="post-metadata">

### Author: ![nluetts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nluetts/32/24967_2.png) [@nluetts](https://discourse.julialang.org/u/nluetts)
#### Post date: [January 8, 2022, 9:14pm UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/4 "2022-01-08T21:14:29Z")

</div>

Thanks for sharing, @junix

I am trying to get YouCompleteMe in NeoVim to play nice with LanguageServer.jl, but it does not work for me. My log files say that the Julia language server crashes. I tried with Julia 1.7 and (after reading [this issue](https://github.com/julia-vscode/LanguageServer.jl/issues/1009)) with 1.6, but to no avail. Different errors pop up, but all involve the JSONRPC package. Could you share the Manifest of your Julia environment that runs language server? I would like to try with the exact same versions.

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [March 15, 2022, 4:27am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/5 "2022-03-15T04:27:34Z")

</div>

I just try it and it still works using ycm for julia 1.6 if you follow [https://github.com/ycm-core/lsp-examples](https://github.com/ycm-core/lsp-examples) but it is horribly slow and consumes lots of CPU when starting(I wait for 1min).

Actually, I find I actually don’t need julia lsp to write julialang.

Gutentags and tag completion are nice for a project.

OhMyREPL and vim-slime(lots of similar plugins) are nice for REPL.

`ftplugin/julia.vim`

```julia
noremap <buffer> <localleader>d :call slime#send("@doc " . expand("<cword>") . "\r")<CR>

xmap <silent><buffer> <CR> <Plug>SlimeRegionSend
nmap <silent><buffer> <space><space> <Plug>SlimeParagraphSend

```

Btw localleader is for ftplugin and I think it may be silly to set localleader the same as leader.

Also, you can use [quickui](https://github.com/skywind3000/vim-quickui)

```julia
nnoremap <localleader>] :call quickui#tools#preview_tag('')<cr>

```

to preview tags in a popup window

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [March 16, 2022, 2:39am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/7 "2022-03-16T02:39:27Z")

</div>

```julia
vim ~/.ctags

```

add [https://gist.github.com/Evizero/e1595c35611c15ebf8f9](https://gist.github.com/Evizero/e1595c35611c15ebf8f9).

```julia
vim ~/.ctags.d/exclusion.ctags

```

add exclusion.

```julia
cd $HOME/packages/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/
ctags -R --languages=julia --fields=+nl

```

DONOT forget `--fields=+l`

Add

```julia
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_min_num_of_chars_for_completion = 4

```

into your vimrc.

```julia
vim ~/.vim/ftplugin/julia.vim

```

add

```julia
setlocal tags+=$HOME/packages/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/tags

```

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [March 16, 2022, 2:49am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/8 "2022-03-16T02:49:07Z")

</div>

```julia
vim ~/.dotfiles/vim/.vim/after/syntax/julia.vim

```

add

```julia
hi link juliaFunctionCall juliaFunction

syntax keyword juliaFunction println zero zeros summary
syntax keyword juliaFunction eigvecs eigen eigvals

```

such like that.

Add

```julia
let g:ycm_seed_identifiers_with_syntax = 1

```

in your vimrc

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [March 16, 2022, 6:00am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/9 "2022-03-16T06:00:29Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/4/5/45099536ba13603f60c80292548576ba43e21a0c.png)

---

<div class="post-metadata">

### Author: ![KaiWizardly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiwizardly/32/35389_2.png) [@KaiWizardly](https://discourse.julialang.org/u/KaiWizardly)
#### Post date: [April 12, 2022, 9:54am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/10 "2022-04-12T09:54:01Z")

</div>

I think I tried to follow your steps ( except for installing julia 1.7) but this is not working for me somehow.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/6/76a1e255df8aa0ab64ec141c1a9ab3dff60f9d02.png)  
as you can see, the `juliacompleter` server is dead. Can you give me some clue about what to check?

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [April 12, 2022, 12:16pm UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/11 "2022-04-12T12:16:08Z")

</div>

Show your config for julia.  
eg:

```nohighlight
let s:julia_cmdline = ['julia', '--startup-file=no', '--history-file=no', expand('~/.vim/lsp-julia/run.jl')]
let g:ycm_language_server += [
			\ { 'name': 'julia',
			\ 'filetypes': ['julia'],
			\ 'project_root_files': ['Project.toml'],
			\ 'cmdline': s:julia_cmdline
			\ },
			\ ]

```

In `lsp-julia/run.jl`

```julia
using LanguageServer;
using Pkg;
import StaticLint;
import SymbolServer;
server = LanguageServer.LanguageServerInstance(stdin, stdout, "", "");
server.runlinter = false;
run(server);

```

Don’t forget to exec `./install.py --enable-julia` in `lsp-examples`

And show your ycm log in `/tmp`

---

<div class="post-metadata">

### Author: ![KaiWizardly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiwizardly/32/35389_2.png) [@KaiWizardly](https://discourse.julialang.org/u/KaiWizardly)
#### Post date: [April 12, 2022, 8:13pm UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/12 "2022-04-12T20:13:07Z")

</div>

I am using NeoVim v0.6.1 and Julia v1.7.2. and I installed the plugins you mentioned.

```julia
Plug 'ycm-core/YouCompleteMe'
Plug 'ycm-core/lsp-examples'
Plug 'JuliaEditorSupport/julia-vim', {'for': 'julia'}

```

then I first tried with the config you posted. It did not work. then I tried to follow some other guides and ran `./install.py --enable-julia` in `lsp-examples`, which suggested to `source ~/.local/share/nvim/plugged/lsp-examples/vimrc.generated`. which has the following config

```julia
     let g:ycm_lsp_dir = '/home/$USER/.local/share/nvim/plugged/lsp-examples'
     let g:ycm_language_server = []
  let s:julia_cmdline = ['julia', '--startup-file=no', '--history-file=no', '-e', '
\ using LanguageServer;
\ using Pkg;
\ import StaticLint;
\ import SymbolServer;
\ env_path = dirname(Pkg.Types.Context().env.project_file);
\ debug = false;
\
\ server = LanguageServer.LanguageServerInstance(stdin, stdout, debug, env_path, "", Dict());
\ server.runlinter = true;
\ run(server);
\ ']

let g:ycm_language_server += [
  \ { 'name': 'julia',
  \ 'filetypes': ['julia'],
  \ 'project_root_files': ['Project.toml'],
  \ 'cmdline': s:julia_cmdline
  \ },
  \ ]

```

I have then tried using `Plug 'autozimu/LanguageClient-neovim'` but that did not work either. So I am assuming I am missing a very basic step, which I cannot figure out on my own.

---

<div class="post-metadata">

### Author: ![KaiWizardly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiwizardly/32/35389_2.png) [@KaiWizardly](https://discourse.julialang.org/u/KaiWizardly)
#### Post date: [April 12, 2022, 8:24pm UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/13 "2022-04-12T20:24:08Z")

</div>

logs at `/tmp` are

```julia
% cat ycm_1lp7j2jp.log 
2022-04-12 14:58:50,287 - ERROR - <urlopen error [Errno 111] Connection refused>
2022-04-12 14:58:50,390 - ERROR - <urlopen error [Errno 111] Connection refused>
2022-04-12 14:58:50,493 - ERROR - <urlopen error [Errno 111] Connection refused>

```

```julia
% cat ycmd_54423_stderr_e1g9hzuu.log 
2022-04-12 14:58:50,561 - INFO - Completion config: 50, detailing -1 candiates
2022-04-12 14:58:50,562 - INFO - Completion config: 50, detailing -1 candiates
2022-04-12 14:58:50,562 - INFO - Completion config: 50, detailing -1 candiates
2022-04-12 14:58:50,563 - INFO - Completion config: 50, detailing -1 candiates
127.0.0.1 - - [12/Apr/2022 14:58:50] "GET /ready HTTP/1.1" 200 4
127.0.0.1 - - [12/Apr/2022 14:58:50] "GET /signature_help_available?subserver=vim HTTP/1.1" 200 18
2022-04-12 14:58:50,612 - ERROR - Semantic completion not available for ['vim']
Traceback (most recent call last):
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 106, in FiletypeCompletionAvailable
    self.GetFiletypeCompleter( filetypes )
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 91, in GetFiletypeCompleter
    raise ValueError(
ValueError: No semantic completer exists for filetypes: ['vim']
127.0.0.1 - - [12/Apr/2022 14:58:50] "POST /event_notification HTTP/1.1" 200 2
2022-04-12 14:58:50,620 - INFO - Adding buffer identifiers for file: ~/.config/nvim/init.vim
2022-04-12 14:58:50,623 - ERROR - Semantic completion not available for ['vim']
Traceback (most recent call last):
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 106, in FiletypeCompletionAvailable
    self.GetFiletypeCompleter( filetypes )
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 91, in GetFiletypeCompleter
    raise ValueError(
ValueError: No semantic completer exists for filetypes: ['vim']
127.0.0.1 - - [12/Apr/2022 14:58:50] "POST /event_notification HTTP/1.1" 200 2
127.0.0.1 - - [12/Apr/2022 14:58:50] "POST /receive_messages HTTP/1.1" 200 5
2022-04-12 14:58:50,728 - ERROR - Semantic completion not available for ['vim']
Traceback (most recent call last):
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 106, in FiletypeCompletionAvailable
    self.GetFiletypeCompleter( filetypes )
  File "~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 91, in GetFiletypeCompleter
    raise ValueError(
ValueError: No semantic completer exists for filetypes: ['vim']
127.0.0.1 - - [12/Apr/2022 14:58:50] "POST /semantic_completion_available HTTP/1.1" 200 5

```

```julia
% cat ycmd_54423_stdout_557d38wt.log 
serving on http://localhost:54423

% cat ycm_ik9n26h_.log 
2022-04-12 04:59:18,561 - ERROR - The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 0. Type ':YcmToggleLogs ycmd_38959_stderr_r1z7u8c7.log' to check the logs.

```

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [April 13, 2022, 6:46am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/14 "2022-04-13T06:46:07Z")

</div>

1st, I’m using Julia v1.7.2 and vim8.2. I’m not sure whether it’s suitable for neovim. But I guess it should work.

2nd, don’t use the config you posted.  
If you `@doc LanguageServer.LanguageServerInstance`, you will find how to use LanguageServerInstance. Or if the doc is not right, then you should check the source code of LanguageServer, which is not hard if you use ctags. It may be not the ycm team’s fault, LanguageServer’s API may have often been changed.

And I suggest you split your julia config as I do because it’s convenient to modify. Note: without the `-e`.

3rd, the log  
`ValueError: No semantic completer exists for filetypes: ['vim']`  
confuses me.  
Does lsp-examples work for other languages?

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [April 13, 2022, 7:43am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/15 "2022-04-13T07:43:29Z")

</div>

Or you should try neovim built-in lsp. It sounds great. though I’m satisfied with my current workflow

---

<div class="post-metadata">

### Author: ![KaiWizardly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiwizardly/32/35389_2.png) [@KaiWizardly](https://discourse.julialang.org/u/KaiWizardly)
#### Post date: [April 13, 2022, 7:33pm UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/16 "2022-04-13T19:33:50Z")

</div>

I have not tried lsp with other languages.

I don’t understand what you mean by `@doc LanguageServer.LanguageServerInstance` I tried running this in `julia` but that did not show me anything.

---

<div class="post-metadata">

### Author: ![junix](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junix/32/14941_2.png) [@junix](https://discourse.julialang.org/u/junix)
#### Post date: [April 14, 2022, 12:47am UTC](https://discourse.julialang.org/t/my-julia-setup-for-vim-with-ycm-on-linux/45485/17 "2022-04-14T00:47:36Z")

</div>

using LanguageServer
