folke / edgy.nvim

Easily create and manage predefined window layouts, bringing a new edge to your workflow
Apache License 2.0
783 stars 14 forks source link

bug: Multiple Trouble windows in different locations possible? #86

Closed GeorgeZack closed 1 month ago

GeorgeZack commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

Artix Linux x86_64 | Kernel: 6.9.2-artix1-1

Describe the bug

Is it possible to produce three different Trouble windows with two in the right edge area and one in the bottom? Looking at Trouble and Edgy examples and docs, I could not find if it was possible. I noticed that because each Trouble window is of Filetype trouble they aren't unique and, therefore, seem to not divide into different areas.

For example, I'd love to have the Trouble symbols mode split horizontally with the LSP mode on the right, and all along the bottom have the diagnostics mode.

I hope that makes sense, please let me know if I need to add anything. Thank you for your time!

Steps To Reproduce

Issue is related to my init.lua, see below for details.

Expected Behavior

I'd like to have this setup ideally utilizing the different modes of Trouble:

 ----------------------- 
| Editor      | Symbols |
|             |---------|
|             | LSP     |
|-----------------------|
| Diagnostics           |
 -----------------------

Repro

init.lua

local vim = vim
local api = vim.api

-- Init plugins
vim.cmd[[ source $HOME/.config/nvim/vim-plug/plugins.vim ]]

-- Setup Trouble
require('trouble').setup({
    modes = {
        mydiagnostics = {
            filter = {
                any = {
                    buf = 0, -- current buffer
                    {
                        severity = vim.diagnostic.severity.ERROR, -- errors only
                        -- limit to files in the current project
                        function(item)
                            return item.filename:find((vim.loop or vim.uv).cwd(), 1, true)
                        end,
                    },
                },
            },
            mode = 'diagnostics',
            open_no_results = true,
        },
        mysymbols = {
            auto_preview = false,
            mode = 'symbols',
            open_no_results = true,
        },
        mylsp = {
            auto_preview = false,
            mode = 'lsp',
            open_no_results = true,
        },
    }
})

-- Setup Edgy
-- recommended options for Edgy
vim.opt.laststatus = 3
vim.opt.splitkeep = 'screen'
require('edgy').setup({
    exit_when_last = true,
    animate = { enabled = false },
    bottom = {
        {
            title = 'Diagnostics',
            ft = 'trouble',
            filter = function(buf)
                if buf ~= nil and vim.api.nvim_buf_is_valid(buf) then
                    local success, buf_type = pcall(vim.api.nvim_buf_get_var, buf, 'type')
                    if not success then
                        return false
                    end
                    if buf_type == 'mydiagnostics' then
                        return true
                    else
                        return false
                    end
                else
                    return false
                end
            end,
            pinned = true,
            open = function() vim.cmd('Trouble mydiagnostics toggle') end,
        },
    },
    right = {
        {
            title = 'Symbols',
            ft = 'trouble',
            size = { height = 0.5 },
            pinned = true,
            open = function() vim.cmd('Trouble mysymbols toggle') end,
        },
        {
            title = 'LSP',
            ft = 'trouble',
            size = { height = 0.5 },
            pinned = true,
            open = function() vim.cmd('Trouble mylsp toggle') end,
        },
    },
    options = {
        left = { size = 20 },
        bottom = { size = 8 },
        right = { size = 40 },
        top = { size = 8 },
    },
})
require('edgy').open()

plugins.vim

" auto-install vim-plug
if empty(glob('~/.config/nvim/autoload/plug.vim'))
    silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

call plug#begin('~/.config/nvim/autoload/plugged')
    Plug 'williamboman/mason.nvim', { 'do': ':MasonUpdate' } "LSP language server(s) installer via Mason
    Plug 'williamboman/mason-lspconfig.nvim' "LSP config + Mason bridge
    Plug 'neovim/nvim-lspconfig' "LSP configurations
    Plug 'hrsh7th/nvim-cmp' "Completion framework
    Plug 'hrsh7th/cmp-nvim-lsp' "LSP completion for nvim-cmp
    Plug 'hrsh7th/cmp-path' "System paths for nvim-cmp
    Plug 'hrsh7th/cmp-buffer' "Buffer words for nvim-cmp
    Plug 'hrsh7th/cmp-vsnip' "Snippet completion for nvim-cmp
    Plug 'hrsh7th/vim-vsnip' "Snippet engine
    Plug 'folke/edgy.nvim' "Edgy (for laying out Trouble windows)
    Plug 'folke/trouble.nvim' "Trouble (diagnostics, LSP definitions, symbols, etc.)
call plug#end()
folke commented 1 month ago

Yes! Check how I do it in LazyVim here https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/ui/edgy.lua#L115

And please use discussions next time if it's a usage related question

GeorgeZack commented 1 month ago

Yes! Check how I do it in LazyVim here https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/ui/edgy.lua#L115

Wonderful thank you for showing me where that was in the configuration. I have been looking over various source files but obviously couldn't find it.

And please use discussions next time if it's a usage related question

My bad, I'll keep that in mind.

folke commented 1 month ago

I should probably add this somewhere in the docs of edgy / trouble or both...