Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecations, adapted some code, format with stylua, README overhaul #158

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8f984f6
chore: Format with stylua.
DrKJeff16 Jun 30, 2024
2a18fba
fix: Got rid of deprecations.
DrKJeff16 Jun 30, 2024
8cb4b93
fix: Renamed declared identifiers.
DrKJeff16 Jun 30, 2024
b6ec183
fix: Favour `vim.uv` over `vim.loop`.
DrKJeff16 Jun 30, 2024
85c2300
docs: Add some annotations.
DrKJeff16 Jun 30, 2024
0268421
docs: Add annotation to func for warning removal.
DrKJeff16 Jun 30, 2024
51fff27
fix: Favour `vim.uv` over `vim.loop`.
DrKJeff16 Jun 30, 2024
e7a4c10
docs: Add some annotations.
DrKJeff16 Jun 30, 2024
85df8e7
docs: Add annotation to func for warning removal.
DrKJeff16 Jun 30, 2024
f98a0b9
fix: (Read description) Annotations + code fixes.
DrKJeff16 Aug 9, 2024
4e7d846
fix: (Read description) `project.lua` code improvements
DrKJeff16 Aug 9, 2024
3249dca
fix: (Read description) `utils/history.lua` code improvements
DrKJeff16 Aug 9, 2024
85bc488
fix: Favour `vim.uv` over `vim.loop`.
DrKJeff16 Jun 30, 2024
41a7a09
fix: (Read description) Annotations + code fixes.
DrKJeff16 Aug 9, 2024
495a874
fix: (Read description) `project.lua` code improvements
DrKJeff16 Aug 9, 2024
6f1ed8d
fix: (Read description) `utils/history.lua` code improvements
DrKJeff16 Aug 9, 2024
1e716ea
chore: Add Vim comment to `README` for consistent indentation.
DrKJeff16 Aug 11, 2024
226f3eb
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
b4e4c9d
feat: Added install instructions for `lazy.nvim`.
DrKJeff16 Aug 11, 2024
58765dd
fix: Extended instructions, fixed some words.
DrKJeff16 Aug 11, 2024
9f1505c
fix(telescope): Added annotations across the file.
DrKJeff16 Aug 12, 2024
aca62fb
fix(telescope): Fixed redundant conditional statement.
DrKJeff16 Aug 12, 2024
f86cf8e
fix(telescope): Added annotations across the file.
DrKJeff16 Aug 12, 2024
e4db2d4
fix(telescope): Fixed redundant conditional statement.
DrKJeff16 Aug 12, 2024
33702e2
chore: Added Vim comments on top of all lua files.
DrKJeff16 Aug 12, 2024
4a0eb11
refactor(project)!: Rewrote autocmd statements using Lua.
DrKJeff16 Aug 12, 2024
6fc9275
chore: Added Vim comments on top of all lua files.
DrKJeff16 Aug 12, 2024
5ac6e7a
refactor(project)!: Rewrote autocmd statements using Lua.
DrKJeff16 Aug 12, 2024
19fd3b8
fix(telescope): Added annotations across the file.
DrKJeff16 Aug 12, 2024
168826a
fix(telescope): Fixed redundant conditional statement.
DrKJeff16 Aug 12, 2024
048fd2f
chore: Added Vim comments on top of all lua files.
DrKJeff16 Aug 12, 2024
96e778b
refactor(project)!: Rewrote autocmd statements using Lua.
DrKJeff16 Aug 12, 2024
3dc4dec
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
cab38c6
chore: Add Vim comment to `README` for consistent indentation.
DrKJeff16 Aug 11, 2024
222884d
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
cdd0d2a
feat: Added install instructions for `lazy.nvim`.
DrKJeff16 Aug 11, 2024
554ebc9
fix: Extended instructions, fixed some words.
DrKJeff16 Aug 11, 2024
136615f
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
1caa6e1
Merge remote-tracking branch 'refs/remotes/origin/docs' into docs
DrKJeff16 Aug 21, 2024
2c66e15
chore: Add Vim comment to `README` for consistent indentation.
DrKJeff16 Aug 11, 2024
9361f14
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
48e1e3f
feat: Added install instructions for `lazy.nvim`.
DrKJeff16 Aug 11, 2024
00a6906
fix: Extended instructions, fixed some words.
DrKJeff16 Aug 11, 2024
5f8661d
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
794f45f
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
2424772
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
fc134ea
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
ba2f6be
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
471e693
Merge remote-tracking branch 'refs/remotes/origin/main'
DrKJeff16 Aug 21, 2024
9b9cb37
fix!: Set type annotation to main module, improve `setup()`.
DrKJeff16 Aug 21, 2024
eede615
fix!: Set type annotation to main module, improve `setup()`.
DrKJeff16 Aug 21, 2024
3759f76
feat: Added install instructions for `lazy.nvim`.
DrKJeff16 Aug 11, 2024
5d97033
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
e685055
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
8b28ce9
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
442ddd1
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
ac8b643
fix: Extended instructions, fixed some words.
DrKJeff16 Aug 11, 2024
3ff24f5
fix: More hyperlinks and better code blocks in `README`.
DrKJeff16 Aug 11, 2024
c63ba91
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
3914103
feat: Added install instructions for `lazy.nvim`.
DrKJeff16 Aug 11, 2024
250d1b1
fix(README): Aesthetic fixes, sections dropped, comments and more.
DrKJeff16 Aug 12, 2024
2aa7f74
Merge branch 'main' of github.com:DrKJeff16/project.nvim
DrKJeff16 Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 139 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
<!--vim:ts=2:sts=2:sw=2:et:-->>

# 🗃️ project.nvim

**project.nvim** is an all in one neovim plugin written in lua that provides
superior project management.
**project.nvim** is an all in one [Neovim](https://github.com/neovim/neovim) plugin written in Lua
that provides superior project management.

![Telescope Integration](https://user-images.githubusercontent.com/36672196/129409509-62340f10-4dd0-4c1a-9252-8bfedf2a9945.png)

## ⚡ Requirements

- Neovim >= 0.5.0
- Neovim >= 0.9.0
- [telescope.nvim](nvim-telescope/telescope.nvim) (optional if you don't want to use the Telescope picker)

## ✨ Features

- Automagically cd to project directory using nvim lsp
- Dependency free, does not rely on lspconfig
- If no lsp then uses pattern matching to cd to root directory
- Telescope integration `:Telescope projects`
- Automagically cd to the project root directory using nvim LSP
- Dependency free, does not rely on [lspconfig](https://github.com/neovim/nvim-lspconfig)
- If no LSP is available then it'll try using pattern matching to cd to the project root directory instead
- [Telescope integration](#telescope-integration) `:Telescope projects`
- Access your recently opened projects from telescope!
- Asynchronous file io so it will not slow down vim when reading the history
file on startup.
- ~~Nvim-tree.lua support/integration~~
- Please add the following to your config instead:
```vim
" Vim Script
lua << EOF
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true
},
})
EOF
```
```lua
-- lua
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true
},
})
```
- Asynchronous file IO so it will not slow down neovim when reading the history file on startup.
- ~~Nvim-tree.lua support/integration~~ Make sure these flags are enabled
in your `nvim-tree.lua` config instead:
```lua
-- Lua
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true
},
})
```
<!-- NOTE(DrKJeff16): I think it's a bit redundantm to put the same instruction back to back, only
in a different language
```vim
" Vim Script
lua << EOF
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true
},
})
EOF
```
-->

## 📦 Installation

Install the plugin with your preferred package manager:

### [vim-plug](https://github.com/junegunn/vim-plug)
<details>
<summary>
<a href="https://github.com/junegunn/vim-plug">vim-plug</a>
</summary>

```vim
" Vim Script
Expand All @@ -64,7 +72,39 @@ lua << EOF
EOF
```

### [packer](https://github.com/wbthomason/packer.nvim)
</details>

<details>
<summary>
<a href="https://github.com/folke/lazy.nvim">lazy.nvim</a>
</summary>

```lua
-- Lua
require("lazy").setup({
spec = {
-- Other plugins
{
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end,
},
},
-- ...
})
```

</details>

<details>
<summary>
<a href="https://github.com/wbthomason/packer.nvim">packer.nvim</a>
</summary>

```lua
-- Lua
Expand All @@ -80,8 +120,18 @@ use {
}
```

</details>

## ⚙️ Configuration

To enable the plugin you must call `setup{}`:

```lua
require("project_nvim").setup{
-- Options
}
```

**project.nvim** comes with the following defaults:

```lua
Expand All @@ -91,16 +141,16 @@ use {
manual_mode = false,

-- Methods of detecting the root directory. **"lsp"** uses the native neovim
-- lsp, while **"pattern"** uses vim-rooter like glob pattern matching. Here
-- LSP, while **"pattern"** uses vim-rooter like glob pattern matching. Here
-- order matters: if one is not detected, the other is used as fallback. You
-- can also delete or rearangne the detection methods.
detection_methods = { "lsp", "pattern" },

-- All the patterns used to detect root dir, when **"pattern"** is in
-- detection_methods
-- All the patterns used to detect root dir, when `"pattern"` is in
-- `detection_methods`
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },

-- Table of lsp clients to ignore by name
-- Table of LSP clients to ignore by name
-- eg: { "efm", ... }
ignore_lsp = {},

Expand All @@ -119,7 +169,7 @@ use {
-- * global (default)
-- * tab
-- * win
scope_chdir = 'global',
scope_chdir = "global",

-- Path where project.nvim will store the project history for use in
-- telescope
Expand All @@ -132,74 +182,73 @@ called for the plugin to start.

### Pattern Matching

**project.nvim**'s pattern engine uses the same expressions as vim-rooter, but
for your convenience, I will copy paste them here:

To specify the root is a certain directory, prefix it with `=`.

```lua
patterns = { "=src" }
```
**project.nvim**'s pattern engine uses the same expressions as **vim-rooter**, but
for your convenience I will copy-paste them here:

- To specify the root is a certain directory, prefix it with `=`:
```lua
patterns = { "=src" }
```
- To specify the root has a certain directory or file (which may be a glob), just
give the name:
```lua
patterns = { ".git", "Makefile", "*.sln", "build/env.sh" }
```
- To specify the root has a certain directory as an ancestor (useful for
excluding directories), prefix it with `^`:
```lua
patterns = { "^fixtures" }
```
- To specify the root has a certain directory as its direct ancestor / parent
(useful when you put working projects in a common directory), prefix it with
`>`:
```lua
patterns = { ">Latex" }
```
- To exclude a pattern, prefix it with `!`.
```lua
patterns = { "!.git/worktrees", "!=extras", "!^fixtures", "!build/env.sh" }
```
**NOTE**: Make sure to put your pattern exclusions first, and then the patterns you do want included.

To specify the root has a certain directory or file (which may be a glob), just
give the name:

```lua
patterns = { ".git", "Makefile", "*.sln", "build/env.sh" }
```

To specify the root has a certain directory as an ancestor (useful for
excluding directories), prefix it with `^`:

```lua
patterns = { "^fixtures" }
```
### Telescope Integration

To specify the root has a certain directory as its direct ancestor / parent
(useful when you put working projects in a common directory), prefix it with
`>`:
To enable [Telescope](https://github.com/nvim-telescope/telescope.nvim) integration run the following code in your config:

```lua
patterns = { ">Latex" }
require("telescope").load_extension("projects")
```

To exclude a pattern, prefix it with `!`.
After that you can now call it from the command line:

```lua
patterns = { "!.git/worktrees", "!=extras", "!^fixtures", "!build/env.sh" }
```vim
:Telescope projects
```

List your exclusions before the patterns you do want.

### Telescope Integration
#### Telescope Projects Picker

To enable telescope integration:
```lua
require('telescope').load_extension('projects')
```
To use the projects picker execute the following Lua code:

#### Telescope Projects Picker
To use the projects picker
```lua
require'telescope'.extensions.projects.projects{}
require("telescope").extensions.projects.projects{}
```

#### Telescope mappings

**project.nvim** comes with the following mappings:
**project.nvim** comes with the following mappings for Telescope:

| Normal mode | Insert mode | Action |
| ----------- | ----------- | -------------------------- |
| f | \<c-f\> | find\_project\_files |
| b | \<c-b\> | browse\_project\_files |
| d | \<c-d\> | delete\_project |
| s | \<c-s\> | search\_in\_project\_files |
| r | \<c-r\> | recent\_project\_files |
| w | \<c-w\> | change\_working\_directory |
| f | \<c-f\> | `find_project_files` |
| b | \<c-b\> | `browse_project_files` |
| d | \<c-d\> | `delete_project` |
| s | \<c-s\> | `search_in_project_files` |
| r | \<c-r\> | `recent_project_files` |
| w | \<c-w\> | `change_working_directory` |

## API

Get a list of recent projects:
You can get a list of recent projects by running the code below:

```lua
local project_nvim = require("project_nvim")
Expand All @@ -208,6 +257,8 @@ local recent_projects = project_nvim.get_recent_projects()
print(vim.inspect(recent_projects))
```

Where `recent_projects` is either an empty table `{}` or a string array `{ "/path/to/project", ... }`

## 🤝 Contributing

- All pull requests are welcome.
Expand Down
Loading