You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I use a terminal emulator 99% of the time and neovim from within it. If I am working on a Python project, I cd into the project root, activate a virtual environment where I have installed the project in development mode and then start neovim. This gives me two important advantages:
It allows pyright (a Python language server) to have access to the Python modules being used by the project which helps with completion and documentation.
It makes require('telescope.builtin').find_files use the project root.
If I start neovide, open a file in the project using :e file_path, pyright is able to detect the project root but not able to source the virtual environment. And require('telescope.builtin').find_files searches for file in my $HOME directory.
Any idea how I can handle this better? For example, emacs has a plugin called projectile which is able to help with the latter. For the former I think it falls in the scope of the language server but any advice is appreciated nonetheless.
Edit:
For pyright, I am creating a pyrightconfig.json in the project root like this:
{
"venvPath": ".",
"venv": "env"
}
This works perfectly.
For the find_files problem, there is another telescope builtin called git_files. I am trying to modify the config so that '.' invokes git_files if the file belongs to a git repository or find_files if it doesn't but having skill issue with Lua.
Edit 2:
For find_files/git_files I am trying this:
vim.keymap.set('n', '<leader>.', function()
local git_root = require('lspconfig.util').find_git_ancestor(vim.api.nvim_buf_get_name(0))
if git_root then
require('telescope.builtin').git_files { cwd = git_root, previewer = false }
else
require('telescope.builtin').find_files { previewer = false, find_command = {"fd"} }
end
end)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently I use a terminal emulator 99% of the time and neovim from within it. If I am working on a Python project, I
cd
into the project root, activate a virtual environment where I have installed the project in development mode and then start neovim. This gives me two important advantages:require('telescope.builtin').find_files
use the project root.If I start neovide, open a file in the project using
:e file_path
, pyright is able to detect the project root but not able to source the virtual environment. Andrequire('telescope.builtin').find_files
searches for file in my $HOME directory.Any idea how I can handle this better? For example, emacs has a plugin called projectile which is able to help with the latter. For the former I think it falls in the scope of the language server but any advice is appreciated nonetheless.
Edit:
For pyright, I am creating a pyrightconfig.json in the project root like this:
This works perfectly.
For the find_files problem, there is another telescope builtin called git_files. I am trying to modify the config so that '.' invokes git_files if the file belongs to a git repository or find_files if it doesn't but having skill issue with Lua.
Edit 2:
For find_files/git_files I am trying this:
Will see how it goes.
Beta Was this translation helpful? Give feedback.
All reactions