Code Monkey home page Code Monkey logo

nvim-bacon's Introduction

nvim-bacon

This plugin enables viewing the locations found in a .bacon-locations file, and jumping to them.

Installation

This extension may be imported with a standard plugin system, for example with vim-plug:

Plug 'Canop/nvim-bacon'

You must enable locations export in bacon. Add this to your bacon.prefs file:

[export]
enabled = true

Usage

You'll use this plugin in nvim while a bacon instance is running in another panel, probably side to it.

To navigate among errors and warnings, you'll use either the standard Quickfix feature of your editor or nvim-bacon dedicated commands and view.

Specialized Commands and View

The following functions are exposed by the plugin:

Function Usage
:BaconLoad Silently load the locations of the .bacon-locations file
:BaconShow Display the locations in a floating windoaw
:BaconList Does :BaconLoad then :BaconShow
:BaconPrevious Jump to the previous location in the current list
:BaconNext Jump to the next location in the current list

You should define at least two shortcuts, for example like this:

nnoremap ! :BaconLoad<CR>:w<CR>:BaconNext<CR>
nnoremap , :BaconList<CR>

The first shortcut navigates from location to location, without opening the window. This is probably the one you'll use all the time. You may notice it loads the list (:BaconLoad) then saves the current document (:w), to prevent both race conditions and having a bunch of unsaved buffers.

The second shortcut, which is mapped to the , key, opens the list of all bacon locations:

list-and-bacon

When the list is open, you can select a line and hit enter or just hit the number of the location if it's in 1-9. As there's no need to wait for the window to appear, you may just type ,3 to go to location 3 without opening the window.

You may define other shortcuts using the various API functions.

Quickfix Integration

Errors and warnings also populate the Quicklist list by default.

You can disable this feature with this configuration:

require("bacon").setup({
    quickfix  = {
         enabled = false, -- true to populate the quickfix list with bacon errors and warnings
         event_trigger = true, -- triggers the QuickFixCmdPost event after populating the quickfix list
    }
)}

nvim-bacon's People

Contributors

canop avatar connorway32 avatar mikavilpas avatar restedwicked avatar

Stargazers

Fedi Jamoussi avatar Porrith Suong avatar Michał Walczak avatar  avatar Eliot Foss avatar Mars avatar  avatar Caleb Eby avatar James H. avatar Brad Wojcik avatar Martin Walls avatar  avatar ngx3 avatar  avatar Ângelo avatar  avatar John K avatar Naz avatar  avatar Towry Wang avatar Jon avatar Gkoran Stoilkovits avatar Matteo Bigoi avatar Sebastian Kempf avatar Diego Frias avatar  avatar David Krauthamer avatar Josh McKinney avatar dj8yf0μl avatar Arvid Gerstmann avatar Joel Palmer avatar  avatar Suraj avatar  avatar Qingyao Lin avatar David M. Golembiowski avatar ZJPzjp avatar Brad Svercl avatar

Watchers

 avatar James Cloos avatar  avatar David M. Golembiowski avatar

nvim-bacon's Issues

Error closing window when running `:BaconList` twice

If I run :BaconList while the UI from :BaconList is already open and then try to close it with q, the following error occurs:

E5108: Error executing lua .../.local/share/nvim/plugged/nvim-bacon/lua/bacon/init.lua:53: Invalid window id: 1004
stack traceback:
        [C]: in function 'nvim_win_close'
        .../.local/share/nvim/plugged/nvim-bacon/lua/bacon/init.lua:53: in function 'close_window'
        [string ":lua"]:1: in main chunk

Automatic Loading on Save

One feature I think would be useful (but not sure if it's possible to implement within Lua/the Neovim API) would be functionality to automatically trigger the bacon_load function when the relevant bacon-locations file is updated. While directly triggering it on file save is trivial, the issue is the variable time between save and the bacon location file getting updated (due to compile time, tests running, linters, etc).

My current hacky solution in my own config is just to trigger the function half a second after a file save (with a rust filetype), but that only works when the checking time is short enough, so would be an unsuitable solution for large projects.

An ideal solution could be watching the bacon locations file for updates, then triggering bacon_load, but to the best of my understanding, that would be OS dependent.

Any thoughts?

Integration into quickfix list?

I notice that BaconList seems to open its own UI with its own color scheme on my system, which is somewhat jarring. It might be nicer to integrate BaconList into the concept of a Quick Fix List which is already part of vim/neovim and is the usual place for compiler errors as I understand it.

Export locations with spaces in path not handled.

Generally I don't like to have spaces in the path, but here I'm not sure who is responsible: bacon itself doesn't have any other documented way than {path}. When attempting to jump from the Quicklist:

E5108: Error executing lua ...nes/.local/share/nvim/lazy/nvim-bacon/lua/bacon/init.lua:136: BufNewFile Autocommands for "*": Vim(append):Error executing lua callback: ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24: Error executing lua: ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:25: BufNewFile Autocommands for "*".
.FileType Autocommands for "rust"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[19]..script /Users/sjanes/.local/share/nvim/lazy/rustaceanvim/ftplugin/rust.lua: Vim(runtime):E5113: Error while calling lua chunk: Vim:E475: Invalid argument: expected valid directory                                                                     
stack traceback:                                                                                                                                                                                                                                                                                                                                            
        [C]: in function 'jobstart'                                                                                                                                                                                                                                                                                                                         
        .../share/nvim/lazy/rustaceanvim/lua/rustaceanvim/cargo.lua:53: in function 'get_root_dir'                                                                                                                                                                                                                                                          
        ...al/share/nvim/lazy/rustaceanvim/lua/rustaceanvim/lsp.lua:98: in function 'start'                                                                                                                                                                                                                                                                 
        ...es/.local/share/nvim/lazy/rustaceanvim/ftplugin/rust.lua:56: in main chunk                                                                                                                                                                                                                                                                       
        [C]: in function 'nvim_exec_autocmds'                                                                                                                                                                                                                                                                                                               
        ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:157: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:156>                                                                                                                                                                                                      
        [C]: in function 'xpcall'                                                                                                                                                                                                                                                                                                                           
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:113: in function 'try'                                                                                                                                                                                                                                                                  
        ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:156: in function 'trigger'                                                                                                                                                                                                                                                              
        ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:87: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:72>                                                                                                                                                                                                        
        [C]: in function 'nvim_cmd'                                                                                                                                                                                                                                                                                                                         
        ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:25: in function <...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24>                                                                                                                                                                                                        
        [C]: in function 'nvim_buf_call'                                                                                                                                                                                                                                                                                                                    
        ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:10>                                                                                                                                                                                                        
        [C]: in function 'nvim_command'                                                                                                                                                                                                                                                                                                                     
        ...nes/.local/share/nvim/lazy/nvim-bacon/lua/bacon/init.lua:136: in function 'open_location'                                                                                                                                                                                                                                                        
        ...nes/.local/share/nvim/lazy/nvim-bacon/lua/bacon/init.lua:146: in function 'open_selected_location'                                                                                                                                                                                                                                               
        [string ":lua"]:1: in main chunk                                                                                                                                                                                                                                                                                                                    
stack traceback:                                                                                                                                                                                                                                                                                                                                            
        [C]: in function 'nvim_cmd'                                                                                                                                                                                                                                                                                                                         
        ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:25: in function <...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24>                                                                                                                                                                                                        
        [C]: in function 'nvim_buf_call'                                                                                                                                                                                                                                                                                                                    
        ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:10>                                                                                                                                                                                                        
        [C]: in function 'nvim_command'                                                                                                                                                                                                                                                                                                                     
        ...nes/.local/share/nvim/lazy/nvim-bacon/lua/bacon/init.lua:136: in function 'open_location'                                                                                                                                                                                                                                                        
        ...nes/.local/share/nvim/lazy/nvim-bacon/lua/bacon/init.lua:146: in function 'open_selected_location'                                                                                                                                                                                                                                               
        [string ":lua"]:1: in main chunk                                                                                                                                                                                                                                                                                                                    
stack traceback:                                                                                                                                                                                                                                                                                                                                            
        [C]: in function 'nvim_buf_call'                                                                                                                                                                                                                                                                                                                    
        ...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.5/share/nvim/runtime/filetype.lua:10>                                                                                                                                                                                                        
        [C]: in function 'nvim_command'                                                                            

Changing the export to surround {path} with double quotes as in:

[export]
enabled = true
path = ".bacon-locations"
line_format = "{kind} \"{path}\":{line}:{column} {message}"

still breaks nvim-bacon.

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.