/leetcode-emacs

an emacs plugin to write leetcode programs

Primary LanguageEmacs Lisp

Leetcode-emacs

This is an Emacs plugin that makes it easier and faster to write leetcode programs.

Prerequisites

  • leetcode-cli

This tool is based on leetcode-cli, You can install the latest version through its website.

The backend leetcode-cli changed to other implement github

  • ctable

This tool uses the emacs package ctable to show all leetcode issues, you can download it from github or install it using ELPA.

Installing

  • clone the project in your own emacs configuration files directory, like:
git clone git@github.com:ginqi7/leetcode-emacs.git ~/.emacs.d/lisp/leetcode
  • add the path to ‘load-path’
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/leetcode"))

Configuration

You can use the ‘use-package’, there is a configurable variable.

  • leetcode-language : assign the language of solutions
(use-package leetcode
    :config
    (setq leetcode-language "java")
)

Change leetcode-cli config

You will find leetcode-cli config in “~/.leetcode/leetcode.toml”

[code]
editor = 'cat'
lang = 'java'

You should change editor to ‘cat’, let leetcode-cli don’t open a editor to edit the anwser file.

You can change the answer languary using ‘lang’ item.

Configurable Variable

There are some variable

leetcode-hide-no-auth-problems ;; Whether to hide topics that do not have permission, default value is t

Features

login / logout

New leetcode-cli not provides command to login / logout. You just need login/logout leetcode in Chrome, the leetcode-cli will use the Chrome cookie to access leetcode website.

List all questions

leetcode-list-all:

There will hide 🔒 problems.

If you select a problem and click or press `return` will open the problem code.

Filter questions by difficulty

You can filter problems by difficulty:

Filter questions by tag

You can filter problems by tag:

Filter questions by keyword

You can filter problems by keyword:

Show a specific question

leetcode-show n: show a description and generate a code’s template of a specific question. The parameter of function is the question’s index number.

Show next question

leetcode-show-next:

If you solve the question in order, you can go to the next question through leetcode-show-next.

Submit the question answer

leetcode-submit:

Test the question answer

leetcode-test:

Like leetcode-submit , you can using leetcode-test function to test current buffer using some default test cases.

Quickly jump max index problem in local

leetcode-show-local-max-problem

Use this function, you can quickly jump the max index problem in your local file. You needn’t go to your leetcode directory to find last file you handled

Interactively filter and select problem and open it

leetcode-interactive You could filter and select and open problem interactively.