-1

Consider the following script:

vim9script

filetype plugin indent on

import "./plugin/myplugin.vim"
exe $"edit testfile.py"
MyCommand
                    

In the specific case, MyCommand is set to open a terminal buffer if, and only if, the current buffer is a python filetype.

The script works when I source it with my stardard vim with all the bells and whistles, but if I start vim with vim -u NONE, then MyCommand does not do anything.

If I echo exists(':MyCommand') I get 2, which means that myplugin is correctly loaded.

I feel that I shall set some more options, but I really don't know which ones. Any help?

7
  • "Consider the following script:" what is the path of that script? What kind of script is it? Is it supposed to be your vimrc? What makes you say that myplugin is a "ftplugin"? It looks like a regular plugin to me.
    – romainl
    Commented Jun 13 at 15:24
  • Is that relevant if echo exists(':MyCommand') returns 2? Btw, it is the current folder.
    – Barzi2001
    Commented Jun 13 at 15:28
  • 1
    I believe we need more information about what you expect to be able to help you. What are the steps you do? What do you expect? What do you get? Maybe the problem is not the ftplugin loading but something else. With the information we have I don't know how to help :-| Commented Jun 13 at 16:13
  • 1
    I will write a more crisp question. This can be closed (or I can delete it, I don’t know what’s better).
    – Barzi2001
    Commented Jun 13 at 17:42
  • 1
    In the future, while asking new questions is great, editing questions into useful shape is part of the flow of this site, too.
    – D. Ben Knoble
    Commented Jun 14 at 11:53

2 Answers 2

1

Your question really boils down to:

Why is my custom command :MyCommand working fine when I start Vim normally and not when I start Vim with -u NONE?

A question that will be difficult to answer without seeing the relevant code.

Anyway, when you start Vim with -u NONE, you tell it to act like vi, which it will happily do by, among other things, setting :help 'compatible', which in turns sets and resets a whole lot of options and default behaviors and makes Vim nearly unusable unless you know vi very well.

Note that the above is just a rehash of the following paragraph, under :help -u:

Using the "-u" argument with another argument than DEFAULTS
has the side effect that the 'compatible' option will be on by
default.  This can have unexpected effects.  See
|'compatible'|.

Which leads you to :help 'compatible' (and then :help 'cpoptions'), where you can get a good idea of all the damage it does.

If your custom command relies on one or more of those options to be set in a different way than what set compatible does, then it is very likely to break in unpredictable ways.

Adding set nocompatible to your script would be the first thing to try.

Also, unless you are very comfortable with vi or you are debugging things by establishing an unrealistically low baseline, starting Vim with -u NONE is generally pointless. -Nu NONE or --clean would be more useful. The former because it starts Vim with nocompatible, the latter because it mimics the out-of-the-box experience.

In short: you are using -u NONE without understanding what it does and, when things go sideways, you have no idea where to look at. It is a shame to treat Vim like a black box when it is the text editor with the best documentation ever.

1
  • 1
    I will write a more crisp question. This can be closed (or I can delete it, I don’t know what’s better).
    – Barzi2001
    Commented Jun 13 at 17:43
0

For the ftplugin folder to be considered by Vim you need:

filetype plugin on

Remark: If you have no vimrc then the default.vim will be used that set that setting.

If you run vim -u NONE no vimrc will be loaded and you have to run the command yourself.

1
  • 1
    I already have filetype plugin indent on and it didn't help.
    – Barzi2001
    Commented Jun 13 at 15:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.