Giter Site home page Giter Site logo

aserebryakov / vim-branch-stack Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 25 KB

If you have to work with legacy code and long funcitons with lots of nested "if-else" etc. this plugin will help you to find a way to current line.

Home Page: https://www.vim.org/scripts/script.php?script_id=5735

License: MIT License

Vim Script 16.54% Python 61.78% C++ 21.68%
vim-plugin legacy-code c cpp

vim-branch-stack's Introduction

vim-branch-stack

vim-branch-stack is a Vim plugin helping to find the branching path to current line of code.

Introduction

vim-branch-stack plugin is intended to help working on legacy C/C++ code where functions are long and have many nested branches (if-else, switch-case, try-catch, while, for).

Installation

Requirements

  • python3

Vim 8+

$ cd ~/.vim/pack/directory_name/start/
$ git clone --recurse-submodules https://github.com/aserebryakov/vim-branch-stack.git

Pathogen

$ cd ~/.vim/bundle
$ git clone --recurse-submodules https://github.com/aserebryakov/vim-branch-stack.git

NeoBundle

NeoBundle 'aserebryakov/vim-branch-stack'

Without plugin manager:

Clone or download this repository and copy its contents to your ~/.vim/ directory.

Usage

The stack is shown in the location window after BranchStack command execuiton while cursor is placed on the target line.

Example

main.cpp
int main ()
{
    const int meaning = 42;
    const int pi_floor = 3;
    
    if (meaning)
    {
        if (pi_floor == 4)
        {
            // Do the stuff
        }
        else
        {
            // Cursor is here
        }
    }
    
    return 0;
}
Location window
1 main.cpp |6| if (meaning)
2 main.cpp |12| + else

Limitations

The plugin has the following limitations:

  • Commented out code with /* block comments */ brakes parsing
  • goto is not supported
  • do-while is not supported
  • Preprocessing is not supported

Contribution

Source code and issues are hosted on GitHub:

https://github.com/aserebryakov/vim-branch-stack

License

MIT License

Changelog

0.1.0

  • Initial version

0.1.1

  • Fixed handling of single line comments

Credits

vim-branch-stack's People

Contributors

aserebryakov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vim-branch-stack's Issues

Improve the location window output.

In the following case:

if (x) {
}
else if (y) {
}
else {
    if(z) {
        // Cursor is on this line
    }
}

The expected content of the location window is:

+ if(x) {
+ else if (y) {
+ else {
++ if (z) {
+++ // Cursor is on this line

Add handling of single expression branches

Plugin should be able to handle something like:

if (something) do;

Handling should take into account:

  1. for(;;) foo(); case
  2. Need to rollback the parser state to a proper state

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.