Skip to content

Commit

Permalink
fix(setup): add check for NEovim 0.10.0 or markdown parsers. Fixes #413
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 12, 2024
1 parent f6a3fbf commit 307f271
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 48 deletions.
97 changes: 49 additions & 48 deletions README.md
Expand Up @@ -42,6 +42,7 @@ with a lot of new features and improvements:
## 鈿★笍 Requirements

- Neovim >= 0.9.2
- Neovim >= 0.10.0 **OR** the `markdown` and `markdown_inline` [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) parsers
- 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
Expand Down Expand Up @@ -379,7 +380,7 @@ require("trouble").first(opts)
---@return trouble.View
require("trouble").focus(opts)

-- Fold close
-- Fold close
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").fold_close(opts)
Expand Down Expand Up @@ -409,7 +410,7 @@ require("trouble").fold_enable(opts)
---@return trouble.View
require("trouble").fold_more(opts)

-- Fold open
-- Fold open
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").fold_open(opts)
Expand All @@ -429,7 +430,7 @@ require("trouble").fold_open_recursive(opts)
---@return trouble.View
require("trouble").fold_reduce(opts)

-- Fold toggle
-- Fold toggle
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").fold_toggle(opts)
Expand Down Expand Up @@ -586,51 +587,51 @@ The table below shows all the highlight groups defined for Trouble.

<!-- colors:start -->

| Highlight Group | Default Group | Description |
| --- | --- | --- |
| **TroubleCount** | ***TabLineSel*** | |
| **TroubleDirectory** | ***Directory*** | |
| **TroubleFileName** | ***Directory*** | |
| **TroubleIconArray** | ***@punctuation.bracket*** | |
| **TroubleIconBoolean** | ***@boolean*** | |
| **TroubleIconClass** | ***@type*** | |
| **TroubleIconConstant** | ***@constant*** | |
| **TroubleIconConstructor** | ***@constructor*** | |
| **TroubleIconDirectory** | ***Special*** | |
| **TroubleIconEnum** | ***@lsp.type.enum*** | |
| **TroubleIconEnumMember** | ***@lsp.type.enumMember*** | |
| **TroubleIconEvent** | ***Special*** | |
| **TroubleIconField** | ***@variable.member*** | |
| **TroubleIconFile** | ***Normal*** | |
| **TroubleIconFunction** | ***@function*** | |
| **TroubleIconInterface** | ***@lsp.type.interface*** | |
| **TroubleIconKey** | ***@lsp.type.keyword*** | |
| **TroubleIconMethod** | ***@function.method*** | |
| **TroubleIconModule** | ***@module*** | |
| **TroubleIconNamespace** | ***@module*** | |
| **TroubleIconNull** | ***@constant.builtin*** | |
| **TroubleIconNumber** | ***@number*** | |
| **TroubleIconObject** | ***@constant*** | |
| **TroubleIconOperator** | ***@operator*** | |
| **TroubleIconPackage** | ***@module*** | |
| **TroubleIconProperty** | ***@property*** | |
| **TroubleIconString** | ***@string*** | |
| **TroubleIconStruct** | ***@lsp.type.struct*** | |
| **TroubleIconTypeParameter** | ***@lsp.type.typeParameter*** | |
| **TroubleIconVariable** | ***@variable*** | |
| **TroubleIndent** | ***LineNr*** | |
| **TroubleIndentFoldClosed** | ***CursorLineNr*** | |
| **TroubleIndentFoldOpen** | ***TroubleIndent*** | |
| **TroubleIndentLast** | ***TroubleIndent*** | |
| **TroubleIndentMiddle** | ***TroubleIndent*** | |
| **TroubleIndentTop** | ***TroubleIndent*** | |
| **TroubleIndentWs** | ***TroubleIndent*** | |
| **TroubleNormal** | ***NormalFloat*** | |
| **TroubleNormalNC** | ***NormalFloat*** | |
| **TroublePos** | ***LineNr*** | |
| **TroublePreview** | ***Visual*** | |
| **TroubleSource** | ***Comment*** | |
| **TroubleText** | ***Normal*** | |
| Highlight Group | Default Group | Description |
| ---------------------------- | ----------------------------- | ----------- |
| **TroubleCount** | **_TabLineSel_** | |
| **TroubleDirectory** | **_Directory_** | |
| **TroubleFileName** | **_Directory_** | |
| **TroubleIconArray** | **_@punctuation.bracket_** | |
| **TroubleIconBoolean** | **_@boolean_** | |
| **TroubleIconClass** | **_@type_** | |
| **TroubleIconConstant** | **_@constant_** | |
| **TroubleIconConstructor** | **_@constructor_** | |
| **TroubleIconDirectory** | **_Special_** | |
| **TroubleIconEnum** | **_@lsp.type.enum_** | |
| **TroubleIconEnumMember** | **_@lsp.type.enumMember_** | |
| **TroubleIconEvent** | **_Special_** | |
| **TroubleIconField** | **_@variable.member_** | |
| **TroubleIconFile** | **_Normal_** | |
| **TroubleIconFunction** | **_@function_** | |
| **TroubleIconInterface** | **_@lsp.type.interface_** | |
| **TroubleIconKey** | **_@lsp.type.keyword_** | |
| **TroubleIconMethod** | **_@function.method_** | |
| **TroubleIconModule** | **_@module_** | |
| **TroubleIconNamespace** | **_@module_** | |
| **TroubleIconNull** | **_@constant.builtin_** | |
| **TroubleIconNumber** | **_@number_** | |
| **TroubleIconObject** | **_@constant_** | |
| **TroubleIconOperator** | **_@operator_** | |
| **TroubleIconPackage** | **_@module_** | |
| **TroubleIconProperty** | **_@property_** | |
| **TroubleIconString** | **_@string_** | |
| **TroubleIconStruct** | **_@lsp.type.struct_** | |
| **TroubleIconTypeParameter** | **_@lsp.type.typeParameter_** | |
| **TroubleIconVariable** | **_@variable_** | |
| **TroubleIndent** | **_LineNr_** | |
| **TroubleIndentFoldClosed** | **_CursorLineNr_** | |
| **TroubleIndentFoldOpen** | **_TroubleIndent_** | |
| **TroubleIndentLast** | **_TroubleIndent_** | |
| **TroubleIndentMiddle** | **_TroubleIndent_** | |
| **TroubleIndentTop** | **_TroubleIndent_** | |
| **TroubleIndentWs** | **_TroubleIndent_** | |
| **TroubleNormal** | **_NormalFloat_** | |
| **TroubleNormalNC** | **_NormalFloat_** | |
| **TroublePos** | **_LineNr_** | |
| **TroublePreview** | **_Visual_** | |
| **TroubleSource** | **_Comment_** | |
| **TroubleText** | **_Normal_** | |

<!-- colors:end -->

Expand Down
9 changes: 9 additions & 0 deletions lua/trouble/config/init.lua
Expand Up @@ -170,6 +170,15 @@ function M.setup(opts)
error(msg)
return
end
if vim.fn.has("nvim-0.10.0") == 0 then
local ok = pcall(vim.treesitter.language.add, "markdown_inline") and pcall(vim.treesitter.language.add, "markdown")
if not ok then
local msg =
"trouble.nvim requires Neovim >= 0.10.0 or\nnvim-treesitter with the markdown and markdown_inline parser"
vim.notify_once(msg, vim.log.levels.ERROR, { title = "trouble.nvim" })
error(msg)
end
end
opts = opts or {}
opts.mode = nil
options = {}
Expand Down

0 comments on commit 307f271

Please sign in to comment.