Regenerate nvim config
This commit is contained in:
89
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
89
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
name: Bug Report
|
||||
description: File a bug/issue
|
||||
title: "bug: "
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/trouble.nvim) and search [existing issues](https://github.com/folke/trouble.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/trouble.nvim/discussions) and will be closed.
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check docs and existing issues?
|
||||
description: Make sure you checked all of the below before submitting an issue
|
||||
options:
|
||||
- label: I have read all the trouble.nvim docs
|
||||
required: true
|
||||
- label: I have searched the existing issues of trouble.nvim
|
||||
required: true
|
||||
- label: I have searched the existing issues of plugins related to this issue
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Neovim version (nvim -v)"
|
||||
placeholder: "0.8.0 commit db1b0ee3b30f"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Operating system/version"
|
||||
placeholder: "MacOS 11.5"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps To Reproduce
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: A concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Repro
|
||||
description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
|
||||
value: |
|
||||
-- DO NOT change the paths and don't remove the colorscheme
|
||||
local root = vim.fn.fnamemodify("./.repro", ":p")
|
||||
|
||||
-- set stdpaths to use .repro
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
end
|
||||
|
||||
-- bootstrap lazy
|
||||
local lazypath = root .. "/plugins/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
-- install plugins
|
||||
local plugins = {
|
||||
"folke/tokyonight.nvim",
|
||||
"folke/trouble.nvim",
|
||||
-- add any other plugins here
|
||||
}
|
||||
require("lazy").setup(plugins, {
|
||||
root = root .. "/plugins",
|
||||
})
|
||||
|
||||
vim.cmd.colorscheme("tokyonight")
|
||||
-- add anything else here
|
||||
render: Lua
|
||||
validations:
|
||||
required: false
|
||||
89
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/bug_report_v3.yml
vendored
Normal file
89
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/bug_report_v3.yml
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
name: Bug Report v3
|
||||
description: File a bug/issue
|
||||
title: "bug v3: "
|
||||
labels: [bug v3]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/trouble.nvim/tree/dev) and search [existing issues](https://github.com/folke/trouble.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/trouble.nvim/discussions) and will be closed.
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check docs and existing issues?
|
||||
description: Make sure you checked all of the below before submitting an issue
|
||||
options:
|
||||
- label: I have read all the trouble.nvim docs
|
||||
required: true
|
||||
- label: I have searched the existing issues of trouble.nvim
|
||||
required: true
|
||||
- label: I have searched the existing issues of plugins related to this issue
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Neovim version (nvim -v)"
|
||||
placeholder: "0.8.0 commit db1b0ee3b30f"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Operating system/version"
|
||||
placeholder: "MacOS 11.5"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps To Reproduce
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: A concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Repro
|
||||
description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
|
||||
value: |
|
||||
-- DO NOT change the paths and don't remove the colorscheme
|
||||
local root = vim.fn.fnamemodify("./.repro", ":p")
|
||||
|
||||
-- set stdpaths to use .repro
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
end
|
||||
|
||||
-- bootstrap lazy
|
||||
local lazypath = root .. "/plugins/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
-- install plugins
|
||||
local plugins = {
|
||||
"folke/tokyonight.nvim",
|
||||
"folke/trouble.nvim",
|
||||
-- add any other plugins here
|
||||
}
|
||||
require("lazy").setup(plugins, {
|
||||
root = root .. "/plugins",
|
||||
})
|
||||
|
||||
vim.cmd.colorscheme("tokyonight")
|
||||
-- add anything else here
|
||||
render: Lua
|
||||
validations:
|
||||
required: false
|
||||
36
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
36
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Feature Request
|
||||
description: Suggest a new feature
|
||||
title: "feature: "
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check the docs?
|
||||
description: Make sure you read all the docs before submitting a feature request
|
||||
options:
|
||||
- label: I have read all the trouble.nvim docs
|
||||
required: true
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: A clear and concise description of what you want to happen.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: false
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context or screenshots about the feature request here.
|
||||
36
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/feature_request_v3.yml
vendored
Normal file
36
config/neovim/store/lazy-plugins/trouble.nvim/.github/ISSUE_TEMPLATE/feature_request_v3.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Feature Request v3
|
||||
description: Suggest a new feature
|
||||
title: "feature: "
|
||||
labels: [enhancement v3]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check the docs?
|
||||
description: Make sure you read all the docs before submitting a feature request
|
||||
options:
|
||||
- label: I have read all the trouble.nvim docs
|
||||
required: true
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: A clear and concise description of what you want to happen.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: false
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context or screenshots about the feature request here.
|
||||
72
config/neovim/store/lazy-plugins/trouble.nvim/.github/workflows/ci.yml
vendored
Normal file
72
config/neovim/store/lazy-plugins/trouble.nvim/.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
strategy:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install Neovim
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/nvim
|
||||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||
cd /tmp/nvim
|
||||
chmod a+x ./nvim.appimage
|
||||
./nvim.appimage --appimage-extract
|
||||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||
- name: Run Tests
|
||||
run: |
|
||||
nvim --version
|
||||
[ ! -d tests ] && exit 0
|
||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: panvimdoc
|
||||
uses: kdheepak/panvimdoc@main
|
||||
with:
|
||||
vimdoc: trouble.nvim
|
||||
version: "Neovim >= 0.8.0"
|
||||
demojify: true
|
||||
treesitter: true
|
||||
- name: Push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore(build): auto-generate vimdoc"
|
||||
commit_user_name: "github-actions[bot]"
|
||||
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
||||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||
release:
|
||||
name: release
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
needs:
|
||||
- docs
|
||||
- tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
id: release
|
||||
with:
|
||||
release-type: simple
|
||||
package-name: trouble.nvim
|
||||
- uses: actions/checkout@v3
|
||||
- name: tag stable versions
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email github-actions[bot]@users.noreply.github.com
|
||||
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
|
||||
git tag -d stable || true
|
||||
git push origin :stable || true
|
||||
git tag -a stable -m "Last Stable Release"
|
||||
git push origin stable
|
||||
9
config/neovim/store/lazy-plugins/trouble.nvim/.gitignore
vendored
Normal file
9
config/neovim/store/lazy-plugins/trouble.nvim/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
tt.*
|
||||
.tests
|
||||
doc/tags
|
||||
debug
|
||||
.repro
|
||||
foo.*
|
||||
*.log
|
||||
data
|
||||
.DS_Store
|
||||
13
config/neovim/store/lazy-plugins/trouble.nvim/.lua-format
Normal file
13
config/neovim/store/lazy-plugins/trouble.nvim/.lua-format
Normal file
@ -0,0 +1,13 @@
|
||||
# https://github.com/Koihik/LuaFormatter/blob/master/docs/Style-Config.md
|
||||
#column_limit: 100
|
||||
#indent_width: 4
|
||||
#continuation_indent_width: 4
|
||||
#use_tab: false
|
||||
#chop_down_parameter: true
|
||||
#chop_down_table: true
|
||||
#chop_down_kv_table: true
|
||||
#single_quote_to_double_quote: true
|
||||
#spaces_inside_table_braces: true
|
||||
#align_parameter: true
|
||||
#keep_simple_control_block_one_line: true
|
||||
#extra_sep_at_table_end: true
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"Lua.diagnostics.disable": ["undefined-local"]
|
||||
}
|
||||
283
config/neovim/store/lazy-plugins/trouble.nvim/CHANGELOG.md
Normal file
283
config/neovim/store/lazy-plugins/trouble.nvim/CHANGELOG.md
Normal file
@ -0,0 +1,283 @@
|
||||
# Changelog
|
||||
|
||||
## [2.10.0](https://github.com/folke/trouble.nvim/compare/v2.9.1...v2.10.0) (2023-10-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* `open({focus=false})` now works as intended ([600fe24](https://github.com/folke/trouble.nvim/commit/600fe24ad04f130030fa54f0c70949ff084810a3))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **auto_open:** dont steal focus on auto open. Fixes [#344](https://github.com/folke/trouble.nvim/issues/344) ([1f00b6f](https://github.com/folke/trouble.nvim/commit/1f00b6f730c5ef6bcfeb829a5659ed3780778087))
|
||||
|
||||
## [2.9.1](https://github.com/folke/trouble.nvim/compare/v2.9.0...v2.9.1) (2023-10-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **preview:** skip non-existing. Fixes [#87](https://github.com/folke/trouble.nvim/issues/87). Fixes [#188](https://github.com/folke/trouble.nvim/issues/188). Fixes [#336](https://github.com/folke/trouble.nvim/issues/336). ([#338](https://github.com/folke/trouble.nvim/issues/338)) ([5e78824](https://github.com/folke/trouble.nvim/commit/5e7882429ee2e235148ab759a6159950afd8021a))
|
||||
|
||||
## [2.9.0](https://github.com/folke/trouble.nvim/compare/v2.8.0...v2.9.0) (2023-10-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Make floating window configuration customizable ([#310](https://github.com/folke/trouble.nvim/issues/310)) ([ef0336a](https://github.com/folke/trouble.nvim/commit/ef0336a818e562439e25638b866cb4638a0fdc26))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* check that view is valid before render and focus ([#319](https://github.com/folke/trouble.nvim/issues/319)) ([81e1643](https://github.com/folke/trouble.nvim/commit/81e1643a7c6b426535cf23ebdb28baec4ab7428e))
|
||||
* only filter msg if sev is hardcoded ([#328](https://github.com/folke/trouble.nvim/issues/328)) ([0ccc43d](https://github.com/folke/trouble.nvim/commit/0ccc43d61e0f9278056a8eeefbe022ce71707a85))
|
||||
* **qf:** properly deal with invalid qf entries. Fixes [#87](https://github.com/folke/trouble.nvim/issues/87). Fixes [#188](https://github.com/folke/trouble.nvim/issues/188). Fixes [#336](https://github.com/folke/trouble.nvim/issues/336) ([46b60e9](https://github.com/folke/trouble.nvim/commit/46b60e9fb942d60740c647f61fd779f05e7b9392))
|
||||
|
||||
## [2.8.0](https://github.com/folke/trouble.nvim/compare/v2.7.0...v2.8.0) (2023-07-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Create Configuration for IncludeDeclaration ([#312](https://github.com/folke/trouble.nvim/issues/312)) ([7691d93](https://github.com/folke/trouble.nvim/commit/7691d93131be9c4ef7788892a9c52374642beb89))
|
||||
|
||||
## [2.7.0](https://github.com/folke/trouble.nvim/compare/v2.6.0...v2.7.0) (2023-07-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Expose help action ([#311](https://github.com/folke/trouble.nvim/issues/311)) ([467dc20](https://github.com/folke/trouble.nvim/commit/467dc204af863a9f11bc3444b8f89af286fbf6b2))
|
||||
* Use code descriptions for opening URIs with extra information ([#309](https://github.com/folke/trouble.nvim/issues/309)) ([d2b0f1d](https://github.com/folke/trouble.nvim/commit/d2b0f1de1fe6f013d38234f7557c7935a9f97655))
|
||||
|
||||
## [2.6.0](https://github.com/folke/trouble.nvim/compare/v2.5.0...v2.6.0) (2023-07-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* make multiline the default ([1f2eb71](https://github.com/folke/trouble.nvim/commit/1f2eb71948b8d08cd8fe0947f9dae95c441baf6d))
|
||||
|
||||
## [2.5.0](https://github.com/folke/trouble.nvim/compare/v2.4.0...v2.5.0) (2023-07-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add multiline diagnostic support ([#305](https://github.com/folke/trouble.nvim/issues/305)) ([7a6abd7](https://github.com/folke/trouble.nvim/commit/7a6abd7ed811def9494316d4217d1dcc80b05048))
|
||||
* Map double click to jump action ([#158](https://github.com/folke/trouble.nvim/issues/158)) ([ef53b9a](https://github.com/folke/trouble.nvim/commit/ef53b9a1401919a9a3ae5b2949068c456ce23085))
|
||||
* use markdown to render hover ([835b87d](https://github.com/folke/trouble.nvim/commit/835b87d93537a3cc403b961c084ca8c2998758cd))
|
||||
* **util:** trigger TroubleJump on jump. Closes [#248](https://github.com/folke/trouble.nvim/issues/248) ([d91f3b3](https://github.com/folke/trouble.nvim/commit/d91f3b3d588b0259060780c73dd4c93a8f158f38))
|
||||
|
||||
## [2.4.0](https://github.com/folke/trouble.nvim/compare/v2.3.0...v2.4.0) (2023-07-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add option to control cycling of result list ([#302](https://github.com/folke/trouble.nvim/issues/302)) ([e7805dc](https://github.com/folke/trouble.nvim/commit/e7805dc3448f28599e022dc7a0e58060dfdeeb9a))
|
||||
* rendering messages from provider ([#304](https://github.com/folke/trouble.nvim/issues/304)) ([a66a78b](https://github.com/folke/trouble.nvim/commit/a66a78b8878780e3b3154e9812ff040ec9b0f1d6))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Check parent window is valid before setting active ([#291](https://github.com/folke/trouble.nvim/issues/291)) ([c14786d](https://github.com/folke/trouble.nvim/commit/c14786d5e88f3e66360c70bab56694abd0e60af6))
|
||||
* move end of doc pos to last line. Fixes [#151](https://github.com/folke/trouble.nvim/issues/151) ([cb4da04](https://github.com/folke/trouble.nvim/commit/cb4da0401abe7ae6f368bf79d2ed6c2571b1e7ba))
|
||||
|
||||
## [2.3.0](https://github.com/folke/trouble.nvim/compare/v2.2.3...v2.3.0) (2023-05-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* filter diagnostics by severity level ([#285](https://github.com/folke/trouble.nvim/issues/285)) ([b1f607f](https://github.com/folke/trouble.nvim/commit/b1f607ff0f2c107faf8b0c26d09877028b549d63))
|
||||
|
||||
## [2.2.3](https://github.com/folke/trouble.nvim/compare/v2.2.2...v2.2.3) (2023-05-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* set window options locally ([#282](https://github.com/folke/trouble.nvim/issues/282)) ([a5649c9](https://github.com/folke/trouble.nvim/commit/a5649c9a60d7c5aa2fed1781057af3f29b10f167))
|
||||
|
||||
## [2.2.2](https://github.com/folke/trouble.nvim/compare/v2.2.1...v2.2.2) (2023-04-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **util:** auto_jump when trouble is open. Fixes [#144](https://github.com/folke/trouble.nvim/issues/144) ([e4f1623](https://github.com/folke/trouble.nvim/commit/e4f1623b51e18eb4e2835446e50886062c339f80))
|
||||
* **util:** save position in jump list before jump. Fixes [#143](https://github.com/folke/trouble.nvim/issues/143) Fixes [#235](https://github.com/folke/trouble.nvim/issues/235) ([f0477b0](https://github.com/folke/trouble.nvim/commit/f0477b0e78d9a16ff326e356235876ff3f87882d))
|
||||
|
||||
## [2.2.1](https://github.com/folke/trouble.nvim/compare/v2.2.0...v2.2.1) (2023-03-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **icons:** fixed deprecated icons with nerdfix ([39db399](https://github.com/folke/trouble.nvim/commit/39db3994c8de87b0b5ca7a4d3d415926f201f1fc))
|
||||
|
||||
## [2.2.0](https://github.com/folke/trouble.nvim/compare/v2.1.1...v2.2.0) (2023-02-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* enable looping during next/prev ([#232](https://github.com/folke/trouble.nvim/issues/232)) ([fc4c0f8](https://github.com/folke/trouble.nvim/commit/fc4c0f82c9181f3c27a4cbdd5db97c110fd78ee9))
|
||||
* expose renderer.signs. Fixes [#252](https://github.com/folke/trouble.nvim/issues/252) ([5581e73](https://github.com/folke/trouble.nvim/commit/5581e736c8afc8b227ad958ded1929c8a39f049e))
|
||||
|
||||
## [2.1.1](https://github.com/folke/trouble.nvim/compare/v2.1.0...v2.1.1) (2023-02-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure that the diagnostic parameters are complete ([#179](https://github.com/folke/trouble.nvim/issues/179)) ([210969f](https://github.com/folke/trouble.nvim/commit/210969fce79e7d11554c61bca263d7e1ac77bde0))
|
||||
* icorrect row/line in diagnostics. Fixes [#264](https://github.com/folke/trouble.nvim/issues/264) ([32fa4ed](https://github.com/folke/trouble.nvim/commit/32fa4ed742fc91f3075c98edd3c131b716b9d782))
|
||||
|
||||
## [2.1.0](https://github.com/folke/trouble.nvim/compare/v2.0.1...v2.1.0) (2023-02-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose `require("trouble").is_open()` ([2eb27b3](https://github.com/folke/trouble.nvim/commit/2eb27b34442894e903fdc6e01edea6d7c476be63))
|
||||
|
||||
## [2.0.1](https://github.com/folke/trouble.nvim/compare/v2.0.0...v2.0.1) (2023-02-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **init:** version check ([73eea32](https://github.com/folke/trouble.nvim/commit/73eea32efec2056cdce7593787390fc9aadf9c0c))
|
||||
|
||||
## [2.0.0](https://github.com/folke/trouble.nvim/compare/v1.0.2...v2.0.0) (2023-02-16)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Trouble now requires Neovim >= 0.7.2
|
||||
|
||||
### Features
|
||||
|
||||
* Trouble now requires Neovim >= 0.7.2 ([ef93259](https://github.com/folke/trouble.nvim/commit/ef9325970b341d436f43c50ce876aa0a665d3cf0))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Focus parent before closing ([#259](https://github.com/folke/trouble.nvim/issues/259)) ([66b057b](https://github.com/folke/trouble.nvim/commit/66b057b2b07881bceb969624f4c3b5727703c2c8))
|
||||
* **preview:** properly load buffer when showing preview ([949199a](https://github.com/folke/trouble.nvim/commit/949199a9ac60ce784a417f90388b8f173ef53819))
|
||||
* **util:** properly load a buffer when jumping to it ([bf0eeea](https://github.com/folke/trouble.nvim/commit/bf0eeead88d59d51003f4da1b649b4977ed90e2b))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* dont load buffers when processing items. Get line with luv instead ([82c9a9a](https://github.com/folke/trouble.nvim/commit/82c9a9a9cd2cd2cdb05e05a3e6538529e2473e14))
|
||||
|
||||
## [1.0.2](https://github.com/folke/trouble.nvim/compare/v1.0.1...v1.0.2) (2023-02-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **telescope:** properly fix issue with relative filenames in telescope. See [#250](https://github.com/folke/trouble.nvim/issues/250) ([7da0821](https://github.com/folke/trouble.nvim/commit/7da0821d20342751a7eedecd28cf16040146cbf7))
|
||||
|
||||
## [1.0.1](https://github.com/folke/trouble.nvim/compare/v1.0.0...v1.0.1) (2023-01-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure first line is selected when padding is false ([#233](https://github.com/folke/trouble.nvim/issues/233)) ([b2d6ac8](https://github.com/folke/trouble.nvim/commit/b2d6ac8607e1ab612a85c1ec563aaff3a60f0603))
|
||||
* **telescope:** correctly use cwd for files. Fixes [#250](https://github.com/folke/trouble.nvim/issues/250) ([3174767](https://github.com/folke/trouble.nvim/commit/3174767c61b3786e65d78f539c60c6f70d26cdbe))
|
||||
|
||||
## 1.0.0 (2023-01-04)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* renamed use_lsp_diagnostic_signs to use_diagnostic_signs
|
||||
* removed deprecated commands
|
||||
|
||||
### Features
|
||||
|
||||
* added "hover" action that defaults to "K" to show the full multiline text [#11](https://github.com/folke/trouble.nvim/issues/11) ([9111a5e](https://github.com/folke/trouble.nvim/commit/9111a5eb7881a84cd66107077118614e218fba61))
|
||||
* added actions for opening in new tab, split and vsplit. Fixes [#36](https://github.com/folke/trouble.nvim/issues/36) ([c94cc59](https://github.com/folke/trouble.nvim/commit/c94cc599badb7086878559653ec705ed68579682))
|
||||
* added mapping for jump & close (defaults to "o") [#15](https://github.com/folke/trouble.nvim/issues/15) ([09de784](https://github.com/folke/trouble.nvim/commit/09de78495bad194b2d0d85498a1c1a7996182a71))
|
||||
* added support for vim.diagnostics and Neovim 0.7 ([735dcd5](https://github.com/folke/trouble.nvim/commit/735dcd599871179a835d1e0ebd777d4db24c2c72))
|
||||
* allow proper passing of plugin options ([79513ed](https://github.com/folke/trouble.nvim/commit/79513ed42a273a1bc80d82c7e1117d3a2e0f2c79))
|
||||
* Api to go to first and last items ([#157](https://github.com/folke/trouble.nvim/issues/157)) ([0649811](https://github.com/folke/trouble.nvim/commit/0649811e69a11dea4708a19deee9ab0b1e90313e))
|
||||
* better preview and mode ([160fa6c](https://github.com/folke/trouble.nvim/commit/160fa6cb213db6c7a421450b67adc495ae69cef0))
|
||||
* command complete ([9923b01](https://github.com/folke/trouble.nvim/commit/9923b01692a238535420d58e440b139a89c3de46))
|
||||
* comments to open/toggle workspace or ducument mode directly ([f7db1c2](https://github.com/folke/trouble.nvim/commit/f7db1c29d7eb76cb3310e0aa56a4d546420e7814))
|
||||
* config for auto_preview ([0ad97fb](https://github.com/folke/trouble.nvim/commit/0ad97fb67b21579729090214cbb3bce78fd153b7))
|
||||
* define multiple keybindings for the same action (better for defaults) ([bf8e8ee](https://github.com/folke/trouble.nvim/commit/bf8e8ee63c38103fb42de0b889810b584e378962))
|
||||
* expose items ([#41](https://github.com/folke/trouble.nvim/issues/41)) ([4f84ca4](https://github.com/folke/trouble.nvim/commit/4f84ca4530829b9448c6f13530c26df6d7020fd0))
|
||||
* indent lines ([f9e6930](https://github.com/folke/trouble.nvim/commit/f9e6930b5188593b9e6408d8937093d04198e90a))
|
||||
* inital version ([980fb07](https://github.com/folke/trouble.nvim/commit/980fb07fd33ea0f72b274e1ad3c8626bf8a14ac9))
|
||||
* Lsp implementation ([#50](https://github.com/folke/trouble.nvim/issues/50)) ([069cdae](https://github.com/folke/trouble.nvim/commit/069cdae61d58d2477b150af91692ace636000d47))
|
||||
* lsp references, loclist and quickfix lists! ([0b852c8](https://github.com/folke/trouble.nvim/commit/0b852c8418d65191983b2c9b8f90ad6d7f45ff51))
|
||||
* made it easier to integrate with trouble ([1dd72c2](https://github.com/folke/trouble.nvim/commit/1dd72c22403519c160b0c694762091971bcf191e))
|
||||
* make file grouping and padding configurable ([#66](https://github.com/folke/trouble.nvim/issues/66)) ([ff40475](https://github.com/folke/trouble.nvim/commit/ff40475143ecd40c86f13054935f3afc5653c469))
|
||||
* make position of the trouble list configurable (top, bottom, left or right) [#27](https://github.com/folke/trouble.nvim/issues/27) ([0c9ca5e](https://github.com/folke/trouble.nvim/commit/0c9ca5e10c2e5dd8d8479e864e12383b1d614273))
|
||||
* make signs configurable ([ff9fd51](https://github.com/folke/trouble.nvim/commit/ff9fd51ab05398c83c2a0b384999d49269d95572))
|
||||
* make sorting keys configurable ([#190](https://github.com/folke/trouble.nvim/issues/190)) ([68d3dc5](https://github.com/folke/trouble.nvim/commit/68d3dc52fe49375fe556af69d1e91e0a88b67935))
|
||||
* next/previous API. Implements [#44](https://github.com/folke/trouble.nvim/issues/44) ([a2a7dbf](https://github.com/folke/trouble.nvim/commit/a2a7dbfefc5ebdf1a9c1d37e9df1d26a3b13c1cd))
|
||||
* option to automatically jump when there is only one result (fixes [#57](https://github.com/folke/trouble.nvim/issues/57)) ([#79](https://github.com/folke/trouble.nvim/issues/79)) ([09fafb2](https://github.com/folke/trouble.nvim/commit/09fafb2e01fbaa4fe6ecede10a7e7a738464deba))
|
||||
* **providers.lsp:** Add definitions support ([#20](https://github.com/folke/trouble.nvim/issues/20)) ([a951198](https://github.com/folke/trouble.nvim/commit/a95119893c8dfd4b4bed42da97d601c25c7a495f))
|
||||
* sort files by current directory and prefer non-hidden ([ea9a5e3](https://github.com/folke/trouble.nvim/commit/ea9a5e331b70cf4011081c951015033f0079a0cc))
|
||||
* sort items by severity / filename / lnum / col ([4a45782](https://github.com/folke/trouble.nvim/commit/4a45782db943f95500b61ffce187bf4cada954ae))
|
||||
* sort results by row and column isntead of just row ([#118](https://github.com/folke/trouble.nvim/issues/118)) ([5897b09](https://github.com/folke/trouble.nvim/commit/5897b09933731298382e86a5cf4d1a4861630873))
|
||||
* **telescope provider:** (Smart) multiselect ([#39](https://github.com/folke/trouble.nvim/issues/39)) ([45ff198](https://github.com/folke/trouble.nvim/commit/45ff198f4d436d256f02b14db9c817024c7fc85c))
|
||||
* Telescope support ([9c81e16](https://github.com/folke/trouble.nvim/commit/9c81e16adec697ffd0b694eb86e14cfee453917d))
|
||||
* use vim.notify for logging ([293118e](https://github.com/folke/trouble.nvim/commit/293118e195639c373a6a744621b9341e5e18f6e4))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Add nowait option to keymap ([#30](https://github.com/folke/trouble.nvim/issues/30)) ([4375f1f](https://github.com/folke/trouble.nvim/commit/4375f1f0b2457fcbb91d32de457e6e3b3bb7eba7))
|
||||
* added additional space between message and code ([aae12e7](https://github.com/folke/trouble.nvim/commit/aae12e7b23b3a2b8337ec5b1d6b7b4317aa3929b))
|
||||
* added compatibility to retrieve signs from vim.diagnostic ([dab82ef](https://github.com/folke/trouble.nvim/commit/dab82ef0f39893f50908881fdc5e96bfb1578ba1))
|
||||
* added suport for vim.diagnostic hl groups ([d25a8e6](https://github.com/folke/trouble.nvim/commit/d25a8e6779462127fb227397fa92b07bced8a6fe))
|
||||
* added support for new handler signatures (backward compatible with 0.5) ([87cae94](https://github.com/folke/trouble.nvim/commit/87cae946aee4798bee621ea6108224c08c218d69))
|
||||
* auto_open was broken. Fixed now [#29](https://github.com/folke/trouble.nvim/issues/29) ([a2f2b92](https://github.com/folke/trouble.nvim/commit/a2f2b9248bed41522d8caa3a7e9932981c4087ec))
|
||||
* better detection of the parent window ([4c5fd8a](https://github.com/folke/trouble.nvim/commit/4c5fd8abaf6058312ebe52f662ca002bf0aa9f77))
|
||||
* default to current window in jump_to_item ([#175](https://github.com/folke/trouble.nvim/issues/175)) ([ec24219](https://github.com/folke/trouble.nvim/commit/ec242197b1f72cabe17dfd61119c896f58bda672))
|
||||
* don't "edit" en existing buffer. Use "buffer" instead. ([#5](https://github.com/folke/trouble.nvim/issues/5), [#6](https://github.com/folke/trouble.nvim/issues/6)) ([abef115](https://github.com/folke/trouble.nvim/commit/abef1158c0ff236333f67f9f091e5d9ae67d6a89))
|
||||
* don't steal focus on auto_open. Fixes [#48](https://github.com/folke/trouble.nvim/issues/48) ([36b6813](https://github.com/folke/trouble.nvim/commit/36b6813a2103d85b469a61721b030903ddd8b3b3))
|
||||
* don't try to fetch sign for "other" ([5b50990](https://github.com/folke/trouble.nvim/commit/5b509904f8865bea7d09b7a686e139077a2484c6))
|
||||
* don't use file sorter for items without a valid filename ([20469be](https://github.com/folke/trouble.nvim/commit/20469be985143d024c460d95326ebeff9971d714))
|
||||
* dont advance two items at a time. Fixes https://github.com/folke/todo-comments.nvim/issues/39 ([7de8bc4](https://github.com/folke/trouble.nvim/commit/7de8bc46164ec1f787dee34b6843b61251b1ea91))
|
||||
* files without col/row should be set to col=1 and row=1 [#22](https://github.com/folke/trouble.nvim/issues/22) ([fcd5f1f](https://github.com/folke/trouble.nvim/commit/fcd5f1fc035ee3d9832c63a307247c09f25c9cd1))
|
||||
* filetype set too early ([#230](https://github.com/folke/trouble.nvim/issues/230)) ([c4da921](https://github.com/folke/trouble.nvim/commit/c4da921ba613aa6d6659dc18edc204c37e4b8833))
|
||||
* fixed auto_open swicth_to_parent. Fixes [#7](https://github.com/folke/trouble.nvim/issues/7) ([7cf1aa1](https://github.com/folke/trouble.nvim/commit/7cf1aa1195245d3098097bc3a2510dc358c87363))
|
||||
* give focus back to correct window when closing ([#72](https://github.com/folke/trouble.nvim/issues/72)) ([a736b8d](https://github.com/folke/trouble.nvim/commit/a736b8db9f49b8b49ac96fbab7f8e396032cfa37))
|
||||
* handle normal api calls to trouble as it should [#42](https://github.com/folke/trouble.nvim/issues/42) ([52b875d](https://github.com/folke/trouble.nvim/commit/52b875d1aaf88f32e9f070a0119190c3e65b51a5))
|
||||
* if grouping is off, decrease indent ([#140](https://github.com/folke/trouble.nvim/issues/140)) ([ed65f84](https://github.com/folke/trouble.nvim/commit/ed65f84abc4a1e5d8f368d7e02601fc0357ea15e))
|
||||
* lazy include telescope when needed ([7e3d4f9](https://github.com/folke/trouble.nvim/commit/7e3d4f9efc157bbfeb3e37837f8ded9289c48f25))
|
||||
* lsp diag creates ugly buffers for unopened files in the workspace. Fixed now ([91d1139](https://github.com/folke/trouble.nvim/commit/91d1139d85407b99bd4d2f6850200a793631679b))
|
||||
* lsp diagnostics codes ([dbbd523](https://github.com/folke/trouble.nvim/commit/dbbd523d91fe51e8421909147bf069b1ec780720))
|
||||
* lsp handler error log ([#95](https://github.com/folke/trouble.nvim/issues/95)) ([063aefd](https://github.com/folke/trouble.nvim/commit/063aefd69a8146e27cde860c9ddd807891e5a119))
|
||||
* **lsp:** avoid overwriting uri of result ([#60](https://github.com/folke/trouble.nvim/issues/60)) ([655391c](https://github.com/folke/trouble.nvim/commit/655391c2f592ef61943b6325030333dfacc54757))
|
||||
* only use old hl groups when they exist (Fixes [#49](https://github.com/folke/trouble.nvim/issues/49)) ([d4ce76f](https://github.com/folke/trouble.nvim/commit/d4ce76fa82cdbd12dcf9dbfa682dae89b2a143ac))
|
||||
* possible vim.NIL on diagnostics code ([1faa347](https://github.com/folke/trouble.nvim/commit/1faa347a93748531b5e418d84276c93da21b86a7))
|
||||
* prevent segfault on closing ([756f09d](https://github.com/folke/trouble.nvim/commit/756f09de113a775ab16ba6d26c090616b40a999d))
|
||||
* properly close trouble window on close ([d10ee4b](https://github.com/folke/trouble.nvim/commit/d10ee4bc99b8e2bb842c2274316db400b197cca9))
|
||||
* properly exit when trouble is the last window. Fixes [#24](https://github.com/folke/trouble.nvim/issues/24) ([2b27b96](https://github.com/folke/trouble.nvim/commit/2b27b96c7893ac534ba0cbfc95d52c6c609a0b20))
|
||||
* remove useless "no results" notification ([#164](https://github.com/folke/trouble.nvim/issues/164)) ([da61737](https://github.com/folke/trouble.nvim/commit/da61737d860ddc12f78e638152834487eabf0ee5)), closes [#154](https://github.com/folke/trouble.nvim/issues/154)
|
||||
* removed space betweend rendering of source + code ([b676029](https://github.com/folke/trouble.nvim/commit/b6760291874d078668f4ff04d78acc0670536ca9))
|
||||
* removed unused plenary require. Fixes [#1](https://github.com/folke/trouble.nvim/issues/1) ([1ff45e2](https://github.com/folke/trouble.nvim/commit/1ff45e274de32e816b891b1ca12f73f73b58a604))
|
||||
* replace possible newlines in rendered text ([08d068f](https://github.com/folke/trouble.nvim/commit/08d068fb1668b7f898af721cbc8a1ae72ddf6565))
|
||||
* restore item indentation ([7c93271](https://github.com/folke/trouble.nvim/commit/7c93271e7a6a147b8f4342f5b377fa863419846f))
|
||||
* set buftype before filetype ([#67](https://github.com/folke/trouble.nvim/issues/67)) ([169b2ec](https://github.com/folke/trouble.nvim/commit/169b2ec3a4d0cac01f22cc8f7332f1d0a11f1fa4))
|
||||
* set EndOfBuffer to LspTroubleNormal and hide ~ [#23](https://github.com/folke/trouble.nvim/issues/23) ([7d67f34](https://github.com/folke/trouble.nvim/commit/7d67f34d92b3b52ca63c84f929751d98b3f56b63))
|
||||
* set nowrap for the trouble window. Fixes [#69](https://github.com/folke/trouble.nvim/issues/69) ([51dd917](https://github.com/folke/trouble.nvim/commit/51dd9175eb506b026189c70f81823dfa77defe86))
|
||||
* set the filetype lastly so autocmd's can override options from it ([#126](https://github.com/folke/trouble.nvim/issues/126)) ([b5353dd](https://github.com/folke/trouble.nvim/commit/b5353ddcd09bd7e93d6f934149d25792d455a8fb))
|
||||
* show warning when icons=true but devicons is not installed ([7aabea5](https://github.com/folke/trouble.nvim/commit/7aabea5cca2d51ba5432c988fe84ff9d3644637a))
|
||||
* support LocationLink ([#94](https://github.com/folke/trouble.nvim/issues/94)) ([7f3761b](https://github.com/folke/trouble.nvim/commit/7f3761b6dbadd682a20bd1ff4cb588985c14c9a0))
|
||||
* typos ([#55](https://github.com/folke/trouble.nvim/issues/55)) ([059ea2b](https://github.com/folke/trouble.nvim/commit/059ea2b999171f50019291ee776dd496799fdf3a))
|
||||
* use deprecated vim.lsp.diagnostics for now ([afb300f](https://github.com/folke/trouble.nvim/commit/afb300f18c09f7b474783aa12eb680ea59785b46))
|
||||
* use new DiagnosticChanged event ([#127](https://github.com/folke/trouble.nvim/issues/127)) ([4d0a711](https://github.com/folke/trouble.nvim/commit/4d0a711e7432eed022611ce385f3a7714e81f63b)), closes [#122](https://github.com/folke/trouble.nvim/issues/122)
|
||||
* use vim.diagnostic instead of vim.lsp.diagnostic when available ([a2e2e7b](https://github.com/folke/trouble.nvim/commit/a2e2e7b53f389f84477a1a11c086c9a379af702e))
|
||||
* workspace and document diagnostics were switched around ([1fa8469](https://github.com/folke/trouble.nvim/commit/1fa84691236d16a2d1c12707c1fbc54060c910f7))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* debounce auto refresh when diagnostics get updated ([068476d](https://github.com/folke/trouble.nvim/commit/068476db8576e5b32acf20df040e7fca032cd11d))
|
||||
* much faster async preview ([2c9b319](https://github.com/folke/trouble.nvim/commit/2c9b3195a7fa8cfc19a368666c9f83fd7a20a482))
|
||||
* only fetch line when needed. Fixes [#26](https://github.com/folke/trouble.nvim/issues/26) ([52f18fd](https://github.com/folke/trouble.nvim/commit/52f18fd6bea57af54265247a3ec39f19a31adce3))
|
||||
* only update diagnostics once when window changes ([d965d22](https://github.com/folke/trouble.nvim/commit/d965d22ee37e50be0ab32f6a5987a8cd88206f10))
|
||||
* prevent nested loading of preview [#2](https://github.com/folke/trouble.nvim/issues/2) ([b20a784](https://github.com/folke/trouble.nvim/commit/b20a7844a035cf6795270db575ad8c4db2a774c9))
|
||||
* use vim.lsp.util.get_line to get line instad of bufload ([607b1d5](https://github.com/folke/trouble.nvim/commit/607b1d5bbfdbd19242659415746b5e62f5ddfb94))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* removed deprecated commands ([dd89ad9](https://github.com/folke/trouble.nvim/commit/dd89ad9ebb63e131098ff04857f8598eb88d8d79))
|
||||
* renamed use_lsp_diagnostic_signs to use_diagnostic_signs ([9db77e1](https://github.com/folke/trouble.nvim/commit/9db77e194d848744139673aa246efa00fbcba982))
|
||||
201
config/neovim/store/lazy-plugins/trouble.nvim/LICENSE
Normal file
201
config/neovim/store/lazy-plugins/trouble.nvim/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
267
config/neovim/store/lazy-plugins/trouble.nvim/README.md
Normal file
267
config/neovim/store/lazy-plugins/trouble.nvim/README.md
Normal file
@ -0,0 +1,267 @@
|
||||
# 🚦 Trouble v3 Beta!
|
||||
|
||||
❗**Trouble** has been rewritten from scratch. If you'd like to try the new version,
|
||||
please refer to the [beta docs](https://github.com/folke/trouble.nvim/tree/dev)
|
||||
|
||||

|
||||
|
||||
|
||||
---
|
||||
|
||||
# 🚦 Trouble v2
|
||||
|
||||
A pretty list for showing diagnostics, references, telescope results, quickfix and location lists to help you solve all the trouble your code is causing.
|
||||
|
||||

|
||||
|
||||
## ✨ Features
|
||||
|
||||
- pretty list of:
|
||||
- Diagnostics
|
||||
- LSP references
|
||||
- LSP implementations
|
||||
- LSP definitions
|
||||
- LSP type definitions
|
||||
- quickfix list
|
||||
- location list
|
||||
- [Telescope](https://github.com/nvim-telescope/telescope.nvim) search results
|
||||
- automatically updates on new diagnostics
|
||||
- toggle **diagnostics** mode between **workspace** or **document**
|
||||
- **interactive preview** in your last accessed window
|
||||
- _cancel_ preview or _jump_ to the location
|
||||
- configurable actions, signs, highlights,...
|
||||
|
||||
## ⚡️ Requirements
|
||||
|
||||
- Neovim >= 0.7.2
|
||||
- Properly configured Neovim LSP client
|
||||
- [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) is optional to enable file icons
|
||||
- a theme with properly configured highlight groups for Neovim Diagnostics
|
||||
- or install 🌈 [lsp-colors](https://github.com/folke/lsp-colors.nvim) to automatically create the missing highlight groups
|
||||
- a [patched font](https://www.nerdfonts.com/) for the default severity and fold icons
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
Install the plugin with your preferred package manager:
|
||||
|
||||
### [lazy.nvim](https://github.com/folke/lazy.nvim)
|
||||
|
||||
```lua
|
||||
return {
|
||||
"folke/trouble.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## ⚙️ Configuration
|
||||
|
||||
### Setup
|
||||
|
||||
Trouble comes with the following defaults:
|
||||
|
||||
```lua
|
||||
{
|
||||
position = "bottom", -- position of the list can be: bottom, top, left, right
|
||||
height = 10, -- height of the trouble list when position is top or bottom
|
||||
width = 50, -- width of the list when position is left or right
|
||||
icons = true, -- use devicons for filenames
|
||||
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
||||
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
|
||||
fold_open = "", -- icon used for open folds
|
||||
fold_closed = "", -- icon used for closed folds
|
||||
group = true, -- group results by file
|
||||
padding = true, -- add an extra new line on top of the list
|
||||
cycle_results = true, -- cycle item list when reaching beginning or end of list
|
||||
action_keys = { -- key mappings for actions in the trouble list
|
||||
-- map to {} to remove a mapping, for example:
|
||||
-- close = {},
|
||||
close = "q", -- close the list
|
||||
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
|
||||
refresh = "r", -- manually refresh
|
||||
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
|
||||
open_split = { "<c-x>" }, -- open buffer in new split
|
||||
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
|
||||
open_tab = { "<c-t>" }, -- open buffer in new tab
|
||||
jump_close = {"o"}, -- jump to the diagnostic and close the list
|
||||
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
|
||||
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
|
||||
toggle_preview = "P", -- toggle auto_preview
|
||||
hover = "K", -- opens a small popup with the full multiline message
|
||||
preview = "p", -- preview the diagnostic location
|
||||
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
|
||||
close_folds = {"zM", "zm"}, -- close all folds
|
||||
open_folds = {"zR", "zr"}, -- open all folds
|
||||
toggle_fold = {"zA", "za"}, -- toggle fold of current file
|
||||
previous = "k", -- previous item
|
||||
next = "j" -- next item
|
||||
help = "?" -- help menu
|
||||
},
|
||||
multiline = true, -- render multi-line messages
|
||||
indent_lines = true, -- add an indent guide below the fold icons
|
||||
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
|
||||
auto_open = false, -- automatically open the list when you have diagnostics
|
||||
auto_close = false, -- automatically close the list when you have no diagnostics
|
||||
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
|
||||
auto_fold = false, -- automatically fold a file trouble list at creation
|
||||
auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result
|
||||
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "",
|
||||
warning = "",
|
||||
hint = "",
|
||||
information = "",
|
||||
other = "",
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
}
|
||||
```
|
||||
|
||||
> 💡 if you don't want to use icons or a patched font, you can use the settings below
|
||||
|
||||
```lua
|
||||
-- settings without a patched font or icons
|
||||
{
|
||||
icons = false,
|
||||
fold_open = "v", -- icon used for open folds
|
||||
fold_closed = ">", -- icon used for closed folds
|
||||
indent_lines = false, -- add an indent guide below the fold icons
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "error",
|
||||
warning = "warn",
|
||||
hint = "hint",
|
||||
information = "info"
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
}
|
||||
```
|
||||
|
||||
## 🚀 Usage
|
||||
|
||||
### Commands
|
||||
|
||||
Trouble comes with the following commands:
|
||||
|
||||
- `Trouble [mode]`: open the list
|
||||
- `TroubleClose [mode]`: close the list
|
||||
- `TroubleToggle [mode]`: toggle the list
|
||||
- `TroubleRefresh`: manually refresh the active list
|
||||
|
||||
Modes:
|
||||
|
||||
- **document_diagnostics:** document diagnostics from the builtin LSP client
|
||||
- **workspace_diagnostics:** workspace diagnostics from the builtin LSP client
|
||||
- **lsp_references:** references of the word under the cursor from the builtin LSP client
|
||||
- **lsp_definitions:** definitions of the word under the cursor from the builtin LSP client
|
||||
|
||||
* **lsp_type_definitions:** type definitions of the word under the cursor from the builtin LSP client
|
||||
|
||||
- **quickfix:** [quickfix](https://neovim.io/doc/user/quickfix.html) items
|
||||
- **loclist:** items from the window's [location list](https://neovim.io/doc/user/quickfix.html)
|
||||
|
||||
Example keybindings:
|
||||
|
||||
```vim
|
||||
" Vim Script
|
||||
nnoremap <leader>xx <cmd>TroubleToggle<cr>
|
||||
nnoremap <leader>xw <cmd>TroubleToggle workspace_diagnostics<cr>
|
||||
nnoremap <leader>xd <cmd>TroubleToggle document_diagnostics<cr>
|
||||
nnoremap <leader>xq <cmd>TroubleToggle quickfix<cr>
|
||||
nnoremap <leader>xl <cmd>TroubleToggle loclist<cr>
|
||||
nnoremap gR <cmd>TroubleToggle lsp_references<cr>
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Lua
|
||||
vim.keymap.set("n", "<leader>xx", function() require("trouble").toggle() end)
|
||||
vim.keymap.set("n", "<leader>xw", function() require("trouble").toggle("workspace_diagnostics") end)
|
||||
vim.keymap.set("n", "<leader>xd", function() require("trouble").toggle("document_diagnostics") end)
|
||||
vim.keymap.set("n", "<leader>xq", function() require("trouble").toggle("quickfix") end)
|
||||
vim.keymap.set("n", "<leader>xl", function() require("trouble").toggle("loclist") end)
|
||||
vim.keymap.set("n", "gR", function() require("trouble").toggle("lsp_references") end)
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
You can use the following functions in your keybindings:
|
||||
|
||||
```lua
|
||||
-- toggle trouble with optional mode
|
||||
require("trouble").toggle(mode?)
|
||||
|
||||
-- open trouble with optional mode
|
||||
require("trouble").open(mode?)
|
||||
|
||||
-- close trouble
|
||||
require("trouble").close()
|
||||
|
||||
-- jump to the next item, skipping the groups
|
||||
require("trouble").next({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the previous item, skipping the groups
|
||||
require("trouble").previous({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the first item, skipping the groups
|
||||
require("trouble").first({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the last item, skipping the groups
|
||||
require("trouble").last({skip_groups = true, jump = true});
|
||||
```
|
||||
|
||||
### Telescope
|
||||
|
||||
You can easily open any search results in **Trouble**, by defining a custom action:
|
||||
|
||||
```lua
|
||||
local actions = require("telescope.actions")
|
||||
local trouble = require("trouble.providers.telescope")
|
||||
|
||||
local telescope = require("telescope")
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = { ["<c-t>"] = trouble.open_with_trouble },
|
||||
n = { ["<c-t>"] = trouble.open_with_trouble },
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
When you open telescope, you can now hit `<c-t>` to open the results in **Trouble**
|
||||
|
||||
## 🎨 Colors
|
||||
|
||||
The table below shows all the highlight groups defined for Trouble.
|
||||
|
||||
| Highlight Group |
|
||||
| ------------------------ |
|
||||
| _TroubleCount_ |
|
||||
| _TroubleError_ |
|
||||
| _TroubleNormal_ |
|
||||
| _TroubleTextInformation_ |
|
||||
| _TroubleSignWarning_ |
|
||||
| _TroubleLocation_ |
|
||||
| _TroubleWarning_ |
|
||||
| _TroublePreview_ |
|
||||
| _TroubleTextError_ |
|
||||
| _TroubleSignInformation_ |
|
||||
| _TroubleIndent_ |
|
||||
| _TroubleSource_ |
|
||||
| _TroubleSignHint_ |
|
||||
| _TroubleSignOther_ |
|
||||
| _TroubleFoldIcon_ |
|
||||
| _TroubleTextWarning_ |
|
||||
| _TroubleCode_ |
|
||||
| _TroubleInformation_ |
|
||||
| _TroubleSignError_ |
|
||||
| _TroubleFile_ |
|
||||
| _TroubleHint_ |
|
||||
| _TroubleTextHint_ |
|
||||
| _TroubleText_ |
|
||||
@ -0,0 +1,305 @@
|
||||
*trouble.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 May 19
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *trouble.nvim-table-of-contents*
|
||||
|
||||
1. Trouble v3 Beta! |trouble.nvim-trouble-v3-beta!|
|
||||
2. Trouble v2 |trouble.nvim-trouble-v2|
|
||||
- Features |trouble.nvim-trouble-v2-features|
|
||||
- Requirements |trouble.nvim-trouble-v2-requirements|
|
||||
- Installation |trouble.nvim-trouble-v2-installation|
|
||||
- Configuration |trouble.nvim-trouble-v2-configuration|
|
||||
- Usage |trouble.nvim-trouble-v2-usage|
|
||||
- Colors |trouble.nvim-trouble-v2-colors|
|
||||
3. Links |trouble.nvim-links|
|
||||
|
||||
==============================================================================
|
||||
1. Trouble v3 Beta! *trouble.nvim-trouble-v3-beta!*
|
||||
|
||||
**Trouble**has been rewritten from scratch. If you’d like to try the new
|
||||
version, please refer to the beta docs
|
||||
<https://github.com/folke/trouble.nvim/tree/dev>
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
==============================================================================
|
||||
2. Trouble v2 *trouble.nvim-trouble-v2*
|
||||
|
||||
A pretty list for showing diagnostics, references, telescope results, quickfix
|
||||
and location lists to help you solve all the trouble your code is causing.
|
||||
|
||||
|
||||
FEATURES *trouble.nvim-trouble-v2-features*
|
||||
|
||||
- pretty list of:
|
||||
- Diagnostics
|
||||
- LSP references
|
||||
- LSP implementations
|
||||
- LSP definitions
|
||||
- LSP type definitions
|
||||
- quickfix list
|
||||
- location list
|
||||
- Telescope <https://github.com/nvim-telescope/telescope.nvim> search results
|
||||
- automatically updates on new diagnostics
|
||||
- toggle **diagnostics** mode between **workspace** or **document**
|
||||
- **interactive preview** in your last accessed window
|
||||
- _cancel_ preview or _jump_ to the location
|
||||
- configurable actions, signs, highlights,…
|
||||
|
||||
|
||||
REQUIREMENTS *trouble.nvim-trouble-v2-requirements*
|
||||
|
||||
- Neovim >= 0.7.2
|
||||
- Properly configured Neovim LSP client
|
||||
- nvim-web-devicons <https://github.com/nvim-tree/nvim-web-devicons> is optional to enable file icons
|
||||
- a theme with properly configured highlight groups for Neovim Diagnostics
|
||||
- or install lsp-colors <https://github.com/folke/lsp-colors.nvim> to automatically create the missing highlight groups
|
||||
- a patched font <https://www.nerdfonts.com/> for the default severity and fold icons
|
||||
|
||||
|
||||
INSTALLATION *trouble.nvim-trouble-v2-installation*
|
||||
|
||||
Install the plugin with your preferred package manager:
|
||||
|
||||
|
||||
LAZY.NVIM ~
|
||||
|
||||
>lua
|
||||
return {
|
||||
"folke/trouble.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
},
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
CONFIGURATION *trouble.nvim-trouble-v2-configuration*
|
||||
|
||||
|
||||
SETUP ~
|
||||
|
||||
Trouble comes with the following defaults:
|
||||
|
||||
>lua
|
||||
{
|
||||
position = "bottom", -- position of the list can be: bottom, top, left, right
|
||||
height = 10, -- height of the trouble list when position is top or bottom
|
||||
width = 50, -- width of the list when position is left or right
|
||||
icons = true, -- use devicons for filenames
|
||||
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
||||
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
|
||||
fold_open = "", -- icon used for open folds
|
||||
fold_closed = "", -- icon used for closed folds
|
||||
group = true, -- group results by file
|
||||
padding = true, -- add an extra new line on top of the list
|
||||
cycle_results = true, -- cycle item list when reaching beginning or end of list
|
||||
action_keys = { -- key mappings for actions in the trouble list
|
||||
-- map to {} to remove a mapping, for example:
|
||||
-- close = {},
|
||||
close = "q", -- close the list
|
||||
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
|
||||
refresh = "r", -- manually refresh
|
||||
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
|
||||
open_split = { "<c-x>" }, -- open buffer in new split
|
||||
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
|
||||
open_tab = { "<c-t>" }, -- open buffer in new tab
|
||||
jump_close = {"o"}, -- jump to the diagnostic and close the list
|
||||
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
|
||||
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
|
||||
toggle_preview = "P", -- toggle auto_preview
|
||||
hover = "K", -- opens a small popup with the full multiline message
|
||||
preview = "p", -- preview the diagnostic location
|
||||
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
|
||||
close_folds = {"zM", "zm"}, -- close all folds
|
||||
open_folds = {"zR", "zr"}, -- open all folds
|
||||
toggle_fold = {"zA", "za"}, -- toggle fold of current file
|
||||
previous = "k", -- previous item
|
||||
next = "j" -- next item
|
||||
help = "?" -- help menu
|
||||
},
|
||||
multiline = true, -- render multi-line messages
|
||||
indent_lines = true, -- add an indent guide below the fold icons
|
||||
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
|
||||
auto_open = false, -- automatically open the list when you have diagnostics
|
||||
auto_close = false, -- automatically close the list when you have no diagnostics
|
||||
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
|
||||
auto_fold = false, -- automatically fold a file trouble list at creation
|
||||
auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result
|
||||
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "",
|
||||
warning = "",
|
||||
hint = "",
|
||||
information = "",
|
||||
other = "",
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
if you don’t want to use icons or a patched font, you can use the settings
|
||||
below
|
||||
>lua
|
||||
-- settings without a patched font or icons
|
||||
{
|
||||
icons = false,
|
||||
fold_open = "v", -- icon used for open folds
|
||||
fold_closed = ">", -- icon used for closed folds
|
||||
indent_lines = false, -- add an indent guide below the fold icons
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "error",
|
||||
warning = "warn",
|
||||
hint = "hint",
|
||||
information = "info"
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
USAGE *trouble.nvim-trouble-v2-usage*
|
||||
|
||||
|
||||
COMMANDS ~
|
||||
|
||||
Trouble comes with the following commands:
|
||||
|
||||
- `Trouble [mode]`open the list
|
||||
- `TroubleClose [mode]`close the list
|
||||
- `TroubleToggle [mode]`toggle the list
|
||||
- `TroubleRefresh`manually refresh the active list
|
||||
|
||||
Modes:
|
||||
|
||||
- **document_diagnostics:** document diagnostics from the builtin LSP client
|
||||
- **workspace_diagnostics:** workspace diagnostics from the builtin LSP client
|
||||
- **lsp_references:** references of the word under the cursor from the builtin
|
||||
LSP client
|
||||
- **lsp_definitions:** definitions of the word under the cursor from the builtin
|
||||
LSP client
|
||||
- **lsp_type_definitions:** type definitions of the word under the cursor from
|
||||
the builtin LSP client
|
||||
- **quickfix:** |quickfix| items
|
||||
- **loclist:** items from the window’s |location list|
|
||||
|
||||
Example keybindings:
|
||||
|
||||
>vim
|
||||
" Vim Script
|
||||
nnoremap <leader>xx <cmd>TroubleToggle<cr>
|
||||
nnoremap <leader>xw <cmd>TroubleToggle workspace_diagnostics<cr>
|
||||
nnoremap <leader>xd <cmd>TroubleToggle document_diagnostics<cr>
|
||||
nnoremap <leader>xq <cmd>TroubleToggle quickfix<cr>
|
||||
nnoremap <leader>xl <cmd>TroubleToggle loclist<cr>
|
||||
nnoremap gR <cmd>TroubleToggle lsp_references<cr>
|
||||
<
|
||||
|
||||
>lua
|
||||
-- Lua
|
||||
vim.keymap.set("n", "<leader>xx", function() require("trouble").toggle() end)
|
||||
vim.keymap.set("n", "<leader>xw", function() require("trouble").toggle("workspace_diagnostics") end)
|
||||
vim.keymap.set("n", "<leader>xd", function() require("trouble").toggle("document_diagnostics") end)
|
||||
vim.keymap.set("n", "<leader>xq", function() require("trouble").toggle("quickfix") end)
|
||||
vim.keymap.set("n", "<leader>xl", function() require("trouble").toggle("loclist") end)
|
||||
vim.keymap.set("n", "gR", function() require("trouble").toggle("lsp_references") end)
|
||||
<
|
||||
|
||||
|
||||
API ~
|
||||
|
||||
You can use the following functions in your keybindings:
|
||||
|
||||
>lua
|
||||
-- toggle trouble with optional mode
|
||||
require("trouble").toggle(mode?)
|
||||
|
||||
-- open trouble with optional mode
|
||||
require("trouble").open(mode?)
|
||||
|
||||
-- close trouble
|
||||
require("trouble").close()
|
||||
|
||||
-- jump to the next item, skipping the groups
|
||||
require("trouble").next({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the previous item, skipping the groups
|
||||
require("trouble").previous({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the first item, skipping the groups
|
||||
require("trouble").first({skip_groups = true, jump = true});
|
||||
|
||||
-- jump to the last item, skipping the groups
|
||||
require("trouble").last({skip_groups = true, jump = true});
|
||||
<
|
||||
|
||||
|
||||
TELESCOPE ~
|
||||
|
||||
You can easily open any search results in **Trouble**, by defining a custom
|
||||
action:
|
||||
|
||||
>lua
|
||||
local actions = require("telescope.actions")
|
||||
local trouble = require("trouble.providers.telescope")
|
||||
|
||||
local telescope = require("telescope")
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = { ["<c-t>"] = trouble.open_with_trouble },
|
||||
n = { ["<c-t>"] = trouble.open_with_trouble },
|
||||
},
|
||||
},
|
||||
}
|
||||
<
|
||||
|
||||
When you open telescope, you can now hit `<c-t>` to open the results in
|
||||
**Trouble**
|
||||
|
||||
|
||||
COLORS *trouble.nvim-trouble-v2-colors*
|
||||
|
||||
The table below shows all the highlight groups defined for Trouble.
|
||||
|
||||
Highlight Group
|
||||
------------------------
|
||||
TroubleCount
|
||||
TroubleError
|
||||
TroubleNormal
|
||||
TroubleTextInformation
|
||||
TroubleSignWarning
|
||||
TroubleLocation
|
||||
TroubleWarning
|
||||
TroublePreview
|
||||
TroubleTextError
|
||||
TroubleSignInformation
|
||||
TroubleIndent
|
||||
TroubleSource
|
||||
TroubleSignHint
|
||||
TroubleSignOther
|
||||
TroubleFoldIcon
|
||||
TroubleTextWarning
|
||||
TroubleCode
|
||||
TroubleInformation
|
||||
TroubleSignError
|
||||
TroubleFile
|
||||
TroubleHint
|
||||
TroubleTextHint
|
||||
TroubleText
|
||||
==============================================================================
|
||||
3. Links *trouble.nvim-links*
|
||||
|
||||
1. *image*: https://github.com/folke/trouble.nvim/assets/292349/481bc1f7-cb93-432d-8ab6-f54044334b96
|
||||
2. *LSP Trouble Screenshot*: ./media/shot.png
|
||||
|
||||
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
@ -0,0 +1,34 @@
|
||||
local util = require("trouble.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
local links = {
|
||||
TextError = "TroubleText",
|
||||
TextWarning = "TroubleText",
|
||||
TextInformation = "TroubleText",
|
||||
TextHint = "TroubleText",
|
||||
Text = "Normal",
|
||||
File = "Directory",
|
||||
Source = "Comment",
|
||||
Code = "Comment",
|
||||
Location = "LineNr",
|
||||
FoldIcon = "CursorLineNr",
|
||||
Normal = "Normal",
|
||||
Count = "TabLineSel",
|
||||
Preview = "Search",
|
||||
Indent = "LineNr",
|
||||
SignOther = "TroubleSignInformation",
|
||||
}
|
||||
|
||||
function M.setup()
|
||||
for k, v in pairs(links) do
|
||||
vim.api.nvim_command("hi def link Trouble" .. k .. " " .. v)
|
||||
end
|
||||
|
||||
for _, severity in pairs(util.severity) do
|
||||
vim.api.nvim_command("hi def link Trouble" .. severity .. " " .. util.get_severity_label(severity))
|
||||
vim.api.nvim_command("hi def link TroubleSign" .. severity .. " " .. util.get_severity_label(severity, "Sign"))
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,83 @@
|
||||
local M = {}
|
||||
|
||||
M.namespace = vim.api.nvim_create_namespace("Trouble")
|
||||
|
||||
---@class TroubleOptions
|
||||
---@field buf number|nil
|
||||
---@field win number|nil
|
||||
---@field severity lsp.DiagnosticSeverity|nil
|
||||
-- TODO: make some options configurable per mode
|
||||
-- TODO: make it possible to have multiple trouble lists open at the same time
|
||||
local defaults = {
|
||||
debug = false,
|
||||
cmd_options = {},
|
||||
group = true, -- group results by file
|
||||
padding = true, -- add an extra new line on top of the list
|
||||
position = "bottom", -- position of the list can be: bottom, top, left, right
|
||||
height = 10, -- height of the trouble list when position is top or bottom
|
||||
width = 50, -- width of the list when position is left or right
|
||||
icons = true, -- use devicons for filenames
|
||||
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
||||
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
|
||||
fold_open = "", -- icon used for open folds
|
||||
fold_closed = "", -- icon used for closed folds
|
||||
cycle_results = true, -- cycle item list when reaching beginning or end of list
|
||||
action_keys = { -- key mappings for actions in the trouble list
|
||||
close = "q", -- close the list
|
||||
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
|
||||
refresh = "r", -- manually refresh
|
||||
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
|
||||
open_split = { "<c-x>" }, -- open buffer in new split
|
||||
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
|
||||
open_tab = { "<c-t>" }, -- open buffer in new tab
|
||||
jump_close = { "o" }, -- jump to the diagnostic and close the list
|
||||
toggle_mode = "m", -- toggle between "workspace" and "document" mode
|
||||
switch_severity = "s", -- switch "diagnostics" severity filter level to ALL / HINT / INFO / WARN / ERROR
|
||||
toggle_preview = "P", -- toggle auto_preview
|
||||
hover = "K", -- opens a small popup with the full multiline message
|
||||
preview = "p", -- preview the diagnostic location
|
||||
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
|
||||
close_folds = { "zM", "zm" }, -- close all folds
|
||||
open_folds = { "zR", "zr" }, -- open all folds
|
||||
toggle_fold = { "zA", "za" }, -- toggle fold of current file
|
||||
previous = "k", -- preview item
|
||||
next = "j", -- next item
|
||||
help = "?", -- help menu
|
||||
},
|
||||
multiline = true, -- render multi-line messages
|
||||
indent_lines = true, -- add an indent guide below the fold icons
|
||||
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
|
||||
auto_open = false, -- automatically open the list when you have diagnostics
|
||||
auto_close = false, -- automatically close the list when you have no diagnostics
|
||||
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
|
||||
auto_fold = false, -- automatically fold a file trouble list at creation
|
||||
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
|
||||
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "",
|
||||
warning = "",
|
||||
hint = "",
|
||||
information = "",
|
||||
other = "",
|
||||
},
|
||||
use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client
|
||||
sort_keys = {
|
||||
"severity",
|
||||
"filename",
|
||||
"lnum",
|
||||
"col",
|
||||
},
|
||||
}
|
||||
|
||||
---@type TroubleOptions
|
||||
M.options = {}
|
||||
---@return TroubleOptions
|
||||
|
||||
function M.setup(options)
|
||||
M.options = vim.tbl_deep_extend("force", {}, defaults, options or {})
|
||||
end
|
||||
|
||||
M.setup()
|
||||
|
||||
return M
|
||||
@ -0,0 +1,24 @@
|
||||
local config = require("trouble.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.folded = {}
|
||||
|
||||
function M.is_folded(filename)
|
||||
local fold = M.folded[filename]
|
||||
return (fold == nil and config.options.auto_fold == true) or (fold == true)
|
||||
end
|
||||
|
||||
function M.toggle(filename)
|
||||
M.folded[filename] = not M.is_folded(filename)
|
||||
end
|
||||
|
||||
function M.close(filename)
|
||||
M.folded[filename] = true
|
||||
end
|
||||
|
||||
function M.open(filename)
|
||||
M.folded[filename] = false
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,300 @@
|
||||
local View = require("trouble.view")
|
||||
local config = require("trouble.config")
|
||||
local colors = require("trouble.colors")
|
||||
local util = require("trouble.util")
|
||||
|
||||
colors.setup()
|
||||
|
||||
local Trouble = {}
|
||||
|
||||
local view
|
||||
|
||||
function Trouble.is_open()
|
||||
return view and view:is_valid() or false
|
||||
end
|
||||
|
||||
function Trouble.setup(options)
|
||||
if vim.fn.has("nvim-0.7.2") == 0 then
|
||||
util.error("Trouble needs Neovim >= 0.7.2")
|
||||
return
|
||||
end
|
||||
config.setup(options)
|
||||
util.fix_mode(config.options)
|
||||
colors.setup()
|
||||
end
|
||||
|
||||
function Trouble.close()
|
||||
if Trouble.is_open() then
|
||||
view:close()
|
||||
end
|
||||
end
|
||||
|
||||
local function get_opts(...)
|
||||
local args = { ... }
|
||||
if (vim.islist or vim.tbl_islist)(args) and #args == 1 and type(args[1]) == "table" then
|
||||
args = args[1]
|
||||
end
|
||||
local opts = {}
|
||||
for key, value in pairs(args) do
|
||||
if type(key) == "number" then
|
||||
local k, v = value:match("^(.*)=(.*)$")
|
||||
if k then
|
||||
opts[k] = v
|
||||
elseif opts.mode then
|
||||
util.error("unknown option " .. value)
|
||||
else
|
||||
opts.mode = value
|
||||
end
|
||||
else
|
||||
opts[key] = value
|
||||
end
|
||||
end
|
||||
opts = opts or {}
|
||||
util.fix_mode(opts)
|
||||
config.options.cmd_options = opts
|
||||
return opts
|
||||
end
|
||||
|
||||
function Trouble.open(...)
|
||||
local opts = get_opts(...)
|
||||
if opts.mode and (opts.mode ~= config.options.mode) then
|
||||
config.options.mode = opts.mode
|
||||
end
|
||||
|
||||
if opts.severity and (opts.severity ~= config.options.severity) then
|
||||
config.options.severity = opts.severity
|
||||
end
|
||||
|
||||
opts.focus = (opts.focus == nil and not opts.auto) and true or opts.focus
|
||||
opts.on_open = true
|
||||
|
||||
if Trouble.is_open() then
|
||||
Trouble.refresh(opts)
|
||||
elseif not opts.auto and vim.tbl_contains(config.options.auto_jump, opts.mode) then
|
||||
require("trouble.providers").get(vim.api.nvim_get_current_win(), vim.api.nvim_get_current_buf(), function(results)
|
||||
if #results == 1 then
|
||||
util.jump_to_item(opts.win, opts.precmd, results[1])
|
||||
elseif #results > 0 then
|
||||
view = View.create(opts)
|
||||
end
|
||||
end, config.options)
|
||||
else
|
||||
view = View.create(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.toggle(...)
|
||||
local opts = get_opts(...)
|
||||
|
||||
if opts.mode and (opts.mode ~= config.options.mode) then
|
||||
config.options.mode = opts.mode
|
||||
Trouble.open(...)
|
||||
return
|
||||
end
|
||||
|
||||
if Trouble.is_open() then
|
||||
Trouble.close()
|
||||
else
|
||||
Trouble.open(...)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.help()
|
||||
local lines = { "# Key Bindings" }
|
||||
local height = 1
|
||||
for command, key in pairs(config.options.action_keys) do
|
||||
if type(key) == "table" then
|
||||
key = table.concat(key, " | ")
|
||||
end
|
||||
table.insert(lines, " * **" .. key .. "** " .. command:gsub("_", " "))
|
||||
height = height + 1
|
||||
end
|
||||
-- help
|
||||
vim.lsp.util.open_floating_preview(lines, "markdown", config.options.win_config)
|
||||
end
|
||||
|
||||
local updater = util.debounce(100, function()
|
||||
-- buff might have been closed during the debounce
|
||||
if not Trouble.is_open() then
|
||||
util.debug("refresh: not open anymore")
|
||||
return
|
||||
end
|
||||
|
||||
util.debug("refresh: auto")
|
||||
view:update({ auto = true })
|
||||
end)
|
||||
|
||||
function Trouble.refresh(opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- dont do an update if this is an automated refresh from a different provider
|
||||
if opts.auto then
|
||||
if opts.provider == "diagnostics" and config.options.mode == "document_diagnostics" then
|
||||
opts.provider = "document_diagnostics"
|
||||
elseif opts.provider == "diagnostics" and config.options.mode == "workspace_diagnostics" then
|
||||
opts.provider = "workspace_diagnostics"
|
||||
elseif opts.provider == "qf" and config.options.mode == "quickfix" then
|
||||
opts.provider = "quickfix"
|
||||
elseif opts.provider == "qf" and config.options.mode == "loclist" then
|
||||
opts.provider = "loclist"
|
||||
end
|
||||
if opts.provider ~= config.options.mode then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if Trouble.is_open() then
|
||||
if opts.auto then
|
||||
updater()
|
||||
else
|
||||
util.debug("refresh")
|
||||
view:update(opts)
|
||||
end
|
||||
elseif opts.auto and config.options.auto_open and opts.provider == config.options.mode then
|
||||
require("trouble.providers").get(vim.api.nvim_get_current_win(), vim.api.nvim_get_current_buf(), function(results)
|
||||
if #results > 0 then
|
||||
Trouble.open(opts)
|
||||
end
|
||||
end, config.options)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.action(action)
|
||||
if action == "toggle_mode" then
|
||||
if config.options.mode == "document_diagnostics" then
|
||||
config.options.mode = "workspace_diagnostics"
|
||||
elseif config.options.mode == "workspace_diagnostics" then
|
||||
config.options.mode = "document_diagnostics"
|
||||
end
|
||||
action = "refresh"
|
||||
end
|
||||
|
||||
if action == "switch_severity" then
|
||||
if config.options.severity == nil then
|
||||
config.options.severity = vim.diagnostic.severity.ERROR
|
||||
elseif config.options.severity < 4 then
|
||||
config.options.severity = config.options.severity + 1
|
||||
else
|
||||
config.options.severity = nil
|
||||
end
|
||||
action = "refresh"
|
||||
end
|
||||
|
||||
if view and action == "on_win_enter" then
|
||||
view:on_win_enter()
|
||||
end
|
||||
if not Trouble.is_open() then
|
||||
return Trouble
|
||||
end
|
||||
if action == "hover" then
|
||||
view:hover()
|
||||
end
|
||||
if action == "jump" then
|
||||
view:jump()
|
||||
elseif action == "open_split" then
|
||||
view:jump({ precmd = "split" })
|
||||
elseif action == "open_vsplit" then
|
||||
view:jump({ precmd = "vsplit" })
|
||||
elseif action == "open_tab" then
|
||||
view:jump({ precmd = "tabe" })
|
||||
end
|
||||
if action == "jump_close" then
|
||||
view:jump()
|
||||
Trouble.close()
|
||||
end
|
||||
if action == "open_folds" then
|
||||
Trouble.refresh({ open_folds = true })
|
||||
end
|
||||
if action == "close_folds" then
|
||||
Trouble.refresh({ close_folds = true })
|
||||
end
|
||||
if action == "toggle_fold" then
|
||||
view:toggle_fold()
|
||||
end
|
||||
if action == "on_enter" then
|
||||
view:on_enter()
|
||||
end
|
||||
if action == "on_leave" then
|
||||
view:on_leave()
|
||||
end
|
||||
if action == "cancel" then
|
||||
view:switch_to_parent()
|
||||
end
|
||||
if action == "next" then
|
||||
view:next_item()
|
||||
return Trouble
|
||||
end
|
||||
if action == "previous" then
|
||||
view:previous_item()
|
||||
return Trouble
|
||||
end
|
||||
if action == "first" then
|
||||
view:first_item()
|
||||
return Trouble
|
||||
end
|
||||
if action == "last" then
|
||||
view:last_item()
|
||||
return Trouble
|
||||
end
|
||||
|
||||
if action == "toggle_preview" then
|
||||
config.options.auto_preview = not config.options.auto_preview
|
||||
if not config.options.auto_preview then
|
||||
view:close_preview()
|
||||
else
|
||||
action = "preview"
|
||||
end
|
||||
end
|
||||
if action == "auto_preview" and config.options.auto_preview then
|
||||
action = "preview"
|
||||
end
|
||||
if action == "preview" then
|
||||
view:preview()
|
||||
end
|
||||
if action == "open_code_href" then
|
||||
view:open_code_href()
|
||||
end
|
||||
|
||||
if Trouble[action] then
|
||||
Trouble[action]()
|
||||
end
|
||||
return Trouble
|
||||
end
|
||||
|
||||
function Trouble.next(opts)
|
||||
util.fix_mode(opts)
|
||||
if view then
|
||||
view:next_item(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.previous(opts)
|
||||
util.fix_mode(opts)
|
||||
if view then
|
||||
view:previous_item(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.first(opts)
|
||||
util.fix_mode(opts)
|
||||
if view then
|
||||
view:first_item(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.last(opts)
|
||||
util.fix_mode(opts)
|
||||
if view then
|
||||
view:last_item(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function Trouble.get_items()
|
||||
if view ~= nil then
|
||||
return view.items
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
return Trouble
|
||||
@ -0,0 +1,59 @@
|
||||
local util = require("trouble.util")
|
||||
|
||||
---@class Lsp
|
||||
local M = {}
|
||||
|
||||
local severity = {
|
||||
[1] = "ERROR",
|
||||
[2] = "WARN",
|
||||
[3] = "INFO",
|
||||
[4] = "HINT",
|
||||
}
|
||||
|
||||
---@param options TroubleOptions
|
||||
---@return Item[]
|
||||
function M.diagnostics(_, buf, cb, options)
|
||||
if options.mode == "workspace_diagnostics" then
|
||||
buf = nil
|
||||
end
|
||||
|
||||
local items = {}
|
||||
|
||||
if vim.diagnostic then
|
||||
local diags = vim.diagnostic.get(buf, { severity = options.severity })
|
||||
for _, item in ipairs(diags) do
|
||||
table.insert(items, util.process_item(item))
|
||||
end
|
||||
else
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local diags = buf and { [buf] = vim.lsp.diagnostic.get(buf) } or vim.lsp.diagnostic.get_all()
|
||||
items = util.locations_to_items(diags, 1)
|
||||
end
|
||||
|
||||
local messages = {}
|
||||
if severity[options.severity] then
|
||||
table.insert(messages, { text = "filter:", group = "Information" })
|
||||
table.insert(messages, { text = severity[options.severity], group = "Sign" .. util.severity[options.severity] })
|
||||
end
|
||||
|
||||
cb(items, messages)
|
||||
end
|
||||
|
||||
function M.get_signs()
|
||||
local signs = {}
|
||||
for _, v in pairs(util.severity) do
|
||||
if v ~= "Other" then
|
||||
-- pcall to catch entirely unbound or cleared out sign hl group
|
||||
local status, sign = pcall(function()
|
||||
return vim.trim(vim.fn.sign_getdefined(util.get_severity_label(v, "Sign"))[1].text)
|
||||
end)
|
||||
if not status then
|
||||
sign = v:sub(1, 1)
|
||||
end
|
||||
signs[string.lower(v)] = sign
|
||||
end
|
||||
end
|
||||
return signs
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,94 @@
|
||||
local util = require("trouble.util")
|
||||
local qf = require("trouble.providers.qf")
|
||||
local telescope = require("trouble.providers.telescope")
|
||||
local lsp = require("trouble.providers.lsp")
|
||||
local diagnostic = require("trouble.providers.diagnostic")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.providers = {
|
||||
workspace_diagnostics = diagnostic.diagnostics,
|
||||
document_diagnostics = diagnostic.diagnostics,
|
||||
lsp_references = lsp.references,
|
||||
lsp_implementations = lsp.implementations,
|
||||
lsp_definitions = lsp.definitions,
|
||||
lsp_type_definitions = lsp.type_definitions,
|
||||
quickfix = qf.qflist,
|
||||
loclist = qf.loclist,
|
||||
telescope = telescope.telescope,
|
||||
}
|
||||
|
||||
---@param options TroubleOptions
|
||||
function M.get(win, buf, cb, options)
|
||||
local name = options.mode
|
||||
local provider = M.providers[name]
|
||||
|
||||
if not provider then
|
||||
local ok, mod = pcall(require, "trouble.providers." .. name)
|
||||
if ok then
|
||||
M.providers[name] = mod
|
||||
provider = mod
|
||||
end
|
||||
end
|
||||
|
||||
if not provider then
|
||||
util.error(("invalid provider %q"):format(name))
|
||||
return {}
|
||||
end
|
||||
|
||||
local sort_keys = vim.list_extend({
|
||||
function(item)
|
||||
local cwd = vim.loop.fs_realpath(vim.fn.getcwd())
|
||||
local path = vim.loop.fs_realpath(item.filename)
|
||||
if not path then
|
||||
return 200
|
||||
end
|
||||
local ret = string.find(path, cwd, 1, true) == 1 and 10 or 100
|
||||
-- prefer non-hidden files
|
||||
if string.find(path, ".") then
|
||||
ret = ret + 1
|
||||
end
|
||||
return ret
|
||||
end,
|
||||
}, options.sort_keys)
|
||||
|
||||
provider(win, buf, function(items, messages)
|
||||
table.sort(items, function(a, b)
|
||||
for _, key in ipairs(sort_keys) do
|
||||
local ak = type(key) == "string" and a[key] or key(a)
|
||||
local bk = type(key) == "string" and b[key] or key(b)
|
||||
if ak ~= bk then
|
||||
return ak < bk
|
||||
end
|
||||
end
|
||||
end)
|
||||
cb(items, messages)
|
||||
end, options)
|
||||
end
|
||||
|
||||
---@param items Item[]
|
||||
---@return table<string, Item[]>
|
||||
function M.group(items)
|
||||
local keys = {}
|
||||
local keyid = 0
|
||||
local groups = {}
|
||||
for _, item in ipairs(items) do
|
||||
if groups[item.filename] == nil then
|
||||
groups[item.filename] = { filename = item.filename, items = {} }
|
||||
keys[item.filename] = keyid
|
||||
keyid = keyid + 1
|
||||
end
|
||||
table.insert(groups[item.filename].items, item)
|
||||
end
|
||||
|
||||
local ret = {}
|
||||
for _, group in pairs(groups) do
|
||||
table.insert(ret, group)
|
||||
end
|
||||
table.sort(ret, function(a, b)
|
||||
return keys[a.filename] < keys[b.filename]
|
||||
end)
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,93 @@
|
||||
local lsp = require("vim.lsp")
|
||||
local util = require("trouble.util")
|
||||
|
||||
---@class Lsp
|
||||
local M = {}
|
||||
|
||||
local function lsp_buf_request(buf, method, params, handler)
|
||||
lsp.buf_request(buf, method, params, function(err, m, result)
|
||||
handler(err, method == m and result or m)
|
||||
end)
|
||||
end
|
||||
|
||||
---@return Item[]
|
||||
function M.references(win, buf, cb, options)
|
||||
local method = "textDocument/references"
|
||||
local params = util.make_position_params(win, buf)
|
||||
params.context = { includeDeclaration = vim.tbl_contains(options.include_declaration, options.mode) }
|
||||
|
||||
lsp_buf_request(buf, method, params, function(err, result)
|
||||
if err then
|
||||
util.error("an error happened getting references: " .. err.message)
|
||||
return cb({})
|
||||
end
|
||||
if result == nil or #result == 0 then
|
||||
return cb({})
|
||||
end
|
||||
local ret = util.locations_to_items({ result }, 0)
|
||||
cb(ret)
|
||||
end)
|
||||
end
|
||||
|
||||
---@return Item[]
|
||||
function M.implementations(win, buf, cb, options)
|
||||
local method = "textDocument/implementation"
|
||||
local params = util.make_position_params(win, buf)
|
||||
params.context = { includeDeclaration = vim.tbl_contains(options.include_declaration, options.mode) }
|
||||
lsp_buf_request(buf, method, params, function(err, result)
|
||||
if err then
|
||||
util.error("an error happened getting implementation: " .. err.message)
|
||||
return cb({})
|
||||
end
|
||||
if result == nil or #result == 0 then
|
||||
return cb({})
|
||||
end
|
||||
local ret = util.locations_to_items({ result }, 0)
|
||||
cb(ret)
|
||||
end)
|
||||
end
|
||||
|
||||
---@return Item[]
|
||||
function M.definitions(win, buf, cb, options)
|
||||
local method = "textDocument/definition"
|
||||
local params = util.make_position_params(win, buf)
|
||||
params.context = { includeDeclaration = vim.tbl_contains(options.include_declaration, options.mode) }
|
||||
lsp_buf_request(buf, method, params, function(err, result)
|
||||
if err then
|
||||
util.error("an error happened getting definitions: " .. err.message)
|
||||
return cb({})
|
||||
end
|
||||
if result == nil or #result == 0 then
|
||||
return cb({})
|
||||
end
|
||||
for _, value in ipairs(result) do
|
||||
value.uri = value.targetUri or value.uri
|
||||
value.range = value.targetSelectionRange or value.range
|
||||
end
|
||||
local ret = util.locations_to_items({ result }, 0)
|
||||
cb(ret)
|
||||
end)
|
||||
end
|
||||
|
||||
---@return Item[]
|
||||
function M.type_definitions(win, buf, cb, _options)
|
||||
local method = "textDocument/typeDefinition"
|
||||
local params = util.make_position_params(win, buf)
|
||||
lsp_buf_request(buf, method, params, function(err, result)
|
||||
if err then
|
||||
util.error("an error happened getting type definitions: " .. err.message)
|
||||
return cb({})
|
||||
end
|
||||
if result == nil or #result == 0 then
|
||||
return cb({})
|
||||
end
|
||||
for _, value in ipairs(result) do
|
||||
value.uri = value.targetUri or value.uri
|
||||
value.range = value.targetSelectionRange or value.range
|
||||
end
|
||||
local ret = util.locations_to_items({ result }, 0)
|
||||
cb(ret)
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,47 @@
|
||||
local util = require("trouble.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
local severities = { E = 1, W = 2, I = 3, H = 4 }
|
||||
|
||||
function M.get_list(winid)
|
||||
local list = winid == nil and vim.fn.getqflist({ all = true }) or vim.fn.getloclist(winid, { all = true })
|
||||
|
||||
local ret = {}
|
||||
for _, item in pairs(list.items) do
|
||||
local row = (item.lnum == 0 and 1 or item.lnum) - 1
|
||||
local col = (item.col == 0 and 1 or item.col) - 1
|
||||
|
||||
if item.valid == 1 then
|
||||
ret[#ret + 1] = {
|
||||
row = row,
|
||||
col = col,
|
||||
message = item.text,
|
||||
severity = severities[item.type] or 0,
|
||||
bufnr = item.bufnr,
|
||||
range = {
|
||||
start = { line = row, character = col },
|
||||
["end"] = { line = row, character = -1 },
|
||||
},
|
||||
}
|
||||
elseif #ret > 0 then
|
||||
ret[#ret].message = ret[#ret].message .. "\n" .. item.text
|
||||
end
|
||||
end
|
||||
|
||||
for i, item in ipairs(ret) do
|
||||
ret[i] = util.process_item(item)
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.loclist(win, _buf, cb, _options)
|
||||
return cb(M.get_list(win))
|
||||
end
|
||||
|
||||
function M.qflist(_win, _buf, cb, _options)
|
||||
return cb(M.get_list())
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,86 @@
|
||||
local util = require("trouble.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.results = {}
|
||||
|
||||
--- Turns a Telescope item into a Trouble item.
|
||||
local function item_to_result(item)
|
||||
local row = (item.lnum or 1) - 1
|
||||
local col = (item.col or 1) - 1
|
||||
|
||||
if not item.bufnr then
|
||||
local fname = vim.fn.fnamemodify(item.filename, ":p")
|
||||
if vim.fn.filereadable(fname) == 0 and item.cwd then
|
||||
fname = vim.fn.fnamemodify(item.cwd .. "/" .. item.filename, ":p")
|
||||
end
|
||||
item.bufnr = vim.fn.bufnr(fname, true)
|
||||
end
|
||||
|
||||
local pitem = {
|
||||
row = row,
|
||||
col = col,
|
||||
message = item.text,
|
||||
severity = 0,
|
||||
range = {
|
||||
start = { line = row, character = col },
|
||||
["end"] = { line = row, character = -1 },
|
||||
},
|
||||
}
|
||||
|
||||
return util.process_item(pitem, item.bufnr)
|
||||
end
|
||||
|
||||
--- Shows all Telescope results in Trouble.
|
||||
function M.open_with_trouble(prompt_bufnr, _mode)
|
||||
local action_state = require("telescope.actions.state")
|
||||
local actions = require("telescope.actions")
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
local manager = picker.manager
|
||||
|
||||
M.results = {}
|
||||
for item in manager:iter() do
|
||||
table.insert(M.results, item_to_result(item))
|
||||
end
|
||||
|
||||
actions.close(prompt_bufnr)
|
||||
require("trouble").open("telescope")
|
||||
end
|
||||
|
||||
--- Shows the selected Telescope results in Trouble.
|
||||
function M.open_selected_with_trouble(prompt_bufnr, _mode)
|
||||
local action_state = require("telescope.actions.state")
|
||||
local actions = require("telescope.actions")
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
|
||||
M.results = {}
|
||||
for _, item in ipairs(picker:get_multi_selection()) do
|
||||
table.insert(M.results, item_to_result(item))
|
||||
end
|
||||
|
||||
actions.close(prompt_bufnr)
|
||||
require("trouble").open("telescope")
|
||||
end
|
||||
|
||||
--- Shows the selected Telescope results in Trouble.
|
||||
--- If no results are currently selected, shows all of them.
|
||||
function M.smart_open_with_trouble(prompt_bufnr, _mode)
|
||||
local action_state = require("telescope.actions.state")
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
if #picker:get_multi_selection() > 0 then
|
||||
M.open_selected_with_trouble(prompt_bufnr, _mode)
|
||||
else
|
||||
M.open_with_trouble(prompt_bufnr, _mode)
|
||||
end
|
||||
end
|
||||
|
||||
function M.telescope(_win, _buf, cb, _options)
|
||||
if #M.results == 0 then
|
||||
util.warn(
|
||||
"No Telescope results found. Open Telescope and send results to Trouble first. Refer to the documentation for more info."
|
||||
)
|
||||
end
|
||||
cb(M.results)
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,173 @@
|
||||
local providers = require("trouble.providers")
|
||||
local util = require("trouble.util")
|
||||
local config = require("trouble.config")
|
||||
local Text = require("trouble.text")
|
||||
local folds = require("trouble.folds")
|
||||
|
||||
---@class Renderer
|
||||
local renderer = {}
|
||||
|
||||
renderer.signs = {}
|
||||
|
||||
local function get_icon(file)
|
||||
local ok, icons = pcall(require, "nvim-web-devicons")
|
||||
if not ok then
|
||||
util.warn(
|
||||
"'nvim-web-devicons' is not installed. Install it, or set icons=false in your configuration to disable this message"
|
||||
)
|
||||
return ""
|
||||
end
|
||||
local fname = vim.fn.fnamemodify(file, ":t")
|
||||
local ext = vim.fn.fnamemodify(file, ":e")
|
||||
return icons.get_icon(fname, ext, { default = true })
|
||||
end
|
||||
|
||||
local function update_signs()
|
||||
renderer.signs = config.options.signs
|
||||
if config.options.use_diagnostic_signs then
|
||||
local lsp_signs = require("trouble.providers.diagnostic").get_signs()
|
||||
renderer.signs = vim.tbl_deep_extend("force", {}, renderer.signs, lsp_signs)
|
||||
end
|
||||
end
|
||||
|
||||
---@param view TroubleView
|
||||
function renderer.render(view, opts)
|
||||
opts = opts or {}
|
||||
local buf = vim.api.nvim_win_get_buf(view.parent)
|
||||
providers.get(view.parent, buf, function(items, messages)
|
||||
local auto_jump = vim.tbl_contains(config.options.auto_jump, opts.mode)
|
||||
if opts.on_open and #items == 1 and auto_jump and not opts.auto then
|
||||
view:close()
|
||||
util.jump_to_item(opts.win, opts.precmd, items[1])
|
||||
return
|
||||
end
|
||||
|
||||
local grouped = providers.group(items)
|
||||
local count = util.count(grouped)
|
||||
|
||||
-- check for auto close
|
||||
if opts.auto and config.options.auto_close then
|
||||
if count == 0 then
|
||||
view:close()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Update lsp signs
|
||||
update_signs()
|
||||
|
||||
local text = Text:new()
|
||||
view.items = {}
|
||||
|
||||
if config.options.padding then
|
||||
if messages ~= nil then
|
||||
for _, msg in ipairs(messages) do
|
||||
text:render(" " .. msg.text, msg.group, { append = " " })
|
||||
end
|
||||
end
|
||||
text:nl()
|
||||
end
|
||||
|
||||
-- render file groups
|
||||
for _, group in ipairs(grouped) do
|
||||
if opts.open_folds then
|
||||
folds.open(group.filename)
|
||||
end
|
||||
if opts.close_folds then
|
||||
folds.close(group.filename)
|
||||
end
|
||||
renderer.render_file(view, text, group.filename, group.items)
|
||||
end
|
||||
|
||||
view:render(text)
|
||||
if opts.focus then
|
||||
view:focus()
|
||||
end
|
||||
end, config.options)
|
||||
end
|
||||
|
||||
---@param view TroubleView
|
||||
---@param text Text
|
||||
---@param items Item[]
|
||||
---@param filename string
|
||||
function renderer.render_file(view, text, filename, items)
|
||||
view.items[text.lineNr + 1] = { filename = filename, is_file = true }
|
||||
|
||||
if view.group == true then
|
||||
local count = util.count(items)
|
||||
|
||||
text:render(" ")
|
||||
|
||||
if folds.is_folded(filename) then
|
||||
text:render(config.options.fold_closed, "FoldIcon", " ")
|
||||
else
|
||||
text:render(config.options.fold_open, "FoldIcon", " ")
|
||||
end
|
||||
|
||||
if config.options.icons then
|
||||
local icon, icon_hl = get_icon(filename)
|
||||
text:render(icon, icon_hl, { exact = true, append = " " })
|
||||
end
|
||||
|
||||
text:render(vim.fn.fnamemodify(filename, ":p:."), "File", " ")
|
||||
text:render(" " .. count .. " ", "Count")
|
||||
text:nl()
|
||||
end
|
||||
|
||||
if not folds.is_folded(filename) then
|
||||
renderer.render_diagnostics(view, text, items)
|
||||
end
|
||||
end
|
||||
|
||||
---@param view TroubleView
|
||||
---@param text Text
|
||||
---@param items Item[]
|
||||
function renderer.render_diagnostics(view, text, items)
|
||||
for _, diag in ipairs(items) do
|
||||
view.items[text.lineNr + 1] = diag
|
||||
|
||||
local sign = diag.sign or renderer.signs[string.lower(diag.type)]
|
||||
if not sign then
|
||||
sign = diag.type
|
||||
end
|
||||
|
||||
local indent = " "
|
||||
if config.options.indent_lines then
|
||||
indent = " │ "
|
||||
elseif config.options.group == false then
|
||||
indent = " "
|
||||
end
|
||||
|
||||
local sign_hl = diag.sign_hl or ("TroubleSign" .. diag.type)
|
||||
|
||||
text:render(indent, "Indent")
|
||||
text:render(sign .. " ", sign_hl, { exact = true })
|
||||
|
||||
local lines = config.options.multiline and vim.split(diag.full_text, "\n") or { diag.text }
|
||||
|
||||
text:render(lines[1], "Text" .. diag.type, " ")
|
||||
|
||||
if diag.source then
|
||||
text:render(diag.source, "Source")
|
||||
end
|
||||
if diag.code and diag.code ~= vim.NIL then
|
||||
text:render(" (" .. diag.code .. ")", "Code")
|
||||
end
|
||||
|
||||
text:render(" ")
|
||||
|
||||
text:render("[" .. diag.lnum .. ", " .. diag.col .. "]", "Location")
|
||||
|
||||
for l = 2, #lines do
|
||||
local str = lines[l]
|
||||
text:nl()
|
||||
view.items[text.lineNr + 1] = diag
|
||||
text:render(indent .. " ", "Indent")
|
||||
text:render(str, "Text" .. diag.type, " ")
|
||||
end
|
||||
|
||||
text:nl()
|
||||
end
|
||||
end
|
||||
|
||||
return renderer
|
||||
@ -0,0 +1,52 @@
|
||||
---@class Text
|
||||
---@field lines string[]
|
||||
---@field hl Highlight[]
|
||||
---@field lineNr number
|
||||
---@field current string
|
||||
local Text = {}
|
||||
Text.__index = Text
|
||||
|
||||
function Text:new()
|
||||
local this = { lines = {}, hl = {}, lineNr = 0, current = "" }
|
||||
setmetatable(this, self)
|
||||
return this
|
||||
end
|
||||
|
||||
function Text:nl()
|
||||
table.insert(self.lines, self.current)
|
||||
self.current = ""
|
||||
self.lineNr = self.lineNr + 1
|
||||
end
|
||||
|
||||
function Text:render(str, group, opts)
|
||||
str = str:gsub("[\n]", " ")
|
||||
if type(opts) == "string" then
|
||||
opts = { append = opts }
|
||||
end
|
||||
opts = opts or {}
|
||||
|
||||
if group then
|
||||
if opts.exact ~= true then
|
||||
group = "Trouble" .. group
|
||||
end
|
||||
local from = string.len(self.current)
|
||||
---@class Highlight
|
||||
local hl
|
||||
hl = {
|
||||
line = self.lineNr,
|
||||
from = from,
|
||||
to = from + string.len(str),
|
||||
group = group,
|
||||
}
|
||||
table.insert(self.hl, hl)
|
||||
end
|
||||
self.current = self.current .. str
|
||||
if opts.append then
|
||||
self.current = self.current .. opts.append
|
||||
end
|
||||
if opts.nl then
|
||||
self:nl()
|
||||
end
|
||||
end
|
||||
|
||||
return Text
|
||||
@ -0,0 +1,242 @@
|
||||
local config = require("trouble.config")
|
||||
local uv = vim.loop
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.jump_to_item(win, precmd, item)
|
||||
-- requiring here, as otherwise we run into a circular dependency
|
||||
local View = require("trouble.view")
|
||||
|
||||
-- save position in jump list
|
||||
vim.cmd("normal! m'")
|
||||
|
||||
View.switch_to(win)
|
||||
if precmd then
|
||||
vim.cmd(precmd)
|
||||
end
|
||||
if not vim.bo[item.bufnr].buflisted then
|
||||
vim.bo[item.bufnr].buflisted = true
|
||||
end
|
||||
if not vim.api.nvim_buf_is_loaded(item.bufnr) then
|
||||
vim.fn.bufload(item.bufnr)
|
||||
end
|
||||
vim.api.nvim_set_current_buf(item.bufnr)
|
||||
vim.api.nvim_win_set_cursor(win or 0, { item.start.line + 1, item.start.character })
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "TroubleJump", modeline = false })
|
||||
end
|
||||
|
||||
function M.fix_mode(opts)
|
||||
if opts.use_lsp_diagnostic_signs then
|
||||
opts.use_diagnostic_signs = opts.use_lsp_diagnostic_signs
|
||||
M.warn("The Trouble option use_lsp_diagnostic_signs has been renamed to use_diagnostic_signs")
|
||||
end
|
||||
local replace = {
|
||||
lsp_workspace_diagnostics = "workspace_diagnostics",
|
||||
lsp_document_diagnostics = "document_diagnostics",
|
||||
workspace = "workspace_diagnostics",
|
||||
document = "document_diagnostics",
|
||||
}
|
||||
|
||||
for old, new in pairs(replace) do
|
||||
if opts.mode == old then
|
||||
opts.mode = new
|
||||
M.warn("Using " .. old .. " for Trouble is deprecated. Please use " .. new .. " instead.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@return number
|
||||
function M.count(tab)
|
||||
local count = 0
|
||||
for _ in pairs(tab) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
function M.warn(msg)
|
||||
vim.notify(msg, vim.log.levels.WARN, { title = "Trouble" })
|
||||
end
|
||||
|
||||
function M.error(msg)
|
||||
vim.notify(msg, vim.log.levels.ERROR, { title = "Trouble" })
|
||||
end
|
||||
|
||||
function M.debug(msg)
|
||||
if config.options.debug then
|
||||
vim.notify(msg, vim.log.levels.DEBUG, { title = "Trouble" })
|
||||
end
|
||||
end
|
||||
|
||||
function M.debounce(ms, fn)
|
||||
local timer = vim.loop.new_timer()
|
||||
return function(...)
|
||||
local argv = { ... }
|
||||
timer:start(ms, 0, function()
|
||||
timer:stop()
|
||||
vim.schedule_wrap(fn)(unpack(argv))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function M.throttle(ms, fn)
|
||||
local timer = vim.loop.new_timer()
|
||||
local running = false
|
||||
return function(...)
|
||||
if not running then
|
||||
local argv = { ... }
|
||||
local argc = select("#", ...)
|
||||
|
||||
timer:start(ms, 0, function()
|
||||
running = false
|
||||
pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc))
|
||||
end)
|
||||
running = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.severity = {
|
||||
[0] = "Other",
|
||||
[1] = "Error",
|
||||
[2] = "Warning",
|
||||
[3] = "Information",
|
||||
[4] = "Hint",
|
||||
}
|
||||
|
||||
-- returns a hl or sign label for the givin severity and type
|
||||
-- correctly handles new names introduced in vim.diagnostic
|
||||
function M.get_severity_label(severity, type)
|
||||
local label = severity
|
||||
local prefix = "LspDiagnostics" .. (type or "Default")
|
||||
|
||||
if vim.diagnostic then
|
||||
prefix = type and ("Diagnostic" .. type) or "Diagnostic"
|
||||
label = ({
|
||||
Warning = "Warn",
|
||||
Information = "Info",
|
||||
})[severity] or severity
|
||||
end
|
||||
|
||||
return prefix .. label
|
||||
end
|
||||
|
||||
-- based on the Telescope diagnostics code
|
||||
-- see https://github.com/nvim-telescope/telescope.nvim/blob/0d6cd47990781ea760dd3db578015c140c7b9fa7/lua/telescope/utils.lua#L85
|
||||
function M.process_item(item, bufnr)
|
||||
bufnr = bufnr or item.bufnr
|
||||
local filename = vim.api.nvim_buf_get_name(bufnr)
|
||||
local range = item.range or item.targetSelectionRange
|
||||
|
||||
local start = {
|
||||
line = range and vim.tbl_get(range, "start", "line") or item.lnum,
|
||||
character = range and vim.tbl_get(range, "start", "character") or item.col,
|
||||
}
|
||||
local finish = {
|
||||
line = range and vim.tbl_get(range, "end", "line") or item.end_lnum,
|
||||
character = range and vim.tbl_get(range, "end", "character") or item.end_col,
|
||||
}
|
||||
|
||||
if start.character == nil or start.line == nil then
|
||||
M.error("Found an item for Trouble without start range " .. vim.inspect(start))
|
||||
end
|
||||
if finish.character == nil or finish.line == nil then
|
||||
M.error("Found an item for Trouble without finish range " .. vim.inspect(finish))
|
||||
end
|
||||
local row = start.line ---@type number
|
||||
local col = start.character ---@type number
|
||||
|
||||
if not item.message and filename then
|
||||
-- check if the filename is a uri
|
||||
if string.match(filename, "^%w+://") ~= nil then
|
||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
vim.fn.bufload(bufnr)
|
||||
end
|
||||
local lines = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)
|
||||
item.message = lines[1] or ""
|
||||
else
|
||||
local fd = assert(uv.fs_open(filename, "r", 438))
|
||||
local stat = assert(uv.fs_fstat(fd))
|
||||
local data = assert(uv.fs_read(fd, stat.size, 0))
|
||||
assert(uv.fs_close(fd))
|
||||
|
||||
item.message = vim.split(data, "\n", { plain = true })[row + 1] or ""
|
||||
end
|
||||
end
|
||||
|
||||
---@class Item
|
||||
---@field is_file boolean
|
||||
---@field fixed boolean
|
||||
local ret = {
|
||||
bufnr = bufnr,
|
||||
filename = filename,
|
||||
lnum = row + 1,
|
||||
col = col + 1,
|
||||
start = start,
|
||||
finish = finish,
|
||||
sign = item.sign, ---@type string?
|
||||
sign_hl = item.sign_hl, ---@type string?
|
||||
-- remove line break to avoid display issues
|
||||
text = vim.trim(item.message:gsub("[\n]+", "")):sub(0, vim.o.columns),
|
||||
full_text = vim.trim(item.message),
|
||||
type = M.severity[item.severity] or M.severity[0],
|
||||
code = item.code or (item.user_data and item.user_data.lsp and item.user_data.lsp.code), ---@type string?
|
||||
code_href = (item.codeDescription and item.codeDescription.href)
|
||||
or (
|
||||
item.user_data
|
||||
and item.user_data.lsp
|
||||
and item.user_data.lsp.codeDescription
|
||||
and item.user_data.lsp.codeDescription.href
|
||||
), ---@type string?
|
||||
source = item.source, ---@type string?
|
||||
severity = item.severity or 0,
|
||||
}
|
||||
return ret
|
||||
end
|
||||
|
||||
-- takes either a table indexed by bufnr, or an lsp result with uri
|
||||
---@return Item[]
|
||||
function M.locations_to_items(results, default_severity)
|
||||
default_severity = default_severity or 0
|
||||
local ret = {}
|
||||
for bufnr, locs in pairs(results or {}) do
|
||||
for _, loc in pairs(locs.result or locs) do
|
||||
if not vim.tbl_isempty(loc) then
|
||||
local uri = loc.uri or loc.targetUri
|
||||
local buf = uri and vim.uri_to_bufnr(uri) or bufnr
|
||||
loc.severity = loc.severity or default_severity
|
||||
table.insert(ret, M.process_item(loc, buf))
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
-- @private
|
||||
local function make_position_param(win, buf)
|
||||
local row, col = unpack(vim.api.nvim_win_get_cursor(win))
|
||||
row = row - 1
|
||||
local line = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
|
||||
if not line then
|
||||
return { line = 0, character = 0 }
|
||||
end
|
||||
col = vim.str_utfindex(line, col)
|
||||
return { line = row, character = col }
|
||||
end
|
||||
|
||||
function M.make_text_document_params(buf)
|
||||
return { uri = vim.uri_from_bufnr(buf) }
|
||||
end
|
||||
|
||||
--- Creates a `TextDocumentPositionParams` object for the current buffer and cursor position.
|
||||
---
|
||||
-- @returns `TextDocumentPositionParams` object
|
||||
-- @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams
|
||||
function M.make_position_params(win, buf)
|
||||
return {
|
||||
textDocument = M.make_text_document_params(buf),
|
||||
position = make_position_param(win, buf),
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,581 @@
|
||||
local renderer = require("trouble.renderer")
|
||||
local config = require("trouble.config")
|
||||
local folds = require("trouble.folds")
|
||||
local util = require("trouble.util")
|
||||
|
||||
local highlight = vim.api.nvim_buf_add_highlight
|
||||
|
||||
---@class TroubleView
|
||||
---@field buf number
|
||||
---@field win number
|
||||
---@field group boolean
|
||||
---@field items Item[]
|
||||
---@field folded table<string, boolean>
|
||||
---@field parent number
|
||||
---@field float number
|
||||
local View = {}
|
||||
View.__index = View
|
||||
|
||||
-- keep track of buffers with added highlights
|
||||
-- highlights are cleared on BufLeave of Trouble
|
||||
local hl_bufs = {}
|
||||
|
||||
local function clear_hl(bufnr)
|
||||
if vim.api.nvim_buf_is_valid(bufnr) then
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, config.namespace, 0, -1)
|
||||
end
|
||||
end
|
||||
|
||||
---Find a rogue Trouble buffer that might have been spawned by i.e. a session.
|
||||
local function find_rogue_buffer()
|
||||
for _, v in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.fn.bufname(v) == "Trouble" then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---Find pre-existing Trouble buffer, delete its windows then wipe it.
|
||||
---@private
|
||||
local function wipe_rogue_buffer()
|
||||
local bn = find_rogue_buffer()
|
||||
if bn then
|
||||
local win_ids = vim.fn.win_findbuf(bn)
|
||||
for _, id in ipairs(win_ids) do
|
||||
if vim.fn.win_gettype(id) ~= "autocmd" and vim.api.nvim_win_is_valid(id) then
|
||||
vim.api.nvim_win_close(id, true)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_name(bn, "")
|
||||
vim.schedule(function()
|
||||
pcall(vim.api.nvim_buf_delete, bn, {})
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
---@return TroubleView
|
||||
function View:new(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local group
|
||||
if opts.group ~= nil then
|
||||
group = opts.group
|
||||
else
|
||||
group = config.options.group
|
||||
end
|
||||
|
||||
local this = {
|
||||
buf = vim.api.nvim_get_current_buf(),
|
||||
win = opts.win or vim.api.nvim_get_current_win(),
|
||||
parent = opts.parent,
|
||||
items = {},
|
||||
group = group,
|
||||
}
|
||||
setmetatable(this, self)
|
||||
return this
|
||||
end
|
||||
|
||||
function View:set_option(name, value, win)
|
||||
if win then
|
||||
return vim.api.nvim_set_option_value(name, value, { win = self.win, scope = "local" })
|
||||
else
|
||||
return vim.api.nvim_set_option_value(name, value, { buf = self.buf })
|
||||
end
|
||||
end
|
||||
|
||||
---@param text Text
|
||||
function View:render(text)
|
||||
if not self:is_valid() then
|
||||
return
|
||||
end
|
||||
|
||||
self:unlock()
|
||||
self:set_lines(text.lines)
|
||||
self:lock()
|
||||
clear_hl(self.buf)
|
||||
for _, data in ipairs(text.hl) do
|
||||
highlight(self.buf, config.namespace, data.group, data.line, data.from, data.to)
|
||||
end
|
||||
end
|
||||
|
||||
function View:clear()
|
||||
return vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, {})
|
||||
end
|
||||
|
||||
function View:unlock()
|
||||
self:set_option("modifiable", true)
|
||||
self:set_option("readonly", false)
|
||||
end
|
||||
|
||||
function View:lock()
|
||||
self:set_option("readonly", true)
|
||||
self:set_option("modifiable", false)
|
||||
end
|
||||
|
||||
function View:set_lines(lines, first, last, strict)
|
||||
first = first or 0
|
||||
last = last or -1
|
||||
strict = strict or false
|
||||
return vim.api.nvim_buf_set_lines(self.buf, first, last, strict, lines)
|
||||
end
|
||||
|
||||
function View:is_valid()
|
||||
return vim.api.nvim_buf_is_valid(self.buf) and vim.api.nvim_buf_is_loaded(self.buf)
|
||||
end
|
||||
|
||||
function View:update(opts)
|
||||
util.debug("update")
|
||||
renderer.render(self, opts)
|
||||
end
|
||||
|
||||
function View:setup(opts)
|
||||
util.debug("setup")
|
||||
opts = opts or {}
|
||||
vim.cmd("setlocal nonu")
|
||||
vim.cmd("setlocal nornu")
|
||||
if not pcall(vim.api.nvim_buf_set_name, self.buf, "Trouble") then
|
||||
wipe_rogue_buffer()
|
||||
vim.api.nvim_buf_set_name(self.buf, "Trouble")
|
||||
end
|
||||
self:set_option("bufhidden", "wipe")
|
||||
self:set_option("buftype", "nofile")
|
||||
self:set_option("swapfile", false)
|
||||
self:set_option("cursorline", true, true)
|
||||
self:set_option("buflisted", false)
|
||||
self:set_option("winfixwidth", true, true)
|
||||
self:set_option("wrap", false, true)
|
||||
self:set_option("spell", false, true)
|
||||
self:set_option("list", false, true)
|
||||
self:set_option("winfixheight", true, true)
|
||||
self:set_option("signcolumn", "no", true)
|
||||
self:set_option("foldmethod", "manual", true)
|
||||
self:set_option("foldcolumn", "0", true)
|
||||
self:set_option("foldlevel", 3, true)
|
||||
self:set_option("foldenable", false, true)
|
||||
self:set_option("winhighlight", "Normal:TroubleNormal,EndOfBuffer:TroubleNormal,SignColumn:TroubleNormal", true)
|
||||
self:set_option("fcs", "eob: ", true)
|
||||
|
||||
for action, keys in pairs(config.options.action_keys) do
|
||||
if type(keys) == "string" then
|
||||
keys = { keys }
|
||||
end
|
||||
for _, key in pairs(keys) do
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
self.buf,
|
||||
"n",
|
||||
key,
|
||||
[[<cmd>lua require("trouble").action("]] .. action .. [[")<cr>]],
|
||||
{
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if config.options.position == "top" or config.options.position == "bottom" then
|
||||
vim.api.nvim_win_set_height(self.win, config.options.height)
|
||||
else
|
||||
vim.api.nvim_win_set_width(self.win, config.options.width)
|
||||
end
|
||||
|
||||
self:set_option("filetype", "Trouble")
|
||||
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
augroup TroubleHighlights
|
||||
autocmd! * <buffer>
|
||||
autocmd BufEnter <buffer> lua require("trouble").action("on_enter")
|
||||
autocmd CursorMoved <buffer> lua require("trouble").action("auto_preview")
|
||||
autocmd BufLeave <buffer> lua require("trouble").action("on_leave")
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
if not opts.parent then
|
||||
self:on_enter()
|
||||
end
|
||||
self:lock()
|
||||
self:update(opts)
|
||||
end
|
||||
|
||||
function View:on_enter()
|
||||
util.debug("on_enter")
|
||||
|
||||
self.parent = self.parent or vim.fn.win_getid(vim.fn.winnr("#"))
|
||||
|
||||
if (not self:is_valid_parent(self.parent)) or self.parent == self.win then
|
||||
util.debug("not valid parent")
|
||||
for _, win in pairs(vim.api.nvim_list_wins()) do
|
||||
if self:is_valid_parent(win) and win ~= self.win then
|
||||
self.parent = win
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not vim.api.nvim_win_is_valid(self.parent) then
|
||||
return self:close()
|
||||
end
|
||||
|
||||
self.parent_state = {
|
||||
buf = vim.api.nvim_win_get_buf(self.parent),
|
||||
cursor = vim.api.nvim_win_get_cursor(self.parent),
|
||||
}
|
||||
end
|
||||
|
||||
function View:on_leave()
|
||||
util.debug("on_leave")
|
||||
self:close_preview()
|
||||
end
|
||||
|
||||
function View:close_preview()
|
||||
-- Clear preview highlights
|
||||
for buf, _ in pairs(hl_bufs) do
|
||||
clear_hl(buf)
|
||||
end
|
||||
hl_bufs = {}
|
||||
|
||||
-- Reset parent state
|
||||
local valid_win = vim.api.nvim_win_is_valid(self.parent)
|
||||
local valid_buf = self.parent_state and vim.api.nvim_buf_is_valid(self.parent_state.buf)
|
||||
|
||||
if self.parent_state and valid_buf and valid_win then
|
||||
vim.api.nvim_win_set_buf(self.parent, self.parent_state.buf)
|
||||
vim.api.nvim_win_set_cursor(self.parent, self.parent_state.cursor)
|
||||
end
|
||||
|
||||
self.parent_state = nil
|
||||
end
|
||||
|
||||
function View:is_float(win)
|
||||
local opts = vim.api.nvim_win_get_config(win)
|
||||
return opts and opts.relative and opts.relative ~= ""
|
||||
end
|
||||
|
||||
function View:is_valid_parent(win)
|
||||
if not vim.api.nvim_win_is_valid(win) then
|
||||
return false
|
||||
end
|
||||
-- dont do anything for floating windows
|
||||
if View:is_float(win) then
|
||||
return false
|
||||
end
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
-- Skip special buffers
|
||||
if vim.api.nvim_buf_get_option(buf, "buftype") ~= "" then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function View:on_win_enter()
|
||||
util.debug("on_win_enter")
|
||||
|
||||
local current_win = vim.api.nvim_get_current_win()
|
||||
|
||||
if vim.fn.winnr("$") == 1 and current_win == self.win then
|
||||
vim.cmd([[q]])
|
||||
return
|
||||
end
|
||||
|
||||
if not self:is_valid_parent(current_win) then
|
||||
return
|
||||
end
|
||||
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
|
||||
-- update parent when needed
|
||||
if current_win ~= self.parent and current_win ~= self.win then
|
||||
self.parent = current_win
|
||||
-- update diagnostics to match the window we are viewing
|
||||
if self:is_valid() then
|
||||
vim.defer_fn(function()
|
||||
util.debug("update_on_win_enter")
|
||||
self:update()
|
||||
end, 100)
|
||||
end
|
||||
end
|
||||
|
||||
-- check if another buffer took over our window
|
||||
local parent = self.parent
|
||||
if current_win == self.win and current_buf ~= self.buf then
|
||||
-- open the buffer in the parent
|
||||
vim.api.nvim_win_set_buf(parent, current_buf)
|
||||
-- HACK: some window local settings need to be reset
|
||||
vim.api.nvim_win_set_option(parent, "winhl", "")
|
||||
-- close the current trouble window
|
||||
vim.api.nvim_win_close(self.win, false)
|
||||
-- open a new trouble window
|
||||
require("trouble").open()
|
||||
-- switch back to the opened window / buffer
|
||||
View.switch_to(parent, current_buf)
|
||||
-- util.warn("win_enter pro")
|
||||
end
|
||||
end
|
||||
|
||||
function View:focus()
|
||||
if not self:is_valid() then
|
||||
return
|
||||
end
|
||||
|
||||
View.switch_to(self.win, self.buf)
|
||||
local line = self:get_line()
|
||||
if line == 1 then
|
||||
self:next_item()
|
||||
if config.options.padding then
|
||||
self:next_item()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function View.switch_to(win, buf)
|
||||
if win then
|
||||
vim.api.nvim_set_current_win(win)
|
||||
if buf then
|
||||
vim.api.nvim_win_set_buf(win, buf)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function View:switch_to_parent()
|
||||
-- vim.cmd("wincmd p")
|
||||
View.switch_to(self.parent)
|
||||
end
|
||||
|
||||
function View:close()
|
||||
util.debug("close")
|
||||
if vim.api.nvim_win_is_valid(self.win) then
|
||||
if vim.api.nvim_win_is_valid(self.parent) then
|
||||
vim.api.nvim_set_current_win(self.parent)
|
||||
end
|
||||
vim.api.nvim_win_close(self.win, {})
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(self.buf) then
|
||||
vim.api.nvim_buf_delete(self.buf, {})
|
||||
end
|
||||
end
|
||||
|
||||
function View.create(opts)
|
||||
opts = opts or {}
|
||||
---@type TroubleView
|
||||
local view
|
||||
vim.api.nvim_win_call(0, function()
|
||||
if opts.win then
|
||||
View.switch_to(opts.win)
|
||||
vim.cmd("enew")
|
||||
else
|
||||
vim.cmd("below new")
|
||||
local pos = { bottom = "J", top = "K", left = "H", right = "L" }
|
||||
vim.cmd("wincmd " .. (pos[config.options.position] or "K"))
|
||||
end
|
||||
view = View:new(opts)
|
||||
view:setup(opts)
|
||||
end)
|
||||
|
||||
if opts.focus == true then
|
||||
view:focus()
|
||||
end
|
||||
|
||||
return view
|
||||
end
|
||||
|
||||
function View:get_cursor()
|
||||
return vim.api.nvim_win_get_cursor(self.win)
|
||||
end
|
||||
function View:get_line()
|
||||
return self:get_cursor()[1]
|
||||
end
|
||||
function View:get_col()
|
||||
return self:get_cursor()[2]
|
||||
end
|
||||
|
||||
function View:current_item()
|
||||
local line = self:get_line()
|
||||
local item = self.items[line]
|
||||
return item
|
||||
end
|
||||
|
||||
function View:next_item(opts)
|
||||
opts = opts or { skip_groups = false }
|
||||
local line = opts.first and 0 or self:get_line() + 1
|
||||
|
||||
if line > #self.items then
|
||||
if config.options.cycle_results then
|
||||
self:first_item(opts)
|
||||
end
|
||||
else
|
||||
for i = line, vim.api.nvim_buf_line_count(self.buf), 1 do
|
||||
if self.items[i] and not (opts.skip_groups and self.items[i].is_file) then
|
||||
vim.api.nvim_win_set_cursor(self.win, { i, self:get_col() })
|
||||
if opts.jump then
|
||||
self:jump()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function View:previous_item(opts)
|
||||
opts = opts or { skip_groups = false }
|
||||
local line = opts.last and vim.api.nvim_buf_line_count(self.buf) or self:get_line() - 1
|
||||
|
||||
for i = 0, vim.api.nvim_buf_line_count(self.buf), 1 do
|
||||
if self.items[i] then
|
||||
if line < i + (opts.skip_groups and 1 or 0) then
|
||||
if config.options.cycle_results then
|
||||
self:last_item(opts)
|
||||
end
|
||||
return
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for i = line, 0, -1 do
|
||||
if self.items[i] and not (opts.skip_groups and self.items[i].is_file) then
|
||||
vim.api.nvim_win_set_cursor(self.win, { i, self:get_col() })
|
||||
if opts.jump then
|
||||
self:jump()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function View:first_item(opts)
|
||||
opts = opts or {}
|
||||
opts.first = true
|
||||
return self:next_item(opts)
|
||||
end
|
||||
|
||||
function View:last_item(opts)
|
||||
opts = opts or {}
|
||||
opts.last = true
|
||||
return self:previous_item(opts)
|
||||
end
|
||||
|
||||
function View:hover(opts)
|
||||
opts = opts or {}
|
||||
local item = opts.item or self:current_item()
|
||||
if not (item and item.full_text) then
|
||||
return
|
||||
end
|
||||
vim.lsp.util.open_floating_preview(vim.split(item.full_text, "\n"), "markdown", config.options.win_config)
|
||||
end
|
||||
|
||||
function View:jump(opts)
|
||||
opts = opts or {}
|
||||
local item = opts.item or self:current_item()
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
|
||||
if item.is_file == true then
|
||||
folds.toggle(item.filename)
|
||||
self:update()
|
||||
else
|
||||
util.jump_to_item(opts.win or self.parent, opts.precmd, item)
|
||||
end
|
||||
end
|
||||
|
||||
function View:toggle_fold()
|
||||
folds.toggle(self:current_item().filename)
|
||||
self:update()
|
||||
end
|
||||
|
||||
function View:_preview()
|
||||
if not vim.api.nvim_win_is_valid(self.parent) then
|
||||
return
|
||||
end
|
||||
if not vim.api.nvim_win_is_valid(self.win) then
|
||||
return
|
||||
end
|
||||
|
||||
local item = self:current_item()
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
if item.bufnr == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
util.debug("preview")
|
||||
|
||||
if item.is_file ~= true then
|
||||
vim.api.nvim_win_set_buf(self.parent, item.bufnr)
|
||||
local pos = { item.start.line + 1, item.start.character }
|
||||
local line_count = vim.api.nvim_buf_line_count(item.bufnr)
|
||||
pos[1] = math.min(pos[1], line_count)
|
||||
vim.api.nvim_win_set_cursor(self.parent, pos)
|
||||
|
||||
vim.api.nvim_buf_call(item.bufnr, function()
|
||||
-- Center preview line on screen and open enough folds to show it
|
||||
vim.cmd("norm! zz zv")
|
||||
if not vim.api.nvim_buf_is_loaded(item.bufnr) then
|
||||
vim.fn.bufload(item.bufnr)
|
||||
end
|
||||
end)
|
||||
|
||||
clear_hl(item.bufnr)
|
||||
hl_bufs[item.bufnr] = true
|
||||
for row = item.start.line, item.finish.line, 1 do
|
||||
local col_start = 0
|
||||
local col_end = -1
|
||||
if row == item.start.line then
|
||||
col_start = item.start.character
|
||||
end
|
||||
if row == item.finish.line then
|
||||
col_end = item.finish.character
|
||||
end
|
||||
highlight(item.bufnr, config.namespace, "TroublePreview", row, col_start, col_end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- View.preview = View._preview
|
||||
|
||||
View.preview = util.throttle(50, View._preview)
|
||||
|
||||
function View:open_code_href()
|
||||
if not vim.api.nvim_win_is_valid(self.parent) then
|
||||
return
|
||||
end
|
||||
|
||||
local item = self:current_item()
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
util.debug("open code href")
|
||||
|
||||
if item.is_file ~= true and item.code_href then
|
||||
local cmd
|
||||
if vim.fn.has("win32") == 1 then
|
||||
cmd = "explorer"
|
||||
elseif vim.fn.executable("xdg-open") == 1 then
|
||||
cmd = "xdg-open"
|
||||
elseif vim.fn.executable("wslview") == 1 then
|
||||
cmd = "wslview"
|
||||
else
|
||||
cmd = "open"
|
||||
end
|
||||
|
||||
local ret = vim.fn.jobstart({ cmd, item.code_href }, { detach = true })
|
||||
if ret <= 0 then
|
||||
local msg = {
|
||||
"Failed to open code href",
|
||||
ret,
|
||||
vim.inspect(cmd),
|
||||
}
|
||||
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return View
|
||||
BIN
config/neovim/store/lazy-plugins/trouble.nvim/media/shot.png
Normal file
BIN
config/neovim/store/lazy-plugins/trouble.nvim/media/shot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 KiB |
@ -0,0 +1,21 @@
|
||||
|
||||
augroup Trouble
|
||||
autocmd!
|
||||
if has('nvim-0.6')
|
||||
" Use the new diagnostic subsystem for neovim 0.6 and up
|
||||
au DiagnosticChanged * lua require'trouble'.refresh({auto = true, provider = "diagnostics"})
|
||||
else
|
||||
au User LspDiagnosticsChanged lua require'trouble'.refresh({auto = true, provider = "diagnostics"})
|
||||
endif
|
||||
autocmd BufWinEnter,BufEnter * lua require("trouble").action("on_win_enter")
|
||||
augroup end
|
||||
|
||||
function! s:complete(arg,line,pos) abort
|
||||
return join(sort(luaeval('vim.tbl_keys(require("trouble.providers").providers)')), "\n")
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=custom,s:complete Trouble lua require'trouble'.open(<f-args>)
|
||||
command! -nargs=* -complete=custom,s:complete TroubleToggle lua require'trouble'.toggle(<f-args>)
|
||||
command! TroubleClose lua require'trouble'.close()
|
||||
command! TroubleRefresh lua require'trouble'.refresh()
|
||||
|
||||
@ -0,0 +1 @@
|
||||
std="lua51+vim"
|
||||
@ -0,0 +1,3 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
||||
2
config/neovim/store/lazy-plugins/trouble.nvim/vim.toml
Normal file
2
config/neovim/store/lazy-plugins/trouble.nvim/vim.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[vim]
|
||||
any = true
|
||||
Reference in New Issue
Block a user