Skip to content

Commit

Permalink
Include enhancements suggested in PR #18 #18
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolashainaux committed Oct 19, 2020
1 parent 15fbc6c commit 753eb41
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Whenever possible, I'll create a PR on symbols-tree-view to propose a new featur
## Extra Settings
The ones that are not in symbols-tree-view:

![New settings illustration][new_settings_url]
* `AutoSort By Name` If this option is enabled then symbols will be sorted by name by default. Credits go to [https://github.com/lowegreg](https://github.com/lowegreg) in [PR #18](https://github.com/nicolashainaux/symbols-tree-nav/pull/18))

* `Sort by name and type` If this option is enabled then sorting by name will also group results by type. Credits go to [https://github.com/lowegreg](https://github.com/lowegreg) in [PR #18](https://github.com/nicolashainaux/symbols-tree-nav/pull/18))

* `Collapsed By Default` Self-explanatory (default=false)

Expand Down Expand Up @@ -43,6 +45,8 @@ The ones that are not in symbols-tree-view:
## Extra Features (without settings)
Here I'll try to keep an up-to-date list of the features that are proposed in symbols-tree-nav but not (yet?) in symbols-tree-view. Apart from the features already described in the Extra Settings section above.

* Highlight symbol parent when current element is collapsed and other enhancements (credits go to [https://github.com/lowegreg](https://github.com/lowegreg) in [PR #18](https://github.com/nicolashainaux/symbols-tree-nav/pull/18)).

* Enhanced support for markdown files (from [symbols-tree-view PR #138](https://github.com/xndcn/symbols-tree-view/pull/138)) and for YAML files.

* Support for several languages: R, Elixir, [taskpaper](https://github.com/xndcn/symbols-tree-view/issues/146), Fountain, Julia, LaTeX, [TypeScript](https://github.com/xndcn/symbols-tree-view/issues/101)
Expand Down
30 changes: 29 additions & 1 deletion lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ module.exports =
type: 'boolean'
default: false
description: 'If this option is enabled then symbols-tree-nav will auto open when you open files.'
order: 1
scrollAnimation:
type: 'boolean'
default: true
description: 'If this option is enabled then when you click the item in symbols-tree it will scroll to the destination gradually.'
order: 2
collapsedByDefault:
type: 'boolean'
default: false
description: 'If this option is enabled then all collapsable elements are displayed collapsed by default.'
order: 3
minTitlesLength:
type: 'number'
default: -1
Expand All @@ -22,41 +25,66 @@ module.exports =
type: 'boolean'
default: false
description: 'If this option is enabled then symbols-tree-nav is always hidden unless mouse hover over it.'
order: 4
autoSortByName:
title: 'Automatically sort by name'
type: 'boolean'
default: false
description: 'If this option is enabled then symbols will be sorted by name by default'
order: 5
sortByNameType:
title: 'Sort by name and type'
type: 'boolean'
default: false
description: 'If this option is enabled then sorting by name will also group results by type'
order: 6
minTitlesLength:
type: 'number'
default: -1
description: 'Any element having a length greater or equal to this value will display a title when mouse hover over it. Default -1 value means that titles will never be displayed.'
order: 7
zAutoHideTypes:
title: 'AutoHideTypes'
type: 'string'
description: 'Here you can specify a list of types that will be hidden by default (ex: "variable class")'
order: 8
default: ''
sortByNameScopes:
type: 'string'
description: 'Here you can specify a list of scopes that will be sorted by name (ex: "text.html.php")'
default: ''
order: 9
defaultWidth:
type: 'number'
description: 'Width of the panel (needs Atom restart)'
default: 200
order: 10
customColors:
type: 'boolean'
description: 'Colorize the entries with user-defined values'
default: false
order: 11
colorsFromSyntaxTheme:
type: 'boolean'
description: 'Colorize the entries, matching syntax theme. (Yet experimental; only partial support)'
default: false
order: 12
showIcons:
type: 'boolean'
default: true
description: 'If this option is enabled, then icons will be displayed before each element.'
order: 13
showIconsExceptions:
type: 'string'
description: 'Here you can specify a list of scopes (ex: gfm python r). If Show Icons is on, then icons will not be displayed for the specified scopes; if Show Icons is off, then icons will be displayed only for the specified scopes. Default value will not affect any scope.'
default: 'default'
order: 14
zzAlternativeCtagsBinary:
title: 'AlternativeCtagsBinary'
type: 'string'
description: 'Here you can specify a path to a binary to use for ctags creation instead of the one shipped with symbols-tree-nav. For instance, Linux users may want to use the binary available for their distribution (exuberant or universal, usually it is /usr/bin/ctags). Caution, if the path you specify is wrong, symbols-tree-nav will not work.'
default: 'default'

order: 15

symbolsTreeNav: null

Expand Down
12 changes: 11 additions & 1 deletion lib/symbols-tree-nav.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports =
@cachedStatus = {}
@contextMenu = new SymbolsContextMenu
@autoHideTypes = atom.config.get('symbols-tree-nav.zAutoHideTypes')
@autoSortByName = atom.config.get('symbols-tree-nav.autoSortByName')

@treeView.onSelect ({node, item}) =>
if item.position.row >= 0 and editor = atom.workspace.getActiveTextEditor()
Expand Down Expand Up @@ -130,13 +131,17 @@ module.exports =
@updateContextMenu(types)
@focusCurrentCursorTag()

if (@autoSortByName)
@treeView.sortByName(true)
@nowSortStatus[0] = true
@updateContextMenu(types)

if (@autoHideTypes)
for type in types
if(@autoHideTypes.indexOf(type) != -1)
@treeView.toggleTypeVisible(type)
@contextMenu.toggle(type)


# Returns an object that can be retrieved when package is activated
serialize: ->

Expand All @@ -157,6 +162,11 @@ module.exports =
@removeEventForEditor()
@populate()

#Added onDidOpen to populate while clicking through files in tree view
@onChangeEditor = atom.workspace.onDidOpen (editor) =>
@removeEventForEditor()
@populate()

@onChangeAutoHide = atom.config.observe 'symbols-tree-nav.autoHide', (autoHide) =>
unless autoHide
@off('mouseenter mouseleave')
Expand Down
15 changes: 13 additions & 2 deletions lib/tree-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ module.exports =
sortByName: (ascending=true) =>
@traversal @rootNode, (item) =>
item.children?.sort (a, b) =>
typeComp = atom.config.get('symbols-tree-nav.sortByNameType')
if typeComp
typeComp = b.type.localeCompare(a.type)
if ascending
return a.name.localeCompare(b.name)
nameComp = a.name.localeCompare(b.name)
else
return b.name.localeCompare(a.name)
nameComp = b.name.localeCompare(a.name)
return typeComp || nameComp
@setRoot(@rootNode.item)

sortByRow: (ascending=true) =>
Expand All @@ -166,3 +170,10 @@ module.exports =
select: (item) ->
@clearSelect()
item?.view.setSelected()
if item?.parent?
$parent = item?.view.closest('.list-nested-item')
if !$parent.find('div.list-item').first().hasClass('selectedParent')
$('.selectedParent').removeClass('selectedParent')
$parent.find('div.list-item').first().addClass('selectedParent')
else
$('.selectedParent').removeClass('selectedParent')
Binary file removed new_settings.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "symbols-tree-nav",
"main": "./lib/main",
"version": "0.15.4",
"version": "0.15.5",
"description": "A symbols view like taglist (experimental fork from symbols-tree-view)",
"repository": "https://github.com/nicolashainaux/symbols-tree-nav",
"providedServices": {
Expand Down
13 changes: 13 additions & 0 deletions styles/symbols-tree-nav.less
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,16 @@
.symbols-tree-nav .icon-union::before {
.symbol-icon(symbol-union);
}

.list-tree.has-collapsable-children li.list-item {
margin-left: 18px;
}
.list-tree.has-collapsable-children li.list-nested-item > .list-item::before {
margin-right: 6px;
}
.list-tree.has-collapsable-children li.list-nested-item.selected > .list-item::before {
background: rgba(96, 125, 139, 0) !important;
}
.selectedParent {
background: rgba(96, 125, 139, 0.04);
}

0 comments on commit 753eb41

Please sign in to comment.