Skip to content

Commit 300d2eb

Browse files
authored
Merge pull request #2 from jglasovic/jglasovic/venv-selector
refactor: full code refactor and interactive venv and root directory selection
2 parents fcb8d9e + 6b430f8 commit 300d2eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1539
-452
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ end_of_line = lf
88
insert_final_newline = true
99

1010
[*.lua]
11-
max_line_length = 120
11+
max_line_length = 100

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Ci
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Stylua
11+
uses: JohnnyMorganz/stylua-action@v3
12+
with:
13+
token: ${{ secrets.GITHUB_TOKEN }}
14+
version: latest
15+
args: --check .
16+
17+
docs:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
22+
name: pandoc to vimdoc
23+
if: ${{ github.ref == 'refs/heads/main' }}
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: panvimdoc
27+
uses: kdheepak/panvimdoc@main
28+
with:
29+
vimdoc: venv-lsp.nvim
30+
treesitter: true
31+
- uses: stefanzweifel/git-auto-commit-action@v4
32+
with:
33+
commit_message: "chore(doc): auto generate docs"
34+
commit_user_name: "github-actions[bot]"
35+
commit_user_email: "github-actions[bot]@users.noreply.github.com"
36+
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run tests
2+
on:
3+
pull_request: ~
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Run tests
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
neovim_version: ['nightly', 'stable']
15+
16+
steps:
17+
- name: Run tests
18+
shell: bash
19+
run: |
20+
echo ${{ matrix.neovim_version }}
21+
# uses: nvim-neorocks/nvim-busted-action@v1
22+
# with:
23+
# nvim_version: ${{ matrix.neovim_version }}

.luarc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"${3rd}/luv/library"
1111
],
1212
"checkThirdParty": false
13+
},
14+
"diagnostics": {
15+
"disable": [
16+
"duplicate-set-field"
17+
]
1318
}
1419
}

.stylua.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
column_width = 120
1+
column_width = 100
22
line_endings = "Unix"
33
indent_type = "Spaces"
44
indent_width = 2

README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,48 @@ require("venv-lsp").setup()
9191

9292
### Commands
9393

94-
- `:VenvLspAutoDisable` — Disable automatic virtual environment detection.
95-
- `:VenvLspAutoEnable` — Enable automatic virtual environment detection.
96-
- `:VenvLspAddVenv` — Manually add a `<root dir path>``<virtual environment path>` mapping.
97-
(You will be prompted to enter the root dir path and venv path.)
98-
- `:VenvLspRemoveVenv` — Remove the manually set `<root dir path>``<virtual environment path>` mapping.
99-
(You will be prompted to select the root path to remove.)
94+
The following user commands are provided by `venv-lsp`:
95+
96+
- `:VenvLspAddVenv`
97+
Prompt to add a virtual environment mapping for a project root.
98+
99+
- `:VenvLspRemoveVenv`
100+
Prompt to remove a virtual environment mapping.
101+
102+
- `:VenvLspCacheDisable`
103+
Disable the virtual environment cache.
104+
105+
- `:VenvLspCacheEnable`
106+
Enable the virtual environment cache.
107+
108+
- `:VenvLspAutoDisable`
109+
Disable automatic virtual environment detection.
110+
111+
- `:VenvLspAutoEnable`
112+
Enable automatic virtual environment detection.
113+
114+
- `:VenvLspCacheFile`
115+
Open the cache file in the editor.
116+
100117

101118
## Configuration
102119

103120
You can pass a config table to `setup()` to customize behavior:
104121

105122
```lua
106123
require("venv-lsp").setup({
107-
disabled_auto_venv = false, -- (default) Set to true to disable automatic venv detection
108-
cache_json_path = vim.fn.stdpath("cache") .. "/venv_lsp/cache.json", -- (default) Custom path for venv cache file
124+
cache_json_path = vim.fn.stdpath('cache') .. '/venv_lsp/cache.json', -- (default) Custom path for venv cache file
125+
disable_cache = false, -- (default) Set to true to disable reading/writing cached venv in json file (still uses in-memory cache)
126+
disable_auto_venv = false, -- (default) Set to true to disable automatic venv detection
109127
})
110128
```
111129

112-
- `disabled_auto_venv`: (boolean) If true, disables automatic virtual environment detection and activation.
130+
- `disable_auto_venv`: (boolean) If true, disables automatic virtual environment detection and activation.
131+
Default: `false`
132+
- `disable_cache`: (boolean) If true, disables reading/writing cached venvs in the JSON file (still uses in-memory cache).
113133
Default: `false`
114134
- `cache_json_path`: (string) Path to the JSON file used for caching venv locations per project.
115-
Default: `utils.path_join(vim.fn.stdpath("cache"), 'venv_lsp', 'cache.json')`
135+
Default: `vim.fn.stdpath('cache') .. '/venv_lsp/cache.json'`
116136

117137
## How it works
118138

@@ -183,7 +203,8 @@ MIT License
183203

184204
## TODO
185205

186-
- [ ] Support `pipenv` venvs
206+
- [ ] Add venv search as in [vscode-python](https://github.com/microsoft/vscode-python/tree/2faa16417084e4b3f9a448127f361dcb336d3ce6/src/client/pythonEnvironments/common/environmentManagers)
207+
- [ ] fzf.vim, fzf-lua, telescope.nvim support for venv search
187208
- [ ] Support for `jedi-language-server`
188209
- [ ] Support for `pylsp`
189210
- [ ] Support for `pylyzer`

doc/.gitkeep

Whitespace-only changes.

doc/tags

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
venv-lsp.nvim-links venv-lsp.nvim.txt /*venv-lsp.nvim-links*
2+
venv-lsp.nvim-table-of-contents venv-lsp.nvim.txt /*venv-lsp.nvim-table-of-contents*
3+
venv-lsp.nvim-venv-lsp.nvim venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim*
4+
venv-lsp.nvim-venv-lsp.nvim-configuration venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-configuration*
5+
venv-lsp.nvim-venv-lsp.nvim-contributing venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-contributing*
6+
venv-lsp.nvim-venv-lsp.nvim-faq venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-faq*
7+
venv-lsp.nvim-venv-lsp.nvim-features venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-features*
8+
venv-lsp.nvim-venv-lsp.nvim-how-it-works venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-how-it-works*
9+
venv-lsp.nvim-venv-lsp.nvim-installation venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-installation*
10+
venv-lsp.nvim-venv-lsp.nvim-license venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-license*
11+
venv-lsp.nvim-venv-lsp.nvim-quick-start venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-quick-start*
12+
venv-lsp.nvim-venv-lsp.nvim-requirements venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-requirements*
13+
venv-lsp.nvim-venv-lsp.nvim-supported-lsps venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-supported-lsps*
14+
venv-lsp.nvim-venv-lsp.nvim-todo venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-todo*
15+
venv-lsp.nvim-venv-lsp.nvim-troubleshooting venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-troubleshooting*
16+
venv-lsp.nvim-venv-lsp.nvim-usage venv-lsp.nvim.txt /*venv-lsp.nvim-venv-lsp.nvim-usage*
17+
venv-lsp.nvim.txt venv-lsp.nvim.txt /*venv-lsp.nvim.txt*

0 commit comments

Comments
 (0)