Giter Site home page Giter Site logo

simrat39 / symbols-outline.nvim Goto Github PK

View Code? Open in Web Editor NEW
1.8K 11.0 97.0 185 KB

A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.

License: MIT License

Lua 99.59% Vim Script 0.41%
neovim

symbols-outline.nvim's Introduction

Note

Due to lack of time, this plugin has been archived.

symbols-outline.nvim

A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.

demo

Prerequisites

  • neovim 0.7+
  • Properly configured Neovim LSP client

Installation

Using packer.nvim

use 'simrat39/symbols-outline.nvim'

Setup

Put the setup call in your init.lua or any lua file that is sourced.

require("symbols-outline").setup()

Configuration

Pass a table to the setup call above with your configuration options.

local opts = {
  highlight_hovered_item = true,
  show_guides = true,
  auto_preview = false,
  position = 'right',
  relative_width = true,
  width = 25,
  auto_close = false,
  show_numbers = false,
  show_relative_numbers = false,
  show_symbol_details = true,
  preview_bg_highlight = 'Pmenu',
  autofold_depth = nil,
  auto_unfold_hover = true,
  fold_markers = { '', '' },
  wrap = false,
  keymaps = { -- These keymaps can be a string or a table for multiple keys
    close = {"<Esc>", "q"},
    goto_location = "<Cr>",
    focus_location = "o",
    hover_symbol = "<C-space>",
    toggle_preview = "K",
    rename_symbol = "r",
    code_actions = "a",
    fold = "h",
    unfold = "l",
    fold_all = "W",
    unfold_all = "E",
    fold_reset = "R",
  },
  lsp_blacklist = {},
  symbol_blacklist = {},
  symbols = {
    File = { icon = "", hl = "@text.uri" },
    Module = { icon = "", hl = "@namespace" },
    Namespace = { icon = "", hl = "@namespace" },
    Package = { icon = "", hl = "@namespace" },
    Class = { icon = "𝓒", hl = "@type" },
    Method = { icon = "ƒ", hl = "@method" },
    Property = { icon = "", hl = "@method" },
    Field = { icon = "", hl = "@field" },
    Constructor = { icon = "", hl = "@constructor" },
    Enum = { icon = "", hl = "@type" },
    Interface = { icon = "", hl = "@type" },
    Function = { icon = "", hl = "@function" },
    Variable = { icon = "", hl = "@constant" },
    Constant = { icon = "", hl = "@constant" },
    String = { icon = "𝓐", hl = "@string" },
    Number = { icon = "#", hl = "@number" },
    Boolean = { icon = "", hl = "@boolean" },
    Array = { icon = "", hl = "@constant" },
    Object = { icon = "⦿", hl = "@type" },
    Key = { icon = "🔐", hl = "@type" },
    Null = { icon = "NULL", hl = "@type" },
    EnumMember = { icon = "", hl = "@field" },
    Struct = { icon = "𝓢", hl = "@type" },
    Event = { icon = "🗲", hl = "@type" },
    Operator = { icon = "+", hl = "@operator" },
    TypeParameter = { icon = "𝙏", hl = "@parameter" },
    Component = { icon = "", hl = "@function" },
    Fragment = { icon = "", hl = "@constant" },
  },
}
Property Description Type Default
highlight_hovered_item Whether to highlight the currently hovered symbol (high cpu usage) boolean true
show_guides Whether to show outline guides boolean true
position Where to open the split window 'right' or 'left' 'right'
relative_width Whether width of window is set relative to existing windows boolean true
width Width of window (as a % or columns based on relative_width) int 25
auto_close Whether to automatically close the window after selection boolean false
auto_preview Show a preview of the code on hover boolean false
show_numbers Shows numbers with the outline boolean false
show_relative_numbers Shows relative numbers with the outline boolean false
show_symbol_details Shows extra details with the symbols (lsp dependent) boolean true
preview_bg_highlight Background color of the preview window string Pmenu
winblend Pseudo-transparency of the preview window int 0
keymaps Which keys do what table (dictionary) here
symbols Icon and highlight config for symbol icons table (dictionary) scroll up
lsp_blacklist Which lsp clients to ignore table (array) {}
symbol_blacklist Which symbols to ignore (possible values) table (array) {}
autofold_depth Depth past which nodes will be folded by default int nil
auto_unfold_hover Automatically unfold hovered symbol boolean true
fold_markers Markers to denote foldable symbol's status table (array) { '', '' }
wrap Whether to wrap long lines, or let them flow off the window boolean false

Commands

Command Description
:SymbolsOutline Toggle symbols outline
:SymbolsOutlineOpen Open symbols outline
:SymbolsOutlineClose Close symbols outline

Default keymaps

Key Action
Escape Close outline
Enter Go to symbol location in code
o Go to symbol location in code without losing focus
Ctrl+Space Hover current symbol
K Toggles the current symbol preview
r Rename symbol
a Code actions
h fold symbol
l Unfold symbol
W Fold all symbols
E Unfold all symbols
R Reset all folding
? Show help message

Highlights

Highlight Purpose
FocusedSymbol Highlight of the focused symbol
Pmenu Highlight of the preview popup windows
SymbolsOutlineConnector Highlight of the table connectors
Comment Highlight of the info virtual text

symbols-outline.nvim's People

Contributors

andersevenrud avatar axieax avatar disrupted avatar dsully avatar ehaynes99 avatar eruizc-dev avatar folliehiyuki avatar gabmus avatar geekifan avatar jamestrew avatar krady21 avatar luk3ya0 avatar madlep avatar marcuscaisey avatar mxsdev avatar ovikk13 avatar ram02z avatar samuelnittala avatar scheatkode avatar showermat avatar simrat39 avatar toppair avatar zeertzjq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symbols-outline.nvim's Issues

Option to hide some symbols.

Hello.
I want to see a few symbols(function, class, method) in SymbolsOutline.
Is there the option to hide symbols that I don't want?

thanks.

highlight_hovered_item only working on first open

When I first open the symbol outline, the currently hovered symbol is correctly highlighted in the outline view but not the code. Similarly, once I select a symbol and move in the code, the symbol outline does not highlight anything.

Working in a python file using builtin LSP and Treesitter. Happy to provide any additional debug info that could be helpful.

[Bug]: markdown: the plugin takes `comment` in `code block` as `headings`

The symbols-outline can't recognize the comment in code block in md files. It takes them as md headings instead.

eg. symbols-outline takes # clone it in sh code block as Heading level 1.
symbol

vista can handle this situation correctly.
vista

Is it possible to achieve it with symbols-outline for md files? If it's painful to fix then feel free to close this issue.

Doesn't work with vue language server

My configuration

Vue language server installed with lspinstall
https://github.com/kabouzeid/nvim-lspinstall

:LspInstall vue
local lsp = require'lspconfig'
lsp.vue.setup{...}

vim.g.symbols_outline = {
    highlight_hovered_item = true,
    show_guides = true,
    auto_preview = false, -- experimental
    position = 'right',
    keymaps = {
        close = "<Esc>",
        goto_location = "<Cr>",
        focus_location = "o",
        hover_symbol = "<C-space>",
        rename_symbol = "r",
        code_actions = "a",
    },
    -- lsp_blacklist = {'vue'},
}

When I try to run :SymbolsOutline I am getting the following errors.

Error executing vim.schedule lua callback: ...gged/symbols-outline.nvim/lua/symbols-outline/parser.lua:42: attempt to index field 'selectionRange' (a nil value)

Settings executed inside Packer's config field don't register

Packer has a convenient config field where one customarily puts all configuration related to a plugin; this is a huge aid in plugin organisation. However symbols-outline configuration method seems to be incompatible with it.

  • config.plugins.symbols_outline contains the config.
  • Calling it from init.lua works.
  • Calling it from inside the Packer field doesn't.

init.lua:

require'config.packerInit'

require'config.pluginList'
# This works:
require'config.plugins.symbols_outline'

require'config.options'

require'config.mappings'.misc()

pluginList.lua:

return {
    require('packer').startup(function(use)
        use {'simrat39/symbols-outline.nvim',
            config = function()
                # This doesn't work:
                require'config.plugins.symbols_outline'
            end
        }
    end)
}

config/plugins/symbols_outline.lua:

vim.g.symbols_outline = {
    position = 'left'
}

Preview seems to be interfering with <C-w><C-w>

Open the outline in a single buffer view. If you do <C-w><C-w> fast enough it switches focus back and forth as expected. But if you are currently focused on the outline, and you let the preview window come up, then <C-w><C-w> seems to just close the preview window but the focus stays on the outline.

open left even if positon ist set to right

Symbols open's on the left even tough postion ist set to right.

I m using the default setting

vim.g.symbols_outline = {
    highlight_hovered_item = true,
    show_guides = true,
    position = 'right',
    keymaps = {
        close = "<Esc>",
        goto_location = "<Cr>",
        focus_location = "o",
        hover_symbol = "<C-space>",
        rename_symbol = "r",
        code_actions = "a",
    },
    lsp_blacklist = {},
}

Thanks for your help

show_hover without hotkeys

I was thinking that highlight_hovered_item was showing the modal instead not when I move with the cursor the position.
It is possible to turn it when the item is highlight in the sidebar?
Also with a flag is not a problem (also for performance is not a problem too).

Error upon installation

I get the following error when trying to install the plugin, or when starting nvim again after the failed installation:

Error detected while processing /home/andrew/.vim/plugged/symbols-outline.nvim/plugin/symbols-outline.vim:
line    7:
E5108: Error while calling lua chunk for luaeval(): ...gged/symbols-outline.nvim/lua/symbols-outline/config.lua:51: attempt to call field 'tbl_deep_extend' (a nil value)
Press ENTER or type command to continue

I have the plugin definition in my nvimrc of course:

call plug#begin('~/.vim/plugged')
...
Plug 'simrat39/symbols-outline.nvim'
...
call plug#end()

And a bit further down in the config have defined:

let g:symbols_outline = {
    \ "highlight_hovered_item": v:true,
    \ "show_guides": v:true,
    \ "position": 'right',
    \ "auto_preview": v:false,
    \ "keymaps": {
        \ "close": "<Esc>",
        \ "goto_location": "<Cr>",
        \ "focus_location": "o",
        \ "hover_symbol": "<C-space>",
        \ "rename_symbol": "r",
        \ "code_actions": "a",
    \ },
    \ "lsp_blacklist": [],
\ }

as seen in the README.

$ nvim --version
NVIM v0.4.4
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/builddir/build/BUILD/neovim-0.4.4/x86_64-redhat-linux-gnu/config -I/builddir/build/BUILD/neovim-0.4.4/src -I/usr/include -I/usr/include/lua-5.1 -I/builddir/build/BUILD/neovim-0.4.4/x86_64-redhat-linux-gnu/src/nvim/auto -I/builddir/build/BUILD/neovim-0.4.4/x86_64-redhat-linux-gnu/include
Compiled by mockbuild

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

This is Fedora 33 with nvim as installed from the standard repos.

Request for silent mappings

When I press any mapping the lua command is written to command line:

image

The idea is to make all mappings silent so they don't appear there

Custom keymaps

Hi, thanks for your great plugin, looks beautiful.

Can I make custom keymaps? I use <c-space> already for my windowmanager.

Thanks

Markdown support.

This is an awesome plugin, thanks for your contribution.

Markdown is a very general file type that does not have an LSP. So would this plugin support markdown outline buildin as vista.nvim?

Outline popup (with floating window)

My main use case of an outline view is to navigate to a different position in large files. I usually:

  • Open outline window
  • Scroll down/up a bit, or use /, to find the symbol I'm looking for
  • Press enter on an item to jump there
  • Close the outline

For this workflow, it would be a big user experience upgrade if it was possible to launch the outline window as a Neovim floating window on top of the current buffer, then automatically close it when I press enter on a symbol.

Would this be possible to achieve now with a bit of advanced configuration? Or would it require additions to the plugin?

E421: Color name or number not recognized in ui.lua

When I run :SymbolsOutline the first time, I get the following error message:

Error executing vim.schedule lua callback: ...qs/start/symbols-outline.nvim/lua/symbols-outline/ui.lua:45: Vim(highlight):E421: Color name or
number not recognized: ctermfg= guifg=#6272A4

Running :echo synIDattr(synIDtrans(hlID('Comment')), 'fg','cterm') returns nothing. However, running :echo synIDattr(synIDtrans(hlID('Comment')), 'fg','gui') returns #6272A4.

After toggling SymbolsOutline the second time, the outline seems to use colors correctly. I'm using the Mofiqul/dracula.nvim colorscheme.

requirements unclear

The documentations states A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.: does this mean that nvim-lspconfig is a prerequisite (it is not indicated as such)?

I have installed the plugin but nothing happens after invoking it, therefore I suppose I miss some dependencies that are not explicitly indicated, or am I wrong?

'SignColumn' highlight cleared, results in coloring error

I just installed this plugin, and apparently something's wrong with my theme (palenight), possibly the fact that it isn't made for neovim specifically. Anyway, apparently the 'SignColumn' color is cleared (can verify running :highlight) resulting in colors failing completely.

I looked at the source code, line 40 and 42 of ui.lua in particular. Changing SignColumn to Comment results in a decent color and eliminates any errors.

Not sure if this is a viable solution, but please think about adding some fallback options for themes that don't support these colors.

Also thanks a lot for this awesome plugin, it's well made and really useful.

Error when calling SymbolsOutline

NVIM-version: NVIM v0.5.0-dev+1384-gf2906a466
Using latest version of symbols-outline.nvim

Calling SymbolsOutline in a PHP file throws the following error:
Error executing vim.schedule lua callback: .../packer/opt/symbols-outline.nvim/lua/symbols-outline.lua:188: Failed to rename buffer

SymbolsOutline works fine in lua files.

Doesn't work with pyls (python-language-server)

Hi,

Love your plugin. It doesn't work for python-language-server, it fails with the following error.

Error executing vim.schedule lua callback: ...gged/symbols-outline.nvim/lua/symbols-outline/parser.lua:42: attempt to index field 'selectionRange' (a nil value)

Weirdly, it does work for jedi-language-server (another python language server), so I'm not sure if I should report the error here or somewhere else.

Add a help file

The only documentation is in the readme. I have the plugin installed and could not remember some keybinding or command name. I then had to find the installed repository in the directory of my package manager and look at the markdown readme in nvim.

It would be nice to have a proper vim help file that can be used with :help.

(In my opinion the readme is a place to advertise and describe the plugin, maybe also give installatino instructions. But the main documentation should be in a help file because that is what we are used to in (n)vim and also because it is not interesting for a new user/passer by who just wants to know what the project is about.)

[Question] Folding

Is there any keymap which I can use to fold functions? By default, it lists all the symbols. I would like to have a functionality where we can fold and unfold the selected symbol.

Error when try to open in C++ header files

Works in C++ source .cpp files, but throw an error when try to open in C++ header .hpp file:

Error executing vim.schedule lua callback: ...art/symbols-outline.nvim/lua/symbols-outline/symbols.lua:37: attempt to index a nil value

Layout seems broken with python-lsp-server and python-language-server

Hi,

I installed the python-lsp-server, which works very nice with symbols-outline.nvim. But is seems the layout is broken.
The config works with jedi-language-server.

My config:

require('symbols-outline')

vim.g.symbols_outline = {
    highlight_hovered_item = true,
    show_guides = true,
    auto_preview = false, -- experimental
    position = 'right',
    keymaps = {
        close = "<Esc>",
        goto_location = "<Cr>",
        focus_location = "o",
        hover_symbol = "<C-space>",
        rename_symbol = "r",
        code_actions = "a",
    },
    lsp_blacklist = {},
}

2021-05-07-211714

Arjen

keymaps dont work

Default Config (just installed the plugin)

Calling :SymbolsOutline opens up the right split, and shows the correct entries and fields and auto highlight works correctly with the icons and everything but the any keymap doesnt work, including <cr> or r or anything. Nor does the mouse click work.

NVIM v0.5.0-dev+1326-ge0a01bdf7
LSP Server: pylsp

:messages is clean

Toggle preview window mapping

I find the preview window useful, however, I would prefer if I can use a mapping, like p , to toggle the preview window for the symbol when I don't need the preview.

highlights

Hello.
Thank you for the great plugin.

I have is a pretty unpleasant view in floating window
image

The only option related to highlighting I've found is FocusedSymbol

if vim.fn.hlexists('FocusedSymbol') == 0 then

Is it possible to control floating window background for this plugin?

Use vim.lsp.protocol.CompletionItemKind

Users can override their icons for completion popup menu with vim.lsp.protocol.CompletionItemKind. It would be nice if symbols-outline could use them as well so icons are the same. What do you think? Is it feasible?

Coc support?

Always need coc in life...
Should be possible, have to see how to request Coc for symbols data.

Highlight group for background

Hi, I'd like to change the background colour so the plugin window stands out a bit more. Would it be possible to add a highlight group for it? Many thanks. :)

No treesitter highlight in preview

No treesitter highligh in preview

As you can see in the following image, both are the exact same function. Left one is in active buffer and right one is in preview popup. The highlight is different because it's the popup is not using Treesitter.

image

error after fresh installation

i have

Plug 'https://github.com/simrat39/symbols-outline.nvim'

plus many other plugins

but when i open nvim i get this error:
Screenshot_2021-06-10_18-33-51
ignore that part with deprecated nerdtree bla bla variable

here is the location of the error (line 51):
image

i changed M to local M but it doesnt work anyway.

Make fixed window width optional

The symbols in the files I work in are usually quite long so I tend to make the symbols outline equal width as the other windows (<C-w>=).

Since 0868b5f makes the window fixed width, this no longer works (:h <CTRL-W_=).

Even better would be an option to configure the default size.

Thanks!

Multiple LSP clients

For python I'm using both pyls and jedi-language-server. As seen in #5 pyls does not excel in this area, but I would prefer Jedi for symbols anyway.

Need some options to blacklist/whitelist/mask/whatever which LSP client(s) to use.

Failed to call `focusable_float`

NeoVim version

image

Issue

When I triggered the hover symbol manually, the console was printing the function call failure which said the focusable_float does not exist. The error message is attached.
image

The weird thing is when I was hovering on the symbol, the auto preview could work.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.