Giter Club home page Giter Club logo

vis-golang's Introduction

vis-golang

A Go plugin for the Vis editor.

Inspired by vis-go but with a slightly different set of features.

Commands

godef[!]

Displays type information of the symbol at the current cursor position in the info line (bottom). If forced, it will open the source file and position the cursor at the definition with respect to the current window layout.

gofmt[!] and goimports[!]

The current range is replaced with its formatted version. If forced, the changes will be written to disk.

  • gofmt runs with the -s (simplify code) flag
  • goimports's -local flag can be set through a GOIMPORTS_LOCAL environment variable

gotest[!]

Runs go test for the currently active file's package. In case of failure a window with the output is opened. The current window layout will be respected.

It looks for a GOTEST_FLAGS environment variable at runtime. If it's present then it appends its content to the end of the go test command (useful together with direnv for example).

If forced, only the test under the current cursor possition will be executed. The cursor has to be located on a word matching the ^Test pattern.

gout

Opens fzf with a list of lines containing type or function definitions (outline) of the current file. When an entry is chosen the cursor jumps to its location. If you're looking for the same experience but don't want to be limited to Go I suggest you take a look at vis-fzf-outline.

goswap[!]

Swaps the currently open file with its testing related counterpart (test/implementation). Let's say that you're working on a file named abc.go, goswap will try to open abc_test.go in a split window. If forced, it will replace the file in the currently active window instead of splitting. In case that the counterpart is already open in one of the other unfocused windows the focus will move to it. The current window layout should be respected.

Installation

First clone the repository into your config folder:

cd ~/.config/vis
git clone https://github.com/rokf/vis-golang

Then import the plugin in your visrc.lua file:

require('vis-golang/init')

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

vis-golang's People

Contributors

rokf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vis-golang's Issues

goswap sometimes doesn't want to switch

Looks like the goswap command sometimes doesn't want to switch from the test file to the implementation file or the other way around.

Most probably that it's happening with long files/paths.

Unit tests

Extract some of the command code into separate functions and write unit tests for them. Take a look at the available Lua testing libraries.

Leave vis mocking for now, just the basic stuff.

Integrate goimports

Add a goimports command that pipes the current range through goimports.

It should have a configurable -local flag option (presumably through an environment variable - GOIMPORTS_LOCAL - to make it more convenient).

Integrate a formatter command

It should operate on the file buffer instead of a file (if possible), otherwise make sure that the file gets reloaded properly and on time.

Integrate a test command

It should run go test on the current file/package.

If the cursor is inside a test it should only run that test (utilize the force flag).

gotest! should run single test

Update the gotest command so that it runs a single test (the one the cursor is in?) in the presence of the force suffix (gotest!).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.