GithubHelp home page GithubHelp logo

crusj / structrue-go.nvim Goto Github PK

View Code? Open in Web Editor NEW
37.0 1.0 0.0 3.95 MB

A better structured display of golang symbols information

License: MIT License

Lua 100.00%
go lua neovim structures vim nvim-plugin

structrue-go.nvim's Introduction

structrue-go.nvim

A more intuitive display of the symbol structure of golang files.

Description

Fast, asynchronous, intuitive, collapsible, automatic, show all methods even if they are not in the same file as the corresponding type and more.

Screenshots

Install

Requirement

neovim >= 0.7

gotags

go get -u github.com/jstemmer/gotags

Installation

Use your favorite package management tool

With Packer

use {
	'crusj/structrue-go.nvim',
	branch = "main"
}

Or

git clone https://github.com/crusj/structrue-go.nvim.git  ~/.local/share/nvim/site/pack/plugins/start/structrue-go.nvim

Usage

Start

require"structrue-go".setup()

Default config

require"structrue-go".setup({
	show_others_method = true, -- bool show methods of struct whose not in current file
	show_filename = true, -- bool
	number = "no", -- show number: no | nu | rnu
	fold_open_icon = "",
	fold_close_icon = "",
	cursor_symbol_hl = "guibg=Gray guifg=White", -- symbol hl under cursor,
	indent = "",  -- Hierarchical indent icon, nil or empty will be a tab
	position = "botright", -- window position,default botright,also can set float
	symbol = { -- symbol style
		filename = {
		    hl = "guifg=#0096C7", -- highlight symbol
		    icon = "" -- symbol icon
		},
		package = {
		    hl = "guifg=#0096C7",
		    icon = ""
		},
		import = {
		    hl = "guifg=#0096C7",
		    icon = ""
		},
		const = {
		    hl = "guifg=#E44755",
		    icon = " π ",
		},
		variable = {
		    hl = "guifg=#52A5A2",
		    icon = "",
		},
		func = {
		    hl = "guifg=#CEB996",
		    icon = "",
		},
		interface = {
		    hl = "guifg=#00B4D8",
		    icon = ""
		},
		type = {
		    hl = "guifg=#00B4D8",
		    icon = "",
		},
		struct = {
		    hl = "guifg=#00B4D8",
		    icon = "",
		},
		field = {
		    hl = "guifg=#CEB996",
		    icon = ""
		},
		method_current = {
		    hl = "guifg=#CEB996",
		    icon = " ƒ "
		},
		method_others = {
		    hl = "guifg=#CEB996",
		    icon = ""
		},
	},
	keymap = {
		toggle = "<leader>m", -- toggle structure-go window
		show_others_method_toggle = "H", -- show or hidden the methods of struct whose not in current file
		symbol_jump = "<CR>", -- jump to then symbol file under cursor
		center_symbol = "\\f", -- Center the highlighted symbol
		fold_toggle = "\\z",
		refresh = "R", -- refresh symbols
		preview_open = "P", -- preview  symbol context open
		preview_close = "\\p" -- preview  symbol context close
	},
	fold = { -- fold symbols
		import = true,
		const = false,
		variable = false,
		type = false,
		interface = false,
		func = false,
	},
})

keymap

Keymap Action Description
<leader>m :lua require'structrue-go'.toggle() Toggle structure-go
:lua require'structrue-go'.close() Close structrue-go
:lua require'structrue-go'.open() Open structrue-go
H :lua require'structrue-go'.hide_others_methods_toggle() Show or hidden the methods of struct whose not in current file
<CR> :lua require'structrue-go'.jump() Jump to the symbol file under cursor
R :lua require'structrue-go'.refresh() Refresh symbols
<leader>z :lua require'structrue-go'.fold_toggle() Toggle fold
P :lua require'structrue-go'.preview_open() Preview symbol context
\p :lua require'structrue-go'.preview_close() Close preview symbol context
<leader>f :lua require'structrue-go'.center_symbol() Center the highlighted symbol

Thanks

JetBrains Logo (Main) logo.

structrue-go.nvim's People

Contributors

crusj 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

Watchers

 avatar

structrue-go.nvim's Issues

cant find gotags

Miss gotags or not in PATH
this error is thrown by neovim even after installing gotags and adding it to path

Plugin sets modifiable for buffer which plugin is attached to

When function tags.flush_to_bufs() is executed, it sets my current file buffer state to false.

I guess the intended purpose was to specific some target buffer, but on my environment it does that to whatever structure is attached to.

How to reproduce:

  1. open file
  2. toggle structure
  3. on anything
  4. <\-p> to exit
  5. switch to file
  6. voila, modifiable set to false

E5108 error: structrue-go/window.lua:100: attempt to index upvalue 'config' (a nil value)

errors:

E5108: Error executing lua ...im/plugged/structrue-go.nvim/lua/structrue-go/window.lua:100: attempt to index upvalue 'config' (a nil value)
stack traceback:
        ...im/plugged/structrue-go.nvim/lua/structrue-go/window.lua:100: in function 'buf_key_binds'
        ...im/plugged/structrue-go.nvim/lua/structrue-go/window.lua:23: in function 'create_structrue_window'
        ...-ops/.vim/plugged/structrue-go.nvim/lua/structrue-go.lua:30: in function 'open'
        ...-ops/.vim/plugged/structrue-go.nvim/lua/structrue-go.lua:46: in function 'toggle'
        [string ":lua"]:1: in main chunk
  • default configuration
  • MacOS 12.3.1
  • nvim 0.7
  • go version go1.17.5 darwin/arm64
  • gotags version 1.4.1

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.