Commit Graph

128 Commits

Author SHA1 Message Date
Jason Franklin
b0f60552ea Rewrite and expand the header in bookmark.vim
The header in "bookmark.vim" was pretty weak. It provided no description
of the class it contains and no direction for the reader. In particular
it did not note the dual purpose of the "Bookmark" class.

The fact that the "Bookmark" class serves two purposes must be noted
because many readers will expect class definitions to obey the single
responsibility principle!

If there is a chance for a major refactor of this class in the future, a
priority would be splitting the class in two so that a "BookmarkList"
class can assume the responsibility for providing a container for all
"Bookmark" objects.
2017-06-10 09:57:18 -04:00
Jason Franklin
81a42acb97 Refactor the bookmark query function
The function in "bookmark.vim" that allows the caller to query the list
of Bookmarks by name had stale commentary. In addition, the internals of
the function needed to be reworked to improve readability. Making this
function very clean is important because it is heavily used elsewhere.

As a side note, it might be beneficial to later rename this function to
something like "GetBookmarkByName" to further improve readability. That
change is not critical and can be safely delayed.
2017-06-10 09:28:14 -04:00
Jason Franklin
2a7a375729 Remove code duplication from sorting bookmarks
It makes the most sense to sort the global bookmarks list just before
rendering them in the NERDTree window. Since Vim's sort function is fast
and stable, and since users are very unlikely to have a number of
bookmarks that is too large, we can sort before rendering without
concern for the negligible performance penalty.

This has two benefits:
  1. Users can change their sort settings and have them take effect
     on the next render or refresh.
  2. As mentioned, code duplication is avoided.
2017-05-26 13:46:09 -04:00
Jason Franklin
0b65089122 Reimplement the bookmark comparison method
Sorting the list of user bookmarks requires care to ensure that Vim's
builtin sort function is called correctly. Previously, this function was
called incorrectly. This is why the sorting of bookmarks never worked.

The offending functions have been removed here and replaced with
"s:Bookmark.CompareBookmarksByName". To understand the necessity for
this change, read ":h sort()" for the requirements of the function
reference argument (esp., note that it must return -1, 0, or 1).

In addition to fixing this problem, the new comparison function will
inspect the "g:NERDTreeBookmarksSort" setting to determine whether
case-sensitivity is preferred in the sort. The documentation has been
modified to accurately reflect this adjustment. The change is also made
in such a way as not to break any existing configurations.

Fixes #361 ("My bookmarks aren't sorted").
2017-05-26 13:23:05 -04:00
Jason Franklin
5aec5ecfef Rename the class method for sorting bookmarks
A more intention-revealing name was chosen for the script-local sorting
function. The function comment was also rewritten.
2017-05-26 08:48:38 -04:00
Jason Franklin
519436ad20 Apply consistent spacing before fold markers
The trailing fold markers in "bookmark.vim" varied in how far they were
from the end of the line. This created an unpleasant visual effect when
folding was in use.
2017-05-26 08:27:14 -04:00
Phil Runninger
925627536e Merge pull request #574 from sooth-sayer/master
Remove empty segments
2017-05-20 03:07:36 -04:00
Martin Grenfell
e671e403dd don't touch @o and @h registers when rendering
This just isn't needed, and leaves traces as it turns out:
http://stackoverflow.com/questions/42455953/ho-automatically-writes-vim-registers

Thanks @romainl
2017-02-25 15:23:12 +00:00
Alex Geana
9c73a19f56 fix bug with files and directories that have dollar sign in name 2016-12-29 23:22:48 +01:00
Martin Grenfell
eee431dbd4 really fix the previous buffer issue when closing a tree win
So :bprev was failing to jump back to the right buffer. I dont fully
understand this yet, but I'm fairly sure this is because there is a
magic <directory> buffer that we delete when creating a wintree :-/

Anyway, we are explicitly storing the prev buffer again - and updating
it when reusing treewins. It's worky, but there may be a superior way...
2016-10-21 14:48:05 +01:00
Martin Grenfell
48df6bfd6e Revert "remove NERDTree.previousBuf() and related code"
This reverts commit 2027ae03db.
2016-10-21 14:40:18 +01:00
Martin Grenfell
2027ae03db remove NERDTree.previousBuf() and related code
We were using this when closing a wintree - to go to the previous
buffer. Not sure why we weren't just using `:bprev` ...
2016-10-19 13:28:44 +01:00
Phil Runninger
5d7bc3b0b8 Merge pull request #533 from devm33/fix_e_on_dir
update api call to open directory tree in window
2016-09-22 15:54:39 -04:00
Phil Runninger
ac2d3b077a Merge branch 'disable-cascade' of git://github.com/juanibiapina/nerdtree into juanibiapina-disable-cascade 2016-09-08 01:02:17 -04:00
Phil Runninger
4428aba2a2 Replace strchars() with a backward compatible workaround. 2016-08-26 08:59:25 -04:00
Phil Runninger
0b73db9368 Simplify some statements. Don't convert path WinToUnix. 2016-08-26 01:32:04 -04:00
Skyler
7730c8731a Quick syntax issue fix 2016-08-25 18:20:32 -07:00
Skyler Lipthay
b5519197e9 Added support for the copy command for both file and directory nodes on Windows systems 2016-08-25 18:19:38 -07:00
Martin Grenfell
15445be5fb remove unneeded exec
As @mkoskar pointed out at:
https://github.com/scrooloose/nerdtree/pull/576#issuecomment-218470556
2016-05-11 16:28:34 +01:00
Mike Zueff
5458680265 Fixed read-only files opening. 2016-04-30 04:08:18 +03:00
Martin Grenfell
35c859179d update initialization of default value for g:NERDTreeCreatePrefix
Init it with the rest of the option defaults - rather than specify the
default at point of use. For consistency.

See #550.
2016-04-26 09:17:03 +01:00
Martin Grenfell
0cb999c070 Merge pull request #550 from wincent/keepalt
Make window creation command configurable
2016-04-26 09:05:57 +01:00
d.chernyatiev
1a55a93788 Remove empty segments 2016-04-25 19:05:17 +04:00
Juan Ibiapina
b2bbed41fa Add option to disable collapsing of diretory names 2016-03-05 14:20:04 -03:00
Juan Ibiapina
88946e9832 Rewrite getCascade recursively 2016-03-05 13:59:27 -03:00
Juan Ibiapina
7f6c608a35 Remove extra whitespace at the end of the line 2016-03-05 13:35:41 -03:00
Alex Carlson
dfb9111786 Allow user-defined RO indicator.
(inspired by overwriting g:NERDTreeDirArrowCollapsible/Expandable)

Replace instances of the RO string with a variable that the user can
override. Useful for custom unicode glyphs, i.e. Font Awesome.

* Initialize variable g:NERDTreeGlyphReadOnly = "RO".
   -> plugin/NERD_tree.vim
* Replace instances of 'RO' with g:NERDTreeGlyphReadOnly
2016-02-26 17:57:40 -08:00
Greg Hurrell
9843fd3686 Make window creation command configurable
This commit adds a `NERDTreeCreatePrefix` setting that can be used to
prefix the `:edit` command that is used to create the NERDTree tree
window. Defaults to "silent", meaning that out of the box the window
will be created with "silent edit".

Users may wish to configure this to produce other effects. For example,
`NERDTreeCreatePrefix` can be set to "silent keepalt keepjumps" in order
to make NERDTree create its window with "silent keepalt keepjumps edit".

This can be used to create an effect analogous to the `g:netrw_altfile`
setting in netrw. An example of why you might want to do this is
described here:

    https://github.com/tpope/vim-vinegar/issues/25

I'm not using vim-vinegar myself, but I am using something like it here:

    https://github.com/wincent/wincent/blob/3efaa8fa50895/roles/dotfiles/files/.vim/plugin/mappings.vim#L60

And having `NERDTreeCreatePrefix` enables me to map "-" to show the
current file in context, and `^-6` to jump back to it.
2016-02-09 00:17:46 -08:00
Devraj Mehta
afe99a46d8 update api call to open directory tree in window 2016-01-17 18:51:36 -05:00
Martin Grenfell
2f8a72144f silence an ls! call 2015-11-27 10:14:45 +00:00
Martin Grenfell
bbb819d696 bugfix for win trees when using "stay in current win" command variants
Previously maps like T would not restore the cursor position. Not sure
why the code was like this in the first place... hopefully I haven't
just broken a bunch of shit.

Closes #146.
2015-11-26 19:52:40 +00:00
Martin Grenfell
0544ff524c handle tab tree buffers being :bdeleted
Closes #375
2015-11-26 19:14:51 +00:00
Martin Grenfell
fddac60afb fix a bug that occurs when opening window trees
Closes #507
2015-11-26 09:31:55 +00:00
Martin Grenfell
c800aa27e2 fix a bug with C mapping
Closes #512
2015-11-26 09:27:44 +00:00
Martin Grenfell
a2b06bbac3 remove references to NERDTreeDirArrows
Closes #515
2015-11-26 00:25:06 +00:00
Martin Grenfell
677a83b2b6 remove NERDTreeDirArrows option
Use +/~ for windows - which seems to not have the arrow chars in its
default font. TBH I don't really understand this.

Inprove the UI indent matching so that it should handle any combo of
open/close symbol lengths e.g. the fancy arrows are 3 bytes each,
whereas +/~ are 1 byte each.
2015-11-25 23:29:00 +00:00
Martin Grenfell
fb15cfbf45 fix flag rendering for cascading dirs
Use the innermost dirs flags only. Previously each dirs flags were
rendered inline i.e.

    [x]dir1/[y]dir2/[z]dir3/

This looked bad and broke the UI. Now we only render the flags for dir3
- and render them on the left side of the cascade.

Not sure if this is ultimately the right decision - but will do for now.
2015-11-25 22:12:52 +00:00
Martin Grenfell
af39458989 rework the cascading slightly to correctly show open/closed dir arrows 2015-11-24 22:06:04 +00:00
Martin Grenfell
2cef8bb602 make cascading dirs more compact
Render cascading dirs on one line i.e.

    > foo/bar/baz
      file1

instead of

    > foo
      > bar
        > baz
          > file1

This should be useful things like java projects that have deep dir
structures.

Remove the old UI view (pre the dir arrows) as this simply isnt worth
supporting for a proof of concept. This may get added back - or not.
2015-11-24 20:59:35 +00:00
Martin Grenfell
ee4d42cfed encapsulate dep on g:NERDTreeMinimalUI in a function 2015-11-22 14:02:56 +00:00
Martin Grenfell
dd754c7bc6 add path.isAncestor 2015-11-20 19:16:07 +00:00
Martin Grenfell
9eb0004278 fix a syntax issue for older versions of vim
closes #508
2015-11-20 19:15:51 +00:00
Martin Grenfell
7c6795c5a2 fix a typo 2015-11-20 16:45:05 +00:00
Martin Grenfell
a60bd34a33 add NERDTree.getroot()
Eventually 'root' will become a "private" instance var '_root'
2015-11-20 16:16:12 +00:00
Martin Grenfell
c4f8681b77 add NERDTree.getRoot() and NERDTree.ForCurrentTab() 2015-11-20 01:52:38 +00:00
Martin Grenfell
665f326577 remove dependency on b:NERDTree from classes that dont need it
Inject it where needed.
2015-11-20 01:44:12 +00:00
Martin Grenfell
a0de028688 wipeout "stale" nerdtree bufs
When :NERDTree is called several times and &hidden is set, stale
nerdtree bufs will exist. Wipe them out.
2015-11-19 23:44:39 +00:00
Martin Grenfell
cedb40b4f5 move TreeFileNode.makeRoot() to NERDTree.changeRoot(node) 2015-11-16 13:17:59 +00:00
Martin Grenfell
71ee64fed7 add TreeDirNode.getDirChildren() - using this in a plugin 2015-11-16 11:30:16 +00:00
Martin Grenfell
bf217c75f9 fix a couple of var references in UI 2015-11-16 11:29:54 +00:00