Repository: neovim
Issue: option error message should mention the option name, etc
Labels: enhancement,ux,options,messages

### Problem

Setting an invalid filetype via lua produces an nondescript E474 saying:

```
E5108: Error executing lua [string ":lua"]:1: E474: Invalid argument                                                                                                                                                                                                                                                            
stack traceback:                                                                                                                                                                                                                                                                                                                
        [C]: in function '__newindex'                                                                                                                                                                                                                                                                                           
        [string ":lua"]:1: in main chunk                                                                                                                                                                                                                                                                                        
```

### Steps to reproduce

`nvim --clean +'lua vim.bo.filetype = "foo bar"'`

### Expected behavior

The error message should at least mention that it's the `filetype` option which was being set. Ideally it would also mention something about what was invalid, but that seems like asking for more than what's needed.

Compare what you get when setting this option from vimscript:

```
⊙  nvim --clean +'set filetype=foo\ bar'
```

which produces:

```
E474: Invalid argument: filetype=foo\ bar                                                                                                                                                                                                                                                                                       
```

I gave a quick look at modifying `optionstr.c` to:

```diff
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 8e853b6ee..4917dd473 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -1308,7 +1308,8 @@ const char *did_set_filetype_or_syntax(optset_T *args)
   char **varp = (char **)args->os_varp;
 
   if (!valid_filetype(*varp)) {
-    return e_invarg;
+    semsg(_(e_invarg2), *varp);
+    return NULL;
   }
 
   args->os_value_changed = strcmp(args->os_oldval.string.data, *varp) != 0;
```

but this isn't enough it seems (partially because I'm not sure where in the struct the name of the argument is, considering that callback is called for multiple options).

But I'm filing this also because this seems like something *generic* perhaps, that should happen for all of the `return e_invarg`s in that file (they should include the option name), so filing this to hear feedback on that, and to hear whether it exists somewhere I didn't see in my quick look.

### Neovim version (nvim -v)

v0.10.1, reproducible on main

### Vim (not Nvim) behaves the same?

no / n/a

### Operating system/version

macOS 14.6.1

### Terminal name/version

kitty 0.36.1

### $TERM environment variable

xterm-kitty

### Installation

homebrew