Compare commits
6 Commits
v1.12.0
...
chore-poc-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91e6b978e0 | ||
|
|
006b27dc0a | ||
|
|
63cd226c3e | ||
|
|
f9dc294829 | ||
|
|
2dcf249d49 | ||
|
|
9ac1e05fc8 |
@@ -7,9 +7,6 @@ end_of_line = lf
|
|||||||
[nvim-tree-lua.txt]
|
[nvim-tree-lua.txt]
|
||||||
max_line_length = 78
|
max_line_length = 78
|
||||||
|
|
||||||
# keep these in sync with .luarc.json
|
|
||||||
# .editorconfig is used within nvim, overriding .luarc.json
|
|
||||||
# .luarc.json is used by style check
|
|
||||||
[*.lua]
|
[*.lua]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
max_line_length = 140
|
max_line_length = 140
|
||||||
|
|||||||
63
.github/workflows/ci.yml
vendored
63
.github/workflows/ci.yml
vendored
@@ -20,25 +20,45 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
lua_version: [ 5.1 ]
|
lua_version: [ 5.1 ]
|
||||||
luacheck_version: [ 1.2.0 ]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: install lua ${{ matrix.lua_version }}
|
- uses: leafo/gh-actions-lua@v10
|
||||||
uses: leafo/gh-actions-lua@v11
|
|
||||||
with:
|
with:
|
||||||
luaVersion: ${{ matrix.lua_version }}
|
luaVersion: ${{ matrix.lua_version }}
|
||||||
|
|
||||||
- name: install luarocks
|
- uses: leafo/gh-actions-luarocks@v4
|
||||||
uses: leafo/gh-actions-luarocks@v5
|
|
||||||
|
|
||||||
- name: install luacheck ${{ matrix.luacheck_version }}
|
- run: luarocks install luacheck 1.1.1
|
||||||
run: luarocks install luacheck ${{ matrix.luacheck_version }}
|
|
||||||
|
|
||||||
- run: make lint
|
- run: make lint
|
||||||
|
|
||||||
|
style:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ matrix.emmy_lua_code_style_version }}-${{ github.head_ref || github.ref_name }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
emmy_lua_code_style_version: [ 1.5.6 ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: install emmy_lua_code_style
|
||||||
|
run: |
|
||||||
|
mkdir -p CodeFormat
|
||||||
|
curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmy_lua_code_style_version }}/linux-x64.tar.gz" | tar zx --directory CodeFormat
|
||||||
|
|
||||||
|
- run: echo "CodeFormat/linux-x64/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- run: make style
|
||||||
|
|
||||||
|
- run: make style-doc
|
||||||
|
|
||||||
check:
|
check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
@@ -49,31 +69,26 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
nvim_version: [ stable, nightly ]
|
nvim_version: [ stable, nightly ]
|
||||||
luals_version: [ 3.13.9 ]
|
luals_version: [ 3.11.0 ]
|
||||||
|
|
||||||
env:
|
|
||||||
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: install nvim ${{ matrix.nvim_version }}
|
- uses: rhysd/action-setup-vim@v1
|
||||||
uses: rhysd/action-setup-vim@v1
|
|
||||||
with:
|
with:
|
||||||
neovim: true
|
neovim: true
|
||||||
version: ${{ matrix.nvim_version }}
|
version: ${{ matrix.nvim_version }}
|
||||||
|
|
||||||
- name: install lua-language-server ${{ matrix.luals_version }}
|
- name: install luals
|
||||||
run: |
|
run: |
|
||||||
mkdir -p luals
|
mkdir -p luals
|
||||||
curl -L "https://github.com/LuaLS/lua-language-server/releases/download/${{ matrix.luals_version }}/lua-language-server-${{ matrix.luals_version }}-linux-x64.tar.gz" | tar zx --directory luals
|
curl -L "https://github.com/LuaLS/lua-language-server/releases/download/${{ matrix.luals_version }}/lua-language-server-${{ matrix.luals_version }}-linux-x64.tar.gz" | tar zx --directory luals
|
||||||
echo "luals/bin" >> "$GITHUB_PATH"
|
|
||||||
|
|
||||||
- run: make check
|
- run: echo "luals/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: make check
|
||||||
|
env:
|
||||||
|
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
|
||||||
|
run: make check
|
||||||
|
|
||||||
- run: make help-check
|
- run: make help-check
|
||||||
|
|
||||||
- run: make style
|
|
||||||
|
|
||||||
- run: make style-doc
|
|
||||||
|
|||||||
4
.github/workflows/luarocks-release.yml
vendored
4
.github/workflows/luarocks-release.yml
vendored
@@ -1,11 +1,9 @@
|
|||||||
name: Luarocks Release
|
name: Luarocks Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
luarocks-upload:
|
luarocks-upload:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/luals-out/
|
/luals-out/
|
||||||
/luals/
|
/luals/
|
||||||
|
/plenary.nvim/
|
||||||
# backup vim files
|
# backup vim files
|
||||||
*~
|
*~
|
||||||
|
|||||||
16
.luarc.json
16
.luarc.json
@@ -1,23 +1,13 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||||
|
"runtime.version.luals-check-only": "Lua 5.1",
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"library": [
|
"library": [
|
||||||
"$VIMRUNTIME/lua/vim",
|
"$VIMRUNTIME/lua/vim",
|
||||||
"${3rd}/luv/library"
|
"${3rd}/luv/library",
|
||||||
|
"plenary.nvim"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"format": {
|
|
||||||
"defaultConfig": {
|
|
||||||
"indent_style": "space",
|
|
||||||
"max_line_length": "140",
|
|
||||||
"indent_size": "2",
|
|
||||||
"continuation_indent": "2",
|
|
||||||
"quote_style": "double",
|
|
||||||
"call_arg_parentheses": "always",
|
|
||||||
"space_before_closure_open_parenthesis": "false",
|
|
||||||
"align_continuous_similar_call_args": "true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"diagnostics": {
|
"diagnostics": {
|
||||||
"libraryFiles": "Disable",
|
"libraryFiles": "Disable",
|
||||||
"globals": [],
|
"globals": [],
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "1.12.0"
|
".": "1.10.0"
|
||||||
}
|
}
|
||||||
|
|||||||
31
CHANGELOG.md
31
CHANGELOG.md
@@ -1,36 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [1.12.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.11.0...nvim-tree-v1.12.0) (2025-04-20)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add TreePreOpen event ([#3105](https://github.com/nvim-tree/nvim-tree.lua/issues/3105)) ([c24c047](https://github.com/nvim-tree/nvim-tree.lua/commit/c24c0470d9de277fbebecd718f33561ed7c90298))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **#3101:** when renderer.highlight_opened_files = "none" do not reload on BufUnload and BufReadPost ([#3102](https://github.com/nvim-tree/nvim-tree.lua/issues/3102)) ([5bea2b3](https://github.com/nvim-tree/nvim-tree.lua/commit/5bea2b37523a31288e0fcab42f3be5c1bd4516bb))
|
|
||||||
* explicitly set `border` to `"none"` in full name float ([#3094](https://github.com/nvim-tree/nvim-tree.lua/issues/3094)) ([c3c1935](https://github.com/nvim-tree/nvim-tree.lua/commit/c3c193594213c5e2f89ec5d7729cad805f76b256))
|
|
||||||
* reliably dispatch exactly one TreeOpen and TreeClose events ([#3107](https://github.com/nvim-tree/nvim-tree.lua/issues/3107)) ([3a63717](https://github.com/nvim-tree/nvim-tree.lua/commit/3a63717d3d332d8f39aaf65be7a0e4c2265af021))
|
|
||||||
|
|
||||||
## [1.11.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.10.0...nvim-tree-v1.11.0) (2025-02-22)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **#1984:** add quit_on_open and focus opts to various api.node.open functions ([#3054](https://github.com/nvim-tree/nvim-tree.lua/issues/3054)) ([3281f33](https://github.com/nvim-tree/nvim-tree.lua/commit/3281f331f7f0bef13eb00fb2d5a9d28b2f6155a2))
|
|
||||||
* **#3037:** add API node.buffer.delete, node.buffer.wipe ([#3040](https://github.com/nvim-tree/nvim-tree.lua/issues/3040)) ([fee1da8](https://github.com/nvim-tree/nvim-tree.lua/commit/fee1da88972f5972a8296813f6c00d7598325ebd))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **#3045:** wipe scratch buffers for full name and show info popups ([#3050](https://github.com/nvim-tree/nvim-tree.lua/issues/3050)) ([fca0b67](https://github.com/nvim-tree/nvim-tree.lua/commit/fca0b67c0b5a31727fb33addc4d9c100736a2894))
|
|
||||||
* **#3059:** test for presence of new 0.11 API vim.hl.range ([#3060](https://github.com/nvim-tree/nvim-tree.lua/issues/3060)) ([70825f2](https://github.com/nvim-tree/nvim-tree.lua/commit/70825f23db61ecd900c4cfea169bffe931926a9d))
|
|
||||||
* arithmetic on nil value error on first git project open ([#3064](https://github.com/nvim-tree/nvim-tree.lua/issues/3064)) ([8052310](https://github.com/nvim-tree/nvim-tree.lua/commit/80523101f0ae48b7f1990e907b685a3d79776c01))
|
|
||||||
* stl and stlnc fillchars are hidden in window picker ([b699143](https://github.com/nvim-tree/nvim-tree.lua/commit/b69914325a945ee5157f0d21047210b42af5776e))
|
|
||||||
* window picker: hide fillchars: stl and stlnc ([#3066](https://github.com/nvim-tree/nvim-tree.lua/issues/3066)) ([b699143](https://github.com/nvim-tree/nvim-tree.lua/commit/b69914325a945ee5157f0d21047210b42af5776e))
|
|
||||||
|
|
||||||
## [1.10.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.9.0...nvim-tree-v1.10.0) (2025-01-13)
|
## [1.10.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.9.0...nvim-tree-v1.10.0) (2025-01-13)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ Language server: [luals](https://luals.github.io)
|
|||||||
|
|
||||||
Lint: [luacheck](https://github.com/lunarmodules/luacheck/)
|
Lint: [luacheck](https://github.com/lunarmodules/luacheck/)
|
||||||
|
|
||||||
Style Fixing: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck`
|
Style: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck`
|
||||||
|
|
||||||
nvim-tree.lua migrated from stylua to EmmyLuaCodeStyle ~2024/10. `vim.lsp.buf.format()` may be used as it is the default formatter for luals, using an embedded [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle)
|
nvim-tree.lua migrated from stylua to EmmyLuaCodeStyle ~2024/10. `vim.lsp.buf.format()` may be used as it is the default formatter for luals
|
||||||
|
|
||||||
You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks`
|
You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks`
|
||||||
|
|
||||||
@@ -36,14 +36,14 @@ make lint
|
|||||||
|
|
||||||
## style
|
## style
|
||||||
|
|
||||||
1. Runs lua language server `codestyle-check` only, using `.luarc.json` settings
|
1. Runs CodeCheck using `.editorconfig` settings
|
||||||
1. Runs `scripts/doc-comments.sh` to validate annotated documentation
|
1. Runs `scripts/doc-comments.sh` to validate annotated documentation
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make style
|
make style
|
||||||
```
|
```
|
||||||
|
|
||||||
You can automatically fix style issues using `CodeCheck`:
|
You can automatically fix `CodeCheck` issues via:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make style-fix
|
make style-fix
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -17,7 +17,7 @@ luacheck:
|
|||||||
|
|
||||||
# --diagnosis-as-error does not function for workspace, hence we post-process the output
|
# --diagnosis-as-error does not function for workspace, hence we post-process the output
|
||||||
style-check:
|
style-check:
|
||||||
@scripts/luals-check.sh codestyle-check
|
CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua
|
||||||
|
|
||||||
style-doc:
|
style-doc:
|
||||||
scripts/doc-comments.sh
|
scripts/doc-comments.sh
|
||||||
@@ -43,6 +43,19 @@ help-update:
|
|||||||
help-check: help-update
|
help-check: help-update
|
||||||
git diff --exit-code doc/nvim-tree-lua.txt
|
git diff --exit-code doc/nvim-tree-lua.txt
|
||||||
|
|
||||||
|
#
|
||||||
|
# test
|
||||||
|
#
|
||||||
|
test: plenary.nvim
|
||||||
|
scripts/test.sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dependencies
|
||||||
|
#
|
||||||
|
# no plenary tags or releases available
|
||||||
|
plenary.nvim:
|
||||||
|
git clone git@github.com:nvim-lua/plenary.nvim.git
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check
|
.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check
|
||||||
|
|
||||||
|
|||||||
@@ -2007,99 +2007,43 @@ fs.print_clipboard() *nvim-tree-api.fs.print_clipboard()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {node} (Node|nil) file or folder
|
• {node} (Node|nil) file or folder
|
||||||
|
|
||||||
node.open.edit({node}, {opts}) *nvim-tree-api.node.open.edit()*
|
node.open.edit({node}) *nvim-tree-api.node.open.edit()*
|
||||||
File: open as per |nvim-tree.actions.open_file|
|
File: open as per |nvim-tree.actions.open_file|
|
||||||
Folder: expand or collapse
|
Folder: expand or collapse
|
||||||
Root: change directory up
|
Root: change directory up
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.replace_tree_buffer()*
|
*nvim-tree-api.node.open.replace_tree_buffer()*
|
||||||
node.open.replace_tree_buffer({node})
|
node.open.replace_tree_buffer({node})
|
||||||
|nvim-tree-api.node.edit()|, file will be opened in place: in the
|
|nvim-tree-api.node.edit()|, file will be opened in place: in the
|
||||||
nvim-tree window.
|
nvim-tree window.
|
||||||
|
|
||||||
*nvim-tree-api.node.open.no_window_picker()*
|
*nvim-tree-api.node.open.no_window_picker()*
|
||||||
node.open.no_window_picker({node}, {opts})
|
node.open.no_window_picker({node})
|
||||||
|nvim-tree-api.node.edit()|, window picker will never be used as per
|
|nvim-tree-api.node.edit()|, window picker will never be used as per
|
||||||
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
||||||
|
|
||||||
Parameters: ~
|
node.open.vertical({node}) *nvim-tree-api.node.open.vertical()*
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
node.open.vertical({node}, {opts}) *nvim-tree-api.node.open.vertical()*
|
|
||||||
|nvim-tree-api.node.edit()|, file will be opened in a new vertical split.
|
|nvim-tree-api.node.edit()|, file will be opened in a new vertical split.
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.vertical_no_picker()*
|
*nvim-tree-api.node.open.vertical_no_picker()*
|
||||||
node.open.vertical_no_picker({node}, {opts})
|
node.open.vertical_no_picker({node})
|
||||||
|nvim-tree-api.node.vertical()|, window picker will never be used as per
|
|nvim-tree-api.node.vertical()|, window picker will never be used as per
|
||||||
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
||||||
|
|
||||||
Parameters: ~
|
node.open.horizontal({node}) *nvim-tree-api.node.open.horizontal()*
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
node.open.horizontal({node}, {opts}) *nvim-tree-api.node.open.horizontal()*
|
|
||||||
|nvim-tree-api.node.edit()|, file will be opened in a new horizontal split.
|
|nvim-tree-api.node.edit()|, file will be opened in a new horizontal split.
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.horizontal_no_picker()*
|
*nvim-tree-api.node.open.horizontal_no_picker()*
|
||||||
node.open.horizontal_no_picker({node}, {opts})
|
node.open.horizontal_no_picker({node})
|
||||||
|nvim-tree-api.node.horizontal()|, window picker will never be used as per
|
|nvim-tree-api.node.horizontal()|, window picker will never be used as per
|
||||||
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.toggle_group_empty()*
|
*nvim-tree-api.node.open.toggle_group_empty()*
|
||||||
node.open.toggle_group_empty({node}, {opts})
|
node.open.toggle_group_empty({node})
|
||||||
Toggle |nvim-tree.renderer.group_empty| for a specific folder.
|
Toggle |nvim-tree.renderer.group_empty| for a specific folder.
|
||||||
Does nothing on files.
|
Does nothing on files.
|
||||||
Needs |nvim-tree.renderer.group_empty| set.
|
Needs |nvim-tree.renderer.group_empty| set.
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
node.open.drop({node}) *nvim-tree-api.node.open.drop()*
|
node.open.drop({node}) *nvim-tree-api.node.open.drop()*
|
||||||
Switch to window with selected file if it exists.
|
Switch to window with selected file if it exists.
|
||||||
Open file otherwise.
|
Open file otherwise.
|
||||||
@@ -2109,17 +2053,9 @@ node.open.drop({node}) *nvim-tree-api.node.open.drop()*
|
|||||||
Folder: expand or collapse
|
Folder: expand or collapse
|
||||||
Root: change directory up
|
Root: change directory up
|
||||||
|
|
||||||
node.open.tab({node}, {opts}) *nvim-tree-api.node.open.tab()*
|
node.open.tab({node}) *nvim-tree-api.node.open.tab()*
|
||||||
|nvim-tree-api.node.edit()|, file will be opened in a new tab.
|
|nvim-tree-api.node.edit()|, file will be opened in a new tab.
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.tab_drop()*
|
*nvim-tree-api.node.open.tab_drop()*
|
||||||
node.open.tab_drop({node})
|
node.open.tab_drop({node})
|
||||||
Switch to tab containing window with selected file if it exists.
|
Switch to tab containing window with selected file if it exists.
|
||||||
@@ -2129,31 +2065,15 @@ node.open.tab_drop({node})
|
|||||||
Folder: expand or collapse
|
Folder: expand or collapse
|
||||||
Root: change directory up
|
Root: change directory up
|
||||||
|
|
||||||
node.open.preview({node}, {opts}) *nvim-tree-api.node.open.preview()*
|
node.open.preview({node}) *nvim-tree-api.node.open.preview()*
|
||||||
|nvim-tree-api.node.edit()|, file buffer will have |bufhidden| set to `delete`.
|
|nvim-tree-api.node.edit()|, file buffer will have |bufhidden| set to `delete`.
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
*nvim-tree-api.node.open.preview_no_picker()*
|
*nvim-tree-api.node.open.preview_no_picker()*
|
||||||
node.open.preview_no_picker({node}, {opts})
|
node.open.preview_no_picker({node})
|
||||||
|nvim-tree-api.node.edit()|, file buffer will have |bufhidden| set to `delete`.
|
|nvim-tree-api.node.edit()|, file buffer will have |bufhidden| set to `delete`.
|
||||||
window picker will never be used as per
|
window picker will never be used as per
|
||||||
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
|nvim-tree.actions.open_file.window_picker.enable| `false`
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
• {node} (Node|nil) file or folder
|
|
||||||
• {opts} (table) optional parameters
|
|
||||||
|
|
||||||
Options: ~
|
|
||||||
• {quit_on_open} (boolean) quits the tree when opening the file
|
|
||||||
• {focus} (boolean) keep focus in the tree when opening the file
|
|
||||||
|
|
||||||
node.navigate.git.next({node}) *nvim-tree-api.node.navigate.git.next()*
|
node.navigate.git.next({node}) *nvim-tree-api.node.navigate.git.next()*
|
||||||
Navigate to the next item showing git status.
|
Navigate to the next item showing git status.
|
||||||
|
|
||||||
@@ -2769,21 +2689,13 @@ e.g. handler for node renamed: >lua
|
|||||||
|nvim_tree_events_kind|
|
|nvim_tree_events_kind|
|
||||||
|
|
||||||
- Event.Ready
|
- Event.Ready
|
||||||
When NvimTree has been initialized.
|
When NvimTree has been initialized
|
||||||
• Note: Handler takes no parameter.
|
|
||||||
|
|
||||||
- Event.TreePreOpen
|
|
||||||
Invoked before the window and buffer for NvimTree are created
|
|
||||||
or opened. Before |Event.TreeOpen| event.
|
|
||||||
• Note: Handler takes no parameter.
|
• Note: Handler takes no parameter.
|
||||||
|
|
||||||
- Event.TreeOpen
|
- Event.TreeOpen
|
||||||
Invoked after the NvimTree is opened.
|
|
||||||
• Note: Handler takes no parameter.
|
• Note: Handler takes no parameter.
|
||||||
|
|
||||||
- Event.TreeClose
|
- Event.TreeClose
|
||||||
Invoked after the NvimTree is closed, but before the window is
|
|
||||||
closed. Dispatched on |WinClosed| event for NvimTree window.
|
|
||||||
• Note: Handler takes no parameter.
|
• Note: Handler takes no parameter.
|
||||||
|
|
||||||
- Event.Resize - When NvimTree is resized.
|
- Event.Resize - When NvimTree is resized.
|
||||||
|
|||||||
@@ -236,17 +236,6 @@ local function setup_autocommands(opts)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handles event dispatch when tree is closed by `:q`
|
|
||||||
create_nvim_tree_autocmd("WinClosed", {
|
|
||||||
pattern = "*",
|
|
||||||
---@param ev vim.api.keyset.create_autocmd.callback_args
|
|
||||||
callback = function(ev)
|
|
||||||
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
|
|
||||||
require("nvim-tree.events")._dispatch_on_tree_close()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||||
|
|||||||
@@ -80,14 +80,6 @@ local function pick_win_id()
|
|||||||
local win_map = {}
|
local win_map = {}
|
||||||
local laststatus = vim.o.laststatus
|
local laststatus = vim.o.laststatus
|
||||||
vim.o.laststatus = 2
|
vim.o.laststatus = 2
|
||||||
local fillchars = vim.opt.fillchars:get()
|
|
||||||
local stl = fillchars.stl
|
|
||||||
local stlnc = fillchars.stlnc
|
|
||||||
fillchars.stl = nil
|
|
||||||
fillchars.stlnc = nil
|
|
||||||
vim.opt.fillchars = fillchars
|
|
||||||
fillchars.stl = stl
|
|
||||||
fillchars.stlnc = stlnc
|
|
||||||
|
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
local win_ids = vim.api.nvim_tabpage_list_wins(tabpage)
|
local win_ids = vim.api.nvim_tabpage_list_wins(tabpage)
|
||||||
@@ -187,7 +179,6 @@ local function pick_win_id()
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.o.laststatus = laststatus
|
vim.o.laststatus = laststatus
|
||||||
vim.opt.fillchars = fillchars
|
|
||||||
|
|
||||||
if not vim.tbl_contains(vim.split(M.window_picker.chars, ""), resp) then
|
if not vim.tbl_contains(vim.split(M.window_picker.chars, ""), resp) then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -222,46 +222,21 @@ Api.fs.copy.absolute_path = wrap_node(wrap_explorer_member("clipboard", "copy_ab
|
|||||||
Api.fs.copy.filename = wrap_node(wrap_explorer_member("clipboard", "copy_filename"))
|
Api.fs.copy.filename = wrap_node(wrap_explorer_member("clipboard", "copy_filename"))
|
||||||
Api.fs.copy.basename = wrap_node(wrap_explorer_member("clipboard", "copy_basename"))
|
Api.fs.copy.basename = wrap_node(wrap_explorer_member("clipboard", "copy_basename"))
|
||||||
Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_path"))
|
Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_path"))
|
||||||
---
|
|
||||||
---@class NodeEditOpts
|
|
||||||
---@field quit_on_open boolean|nil default false
|
|
||||||
---@field focus boolean|nil default true
|
|
||||||
|
|
||||||
---@param mode string
|
---@param mode string
|
||||||
---@param node Node
|
---@param node Node
|
||||||
---@param edit_opts NodeEditOpts?
|
local function edit(mode, node)
|
||||||
local function edit(mode, node, edit_opts)
|
|
||||||
local file_link = node:as(FileLinkNode)
|
local file_link = node:as(FileLinkNode)
|
||||||
local path = file_link and file_link.link_to or node.absolute_path
|
local path = file_link and file_link.link_to or node.absolute_path
|
||||||
local cur_tabpage = vim.api.nvim_get_current_tabpage()
|
|
||||||
|
|
||||||
actions.node.open_file.fn(mode, path)
|
actions.node.open_file.fn(mode, path)
|
||||||
|
|
||||||
edit_opts = edit_opts or {}
|
|
||||||
|
|
||||||
local mode_unsupported_quit_on_open = mode == "drop" or mode == "tab_drop" or mode == "edit_in_place"
|
|
||||||
if not mode_unsupported_quit_on_open and edit_opts.quit_on_open then
|
|
||||||
view.close(cur_tabpage)
|
|
||||||
end
|
|
||||||
|
|
||||||
local mode_unsupported_focus = mode == "drop" or mode == "tab_drop" or mode == "edit_in_place"
|
|
||||||
local focus = edit_opts.focus == nil or edit_opts.focus == true
|
|
||||||
if not mode_unsupported_focus and not focus then
|
|
||||||
-- if mode == "tabnew" a new tab will be opened and we need to focus back to the previous tab
|
|
||||||
if mode == "tabnew" then
|
|
||||||
vim.cmd(":tabprev")
|
|
||||||
end
|
|
||||||
view.focus()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param mode string
|
---@param mode string
|
||||||
---@param toggle_group boolean?
|
---@param toggle_group boolean?
|
||||||
---@return fun(node: Node, edit_opts: NodeEditOpts?)
|
---@return fun(node: Node)
|
||||||
local function open_or_expand_or_dir_up(mode, toggle_group)
|
local function open_or_expand_or_dir_up(mode, toggle_group)
|
||||||
---@param node Node
|
---@param node Node
|
||||||
---@param edit_opts NodeEditOpts?
|
return function(node)
|
||||||
return function(node, edit_opts)
|
|
||||||
local root = node:as(RootNode)
|
local root = node:as(RootNode)
|
||||||
local dir = node:as(DirectoryNode)
|
local dir = node:as(DirectoryNode)
|
||||||
|
|
||||||
@@ -270,7 +245,7 @@ local function open_or_expand_or_dir_up(mode, toggle_group)
|
|||||||
elseif dir then
|
elseif dir then
|
||||||
dir:expand_or_collapse(toggle_group)
|
dir:expand_or_collapse(toggle_group)
|
||||||
elseif not toggle_group then
|
elseif not toggle_group then
|
||||||
edit(mode, node, edit_opts)
|
edit(mode, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ function HighlightDisplay:render(bufnr, fmt, l)
|
|||||||
|
|
||||||
vim.api.nvim_buf_set_lines(bufnr, l, -1, true, { text })
|
vim.api.nvim_buf_set_lines(bufnr, l, -1, true, { text })
|
||||||
|
|
||||||
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
vim.hl.range(bufnr, namespace_hi_test_id, self.group, { l, 0 }, { l, #self.group, }, {})
|
vim.hl.range(bufnr, namespace_hi_test_id, self.group, { l, 0 }, { l, #self.group, }, {})
|
||||||
else
|
else
|
||||||
vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, #self.group) ---@diagnostic disable-line: deprecated
|
vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, #self.group) ---@diagnostic disable-line: deprecated
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ M.Event = {
|
|||||||
Ready = "Ready",
|
Ready = "Ready",
|
||||||
WillRenameNode = "WillRenameNode",
|
WillRenameNode = "WillRenameNode",
|
||||||
NodeRenamed = "NodeRenamed",
|
NodeRenamed = "NodeRenamed",
|
||||||
TreePreOpen = "TreePreOpen",
|
|
||||||
TreeOpen = "TreeOpen",
|
TreeOpen = "TreeOpen",
|
||||||
TreeClose = "TreeClose",
|
TreeClose = "TreeClose",
|
||||||
WillCreateFile = "WillCreateFile",
|
WillCreateFile = "WillCreateFile",
|
||||||
@@ -92,11 +91,6 @@ function M._dispatch_folder_removed(folder_name)
|
|||||||
dispatch(M.Event.FolderRemoved, { folder_name = folder_name })
|
dispatch(M.Event.FolderRemoved, { folder_name = folder_name })
|
||||||
end
|
end
|
||||||
|
|
||||||
--@private
|
|
||||||
function M._dispatch_on_tree_pre_open()
|
|
||||||
dispatch(M.Event.TreePreOpen, nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
--@private
|
--@private
|
||||||
function M._dispatch_on_tree_open()
|
function M._dispatch_on_tree_open()
|
||||||
dispatch(M.Event.TreeOpen, nil)
|
dispatch(M.Event.TreeOpen, nil)
|
||||||
|
|||||||
@@ -101,19 +101,10 @@ function Explorer:create_autocmds()
|
|||||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||||
group = self.augroup_id,
|
group = self.augroup_id,
|
||||||
callback = function(data)
|
callback = function(data)
|
||||||
-- only handle normal files
|
if (self.filters.state.no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
|
||||||
if vim.bo[data.buf].buftype ~= "" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.filters.state.no_buffer then
|
|
||||||
-- full reload is required to update the filter state
|
|
||||||
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
|
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
|
||||||
self:reload_explorer()
|
self:reload_explorer()
|
||||||
end)
|
end)
|
||||||
elseif self.opts.renderer.highlight_opened_files ~= "none" then
|
|
||||||
-- draw to update opened highlight
|
|
||||||
self.renderer:draw()
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -122,21 +113,10 @@ function Explorer:create_autocmds()
|
|||||||
vim.api.nvim_create_autocmd("BufUnload", {
|
vim.api.nvim_create_autocmd("BufUnload", {
|
||||||
group = self.augroup_id,
|
group = self.augroup_id,
|
||||||
callback = function(data)
|
callback = function(data)
|
||||||
-- only handle normal files
|
if (self.filters.state.no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
|
||||||
if vim.bo[data.buf].buftype ~= "" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.filters.state.no_buffer then
|
|
||||||
-- full reload is required to update the filter state
|
|
||||||
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
|
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
|
||||||
self:reload_explorer()
|
self:reload_explorer()
|
||||||
end)
|
end)
|
||||||
elseif self.opts.renderer.highlight_opened_files ~= "none" then
|
|
||||||
-- draw to update opened highlight; must be delayed as the buffer is still loaded during BufUnload
|
|
||||||
vim.schedule(function()
|
|
||||||
self.renderer:draw()
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -234,9 +214,8 @@ function Explorer:reload(node, project)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local abs = utils.path_join({ cwd, name })
|
local abs = utils.path_join({ cwd, name })
|
||||||
|
---@type uv.fs_stat.result|nil
|
||||||
-- path incorrectly specified as an integer
|
local stat = vim.loop.fs_lstat(abs)
|
||||||
local stat = vim.loop.fs_lstat(abs) ---@diagnostic disable-line param-type-mismatch
|
|
||||||
|
|
||||||
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status)
|
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status)
|
||||||
if filter_reason == FILTER_REASON.none then
|
if filter_reason == FILTER_REASON.none then
|
||||||
@@ -394,9 +373,8 @@ function Explorer:populate_children(handle, cwd, node, project, parent)
|
|||||||
if Watcher.is_fs_event_capable(abs) then
|
if Watcher.is_fs_event_capable(abs) then
|
||||||
local profile = log.profile_start("populate_children %s", abs)
|
local profile = log.profile_start("populate_children %s", abs)
|
||||||
|
|
||||||
-- path incorrectly specified as an integer
|
---@type uv.fs_stat.result|nil
|
||||||
local stat = vim.loop.fs_lstat(abs) ---@diagnostic disable-line param-type-mismatch
|
local stat = vim.loop.fs_lstat(abs)
|
||||||
|
|
||||||
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
|
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
|
||||||
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
|
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
|
||||||
local child = node_factory.create({
|
local child = node_factory.create({
|
||||||
@@ -411,9 +389,9 @@ function Explorer:populate_children(handle, cwd, node, project, parent)
|
|||||||
nodes_by_path[child.absolute_path] = true
|
nodes_by_path[child.absolute_path] = true
|
||||||
child:update_git_status(node_ignored, project)
|
child:update_git_status(node_ignored, project)
|
||||||
end
|
end
|
||||||
elseif node.hidden_stats then
|
else
|
||||||
for reason, value in pairs(FILTER_REASON) do
|
for reason, value in pairs(FILTER_REASON) do
|
||||||
if filter_reason == value and type(node.hidden_stats[reason]) == "number" then
|
if filter_reason == value then
|
||||||
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
|
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ local function open()
|
|||||||
|
|
||||||
-- highlight it
|
-- highlight it
|
||||||
for _, args in ipairs(hl_range_args) do
|
for _, args in ipairs(hl_range_args) do
|
||||||
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
vim.hl.range(M.bufnr, namespace_help_id, args.higroup, args.start, args.finish, {})
|
vim.hl.range(M.bufnr, namespace_help_id, args.higroup, args.start, args.finish, {})
|
||||||
else
|
else
|
||||||
vim.api.nvim_buf_add_highlight(M.bufnr, -1, args.higroup, args.start[1], args.start[2], args.finish[2]) ---@diagnostic disable-line: deprecated
|
vim.api.nvim_buf_add_highlight(M.bufnr, -1, args.higroup, args.start[1], args.start[2], args.finish[2]) ---@diagnostic disable-line: deprecated
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local view = require("nvim-tree.view")
|
local view = require("nvim-tree.view")
|
||||||
local core = require("nvim-tree.core")
|
local core = require("nvim-tree.core")
|
||||||
|
local events = require("nvim-tree.events")
|
||||||
local notify = require("nvim-tree.notify")
|
local notify = require("nvim-tree.notify")
|
||||||
|
|
||||||
---@class LibOpenOpts
|
---@class LibOpenOpts
|
||||||
@@ -129,6 +130,7 @@ function M.open(opts)
|
|||||||
open_view_and_draw()
|
open_view_and_draw()
|
||||||
end
|
end
|
||||||
view.restore_tab_state()
|
view.restore_tab_state()
|
||||||
|
events._dispatch_on_tree_open()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ local function show()
|
|||||||
height = 1,
|
height = 1,
|
||||||
noautocmd = true,
|
noautocmd = true,
|
||||||
style = "minimal",
|
style = "minimal",
|
||||||
border = "none"
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeHighlights"]
|
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeHighlights"]
|
||||||
@@ -81,7 +80,7 @@ local function show()
|
|||||||
local details = extmark[4]
|
local details = extmark[4]
|
||||||
|
|
||||||
if type(details) == "table" then
|
if type(details) == "table" then
|
||||||
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
|
if vim.fn.has("nvim-0.12") == 1 then
|
||||||
vim.hl.range(0, ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
|
vim.hl.range(0, ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
|
||||||
else
|
else
|
||||||
vim.api.nvim_buf_add_highlight(0, ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
|
vim.api.nvim_buf_add_highlight(0, ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function Renderer:render_hl(bufnr, hl_range_args)
|
|||||||
end
|
end
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, namespace_highlights_id, 0, -1)
|
vim.api.nvim_buf_clear_namespace(bufnr, namespace_highlights_id, 0, -1)
|
||||||
for _, args in ipairs(hl_range_args) do
|
for _, args in ipairs(hl_range_args) do
|
||||||
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
vim.hl.range(bufnr, namespace_highlights_id, args.higroup, args.start, args.finish, {})
|
vim.hl.range(bufnr, namespace_highlights_id, args.higroup, args.start, args.finish, {})
|
||||||
else
|
else
|
||||||
vim.api.nvim_buf_add_highlight(bufnr, namespace_highlights_id, args.higroup, args.start[1], args.start[2], args.finish[2]) ---@diagnostic disable-line: deprecated
|
vim.api.nvim_buf_add_highlight(bufnr, namespace_highlights_id, args.higroup, args.start[1], args.start[2], args.finish[2]) ---@diagnostic disable-line: deprecated
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ M.is_wsl = vim.fn.has("wsl") == 1
|
|||||||
-- false for WSL
|
-- false for WSL
|
||||||
M.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
|
M.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
|
||||||
|
|
||||||
|
function M._is_windows()
|
||||||
|
return vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
|
||||||
|
end
|
||||||
|
|
||||||
---@param haystack string
|
---@param haystack string
|
||||||
---@param needle string
|
---@param needle string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
@@ -299,7 +303,7 @@ end
|
|||||||
---@param path string
|
---@param path string
|
||||||
---@return string
|
---@return string
|
||||||
function M.canonical_path(path)
|
function M.canonical_path(path)
|
||||||
if M.is_windows and path:match("^%a:") then
|
if M._is_windows() and path:match("^%a:") then
|
||||||
return path:sub(1, 1):upper() .. path:sub(2)
|
return path:sub(1, 1):upper() .. path:sub(2)
|
||||||
end
|
end
|
||||||
return path
|
return path
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ local function close(tabpage)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
events._dispatch_on_tree_close()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -269,12 +270,9 @@ function M.close_all_tabs()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param tabpage integer|nil
|
function M.close()
|
||||||
function M.close(tabpage)
|
|
||||||
if M.View.tab.sync.close then
|
if M.View.tab.sync.close then
|
||||||
M.close_all_tabs()
|
M.close_all_tabs()
|
||||||
elseif tabpage then
|
|
||||||
close(tabpage)
|
|
||||||
else
|
else
|
||||||
M.close_this_tab_only()
|
M.close_this_tab_only()
|
||||||
end
|
end
|
||||||
@@ -288,7 +286,6 @@ function M.open(options)
|
|||||||
|
|
||||||
local profile = log.profile_start("view open")
|
local profile = log.profile_start("view open")
|
||||||
|
|
||||||
events._dispatch_on_tree_pre_open()
|
|
||||||
create_buffer()
|
create_buffer()
|
||||||
open_window()
|
open_window()
|
||||||
M.resize()
|
M.resize()
|
||||||
@@ -414,7 +411,6 @@ end
|
|||||||
---@param opts OpenInWinOpts|nil
|
---@param opts OpenInWinOpts|nil
|
||||||
function M.open_in_win(opts)
|
function M.open_in_win(opts)
|
||||||
opts = opts or { hijack_current_buf = true, resize = true }
|
opts = opts or { hijack_current_buf = true, resize = true }
|
||||||
events._dispatch_on_tree_pre_open()
|
|
||||||
if opts.winid and vim.api.nvim_win_is_valid(opts.winid) then
|
if opts.winid and vim.api.nvim_win_is_valid(opts.winid) then
|
||||||
vim.api.nvim_set_current_win(opts.winid)
|
vim.api.nvim_set_current_win(opts.winid)
|
||||||
end
|
end
|
||||||
@@ -426,7 +422,6 @@ function M.open_in_win(opts)
|
|||||||
M.reposition_window()
|
M.reposition_window()
|
||||||
M.resize()
|
M.resize()
|
||||||
end
|
end
|
||||||
events._dispatch_on_tree_open()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.abandon_current_window()
|
function M.abandon_current_window()
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
# luals-out/check.json will be produced on any issues, returning 1.
|
# luals-out/check.json will be produced on any issues, returning 1.
|
||||||
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc.
|
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc.
|
||||||
# $VIMRUNTIME specifies neovim runtime path, defaults to "/usr/share/nvim/runtime" if unset.
|
# $VIMRUNTIME specifies neovim runtime path, defaults to "/usr/share/nvim/runtime" if unset.
|
||||||
#
|
|
||||||
# Call with codestyle-check param to enable only codestyle-check
|
|
||||||
|
|
||||||
if [ -z "${VIMRUNTIME}" ]; then
|
if [ -z "${VIMRUNTIME}" ]; then
|
||||||
export VIMRUNTIME="/usr/share/nvim/runtime"
|
export VIMRUNTIME="/usr/share/nvim/runtime"
|
||||||
@@ -19,24 +17,11 @@ FILE_LUARC="${DIR_OUT}/luarc.json"
|
|||||||
rm -rf "${DIR_OUT}"
|
rm -rf "${DIR_OUT}"
|
||||||
mkdir "${DIR_OUT}"
|
mkdir "${DIR_OUT}"
|
||||||
|
|
||||||
case "${1}" in
|
# Uncomment runtime.version for strict neovim baseline 5.1
|
||||||
"codestyle-check")
|
# It is not set normally, to prevent luals loading 5.1 and 5.x, resulting in both versions being chosen on vim.lsp.buf.definition()
|
||||||
jq \
|
cat "${PWD}/.luarc.json" | sed -E 's/.luals-check-only//g' > "${FILE_LUARC}"
|
||||||
'.diagnostics.neededFileStatus[] = "None" | .diagnostics.neededFileStatus."codestyle-check" = "Any"' \
|
|
||||||
"${PWD}/.luarc.json" > "${FILE_LUARC}"
|
|
||||||
|
|
||||||
;;
|
# execute inside lua to prevent luals itself from being checked
|
||||||
*)
|
|
||||||
# Add runtime.version for strict neovim baseline 5.1
|
|
||||||
# It is not set normally, to prevent luals loading 5.1 and 5.x, resulting in both versions being chosen on vim.lsp.buf.definition
|
|
||||||
jq \
|
|
||||||
'."runtime.version" = "Lua 5.1"' \
|
|
||||||
"${PWD}/.luarc.json" > "${FILE_LUARC}"
|
|
||||||
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# execute inside lua directory to prevent luals itself from being checked
|
|
||||||
OUT=$(lua-language-server --check="${DIR_SRC}" --configpath="${FILE_LUARC}" --checklevel=Information --logpath="${DIR_OUT}" --loglevel=error)
|
OUT=$(lua-language-server --check="${DIR_SRC}" --configpath="${FILE_LUARC}" --checklevel=Information --logpath="${DIR_OUT}" --loglevel=error)
|
||||||
RC=$?
|
RC=$?
|
||||||
|
|
||||||
|
|||||||
25
scripts/test.sh
Executable file
25
scripts/test.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR_REPO="$(git rev-parse --show-toplevel)"
|
||||||
|
export DIR_REPO
|
||||||
|
|
||||||
|
DIR_PLENARY="${DIR_REPO}/plenary.nvim"
|
||||||
|
export DIR_PLENARY
|
||||||
|
|
||||||
|
if [ "${#}" -eq 1 ]; then
|
||||||
|
TEST_NAME="${1}"
|
||||||
|
elif [ -z "${TEST_NAME}" ]; then
|
||||||
|
TEST_NAME="tests"
|
||||||
|
fi
|
||||||
|
export TEST_NAME
|
||||||
|
|
||||||
|
echo "testing: ${TEST_NAME}"
|
||||||
|
|
||||||
|
nvim --headless \
|
||||||
|
--clean \
|
||||||
|
-u "${DIR_REPO}/tests/minimal_init.lua" \
|
||||||
|
-l "${DIR_REPO}/tests/test_init.lua" \
|
||||||
|
-c "qa!"
|
||||||
|
|
||||||
8
tests/minimal_init.lua
Normal file
8
tests/minimal_init.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-- Prepend these as plenary appends a "." and plenary directory
|
||||||
|
-- The spawned processes don't specify --clean so contain the full ~/.local runtime path
|
||||||
|
vim.o.runtimepath = string.format(
|
||||||
|
"%s,%s,%s",
|
||||||
|
vim.env.DIR_REPO,
|
||||||
|
vim.env.DIR_PLENARY,
|
||||||
|
vim.o.runtimepath
|
||||||
|
)
|
||||||
9
tests/test_init.lua
Normal file
9
tests/test_init.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
local test_harness = require("plenary.test_harness")
|
||||||
|
|
||||||
|
test_harness.test_directory(
|
||||||
|
vim.env.TEST_NAME,
|
||||||
|
{
|
||||||
|
minimal_init = vim.env.DIR_REPO .. "/tests/minimal_init.lua",
|
||||||
|
sequential = true,
|
||||||
|
}
|
||||||
|
)
|
||||||
30
tests/unit/utils_spec.lua
Normal file
30
tests/unit/utils_spec.lua
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
---@type Luassert
|
||||||
|
local assert = require("luassert")
|
||||||
|
local stub = require("luassert.stub")
|
||||||
|
|
||||||
|
local utils = require("nvim-tree.utils")
|
||||||
|
|
||||||
|
describe("utils.path_add_trailing", function()
|
||||||
|
it("trailing added", function()
|
||||||
|
assert.equals("foo/", utils.path_add_trailing("foo"))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("trailing already present", function()
|
||||||
|
assert.equals("foo/", utils.path_add_trailing("foo/"))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("utils.canonical_path", function()
|
||||||
|
before_each(function()
|
||||||
|
stub(vim.fn, "has")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("is windows", function()
|
||||||
|
vim.fn.has.on_call_with("win32unix").returns(1)
|
||||||
|
assert.equals("C:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"), "should be uppercase drive")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("not windows", function()
|
||||||
|
assert.equals("c:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user