Julia-Vim tutorial for newbies

I have julia v1.4.0 and LanguageServer v2.0.0 and this in my coc-settings.json (open in vim with :CocConfig)

{
"languageserver": {
  "julia": {
      "command": "julia",
           "args" : ["--startup-file=no", "--history-file=no", "-e",
                     "import Pkg; envpath = dirname(Pkg.Types.Context().env.project_file); const DEPOT_DIR_NAME = \".julia\"; depotpath = Sys.iswindows() ? joinpath(ENV[\"USERPROFILE\"], DEPOT_DIR_NAME) : joinpath(ENV[\"HOME\"], DEPOT_DIR_NAME); using LanguageServer; server = LanguageServerInstance(stdin, stdout, false, envpath, depotpath); run(server)"],
      "filetypes": ["julia"]
  }
}
}
3 Likes

Wow @jbrea this is very nice!

@FirstnameLastname Can you share your config to make it send cells to repl?

You can use this plugin made by @mroavi. It’s easier and cleaner than my setup.

6 Likes

@FirstnameLastname, I love how your setup looks. Are you able to share your config/dotfiles?

1 Like

Hi, what do you mean from within vim ‘kitty @ --to unix:/tmp/mykitty send-text “blah”’??

I have a jl file open, open a h-split and with Neoterm open a terminal. I want to use kitty-navigator (plug-in similar to Tmux-navigator, which is also a great plugin for those of you who wish to use Tmux) to move between screens but for whatever reason when I type your “blah” containing command into the new terminal I just get an error.

If everything is within the same kitty window I don’t think you need @ --to.
For some context where @ --to may be useful, see this issue.

Can’t you just use the :T command of neoterm for your setup?

I could, and do, but launching Julia from within a terminal within Nvim is actually slower than opening a new kitty window/pane within the kitty os window and launching a Julia repo from that. My MacBook is a good 8 years old at this point & I want to be as efficient as I can. (Hence the learned use of Neovim, Lua, and the terminal in general rather than relying on bloated VSCode… though I do use it from time to time when work just needs to be done). Side note: Figured increasing my cmd line fu would make me an overall better programmer/data sci dilettante than just learning one editor.

1 Like

In relation to many of these setups: I have been using the Vim \rightarrow vim-slime \rightarrow Julia REPL setup and it works great, especially with the Vim :term option as you can also then pass REPL lines back to Vim.

One non-criticial issue that persists is that sending lines that begin with tab characters (i.e. a lot of lines!) can freak out the REPL somewhat and cause it to dump all Base exports before executing a line. This becomes particularly overwhelming and gluggy when you try and send a big chunk or even the whole script file.

Has anyone else experienced this or come up with a nice way around it? I note that there are two related issues open on the Julia GitHub here and here. It seems to be tied to the fact that <tab> <tab> in an empty REPL “autocompletes” everything . I’ve tried playing around with tabs as spaces etc. but that makes it much harder to write readable code.

You can set

set tabstop=4
set shiftwidth=4
set expandtab

This way your code look exactly as if you use tab, but no actual tabs will be inserted.

2 Likes