Git Product home page Git Product logo

nvim-workspace-manager's Introduction

NVIM WORKSPACE MANAGER

A single layer implementation.

Can be used standalone.

Intended usage is with nvim session manager.

User Commands:

Name Description
WorkspaceAdd Add workspace
- Uses directory name if no argument is given
WorkspaceDel Delete workspace
WorkspaceList List workspaces
WorkspaceChange* Change workspace
WorkspaceName Print current workspace name
WorkspaceRename Rename current workspace

*There is an error in lua which calls the internal function change_workspace() oddly twice, everything works fine on the second call however.

Functions:

Name Description
add(strName) Adds a workspace
- Optional: strName = CURRENT_WORKING_DIRECTORY
del(strName) Deletes a workspace
- Mandatory: strName
- Returns immidiately if no argument is given
list(boolCompletion) Lists workspaces
- Optional: boolCompletion = false (prints only names instead)
rename(strName) Renames current workspace
- Mandatory: strName
change_workspace(strName) Changes active workspace
- Mandatory: strName
is_in_workspace() Returns a table containing workspace names which has the same path as CWD
get_workspace_name(boolPrint) Returns current workspace name
- Optional: boolPrint = false (prints it instead)

Installation:

Lazy.nvim

{
    "The-Plottwist/nvim-workspace-manager",
    dependencies = "The-Plottwist/nvim-session-manager", --optional
    branch = "stable"
}

Defaults:

defaults = {
    event_hooks = {
        on_add = nil, --calls with arg: workspace name
        on_del = nil, --calls with arg: deleted workspace name
        on_change = nil,
        on_rename = nil,
    }
}

Notes

-To modify: require("workspace-manager").setup({event_hooks = {on_add = ...,}})

-Does not load any workspaces by default

Example Usage:

With nvim session manager

require("session-manager").setup()
require("workspace-manager").setup({
    event_hooks = {
        on_add = function(strName)
            require("session-manager").add(strName)
        end,
        on_del = function(strDeletedWorkspace)
            local cur_workspace = require("workspace-manager").get_workspace_name()
            require("session-manager").change_session(cur_workspace, false)
            require("session-manager").del(strDeletedWorkspace)
        end,
        on_change = function()
            local cur_workspace = require("workspace-manager").get_workspace_name()
            require("session-manager").change_session(cur_workspace)
        end,
        on_rename = function()                                                                                                                                                                                                                           
            local cur_workspace = require("workspace-manager").get_workspace_name()                                                                                                                                                                      
            require("session-manager").rename(cur_workspace)                                                                                                                                                                                             
        end                                                                                                                                                                                                                                              
    }                                                                                                                                                                                                                                                    
})                                                                                                                                                                                                                                                       

--load session if no file is given on vim start                                                                                                                                                                                                          
vim.cmd("let g:ARGC = argc()")                                                                                                                                                                                                                           
if vim.g.ARGC == 0 then                                                                                                                                                                                                                                  

    local workspaces = require("workspace-manager").is_in_workspace()                                                                                                                                                                                    
    if next(workspaces) == nil then                                                                                                                                                                                                                      
        --last session                                                                                                                                                                                                                                   
        require("session-manager").load()                                                                                                                                                                                                                
    else                                                                                                                                                                                                                                                 
        --first workspace                                                                                                                                                                                                                                
        require("workspace-manager").change_workspace(workspaces[1])                                                                                                                                                                                     
    end                                                                                                                                                                                                                                                  
end

nvim-workspace-manager's People

Contributors

the-plottwist avatar

Stargazers

Yuta Katayama avatar

Watchers

 avatar

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.