Skip to content

an Emacs "jump to definition" package for 50+ languages

License

Notifications You must be signed in to change notification settings

zenspider/dumber-jump

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dumber-jump

CI Coverage Status MELPA MELPA Stable

Dumber Jump GIF

About

Dumber Jump is an Emacs "jump to definition" package with support for 50+ programming languages that favors "just working". This means minimal -- and ideally zero -- configuration with absolutely no stored indexes (TAGS) or persistent background processes. Dumber Jump requires at least GNU Emacs 28.1.

Dumber Jump is a fork from dumb-jump that removes as many configuration options as possible to go back to the roots of being a fairly config-free "dumb" jump. This version doesn't support other searchers, doesn't support alternative display methods, and only interfaces through xref.

How it works

Dumber Jump uses ripgrep rg to find potential definitions of a function or variable under point. It uses a set of regular expressions based on the file extension, or major-mode, of the current buffer. The matches are run through a shared set of heuristic methods to find the best candidate to jump to. If it can't decide it will present the user with a list.

Success Rate

For the currently supported languages it seems to do a good job of finding what you want. If you find a case where it does not work as expected do not hesitate to open an issue. Although it can be sped up by creating a .dumberjump file in your project's root directory with paths that should be excluded (see configuration).

Supported Languages

There is currently basic support for the following languages:

  • Apex
  • Bash
  • C/C++
  • C#
  • Clojure
  • CoffeeScript
  • Common Lisp
  • Coq
  • Crystal
  • Dart
  • Elixir
  • Emacs Lisp
  • Erlang
  • F#
  • Faust
  • Fennel
  • Fortran
  • Go
  • Groovy
  • Haskell
  • Java
  • JavaScript
  • Julia
  • Kotlin
  • LaTeX
  • Lua
  • Matlab
  • Nim
  • Nix
  • Objective-C
  • OCaml
  • OpenSCAD
  • Org mode
  • Pascal
  • Perl
  • PHP
  • Protocol Buffers
  • Python
  • R
  • Racket
  • Ruby
  • Rust
  • Sass
  • Scala
  • Scheme
  • SML
  • Solidity
  • SQL
  • Swift
  • SystemVerilog
  • Tcl
  • Terraform / HCL
  • TypeScript
  • Vala
  • VHDL
  • Zig

If you have any issues with the existing languages, or you want support for another one, then please open an issue. PRs are also welcome. If you'd like to add a language these PRs for lua and rust are good examples.

Installing

The recommended way to install Dumber Jump is via package.el. It's available on MELPA: M-x package-install dumber-jump

Installing rg

Dumber Jump requires ripgrep rg (rg install instructions) installed on your system.

Usage

Basic

To enable the xref backend, evaluate

(add-hook 'xref-backend-functions #'dumber-jump-xref-activate)

or add it to your initialisation file. Using this, you can now use M-. (or gd when using Evil).

Configuration

Excluding project directories

Dumber Jump will automatically look for a project root. If it's not finding one then either put a .dumberjump file in your project root and optionally add excluded directories to make it faster.

Project root directory denoters: .dumberjump, .projectile .git .hg, and more. See dumber-jump-project-denoters.

If you want to stop a directory from registering as the project root (and have Dumber Jump keep looking) add an empty .dumbjumpignore file in that directory.

Example .dumberjump
-tests
-node_modules
-build
-images
+../some-lib/src
+/usr/lib/src
.emacs options
  • (setq dumber-jump-default-project "~/code") to change default project if one is not found (defaults to ~)
  • (setq dumber-jump-quiet t) if Dumber Jump is too chatty.
  • To support more languages and/or definition types customize dumber-jump-find-rules variable.
  • (setq dumber-jump-rg-search-args "") to set additional command line arguments when using rg for searching (defaults to "--pcre2").
Hydra for effieciency

If you have Hydra installed, the following is an example hydra for easily using Dumber-Jump and not needing to remember the bindings or function names:

(defhydra dumber-jump-hydra (:color blue :columns 3)
    "Dumber Jump"
    ("j" dumber-jump-go "Go")
    ("o" dumber-jump-go-other-window "Other window")
    ("e" dumber-jump-go-prefer-external "Go external")
    ("x" dumber-jump-go-prefer-external-other-window "Go external other window")
    ("i" dumber-jump-go-prompt "Prompt")
    ("l" dumber-jump-quick-look "Quick look")
    ("b" dumber-jump-back "Back"))

It can be explicitly bound or used inside another hydra (if you already use something like Avy/Ace or similar for general "jumping").

Debugging a jump

  1. M-x set-variable dumber-jump-debug t
  2. try to jump
  3. go to buffer *Messages*

More details here. Thanks to @cweiske and @Glumanda99

Why?

I wanted "jump to definition" functionality to "just work" in emacs. I use IntelliJ for Java and this functionality is basically the only thing I miss when I switch back to emacs for work in other languages. There are certainly other packages that offer this type of functionality, but they all require significantly more configuration and are often limited to a particular language. An alternative may be worth setting up if you are in a specific project or language often (see alternatives).

Contributing

Feedback is very welcome via GitHub issues. I will consider supporting other languages either via issue request or PR. If submitting a PR then please add tests as well.

Running Tests

Opening a PR will use CircleCI to run all the tests against all the supported emacs versions and search programs.

Running tests locally

There are a lot of options for running the tests locally:

Basic/Classic

requires Cask using your local emacs

cd /path/to/dumber-jump
cask
make test

Concurrent

requires golang and Cask using your local emacs

cd /path/to/dumber-jump
cask
make test-concurrent

Docker (latest emacs)

only requires docker and runs tests against emacs 26.1

cd /path/to/dumber-jump
cask
make test-in-docker

Docker (all supported emacs versions)

only requires docker and runs tests against all supported emacs versions

cd /path/to/dumber-jump
cask
make test-all-in-docker

Alternatives

Here is a list of potential alternative packages for emacs:

  • Tags supports multiple languages
  • GNU Global supports multiple languages
  • Tern for JavaScript
  • elpy for Python
  • robe for Ruby
  • dumb-jump the original that this project is forked from. See that project's readme for what this used to be like.

Most of these were sourced from this emacs StackExchange answer.

About

an Emacs "jump to definition" package for 50+ languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Emacs Lisp 90.6%
  • Go 4.8%
  • C++ 1.1%
  • JavaScript 1.1%
  • Dockerfile 0.9%
  • Shell 0.9%
  • Other 0.6%