Skip to content

A Lua-based Neovim plugin that enhances competitive programming workflows by integrating with the Competitive Companion browser extension

License

Notifications You must be signed in to change notification settings

A7Lavinraj/assistant.nvim

Repository files navigation

Assistant.nvim - Neovim Plugin for Competitive Programming


Latest release Last commit License Stars Issues Repo Size


Assistant.nvim is a powerful and efficient Neovim plugin designed for competitive programmers. It automates the testing workflow, making it faster and more convenient to run test cases directly inside Neovim.


DEMO


Note

Speed is crucial in competitive programming. Ensure that using this plugin enhances your workflow rather than slowing you down.


Features

  • Automated Test Case Management: Easily fetch and organize test cases from online judges.
  • Customizable Execution Commands: Support for multiple programming languages with configurable commands.
  • Interactive UI: A user-friendly interface for managing test cases.
  • Asynchronous Processing: Ensures Neovim remains responsive during execution.

Requirements


Installation

Using lazy.nvim

{
    "A7lavinraj/assistant.nvim",
    dependencies = { "folke/snacks.nvim" }, -- optional but recommended
    lazy = false, -- Start TCP Listener on Neovim startup
    keys = {
      { "<leader>a", "<cmd>Assistant<cr>", desc = "Assistant.nvim" }
    },
    opts = {}
}

Note

If you encounter issues with the latest updates, consider switching to the most stable version


{
    "A7lavinraj/assistant.nvim",
    commit = "ca42f5231203ff3c9356180f2d4ca96061a70ef4",
    dependencies = { "folke/snacks.nvim" },
    lazy = false,
    keys = {
      { "<leader>a", "<cmd>Assistant<cr>", desc = "Assistant.nvim" }
    },
    opts = {}
}

Default Configuration

{
  commands = {
    python = {
      extension = "py",
      template = nil,
      compile = nil,
      execute = {
        main = "python3",
        args = { "$FILENAME_WITH_EXTENSION" },
      },
    },
    cpp = {
      extension = "cpp",
      template = nil,
      compile = {
        main = "g++",
        args = { "$FILENAME_WITH_EXTENSION", "-o", "$FILENAME_WITHOUT_EXTENSION" },
      },
      execute = {
        main = "./$FILENAME_WITHOUT_EXTENSION",
        args = nil,
      },
    },
  },
  ui = {
    width = 0.8,
    height = 0.8,
    backdrop = 60,
    border = "single",
    icons = {
      title = "",
      success = "",
      failure = "",
      unknown = "",
      loading_frames = { "󰸴 ", "󰸵 ", "󰸸 ", "󰸷 ", "󰸶 " },
    },
  },
  core = {
    process_budget = 5000,
    port = 10043,
  },
}

Custom Command Configuration

To extend the configuration for Python, add the following to the commands table:

python = {
    extension = "py",
    compile = nil, -- Python doesn't require compilation
    execute = {
        main = "python3",
        args = { "$FILENAME_WITH_EXTENSION" }
    },
},

To check the file type of an open file in Neovim, run:

:lua print(vim.bo.filetype)

Commands & Key Bindings

:Assistant
Key Operation
q Close window
r Run current or selected test cases
c Create an empty test case
d Delete current or selected test cases
e Open edit window
s Toggle current test case selection
a Toggle all test case selections
j Move to next test case
k Move to previous test case
<enter> Confirm changes in prompt
<c-l> Navigate to right window
<c-h> Navigate to left window

Want to contribute?

Please read CONTRIBUTING.md to get started