aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2024-11-03 16:36:26 +0600
committerFamiu Haque <famiuhaque@proton.me>2024-11-05 02:36:51 +0600
commitcbc9a03f58394bbb85bbe70c48856cc1efca4ab7 (patch)
tree74560c2f8f05818f10ce01d8febba3c5ee250eae
parent079e5f4f9b67a5aa2c1b481ce78711bf8c76caea (diff)
downloadrneovim-cbc9a03f58394bbb85bbe70c48856cc1efca4ab7.tar.gz
rneovim-cbc9a03f58394bbb85bbe70c48856cc1efca4ab7.tar.bz2
rneovim-cbc9a03f58394bbb85bbe70c48856cc1efca4ab7.zip
refactor(options): remove fileformat macros
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/option.c12
-rw-r--r--src/nvim/option_vars.h15
-rw-r--r--src/nvim/options.lua8
-rw-r--r--src/nvim/optionstr.c2
5 files changed, 14 insertions, 25 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index d22fb65827..a690c70875 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -801,7 +801,7 @@ static int diff_write(buf_T *buf, diffin_T *din)
// Always use 'fileformat' set to "unix".
char *save_ff = buf->b_p_ff;
- buf->b_p_ff = xstrdup(FF_UNIX);
+ buf->b_p_ff = xstrdup("unix");
const bool save_cmod_flags = cmdmod.cmod_flags;
// Writing the buffer is an implementation detail of performing the diff,
// so it shouldn't update the '[ and '] marks.
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 783ec0abf4..14553f9989 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -5105,13 +5105,13 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_fenc = xstrdup(p_fenc);
switch (*p_ffs) {
case 'm':
- buf->b_p_ff = xstrdup(FF_MAC);
+ buf->b_p_ff = xstrdup("mac");
break;
case 'd':
- buf->b_p_ff = xstrdup(FF_DOS);
+ buf->b_p_ff = xstrdup("dos");
break;
case 'u':
- buf->b_p_ff = xstrdup(FF_UNIX);
+ buf->b_p_ff = xstrdup("unix");
break;
default:
buf->b_p_ff = xstrdup(p_ff);
@@ -6240,13 +6240,13 @@ void set_fileformat(int eol_style, int opt_flags)
switch (eol_style) {
case EOL_UNIX:
- p = FF_UNIX;
+ p = "unix";
break;
case EOL_MAC:
- p = FF_MAC;
+ p = "mac";
break;
case EOL_DOS:
- p = FF_DOS;
+ p = "dos";
break;
}
diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h
index 435f919ec0..a60bd047c1 100644
--- a/src/nvim/option_vars.h
+++ b/src/nvim/option_vars.h
@@ -31,21 +31,6 @@
#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m"
-// default values for b_p_ff 'fileformat' and p_ffs 'fileformats'
-#define FF_DOS "dos"
-#define FF_MAC "mac"
-#define FF_UNIX "unix"
-
-#ifdef USE_CRNL
-# define DFLT_FF "dos"
-# define DFLT_FFS_VIM "dos,unix"
-# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode
-#else
-# define DFLT_FF "unix"
-# define DFLT_FFS_VIM "unix,dos"
-# define DFLT_FFS_VI ""
-#endif
-
// Possible values for 'encoding'
#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 71f04a4dde..e648d4350a 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -2684,7 +2684,9 @@ return {
abbreviation = 'ff',
cb = 'did_set_fileformat',
defaults = {
- if_true = macros('DFLT_FF', 'string'),
+ condition = 'USE_CRNL',
+ if_true = 'dos',
+ if_false = 'unix',
doc = 'Windows: "dos", Unix: "unix"',
},
desc = [=[
@@ -2717,7 +2719,9 @@ return {
abbreviation = 'ffs',
cb = 'did_set_fileformats',
defaults = {
- if_true = macros('DFLT_FFS_VIM', 'string'),
+ condition = 'USE_CRNL',
+ if_true = 'dos,unix',
+ if_false = 'unix,dos',
doc = 'Windows: "dos,unix", Unix: "unix,dos"',
},
deny_duplicates = true,
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 48423a1779..af2b09513b 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -84,7 +84,7 @@ static char *(p_dip_values[]) = { "filler", "context:", "iblank", "icase",
"indent-heuristic", "linematch:", "algorithm:", NULL };
static char *(p_dip_algorithm_values[]) = { "myers", "minimal", "patience", "histogram", NULL };
static char *(p_nf_values[]) = { "bin", "octal", "hex", "alpha", "unsigned", "blank", NULL };
-static char *(p_ff_values[]) = { FF_UNIX, FF_DOS, FF_MAC, NULL };
+static char *(p_ff_values[]) = { "unix", "dos", "mac", NULL };
static char *(p_cb_values[]) = { "unnamed", "unnamedplus", NULL };
static char *(p_cmp_values[]) = { "internal", "keepascii", NULL };
// Note: Keep this in sync with fill_culopt_flags()