neotree-mode
is a major mode for the neotree buffer, and major mode functions do not take any arguments, so calling (neotree-mode t)
is an error.
You wouldn't want to invoke that mode yourself, though -- it's only intended to be called from neotree's own buffer.
(Unlike minor modes -- it's very common to call a global minor mode directly from your init file, so you want to establish what sort of a mode any given *-mode
is before trying to use it. You can invariably do so by invoking describe-function
: C-hf neotree-mode
RET -- at minimum you will learn whether or not the function accepts any arguments.)
What you actually wanted to do here is call the command you were already calling via your keybinding, which is neotree-toggle
Like so:
(neotree-toggle)
Although I can see that there's actually a better function to call:
(neotree-show)
(which is the function called by the 'toggle' command when neotree is not currently visible.)
Occasionally you might need to use call-interactively
to mimic a key binding more directly -- e.g.: (call-interactively 'neotree-show)
-- but that's not the case here.
FYI, the different kinds of mode functions you'll encounter in Emacs are:
Major modes: Every buffer is running a single major mode. If you call a different major mode in a buffer, it replaces the previous one.
Buffer-local minor modes: These are enabled or disabled on a per-buffer basis. They are typically invoked via the mode hook of another mode (often a major mode).
Global minor modes: These have a global state and so are either on or off for Emacs globally, and hence might be called directly in your init file.
'Globalized' minor modes: These are global minor modes which control a separate buffer-local minor mode. When the globalized mode is enabled, it causes the buffer-local mode to be enabled en-masse in multiple buffers, and also arranges for it to be enabled in subsequent new buffers as appropriate. When the globalized mode is disabled, the buffer-local mode is also disabled en-masse.
(neotree-toggle)
to my~/.spacemacs
file worked. If you write this up as an answer I will accept it.