aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/globals.h6
-rw-r--r--src/nvim/main.c1
-rw-r--r--src/nvim/option.c17
-rw-r--r--src/nvim/testdir/test10.in1
-rw-r--r--src/nvim/testdir/test39.in14
-rw-r--r--src/nvim/testdir/test39.okbin584 -> 585 bytes
-rw-r--r--src/nvim/testdir/test69.in1
-rw-r--r--src/nvim/testdir/test83.in1
-rw-r--r--src/nvim/testdir/test_eval.in1
-rw-r--r--src/nvim/testdir/unix.vim3
-rw-r--r--src/nvim/tui/input.c11
-rw-r--r--src/nvim/tui/tui.c7
-rw-r--r--src/nvim/ui.c6
-rw-r--r--src/nvim/ui.h1
-rw-r--r--src/nvim/ui_bridge.c12
15 files changed, 29 insertions, 53 deletions
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index e5a993aa5a..183e8fcff2 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -633,6 +633,10 @@ EXTERN int silent_mode INIT(= FALSE);
/* set to TRUE when "-s" commandline argument
* used for ex */
+// Set to true when sourcing of startup scripts (nvimrc) is done.
+// Used for options that cannot be changed after startup scripts.
+EXTERN bool did_source_startup_scripts INIT(= false);
+
EXTERN pos_T VIsual; /* start position of active Visual selection */
EXTERN int VIsual_active INIT(= FALSE);
/* whether Visual mode is active */
@@ -1078,6 +1082,8 @@ EXTERN garray_T error_ga
* Excluded are errors that are only used once and debugging messages.
*/
EXTERN char_u e_abort[] INIT(= N_("E470: Command aborted"));
+EXTERN char_u e_afterinit[] INIT(= N_(
+ "E905: Cannot set this option after startup"));
EXTERN char_u e_api_spawn_failed[] INIT(= N_("E903: Could not spawn API job"));
EXTERN char_u e_argreq[] INIT(= N_("E471: Argument required"));
EXTERN char_u e_backslash[] INIT(= N_("E10: \\ should be followed by /, ? or &"));
diff --git a/src/nvim/main.c b/src/nvim/main.c
index dd2b813b1c..27f8340ec7 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1911,6 +1911,7 @@ static void source_startup_scripts(mparm_T *parmp)
need_wait_return = TRUE;
secure = 0;
}
+ did_source_startup_scripts = true;
TIME_MSG("sourcing vimrc file(s)");
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6e82c45edf..c47616620c 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -575,6 +575,12 @@ void set_init_1(void)
mb_init();
}
+ // Don't change &encoding when resetting to defaults with ":set all&".
+ opt_idx = findoption((char_u *)"encoding");
+ if (opt_idx >= 0) {
+ options[opt_idx].flags |= P_NODEFAULT;
+ }
+
/* Set the default for 'helplang'. */
set_helplang_default(get_mess_lang());
}
@@ -2271,10 +2277,11 @@ did_set_string_option (
else if (varp == &p_ei) {
if (check_ei() == FAIL)
errmsg = e_invarg;
- }
/* 'encoding' and 'fileencoding' */
- else if (varp == &p_enc || gvarp == &p_fenc) {
- if (gvarp == &p_fenc) {
+ } else if (varp == &p_enc || gvarp == &p_fenc) {
+ if (varp == &p_enc && did_source_startup_scripts) {
+ errmsg = e_afterinit;
+ } else if (gvarp == &p_fenc) {
if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL)
errmsg = e_modifiable;
else if (vim_strchr(*varp, ',') != NULL)
@@ -2305,10 +2312,6 @@ did_set_string_option (
* (with another encoding). */
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
(void)keymap_init();
-
- if (varp == &p_enc) {
- ui_update_encoding();
- }
}
} else if (varp == &p_penc) {
/* Canonize printencoding if VIM standard one */
diff --git a/src/nvim/testdir/test10.in b/src/nvim/testdir/test10.in
index 2d0d546606..769d690acb 100644
--- a/src/nvim/testdir/test10.in
+++ b/src/nvim/testdir/test10.in
@@ -4,7 +4,6 @@ STARTTEST
:so small.vim
:" Also test a BOM is ignored.
:so mbyte.vim
-:set encoding=utf-8
:7/start of errorfile/,/end of errorfile/w! Xerrorfile1
:7/start of errorfile/,/end of errorfile/-1w! Xerrorfile2
:/start of testfile/,/end of testfile/w! Xtestfile
diff --git a/src/nvim/testdir/test39.in b/src/nvim/testdir/test39.in
index c4e46fff26..ebbcbd6d0d 100644
--- a/src/nvim/testdir/test39.in
+++ b/src/nvim/testdir/test39.in
@@ -5,8 +5,6 @@ And test "U" in Visual mode, also on German sharp S.
STARTTEST
:so small.vim
:so mbyte.vim
-:" This only works when 'encoding' is "latin1", don't depend on the environment
-:set enc=latin1
/^abcde
:" Test shift-right of a block
jlllljj>wlljlll>
@@ -39,18 +37,18 @@ G$khhhhhkkcmno
:exe ":norm! l\<C-V>j$hhAab\<Esc>"
:.,/^$/w >> test.out
:" Test for Visual block insert when virtualedit=all and utf-8 encoding
-:set ve=all enc=utf-8
+:set ve=all
:/\t\tline
:exe ":norm! 07l\<C-V>jjIx\<Esc>"
:.,/^$/w >> test.out
:" Test for Visual block append when virtualedit=all
:exe ":norm! 012l\<C-v>jjAx\<Esc>"
-:set ve= enc=latin1
+:set ve=
:.,/^$/w >> test.out
-:" gUe must uppercase a whole word, also when ß changes to SS
-Gothe youtußeuu endYpk0wgUe
+:" gUe must uppercase a whole word, also when ß changes to SS
+Gothe youtußeuu endYpk0wgUe
:" gUfx must uppercase until x, inclusive.
-O- youßtußexu -0fogUfx
+O- youßtußexu -0fogUfx
:" VU must uppercase a whole line
YpkVU
:" same, when it's the last line in the buffer
@@ -89,7 +87,7 @@ cccc
dddd
yaaa
-¿¿¿
+¿¿¿
bbb
A23
diff --git a/src/nvim/testdir/test39.ok b/src/nvim/testdir/test39.ok
index 5c517e2223..198e5b14dc 100644
--- a/src/nvim/testdir/test39.ok
+++ b/src/nvim/testdir/test39.ok
Binary files differ
diff --git a/src/nvim/testdir/test69.in b/src/nvim/testdir/test69.in
index 26f41e8a29..f583947dfb 100644
--- a/src/nvim/testdir/test69.in
+++ b/src/nvim/testdir/test69.in
@@ -5,7 +5,6 @@ Also test byteidx() and byteidxcomp()
STARTTEST
:so mbyte.vim
-:set encoding=utf-8
ENDTEST
Results of test69:
diff --git a/src/nvim/testdir/test83.in b/src/nvim/testdir/test83.in
index 297d560d2f..d54b1bcddd 100644
--- a/src/nvim/testdir/test83.in
+++ b/src/nvim/testdir/test83.in
@@ -2,7 +2,6 @@ Tests for tag search with !_TAG_FILE_ENCODING.
STARTTEST
:so mbyte.vim
-:set enc=utf8
:if !has('iconv') || iconv("\x82\x60", "cp932", "utf-8") != "\uff21"
: e! test.ok
: w! test.out
diff --git a/src/nvim/testdir/test_eval.in b/src/nvim/testdir/test_eval.in
index 328ee2e127..b2b982a434 100644
--- a/src/nvim/testdir/test_eval.in
+++ b/src/nvim/testdir/test_eval.in
@@ -4,7 +4,6 @@ Note: system clipboard is saved, changed and restored.
STARTTEST
:so small.vim
-:set encoding=latin1
:set noswapfile
:lang C
:fun AppendRegContents(reg)
diff --git a/src/nvim/testdir/unix.vim b/src/nvim/testdir/unix.vim
index f766e74c30..aa1f6a92bc 100644
--- a/src/nvim/testdir/unix.vim
+++ b/src/nvim/testdir/unix.vim
@@ -1,3 +1,6 @@
" Settings for test script execution
" Always use "sh", don't use the value of "$SHELL".
set shell=sh
+
+" Don't depend on system locale, always use utf-8
+set encoding=utf-8
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index b680e885df..6c362540d0 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -25,7 +25,9 @@ void term_input_init(TermInput *input, Loop *loop)
if (!term) {
term = ""; // termkey_new_abstract assumes non-null (#2745)
}
- input->tk = termkey_new_abstract(term, 0);
+ int enc_flag = enc_utf8 ? TERMKEY_FLAG_UTF8 : TERMKEY_FLAG_RAW;
+ input->tk = termkey_new_abstract(term, enc_flag);
+
int curflags = termkey_get_canonflags(input->tk);
termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
// setup input handle
@@ -57,13 +59,6 @@ void term_input_stop(TermInput *input)
time_watcher_stop(&input->timer_handle);
}
-void term_input_set_encoding(TermInput *input, char* enc)
-{
- int enc_flag = strcmp(enc, "utf-8") == 0 ? TERMKEY_FLAG_UTF8
- : TERMKEY_FLAG_RAW;
- termkey_set_flags(input->tk, enc_flag);
-}
-
static void input_enqueue_event(void **argv)
{
char *buf = argv[0];
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index b2bb80a092..4c8e88c383 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -99,7 +99,6 @@ UI *tui_start(void)
ui->suspend = tui_suspend;
ui->set_title = tui_set_title;
ui->set_icon = tui_set_icon;
- ui->set_encoding = tui_set_encoding;
return ui_bridge_attach(ui, tui_main, tui_scheduler);
}
@@ -625,12 +624,6 @@ static void tui_set_icon(UI *ui, char *icon)
{
}
-static void tui_set_encoding(UI *ui, char* enc)
-{
- TUIData *data = ui->data;
- term_input_set_encoding(&data->input, enc);
-}
-
static void invalidate(UI *ui, int top, int bot, int left, int right)
{
TUIData *data = ui->data;
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index e1bbcdb193..786f6026de 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -113,11 +113,6 @@ void ui_set_icon(char *icon)
UI_CALL(flush);
}
-void ui_update_encoding(void)
-{
- UI_CALL(set_encoding, (char*)p_enc);
-}
-
// May update the shape of the cursor.
void ui_cursor_shape(void)
{
@@ -188,7 +183,6 @@ void ui_attach(UI *ui)
}
uis[ui_count++] = ui;
- ui_update_encoding();
ui_refresh();
}
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index c87d7f0c55..4c051fcfbf 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -38,7 +38,6 @@ struct ui_t {
void (*suspend)(UI *ui);
void (*set_title)(UI *ui, char *title);
void (*set_icon)(UI *ui, char *icon);
- void (*set_encoding)(UI *ui, char *enc);
void (*stop)(UI *ui);
};
diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c
index 6e1a27cc9c..2ec31de5e1 100644
--- a/src/nvim/ui_bridge.c
+++ b/src/nvim/ui_bridge.c
@@ -52,7 +52,6 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
rv->bridge.suspend = ui_bridge_suspend;
rv->bridge.set_title = ui_bridge_set_title;
rv->bridge.set_icon = ui_bridge_set_icon;
- rv->bridge.set_encoding = ui_bridge_set_encoding;
rv->scheduler = scheduler;
rv->ui_main = ui_main;
@@ -334,14 +333,3 @@ static void ui_bridge_set_icon_event(void **argv)
ui->set_icon(ui, argv[1]);
xfree(argv[1]);
}
-
-static void ui_bridge_set_encoding(UI *b, char* enc)
-{
- UI_CALL(b, set_encoding, 2, b, xstrdup(enc));
-}
-static void ui_bridge_set_encoding_event(void **argv)
-{
- UI *ui = UI(argv[0]);
- ui->set_encoding(ui, argv[1]);
- xfree(argv[1]);
-}