Skip to content

kitajusSus/jEMach

Repository files navigation

jemach

A comprehensive Neovim plugin for Julia development with an integrated REPL, workspace panel, and unified workflow mode for fast and efficient coding.

More info: Reddit Discussion

later in text you may seen instructions of building native module written in zig and cpp forget about it its in my experimental branch

Julia Workspace Assistant (tmux TUI)

A standalone terminal UI for monitoring your Julia REPL session from a side tmux pane — no Neovim required, no external Julia packages needed.

Quick start

# 1. In one tmux pane, start Julia:
julia --project=.

# 2. In the Julia REPL, load the background watcher:
julia> include("scripts/jl_watcher.jl")

# 3. In any other pane, launch the TUI:
./scripts/jl-assist

The TUI opens in a new split to the right. It polls the state file every 1.5 s; the Julia watcher writes the file every 2 s — so changes appear within ~3.5 s.

TUI keybindings

Key Action
j / k Move cursor down / up
l / Expand module or send println(var) to REPL
h Collapse module node
d Hide selected item from view
D Restore all hidden items
r Force state refresh
q Quit

Tree view

▼ Main
    x             Int64       42
    greeting      String      "hello"
    myfunc        Function
▶ Revise          [collapsed — press l to expand]
▼ MyPackage
    my_var        Float64     2.718

jl-assist options

jl-assist [-p PANE_ID] [-w WIDTH] [-f]

  -p PANE_ID   tmux pane that runs the Julia REPL (auto-detected by default)
  -w WIDTH     width of the TUI pane in columns (default: 60)
  -f           force a new TUI pane even if one is already open

Requirements

  • luajitsudo pacman -S luajit (Arch Linux)
  • tmux — running in a tmux session

Features

🚀 Core Features

  • Dual REPL Backends: Support for both toggleterm.nvim and vim-slime (tmux/screen)
  • Smart Code Sending: Send current line, visual selection, or automatically detected code blocks using Tree-sitter
  • Workspace Panel: Real-time view of variables, their types, and values updated asynchronously via JSON RPC (no text wrapping)
  • Command History: Track and replay REPL commands using Telescope
  • Workspace Persistence: Save and restore session state across restarts
  • Project Awareness: Automatic project activation based on Project.toml files
  • Revise.jl Support: Optional automatic loading of Revise for interactive development
  • LSP Integration: Full Language Server Protocol support for IDE features (optional)
  • Advanced tmux Integration: Intelligent panel management for tmux users

✨ Layout Modes

The plugin supports multiple layout configurations:

  1. Vertical Split Mode (default): Terminal on right, workspace underneath
  2. Unified Buffer Mode: REPL and workspace in same vertical split
  3. Classic Mode: Workspace on right, REPL at bottom (toggleterm)

Easy navigation between all three components with configurable keybindings!

Installation

Using lazy.nvim

{
  "kitajusSus/jemach",
  dependencies = {
    "akinsho/toggleterm.nvim",  -- Optional, only if using toggleterm mode
    "nvim-telescope/telescope.nvim",  -- Optional, for command history
    "neovim/nvim-lspconfig",  -- Optional, for LSP features
  },
  config = function()
    require("jemach").setup({
      -- REPL backend settings
      backend = "auto",  -- "toggleterm", "vim-slime", or "auto"
      terminal_direction = "horizontal",  -- "horizontal", "vertical", or "float"
      terminal_size = 15,

      -- Optional configuration
      activate_project_on_start = true,
      auto_update_workspace = true,
      workspace_width = 50,
      use_revise = true,
      auto_save_workspace = false,
      save_on_exit = true,

      -- Keybindings (defaults shown)
      keybindings = {
        toggle_repl = "<C-\\>",      -- Toggle REPL visibility
        focus_repl = "<A-1>",        -- Focus REPL window
        focus_workspace = "<A-2>",   -- Focus workspace panel
        focus_code = "<A-3>",        -- Focus code editor
        cycle_focus = "<A-Tab>",     -- Cycle between components
        workflow_mode = "<leader>jw", -- Toggle workflow mode
      },
    })
  end,
}
use {
  "kitajusSus/jemach",
  requires = {
    "akinsho/toggleterm.nvim",
    "nvim-telescope/telescope.nvim",
    "neovim/nvim-lspconfig",
  },
  config = function()
    require("jemach").setup()
  end,
}

Usage

Commands

Main Commands

  • :JuliaToggleREPL (:Jr) - Toggle Julia REPL terminal
  • :JuliaSendToREPL (:Js) - Send current line/selection/block to REPL
  • :JuliaToggleWorkspace (:Jw) - Toggle workspace panel
  • :JuliaHistory (:Jh) - Show command history (requires Telescope)

Workflow Commands

  • :JuliaWorkflowMode (:Jfw) - Toggle unified workflow mode
  • :JuliaFocusREPL - Focus REPL window
  • :JuliaFocusWorkspace - Focus workspace panel
  • :JuliaFocusCode - Focus code editor
  • :JuliaCycleFocus - Cycle focus between components

Terminal Direction

  • :JuliaSetTerminal [float|horizontal|vertical] - Set terminal layout
  • :JuliaCycleTerminal - Cycle through terminal layouts

Workspace Persistence

  • :JuliaSaveWorkspace - Save workspace variables
  • :JuliaRestoreWorkspace - Restore workspace from saved state
  • :JuliaClearSavedWorkspace - Clear saved workspace data

LSP Commands

  • :JuliaLspEnable / :JuliaLspDisable - Toggle LSP
  • :JuliaGotoDefinition - Go to symbol definition
  • :JuliaFindReferences - Find symbol references
  • :JuliaRename - Rename symbol
  • :JuliaCodeAction - Show code actions

Default Keybindings

When configured with default settings:

Mode Key Action
Normal <C-\> Toggle REPL visibility
Terminal <C-\> Toggle REPL visibility
Normal <A-1> Focus REPL window
Normal <A-2> Focus workspace panel
Normal <A-3> Focus code editor
Normal/Terminal <A-Tab> Cycle focus between components
Normal <leader>jw Toggle workflow mode

Workspace Panel Keybindings

When the workspace panel is focused:

Key Action
<CR> Print variable value in REPL
i Inspect variable (show type and size)
d Delete variable (after confirmation)
r Refresh workspace
q Close workspace panel

Workflow Examples

Quick Start Workflow

  1. Open a Julia file

  2. Press <leader>jw to activate workflow mode

  3. Everything is automatically set up:

    • Workspace panel on the right
    • REPL at the bottom
    • Your code in the main window
  4. Navigate quickly:

    • <A-1> to jump to REPL
    • <A-2> to check workspace
    • <A-3> to return to code
    • <A-Tab> to cycle through all

Code Sending

-- In normal mode, cursor on line:
:Js  -- Sends current line

-- Visual selection:
-- Select code, then:
:Js  -- Sends selection

-- Smart block detection (when enabled):
-- Cursor inside a function, struct, loop, etc.
:Js  -- Automatically detects and sends the entire block

Variable Inspection

  1. Send code to REPL: :Js
  2. Open workspace: :Jw
  3. The workspace panel automatically updates when you create or modify variables in the REPL
  4. Navigate variables:
    • <CR> on a variable to print its value
    • i to inspect its type and size
    • d to delete it
    • r to manually refresh the workspace

Note: The workspace panel automatically detects changes when you type commands directly in the Julia REPL (when auto_update_workspace = true). It securely communicates asynchronously with Julia using libuv local sockets without blocking your terminal.

Configuration Options

require("jemach").setup({
  -- REPL Backend Settings
  backend = "auto",                  -- "toggleterm", "vim-slime", or "auto"
  terminal_direction = "horizontal", -- "horizontal", "vertical", or "float"
  terminal_size = 15,                -- Size for terminal splits

  -- Project Management
  activate_project_on_start = true,  -- Auto-activate Julia project
  use_revise = true,                 -- Auto-load Revise.jl

  -- Workspace Panel
  auto_update_workspace = true,      -- Auto-refresh after code execution
  workspace_width = 50,              -- Workspace panel width
  workspace_update_debounce = 300,   -- Debounce time in milliseconds
  use_cache = true,                  -- Enable workspace caching
  cache_ttl = 5000,                  -- Cache time-to-live in milliseconds

  -- Workspace Persistence
  auto_save_workspace = true,        -- Auto-save workspace on changes
  save_on_exit = true,               -- Save workspace on Neovim exit

  -- Code Execution
  smart_block_detection = true,      -- Auto-detect code blocks
  max_history_size = 500,            -- Max commands in history

  -- LSP Integration
  lsp = {
    enabled = true,                  -- Enable LSP features
    auto_start = true,               -- Auto-start language server
    detect_imports = true,           -- Detect and manage imports
  },

  -- Keybindings
  keybindings = {
    toggle_repl = "<C-\\>",
    focus_repl = "<A-1>",
    focus_workspace = "<A-2>",
    focus_code = "<A-3>",
    cycle_focus = "<A-Tab>",
    workflow_mode = "<leader>jw",
  },
})

REPL Backend Configuration

Using toggleterm.nvim

require("jemach").setup({
  backend = "toggleterm",  -- or "auto"
})

Using vim-slime (tmux/screen)

vim.g.slime_target = "tmux"
vim.g.slime_default_config = {
  socket_name = "default",
  target_pane = "{right-of}",
}

require("jemach").setup({
  backend = "vim-slime",
})

Backend Comparison

toggleterm.nvim

  • Pros: Easy setup, automatic REPL management, integrated terminal
  • Cons: Moderate flexibility, tied to Neovim
  • Best for: Quick setup, single-window workflows

vim-slime (tmux/screen)

  • Pros: Excellent performance, high flexibility, persistent REPL
  • Cons: Requires tmux/screen, manual configuration
  • Best for: tmux users, complex workflows, remote development

Layout Modes

Vertical Split Mode (default)

  • Terminal on the right side
  • Workspace panel underneath terminal
  • Easy access with keyboard shortcuts

Unified Buffer Mode

  • REPL and workspace in same vertical split
  • Compact layout for smaller screens
  • Efficient screen usage

Classic Toggleterm Mode

  • Workspace panel on right
  • REPL terminal at bottom
  • Compatible with toggleterm.nvim features

Smart Block Detection

The plugin can automatically detect and send entire code blocks using Neovim's Tree-sitter integration:

  • Functions (function ... end)
  • Macros (macro ... end)
  • Modules (module ... end)
  • Structs (struct ... end, mutable struct ... end)
  • Blocks (begin ... end, quote ... end, let ... end)
  • Control flow (for ... end, while ... end, if ... end, try ... end)

When your cursor is inside any of these blocks (even deeply nested), :Js will send the outermost top-level block.

Requirements

  • Neovim >= 0.8.0
  • Julia >= 1.6
  • Optional:
    • nvim-treesitter (for Smart Block Detection)
    • toggleterm.nvim (for toggleterm backend)
    • vim-slime (for slime backend)
    • telescope.nvim (for command history)
    • neovim/nvim-lspconfig (for LSP features)

Tips & Tricks

  1. Fast Switching: Use <A-Tab> to quickly cycle between REPL, workspace, and code
  2. Terminal Mode: In terminal mode, use <C-\> to hide REPL without switching focus
  3. Project Root: Place a Project.toml file in your project root for automatic activation
  4. Revise Workflow: Enable use_revise for hot-reloading during development
  5. Custom Layouts: Experiment with terminal_direction to find your preferred layout
  6. Persistent Sessions: Use workspace persistence to save your work across sessions

Troubleshooting

REPL Doesn't Start

  • Check that Julia is in your PATH: julia --version
  • Ensure toggleterm.nvim is installed (for toggleterm backend)
  • For vim-slime: ensure tmux/screen is running

Workspace Panel is Empty

  • Start the REPL first (:Jr)
  • Execute some code to create variables (:Js)
  • Manually refresh (press r in workspace panel)

Keybindings Don't Work

  • Make sure you called setup() in your config
  • Check for conflicts with other plugins
  • Customize keybindings in the setup options

Credits


README is 99% created by vibes

About

nvim plugin for Julia Repl Workflow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors