All Projects → fatih → Motion

fatih / Motion

Licence: bsd-3-clause
Navigation and insight in Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Motion

Bookmarklet Maker
Tool to create bookmarklet/ javascript apps to automate the web browser.
Stars: ✭ 52 (-68.1%)
Mutual labels:  tool, navigation
Crana
A CLI tool to create React + Node apps with just one command
Stars: ✭ 160 (-1.84%)
Mutual labels:  tool
Metago
MetaGo provides fast cursor movement/selection for keyboard focused users in vscode
Stars: ✭ 151 (-7.36%)
Mutual labels:  navigation
Bindertool
Dark Souls II / Dark Souls III / Bloodborne bdt, bhd, bnd, dcx, tpf, fmg and param unpacking tool
Stars: ✭ 157 (-3.68%)
Mutual labels:  tool
React Native Nav Transition
React Native Nav Transition
Stars: ✭ 154 (-5.52%)
Mutual labels:  navigation
Jquery Navobile
A jQuery plugin that makes mobile navigation easy.
Stars: ✭ 157 (-3.68%)
Mutual labels:  navigation
Layerjs
layerJS: Javascript UI composition framework
Stars: ✭ 1,825 (+1019.63%)
Mutual labels:  navigation
Tinyconsole
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
Stars: ✭ 1,929 (+1083.44%)
Mutual labels:  tool
Dublin Traceroute
Dublin Traceroute is a NAT-aware multipath tracerouting tool
Stars: ✭ 159 (-2.45%)
Mutual labels:  tool
Mtuner
MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms
Stars: ✭ 2,007 (+1131.29%)
Mutual labels:  tool
Locationsimulator
MacOS 10.15 / 11.0 application to spoof your iOS / iPadOS or iPhoneSimulator device location. WatchOS and TvOS are partially supported.
Stars: ✭ 157 (-3.68%)
Mutual labels:  navigation
React Site Nav
A kick ass site menu powered by styled components inspired by Stripe.
Stars: ✭ 155 (-4.91%)
Mutual labels:  navigation
Pile
⚡️ A simple & powerful app to organize your piled work at one place~
Stars: ✭ 158 (-3.07%)
Mutual labels:  tool
Redux Saga Router
A router for Redux Saga
Stars: ✭ 153 (-6.13%)
Mutual labels:  navigation
Dotnetomdgenerator
A Roslyn-based cross-platform tool that generates an object model diagram from a set of C# source files or assemblies
Stars: ✭ 160 (-1.84%)
Mutual labels:  tool
Supermarker
An automatic marking tool better than mark man.
Stars: ✭ 151 (-7.36%)
Mutual labels:  tool
Proji
A powerful cross-platform CLI project templating tool.
Stars: ✭ 156 (-4.29%)
Mutual labels:  tool
Fdroidserver
F-Droid server and build tools.
Stars: ✭ 156 (-4.29%)
Mutual labels:  tool
Android Rocket Launcher
🚀 Launch android modules from the terminal
Stars: ✭ 161 (-1.23%)
Mutual labels:  tool
Gallerit
A sample Android gallery to search images posted on Reddit built using modern Android development tools (Architecture Components, MVVM, Coroutines, Flow, Navigation, Retrofit, Room, Koin)
Stars: ✭ 153 (-6.13%)
Mutual labels:  navigation

Motion

Motion is a tool that was designed to work with editors. It is providing contextual information for a given offset(option) from a file or directory of files. Editors can use these informations to implement navigation, text editing, etc... that are specific to a Go source code.

It's optimized and created to work with vim-go, but it's designed to work with any editor. It's currently work in progress and open to change.

Install

go get github.com/fatih/motion

Usage

motion is meant to be run via the editor. Currently it has the following modes you can use:

  • decls: returns a list of declarations based on the -include flag
  • enclosing: returns information about the enclosing function for a given offset
  • next: returns the next function information for a given offset
  • prev: returns the previous function information for a given offset
  • comment: returns information about the a comment block (if any).

A function information is currently the following type definition (defined as astcontext.Func):

type Func struct {
	// Signature of the function
	Signature *FuncSignature `json:"sig" vim:"sig"`

	// position of the "func" keyword
	FuncPos *Position `json:"func" vim:"func"`
	Lbrace  *Position `json:"lbrace" vim:"lbrace"` // position of "{"
	Rbrace  *Position `json:"rbrace" vim:"rbrace"` // position of "}"

	// position of the doc comment, only for *ast.FuncDecl
	Doc *Position `json:"doc,omitempty" vim:"doc,omitempty"`

	node ast.Node // either *ast.FuncDecl or *ast.FuncLit
}

motion can output the information currently in formats: json and vim.

An example execution for the enclosing mode and output in json format is:

$ motion -file testdata/main.go -offset 180 -mode enclosing --format json
{
	"mode": "enclosing",
	"func": {
		"sig": {
			"full": "func Bar() (string, error)",
			"recv": "",
			"name": "Bar",
			"in": "",
			"out": "string, error"
		},
		"func": {
			"filename": "testdata/main.go",
			"offset": 174,
			"line": 15,
			"col": 1
		},
		"lbrace": {
			"filename": "testdata/main.go",
			"offset": 201,
			"line": 15,
			"col": 28
		},
		"rbrace": {
			"filename": "testdata/main.go",
			"offset": 225,
			"line": 17,
			"col": 1
		}
	}
}

To include the doc comments for function declarations include the --parse-comments flag:

$ motion -file testdata/main.go -offset 180 -mode enclosing --format json --parse-comments
{
	"mode": "enclosing",
	"func": {
		"sig": {
			"full": "func Bar() (string, error)",
			"recv": "",
			"name": "Bar",
			"in": "",
			"out": "string, error"
		},
		"func": {
			"filename": "testdata/main.go",
			"offset": 174,
			"line": 15,
			"col": 1
		},
		"lbrace": {
			"filename": "testdata/main.go",
			"offset": 201,
			"line": 15,
			"col": 28
		},
		"rbrace": {
			"filename": "testdata/main.go",
			"offset": 225,
			"line": 17,
			"col": 1
		},
		"doc": {
			"filename": "testdata/main.go",
			"offset": 134,
			"line": 14,
			"col": 1
		}
	}
}

For example the same query, but with mode -mode next returns a different result. Instead it returns the next function inside the source code:

$ motion -file testdata/main.go -offset 180 -mode next --format json
{
	"mode": "next",
	"func": {
		"sig": {
			"full": "func example() error",
			"recv": "",
			"name": "example",
			"in": "",
			"out": "error"
		},
		"func": {
			"filename": "testdata/main.go",
			"offset": 318,
			"line": 21,
			"col": 1
		},
		"lbrace": {
			"filename": "testdata/main.go",
			"offset": 339,
			"line": 21,
			"col": 22
		},
		"rbrace": {
			"filename": "testdata/main.go",
			"offset": 402,
			"line": 29,
			"col": 1
		}
	}
}

If there are not functions available for any mode, it returns an error in the specified format:

$ motion -file testdata/main.go -offset 330 -mode next --format json
{
	"err": "no functions found"
}

For the mode decls, we pass the file (you can also pass a directory) and instruct to only include function declarations with the -include func flag:

$ motion -file testdata/main.go -mode decls -include func
{
	"mode": "decls",
	"decls": [
		{
			"keyword": "func",
			"ident": "main",
			"full": "func main()",
			"filename": "testdata/main.go",
			"line": 9,
			"col": 1
		},
		{
			"keyword": "func",
			"ident": "Bar",
			"full": "func Bar() (string, error)",
			"filename": "testdata/main.go",
			"line": 15,
			"col": 1
		},
		{
			"keyword": "func",
			"ident": "example",
			"full": "func example() error",
			"filename": "testdata/main.go",
			"line": 21,
			"col": 1
		}
	]
}

In the comment mode it will try to get information about the comment block for a given offset:

$ motion -mode comment -file ./vim/vim.go -offset 3
{
        "mode": "comment",
        "comment": {
                "startLine": 1,
                "startCol": 1,
                "endLine": 3,
                "endCol": 50
        }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].