All Projects → folke → trouble.nvim

folke / trouble.nvim

Licence: Apache-2.0 license
🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.

Programming Languages

lua
6591 projects
Vim Script
2826 projects

Projects that are alternatives of or similar to trouble.nvim

awesome-neovim
Awesome Configurations for C/C++,Zig,Web and Lua development in NeoVim
Stars: ✭ 54 (-97.97%)
Mutual labels:  neovim-plugin, neovim-lua, neovim-lsp
which-key.nvim
💥 Create key bindings that stick. WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing.
Stars: ✭ 2,043 (-23.28%)
Mutual labels:  neovim-plugin, neovim-lua
tmux.nvim
tmux integration for nvim features pane movement and resizing from within nvim.
Stars: ✭ 299 (-88.77%)
Mutual labels:  neovim-plugin, neovim-lua
modes.nvim
Prismatic line decorations for the adventurous vim user
Stars: ✭ 299 (-88.77%)
Mutual labels:  neovim-plugin, neovim-lua
diffview.nvim
Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Stars: ✭ 1,472 (-44.72%)
Mutual labels:  neovim-plugin, neovim-lua
neovim-config
Modern NeoVim config for IDE-like development
Stars: ✭ 89 (-96.66%)
Mutual labels:  neovim-lua, neovim-lsp
winshift.nvim
Rearrange your windows with ease.
Stars: ✭ 230 (-91.36%)
Mutual labels:  neovim-plugin, neovim-lua
package-info.nvim
✍️ All the npm/yarn commands I don't want to type
Stars: ✭ 248 (-90.69%)
Mutual labels:  neovim-plugin, neovim-lua
nvim-lsp-smag
Seamless integration of language server locations into NeoVim
Stars: ✭ 60 (-97.75%)
Mutual labels:  neovim-plugin, neovim-lsp
Comment.nvim
🧠 💪 // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
Stars: ✭ 796 (-70.11%)
Mutual labels:  neovim-plugin, neovim-lua
nvim-hardline
A simple Neovim statusline
Stars: ✭ 122 (-95.42%)
Mutual labels:  neovim-plugin, neovim-lua
null-ls.nvim
Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Stars: ✭ 965 (-63.76%)
Mutual labels:  neovim-plugin, neovim-lsp
neogen
A better annotation generator. Supports multiple languages and annotation conventions.
Stars: ✭ 339 (-87.27%)
Mutual labels:  neovim-plugin, neovim-lua
nvim-lsp-ts-utils
Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
Stars: ✭ 437 (-83.59%)
Mutual labels:  neovim-plugin, neovim-lsp
sphinx.nvim
Sphinx integrations for Neovim
Stars: ✭ 64 (-97.6%)
Mutual labels:  neovim-plugin
fwatch.nvim
fwatch.nvim lets you watch files or directories for changes and then run vim commands or lua functions.
Stars: ✭ 57 (-97.86%)
Mutual labels:  neovim-plugin
Coc.nvim
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Stars: ✭ 18,268 (+585.99%)
Mutual labels:  neovim-plugin
Vim Ghost
Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim
Stars: ✭ 245 (-90.8%)
Mutual labels:  neovim-plugin
skim.vim
vim support for skim
Stars: ✭ 127 (-95.23%)
Mutual labels:  neovim-plugin
nvim-config
My neovim config
Stars: ✭ 63 (-97.63%)
Mutual labels:  neovim-plugin

🚦 Trouble

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

LSP Trouble Screenshot

Features

  • pretty list of:
    • Diagnostics
    • LSP references
    • LSP implementations
    • LSP definitions
    • LSP type definitions
    • quickfix list
    • location list
    • Telescope 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.5.0
  • Properly configured Neovim LSP client
  • nvim-web-devicons is optional to enable file icons
  • a theme with properly configured highlight groups for Neovim Diagnostics
  • or install 🌈 lsp-colors to automatically create the missing highlight groups
  • a patched font for the default severity and fold icons

📦 Installation

Install the plugin with your preferred package manager:

vim-plug

" Vim Script
Plug 'nvim-tree/nvim-web-devicons'
Plug 'folke/trouble.nvim'

lua << EOF
  require("trouble").setup {
    -- your configuration comes here
    -- or leave it empty to use the default settings
    -- refer to the configuration section below
  }
EOF

packer

-- Lua
use {
  "folke/trouble.nvim",
  requires = "nvim-tree/nvim-web-devicons",
  config = function()
    require("trouble").setup {
      -- your configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  end
}

⚙️ Configuration

Setup

Trouble comes with the following defaults:

{
    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"
    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
    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>"}, -- 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
        toggle_preview = "P", -- toggle auto_preview
        hover = "K", -- opens a small popup with the full multiline message
        preview = "p", -- preview the diagnostic location
        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
    },
    indent_lines = true, -- add an indent guide below the fold icons
    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
    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

-- 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

Example keybindings:

" 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
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>",
  {silent = true, noremap = true}
)
vim.keymap.set("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>",
  {silent = true, noremap = true}
)
vim.keymap.set("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>",
  {silent = true, noremap = true}
)
vim.keymap.set("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>",
  {silent = true, noremap = true}
)
vim.keymap.set("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>",
  {silent = true, noremap = true}
)
vim.keymap.set("n", "gR", "<cmd>TroubleToggle lsp_references<cr>",
  {silent = true, noremap = true}
)

API

You can use the following functions in your keybindings:

-- 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:

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].