https://github.com/ingram1107/origin.nvim
A Neovim plugin that provide functionalities to set your current working directory
https://github.com/ingram1107/origin.nvim
current-working-directory cwd lua neovim nvim nvim-plugin
Last synced: about 1 year ago
JSON representation
A Neovim plugin that provide functionalities to set your current working directory
- Host: GitHub
- URL: https://github.com/ingram1107/origin.nvim
- Owner: ingram1107
- License: gpl-3.0
- Created: 2021-04-25T07:33:57.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-25T17:22:23.000Z (about 2 years ago)
- Last Synced: 2025-01-31T10:42:32.133Z (about 1 year ago)
- Topics: current-working-directory, cwd, lua, neovim, nvim, nvim-plugin
- Language: Lua
- Homepage:
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# origin.nvim
A Neovim plugin that provide functionalities to set your current working
directory.
## Requirement
Neovim 0.7+
## Installation
Vim-plug
```viml
Plug 'ingram1107/origin.nvim'
```
packer
```lua
use 'ingram1107/origin.nvim'
```
## Usage
As Neovim has a fresh start, this plugin will set the parent directory of the
file that you first open as the current working directory.
This plugin provide three operational functions for its users. `Origin` to print
the current working directory, similarly `pwd` in native Vim.
`OriginSetDefaultRoot` and `OriginSetManualRoot` are used to set the current
working directory as you want (empty string implies parent directory of the
current file). The difference between these two commands are that the operations
of `OriginSetDefaultRoot` can be affected by the logic introduced in the
`default_source` configuration whereas `OriginSetManualRoot` cannot.
To change the current working directory, you may use either Vim commands or
Neovim lua commands.
Vim cmds
```viml
:Origin
:OriginSetDefaultRoot
:OriginSetManualRoot
```
Neovim lua cmds
```viml
:lua require('origin').origin() " same with :Origin
:lua require('origin').set_root{} " same with :OriginSetDefaultRoot
:lua require('origin').set_root{'', true} " same with :OriginSetManualRoot
```
You may change the operational logic of `OriginSetDefaultRoot` on which
directory/ies is/are the sub-directory/ies for the project root by configure
through the lua function `default_source` as follow:
```lua
require('origin').setup {
default_source = {
lua = "lua",
c = { "src", "lib", "test" },
},
}
```
Or if you prefer VimL:
```viml
lua << EOF
require('origin').setup {
default_source = {
lua = "lua",
c = { "src", "lib", "test" },
},
}
EOF
```
If you want to prioritise the directory that contain `.git/` as root directory,
turn on the `git` option from the setup. Note that this options will always
prefer git repo as directory regardless of as default source directory you have
been set.
```lua
require('origin').setup {
option = true,
default_source = {
lua = "lua",
c = { "src", "lib", "test" },
},
}
```
```viml
lua << EOF
require('origin').setup {
option = true,
default_source = {
lua = "lua",
c = { "src", "lib", "test" },
},
}
EOF
```
## Plugins Recommendations
- [vim-rooter](https://github.com/airblade/vim-rooter) (main inspiration,
provide more thorough functionalities)