atom / symbols-view

Jump to symbols in Atom
MIT License
163 stars 114 forks source link

How can I hide variables from symbols-view? #125

Open MianSaleem opened 8 years ago

MianSaleem commented 8 years ago

Is there any way to hide the variable name from symbols-view list, I need methods/functions only. Can anyone guide me? Screenhsot

agentphoenix commented 8 years ago

:+1: This is my biggest complaint about Atom. Variables do no good in that list. Any way or any package to do the symbols view with only functions/methods?

mshenfield commented 8 years ago

Atom relies on ctags to actually generate symbols. You can configure ctags to ignore different types of symbols, including variables, interfaces, and classes - see the ENVIRONMENT VARIABLES and FILES section when running man ctags from the command line.

To give you a concrete answer (and guessing you are running python) add a $HOME/.ctags file on Mac, or a $HOME/ctags.cnf on Windows with the following content. This also removes imports from the symbols list.

--python-kinds=-vi

See man ctags --<LANG>-kinds entry for more information about how to exclude and include classes of symbols.

Shagshag commented 8 years ago

Thanks a lot @mshenfield :+1:

to list the available possibilities type

ctags --list-kinds=php

It gave me

c classes i interfaces d constant definitions f functions v variables j javascript functions

So for PHP

--php-kinds=cif

will list only classes, interfaces and functions

agung-wete commented 8 years ago

@mshenfield thanks a lot.

btw, mine only show the left side of this cmd + r popup (name and line only), does anybody know how do i make code snippet and paths shown in the right side (like @MianSaleem image) ? Edit: solved, using atom-ctags

thank you

grantstrotter commented 8 years ago

Would anyone else like for this to be a checkbox in the settings of the symbols-view package? This is the only thing that's got me using the atom-ctags package.

pcluo commented 7 years ago

doesn't seem to work anymore on Windows 10. I created HOME/ctags.cnf but variables still show up.

Running λ ctags --list-kinds=python shows the following:

c classes f functions m class members v variables [off] i imports [off]

Somehow, ctags in Atom is not reading the config file.

zmorris commented 3 years ago

I ended up using Symbols Navigator (repo) because none of the other outline views quite "get it". They all seem to favor opinionated minimalism instead of configurability with sane defaults, which IMHO is a widespread cargo cult anti-pattern these days.

I even tried to go in and manually edit the type list in the code for the built-in outline view, but had no luck because Atom has too many building and caching steps so no matter what I edited, nothing would ever change. If someone else can find the lines to change and the magic incantation to force Atom to reload the code, that might be preferable to installing a bunch of packages. Here are my notes:

# function list (best, the rest all have issues) control-option-o: https://github.com/lejsue/symbols-navigator
# function list control-option-o: https://github.com/nicolashainaux/symbols-tree-nav
# function list control-option-o: https://github.com/xndcn/symbols-tree-view
# function list control-o: https://github.com/alibaba/structure-view
# builtin Atom->View->Toggle Outline: https://github.com/atom-ide-community/atom-ide-outline
# customize types shown in list (doesn't work): ~/.atom/packages/atom-ide-outline/dist/main.js.map
# customize types shown in list (doesn't work): ~/.atom/packages/atom-ide-outline/src/outlineView.ts
# customize types shown in list (doesn't work):  ~/.atom/packages/atom-typescript/lib/main/atom-ide/outlineProvider.ts
# customize types shown in list (doesn't work):  .atom/packages/atom-ide-base/types-packages/outline.d.ts
apm rebuild
# crashes (never rebuilds compile-cache):
apm rebuild-module-cache
# force rebuild:
rm ~/.atom/compile-cache
# relaunch atom
# javascript support: https://github.com/atom-ide-community/atom-ide-javascript

Edit: I realized that I forgot to include the sane defaults that I use to hide variable declarations:

constant property variable

Full list:

array
boolean
class
constant
constructor
enum
field
file
function
interface
method
module
namespace
number
package
property
string
variable

And unfortunately I just discovered that arrow functions break function parsing below that point. Not sure if it's a bug with symbols-navigator or ctags, but here are some breadcrumbs:

https://github.com/lejsue/symbols-navigator/issues/5