Git Product home page Git Product logo

telescope-project.nvim's Introduction

telescope-project.nvim

An extension for telescope.nvim that allows you to switch between projects.

Demo

Demo

Requirements

Setup

You can setup the extension by adding the following to your config:

require'telescope'.load_extension('project')

You may skip explicitly loading extensions (they will then be lazy-loaded), but tab completions will not be available right away.

Available functions:

Project

The projects picker:

require'telescope'.extensions.project.project{}

Default mappings (normal mode):

Key Description
d delete currently selected project
r rename currently selected project
c create a project*
s search inside files within your project
b browse inside files within your project
w change to the selected project's directory without opening it
R find a recently opened file within your project
f find a file within your project (same as <CR>)
o change current cd scope

Default mappings (insert mode):

Key Description
<c-d> delete currently selected project
<c-v> rename currently selected project
<c-a> create a project*
<c-s> search inside files within your project
<c-b> browse inside files within your project
<c-l> change to the selected project's directory without opening it
<c-r> find a recently opened file within your project
<c-f> find a file within your project (same as <CR>)
<c-o> change current cd scope

* defaults to your git root if used inside a git project, otherwise, it will use your current working directory

Workspace mappings (insert mode):

Key Description
<c-w> change workspace

Example key map config:

vim.api.nvim_set_keymap(
        'n',
        '<C-p>',
        ":lua require'telescope'.extensions.project.project{}<CR>",
        {noremap = true, silent = true}
)

Available options:

Keys Description Options
display_type Show the title and the path of the project 'full' or 'minimal' (default)

Options can be added when requiring telescope-project, as shown below:

lua require'telescope'.extensions.project.project{ display_type = 'full' }

Available setup settings:

Keys Description Options
base_dirs Array of project base directory configurations table (default: nil)
hidden_files Show hidden files in selected project bool (default: false)
order_by Order projects by asc, desc, recent string (default: recent)
sync_with_nvim_tree Sync projects with nvim tree plugin bool (default: false)
search_by Telescope finder search by field (title/path) string or table (default: title). Can also be a table {"title", "path"} to search by both title and path
on_project_selected Custom handler when project is selected function(prompt_bufnr) (default: find project files)
cd_scope Array of cd scopes: tab, window, global table (default: {"tab", "window"})
Setup settings can be added when requiring telescope, as shown below:
require('telescope').setup {
  local project_actions = require("telescope._extensions.project.actions")
  extensions = {
    project = {
      base_dirs = {
        '~/dev/src',
        {'~/dev/src2'},
        {'~/dev/src3', max_depth = 4},
        {path = '~/dev/src4'},
        {path = '~/dev/src5', max_depth = 2},
      },
      hidden_files = true, -- default: false
      theme = "dropdown",
      order_by = "asc",
      search_by = "title",
      sync_with_nvim_tree = true, -- default false
      -- default for on_project_selected = find project files
      on_project_selected = function(prompt_bufnr)
        -- Do anything you want in here. For example:
        project_actions.change_working_directory(prompt_bufnr, false)
        require("harpoon.ui").nav_file(1)
      end
    }
  }
}

Roadmap ๐Ÿš™

  • order projects by last opened โœ”๏ธ
  • add all (git-enabled) subdirectories automatically โœ”๏ธ
  • workspaces ๐Ÿšง

telescope-project.nvim's People

Contributors

adelarsq avatar angkeith avatar antoscencovladimir avatar bekaboo avatar claidler avatar conni2461 avatar dhananjaylatkar avatar dzfrias avatar gplusplus314 avatar harrygallagher4 avatar ieverx avatar ikerurda avatar jens1205 avatar l-kershaw avatar l4zygreed avatar lijinglin3 avatar logan-connolly avatar lytex avatar matu3ba avatar narodo avatar oskarskog avatar thorlucas avatar tiagovla avatar tonywu20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telescope-project.nvim's Issues

Request for comment: Reduce necessary keybindings to support workspaces, git worktree and scratchpad

  1. Observation: c,d,r are needed rarely, so reserving (+ remembering) keybindings has a negative payout.
    I think it would be better to have a separate function entry and make it clear to the user that one is inside the project editing mode.
    We need this to support editing title, one workspace, all workspaces (with the underlying name) for basic functionality.

Further the project editing mode should not try to deal with complex editing, which should be recommended to be done by the user including coyping the project file beforehand and deleting after successful edit.
We can provide instructions in the wiki what stuff can be used to keep the scope of this plugin sane (for preventing errors etc).

  1. Observation s,b,w,f do :lcd repo, find x or :cd repo; find y or find y repo.
    Why dont we provide the user with 1. function to lookup a string to the project path, 2. the string to the picked project path, 3. functions to :lcd and :cd and instructions for the find commands?
    That way we enable to use the full scope of telescope by the user instead of restricting it to certain actions. This requires quite abit refactoring though.

3. An additional scratchpad (stored in /tmp) that lists "open projects" with keybindings to add+remove like how harpoon offers buffer navigation would give an excellent overview to quickly close unnecessary and distracting files and buffers. I do envision another entry function for this, call it maybe overview mode or scratchpad mode, so closing many files (messing with harpoon) does not happen mistakenly. Working on more than 2 or 3 projects at the same time sounds crazy, so we leave it as out of scope.
too complicated, more of a nice to have.

Point 1+2 also help with the point on the roadmap "Move the core logic for managing projects and workspaces outside of telescope". only incentivize read-functions for other projects and forbid write-functions to the telescope-project.txt.
Unfortunately lua gives us no control to restrict function access (ie via export or public accessor), so other plugins may abuse it.

Personally I see 3 main use cases for telescope-project (besides lookup of daily used projects, which could also be done with zoxide/z):

  1. Clone, peek through and delete upstream dependencies (or dependencies of dependecies etc) to fix stuff (or manage local forks, cause upstream did not merge it yet).
  2. Reading others code to use it as updatable collection(inspiration or to reuse code). These are hard to navigate without connecting the projects logically ie with workspaces. Keeping them in the same folder loses the information on what language they were (mainly) written.
  3. Lookup project-specific scripts or do project-specific stuff in shell requires a lookup somewhere and having it automatized (ideally with chroot to limit access only to the project etc) sounds better than the aweful manual connecting of scripts or non-portable shell functions or writing it every time.

Slow startup

First of all, thank you for this fantastic plugin.

I just want to mention that I found out that telescope-project.nvim dramatically slows down my startup time. I use packer for plugin configuration and my local figures are as follows:

vim --startuptime with telescope-project.nvim: ~ 255ms
vim --startuptime without telescope-project.nvim (simply commented out): ~ 95ms

Is there any way to reduce startup time? Is this a bug? Does anyone else see this behaviour?

This is somewhat okay for me, but as I guess that this relates to reading of the project cache file, could this be enhanced (maybe async if not already)?

Thanks in advance for your feedback.

[EDIT] Some details on my system:

  • Figures are from Ubuntu 21.10 but similar figures on Manjaro
  • vim => NVIM v0.7.0-dev
  • 76 plugins (of which 1 is optional)
  • 3 directories as local base_dirs (all in ~):
    • 2 * max_depth = 4
    • 1 * max_depth = 5

error in creating project title for projects not having git

Hi, while creating projects, I encountered a bug.
While creating a new project, the project name as
fatal: not a git repository (or any of the parent directories): .git
And as a result I am not able to switch to the project.
I am running neovim nightly on ubuntu 20.10

Issues with project scanner

After updating telescope and telescope-project the latest version today I was keen to try the new project scanning feature implemented in #34. Unfortunately I encountered the following two issues:

  • I need to create /tmp/found_projects.txt file by hand or otherwise I experience the following error on startup. I would prefer if this file would either be created automatically or if there was at least a note in the readme ๐Ÿ™‚
E5113: Error while calling lua chunk: ...e-project.nvim/lua/telescope/_extensions/project/git.lua:28: bad argument #1 t
o 'lines' (/tmp/found_projects.txt: No such file or directory)
  • After "fixing" the above I still see the following error when trying to execute :Telescope project<CR>. Seems like you just need to update the plenary function call.
E5108: Error executing lua ...pack/packer/start/telescope.nvim/lua/telescope/utils.lua:381: strdisplaywidth deprecated.
 please use plenary.strings.strdisplaywidth

Otherwise great plugin that eases my daily work by a lot ๐Ÿ‘

Feature Request: Search on current project's files

Expose the command to search files in the current project directly so that you can bind a shortcut directly to it. As I see currently you have to invoke the menu, find the current project again and then be able to search on its files.

Creating a project in a git repo subdir

Hello,

Where I work, our 3-part product is in a single git repo and I'd like to create different projects for each one, but when I create, it selects the git repo. How can I disable using the git repo as the project root?

Thanks

VSCode-like session management

I would like to suggest a more advanced way of managing sessions.

Instead of displaying a list of files from a session, it would be more convenient to immediately open the last state of the session and automatically save this state on exit. The states for each session could be .vim or .lua files that contains commands to execute and stored in a user-specified folder.

What do you think about it?

Error in packer_compiled: ...project.nvim/lua/telescope/_extensions/project/utils.lua:68: attempt to call method 'match' (a nil value)

I get

Error in packer_compiled: ...project.nvim/lua/telescope/_extensions/project/utils.lua:68: attempt to call method 'match' (a nil value)

with this config:

require("telescope").setup({
  extensions = {
    project = {
      base_dirs = {
        {vim.env.HOME .. "/projects", max_depth=2},
      }
    }
  }
})

I don't know if my config is wrong but the error appears because the get_project_from_path function from _extensions/project/utils is being passed a table instead of a string for some reason. This error can be solved by changing _extensions/project/utils.lua:68 to:

local title = path.filename:match("[^/]+$")

Open project in file tree

I'd like to select a project and open it directly in my file tree (NERDTree) besides changing the working directory.

It could be a new keymap like <C-t> and configure it like:

...
  extensions = {
    project = {
      file_tree = "nerdtree" -- nvim-tree, etc...
    }
  }
...

[Bug] Dap does not recognize launch.json

Hi.
I am using dap, and does not recognize "vscode/launch.json" file if I use Telescope projects. But, if I load the source and try dap, it recognize "vscode/launch.json".
--(02:59:04) - (14 files: 6.3Mb)$ tree -P .
.
โ”œโ”€โ”€ .vscode
โ”‚ย ย  โ”œโ”€โ”€ launch.json
โ”œโ”€โ”€ src
โ”œโ”€โ”€ assets
โ”‚ย ย  โ”œโ”€โ”€ config
โ”‚ย ย  โ”œโ”€โ”€ fonts
โ”‚ย ย  โ”œโ”€โ”€ images
โ”‚ย ย  โ”œโ”€โ”€ music
โ”‚ย ย  โ”œโ”€โ”€ scripts
โ”‚ย ย  โ”œโ”€โ”€ sounds
โ”‚ย ย  โ””โ”€โ”€ tilemaps
โ”œโ”€โ”€ build
โ”œโ”€โ”€ google_test
โ”œโ”€โ”€ My_Cmake
โ”œโ”€โ”€ SH_files

Mapping for selecting project

The mappings in general are pretty convenient but I think it is confusing that <CR> is not changing to the work directory of the project but instead calls the rename action that already has a mapping.

The title of the popup clearly says Select a Project what imo means switching to that project context. My suggestion is to also map <CR> to change to the working directory of the selected project as the main goal of this extension to me is quick project switching.

Show project full path, and project renamings

It would be cool to see not only top level folder of the project, but full path too in different sections like with diagnostics
image

And sometimes your project root directory names like src. Features to set project name/rename project would be nice too

now i create such map to just edit txt file

local path_to_projectile = vim.fn.stdpath('data')..'/telescope-projects.txt' 

  p = {
      name = '+Projects'                                                 ,
      o = {':e '..path_to_projectile..'<CR>' , 'open file'} ,
      s = {':lua require"telescope".extensions.project.project{}<CR>'    , 'projectile'} ,

With these features i think this could be near to emacs projectile coolness

Stay in prompt after selecting project

First of all, great project! Something I was looking for. Is there a way to stay at the prompt after selecting a project? I realize I can just hit "i" to go to the prompt but with file_browser that is not the case. I would like to have it consistent.

Change <C-r> to rename instead of recent files

Have a recommendation to map <C-r> in insert mode to rename project instead of recent files

I mapped esc to close telescope, so i mainly use the insert mode shortcuts, and i feel most people would wanna use rename more often instead of recent files

Python: Activate virtualenv in the project folder

Sometimes in the project there is a venv folder or a .python-version file that specifies the virtualenv to be used. Is there a way of activating the virtual env when I jump to a project via Telescope projects? Otherwise this kinda defeats the purpose because I'd have to manually cd into the project directory, activate the virtual env then open nvim.

Ignore set number

When loading first file, telescope-project ignore number, cursorcolumn, cursorline

Feature/Workspaces

Workspaces

Let's get workspaces done.

It's been on the roadmap for a while now. I would like to put some thoughts out there and get some ideas flowing.

What is a workspace?

A workspace is a place that contains a number of a users chosen projects.

What is the purpose of a workspace?

Sometimes a user will work on a project that contains lots of different projects. For instance, a server, a website and a cms. It would be nice for the user to press ctrl+p to bring up telescope-project and only see the projects that they are currently working on, and to switch between groups of projects at any given moment. Another example would be for a user wanting to see all of their work projects and then switch to all of their personal projects seamlessly. The purpose is to reduce noise.

How do we implement it?

The user's guide

  • ctrl+1 ... ctrl+9 will open workspaces 1-9 (it's capped at 9, would people want more than 9?)
  • ctrl+0 is the default, which shows all projects across all workspaces.
  • The default workspace (on telescope project open) will be specified in the telescope-project setup config, in the users nvim config.
  • ctrl+w, m, 1 move project to workspace 1 (read as ctrl+workspace, move, 1)
  • ctrl+w, d delete project from workspace

I'm not sure about the key commands yet - I just plucked them out of thin air.

The dev's guide

  • currently all projects are saved in the telescope-project text file with a number of properties, separated by '='. We just add another property for workspaces - w1...w9.
  • we update and delete as you'd expect, by removing or updating the w1...w9 for the specified project.

Crash when switching to a non-existent project

When we try to switch to a non-existent project, the plugin crashes. I think it would be nice to handle such cases and display a warning message to the user.

To reproduce:

  1. Open telescope-project and enter the name of some non-existent project:
    image
  2. Press Enter to see the crash:
    image
E5108: Error executing lua ...oject.nvim/lua/telescope/_extensions/project/actions.lua:18: attempt to index a nil value                                                                                              
stack traceback:                                                                                                                                                                                                     
        ...oject.nvim/lua/telescope/_extensions/project/actions.lua:18: in function 'get_selected_path'                                                                                                              
        ...oject.nvim/lua/telescope/_extensions/project/actions.lua:101: in function 'run_replace_or_original'                                                                                                       
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'find_project_files'                                                                                                             
        ...-project.nvim/lua/telescope/_extensions/project/main.lua:73: in function 'run_replace_or_original'                                                                                                        
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'                                                                                                                       
        ...e/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:235: in function 'execute_keymap'                                                                                                                
        [string ":lua"]:1: in main chunk 

Search Ignored Files

Hey there and thanks for the work on this extension!

How can we tell the find files while in project search to include git ignored files? I see that this extension seems to use the find_files built-in under the hood, but it doesn't allow us to pass in additional configuration? (i'm new at lua; apologies if it can and i'm missing it).

Here is an example of the type of arguments I would like to pass to find_files:

find_command=rg,--files,-uu

Example usage in Telescope:

nnoremap <leader>ff <cmd>Telescope find_files find_command=rg,--files,-uu<cr>

My current workaround is I use Telescope project to change into the project dir, exit, and then do a Telescope find_files.

Thanks again!

Project added: Unknown option -c

Project added: Unknow option -C shows up when I try to create project.
image

And when I try to find files in the project with key f, The path 'Unknown option: -C' does not exist shows up.
image

My telescope config:
image

E523: Not allowed here.

Hello,

I am consistently able to reproduce the above error. I'm not sure if I have a bad config or missing dependency.

OS: macOS Big Sur 11.5.2

Running NeoVIM version:

NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/config -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/include
Compiled by brew@BigSur

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.0/share/nvim"

Run :checkhealth for more info

If I perform the following:

  1. # vim .
  2. <CTRL-p> (Open project)
  3. type 'mas' (for master branch)
  4. backspace 3 chars to remove ('mas' from the window, it does not go away from the previous screen)
  5. type 'main' (for selecting main.tf)
  6. jjj (down 3 lines, not sure if this is significant)
  7. i (try to insert text) --- E523: Not allowed here

At this point I am unable to enter insert mode no matter what file I pick. I have to restart nvim to reset the state.

vimrc.txt

Customise default keys

This is probably just my lack of understanding of how Telescope works, but is there a way to customise the default keys?

I currently have my Telescope set up with <Esc> bound to close in Insert mode, and I just bind <C-whatever> to what ever I want to do. This is fine for the other builtins/extensions that I use, but means that I can't use telescope-project, since all the bindings are for Normal mode.

How to save any subdirectory?

I want to create a Frontend or Backend project with the following directory structure.

However, when I try to create it, a MainProject is created.
When I try to create it again, Project added [path] / MainProject is displayed and I cannot create it.

What should I do

MainProject
  - .git
  - Frontend
    - ...
  - Backend
    - ...

Add command to move between opened projects

would be awesome to have a command to switch between the opened projects. After select the project, switch to last opened buffer of this project OR run Telescope projects. i really miss this feature from emacs

Feature Request: auto add project for opened file to list of projects

I'm a vim noob, so I'm not sure how to do this, but I'd like to be able to automatically add the project for an opened file to the list of projects, if it's not already there.

I assume it would be achieved by adding some FileReadPre autocmd.

The workflow would, I guess, be something like:

1 Get file's directory
2. Check if the file has a git root directory (git rev-parse --show-toplevel)
3. If it does, check if that directory doesn't already exist in telescope-projects.txt
4. If it doesn't, add a new project

Does this sound reasonable?

Would this be the recommended approach?

Thanks in advance!

Duplicate entries in project picker

Hi,

I'm facing the following bug with the project picker:

Issue

Projects are duplicated in the project picker, once with double slash after code directory (see screenshot). This happens to all projects within the code directory

Folder structure:

/home/g/                       (git dir)
     - some_project 1          (git dir)
     - code/                   (no git dir)
          - some_project 2     (git dir)
          - some_project 3     (git dir)

Screenshot

telescope projects

Setup

  • nvim 0.5 stable release
  • Ubuntu 21.04

Minimal vimrc:

silent! packadd minpac
call minpac#init({'verbose': 3})
call minpac#add('nvim-lua/popup.nvim')
call minpac#add('nvim-lua/plenary.nvim')
call minpac#add('nvim-telescope/telescope.nvim')
call minpac#add('nvim-telescope/telescope-project.nvim')

nn <esc><esc> <cmd>Telescope project display_type=full<cr>

lua <<EOF
local ok, telescope = pcall(require, 'telescope')
if not ok then
  return
end
 
local actions = require('telescope.actions')
 
local config = {
  defaults = {
    layout_config = {
      horizontal = { 
        preview_width = 0.6
      },
      center = { 
      },
      vertical = {
      }
    },
    mappings = {
      i = {
        ["<c-s>"] = actions.file_split,
        ["<esc>"] = actions.close,
      },
      n = {
        ["<c-s>"] = actions.file_split,
      }
    }
  },
  pickers = {
    buffers = {
      sort_lastused = true,
      theme = "dropdown",
      previewer = false,
      mappings = {
        i = {
          ["<c-d>"] = actions.delete_buffer,
        },
        n = {
          ["<c-d>"] = actions.delete_buffer,
        }
      }
    }
  },
  extensions = {
    project = {
      base_dirs = {
        {'~/code', max_depth = 1}
      }
    }
  }
}
 
telescope.setup(config)
telescope.load_extension('project')
EOF

noob question - how to set the project folder

I am using this extension for the first time. I set up the extension and when opened the nvim in a git enabled root directory, it the telescope project opened a blank panel. After twice it exit from the projects panel and came to the normal mode in my present buffer

Use Telescope `cwd` to project names

Telescope supports parameter cwd.

Current telescope-project.nvim does not use this paramter.

Proposal

Use value of cwd to limit list of projects only to those, which start with given directory.

Example

I have projects organized in folders:

  • ~/sandbox
  • ~/devel/tis
  • ~/devel/ttr

If cwd=~/sandbox, only projects from this folder and subfolders shall be shown

If cwd=~/devel/tis, only projects from here shall be shown.

If cwd=~/devel, only projects from any subdirectory of ~/devel shall be presented.

Search across projects?

Hi! First of all - amazing plugin, thanks for your work!
I was wondering, how hard would it be to implement 'search across projects', either for file or text?

Order projects by last access time

It would be nice if the projects were ordered by last access time. Then the initial order would act like the MRU lists in the startify plugin. I think that plugin uses the info from the oldfiles variable (which Telescope also provides a builtin picker for) and I assume it would be possible to use that per file information to sort the project directory list.

`hidden_files = true` not working?

In my init.lua I have:

cmd([[packadd packer.nvim]])

require("packer").startup(function()
  use("wbthomason/packer.nvim")
	
  use({
    "nvim-telescope/telescope.nvim",
    requires = { { "nvim-lua/plenary.nvim" } },
  })

  use({
    "ahmedkhalf/project.nvim",
    config = function()
      require("project_nvim").setup({
        detection_methods = { ">code" },
      })
    end,
  })
end)

require("telescope").load_extension("projects")

local actions = require("telescope.actions")

require("telescope").setup({
  defaults = {
    mappings = {
      i = {
        ["<C-j>"] = actions.move_selection_next,
        ["<C-k>"] = actions.move_selection_previous,
        ["<esc>"] = actions.close,
      },
    },
  },
  extensions = {
    project = {
      hidden_files = true,
    },
  },
})

But when I switch to my dotfiles project, the files in that project that start with a dot are not visible.

Those files are definitely not git ignored.

Any thoughts about why?

Thanks for a cool tool.

I'm using:

  • Mac OS X 12.1
  • alacritty 0.9.0
  • tmux 3.2a
  • neovim 0.6.0 with no warnings in checkhealth
  • latest plugin versions synced via Packer
  • a minimal set of plugins not shown for formatting, LSP, etc

Loading extension clears telescope config

Problem code: https://github.com/nvim-telescope/telescope-project.nvim/blob/master/lua/telescope/_extensions/project.lua#L16

require('telescope').setup {}

Function it's calling: https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/init.lua#L28-L41

--- Setup function to be run by user. Configures the defaults, extensions
--- and other aspects of telescope.
---@param opts table: Configuration opts. Keys: defaults, extensions
---@eval { ["description"] = require('telescope').__format_setup_keys() }
function telescope.setup(opts)
  opts = opts or {}
  -- irrelevant code omitted
  require('telescope.config').set_defaults(opts.defaults)
  _extensions.set_config(opts.extensions)
end

telescope.setup is supposed to be called by the user, instead of by plugins.
Calling it at all will clear the user's telescope config at that point.

Additionally, while this doesn't really matter yet, calling telescope.setup before telescope.register_extension should render this plugin unconfigurable in the future.

I have no idea why it's even called, but the only way a user can work around it right now is to load this extension, then run telescope.setup with their own config (since this extension's call does nothing), and then load any other extensions.

Add multiple base_dir directories

I started to use this plugin and it's very useful. Great work!

One thing I'm missing is the ability to add multiple directories (base_dirs) where to look for projects. My personal and work projects are not under the same directory so I would like to pass a list (table) to base_dir instead of a string. Can this be done at the moment or any plan to implement it?

Feature Request: Equivalent of `:lcd path_to_project` and "no(l)cd" (improve documentation)

  1. The behavior of how cwd is changed is underspecified. Neovim offers 1. :cd and 2. :lcd to change paths. But one could also think of 3. not changing the path for only opening the file [ie to compare stuff].
  2. I think even changing the default to :lcd would be more optimal, to run things in the script or :e pathtofile on the correct project folder

use cases

  • My simple project for using associated script folders I am frequently looking and copy your code to modify it. Having PATH cluttered makes this annoying for quick lookups.
  • My project intends to make script running usable from the git root of the project. Its very unnatural to have cwd not being set to the project git root, when one wants to run quick scripts or modifies stuff etc.
  • In future I want to make PATH navigation possible (in neovim and shell associated to project) to get restricted to a local project scope. Having correct cwd set is a basic building block for that.

I have also some other remarks on the structure of the project to make re-usage simpler,
but this is not imminent. Thanks for the plugin and let me know what you think on this.

Default and grep option doesn't always change working directory

I'm expecting the working directory to change to the root of the project I switch to, even if I select a file within a sub-directory.

I believe it does work like this sometimes, but it also fails to happen quite a lot, and I remain with pwd set as the directory I was in before.

I think, though it seems odd, that the difference is whether I start vim initially with a directory or a file. If the first thing I open is a directory, it seems to break the changing of the pwd when I jump to a project file.

Starting without a directory or file, which for me currently opens startify (though I'm hoping to replace that with opening into this plugin by default), also shows issues, but it works if I jump to a project from the start screen, but if I select a file from the startify list, then try to jump from there, the issue returns.

Notably, the w command to change the working directory seems to always work, but the f and s commands (as well as the default) show this issue, which leads me to believe it's something that the telescope builtins are doing when they are called, but I have no idea what that might be or why being in a netrw directory or startify opened file would affect it.

[Question] all git subdirs are not automatically added

Hello,

I added these lines in config -

require('telescope').setup {
	extensions = {
		project = {
			base_dir = '~/code',
			max_depth = 3
		}
	}
}

I was expecting it to add all git directories under ~/code in project list but, nothing is happening. I don't want to add all directories manually as there are lots of them. Is there a way to solve this?

Consistency: Ensuring uniqueness of project names or folder names not checked

Ideally this would be 1. checked upon initialisation (if the user messes around with project configs and only error out [user should have backups])
and 2. upon adding projects (to fail with an error message "rename project folder pathtofolder" or asking to rename the project).

I played around in my project and came to the conclusion that its easier to fix upstream/here.

Since this will conflict with workspaces: When are you going to finish this?

I have the following so far, but the check / lookup of workspace tables is missing. And I am unsure, how this is planned to work to adjust accordingly how editing+calling scripts should work (and if and how duplicates ie for git submodules etc should work).

  outfile = 'testdump.log'
  local fp = assert(io.open(outfile, "a"))
  folders = {}
  for index,tables in ipairs(projects) do
    for key,value in pairs(tables) do
      if index == 1 then
        if key == "path" then
          local pr_path = Path:new(value)
          local pr_path_splitted = path:_split('\\')
          local pr_path_folder = path_splitted[#path_splitted]
          fp:write(pr_path_folder)

          if folders[pr_path_folder] then
            error('Your project folders have duplicated names. Rename them.')
            -- TODO: better: disable plugin and
            -- tell user to fix project folder naming or removing them from project index
            -- tell user to prevent duplicate project names
          end

        end
      end
    end
  end
  fp:close()

Show project path

When entering the command :Telescope project, the full path of the project is displayed

[Question] project.nvim for logic?

Hello there and thanks for this project, it helped me move back to nvim from emacs.

As I was looking at the roadmap I started wondering whether it would make sense to separate concerns a bit by creating a library, something like a project.nvim, which would provide all the business logic for managing projects as well as functioning as an API for interacting with the project file. This is pretty much what's in this card. To my knowledge there is currently no such project managing library, but perhaps one should be created?

The benefits from this approach would imo. be that:

  1. users of different fuzzy search (or whatever) library/framework could benefit from the logic project
  2. chances of having more people contribute is larger if the project is less opinionated
  3. perhaps we will end up with one very stable lib instead of many not so stable

This is, I think, how it works in the emacs community, more or less. There's a projectile library that provides the project managing logic and then a bunch of fuzzy matching frameworks etc. providing different UIs and functionality on top of that.

Any thoughts?

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.