mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
refactor(cpoptions): remove 'p'
Deleting a cpo flag a day keeps the doctor away We don't need two different ways to indent LISP code
This commit is contained in:
@ -1720,9 +1720,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
when it didn't exist when editing it. This is a
|
||||
protection against a file unexpectedly created by
|
||||
someone else. Vi didn't complain about this.
|
||||
*cpo-p*
|
||||
p Vi compatible Lisp indenting. When not present, a
|
||||
slightly better algorithm is used.
|
||||
*cpo-P*
|
||||
P When included, a ":write" command that appends to a
|
||||
file will set the file name for the current buffer, if
|
||||
|
@ -675,7 +675,7 @@ Options:
|
||||
bioskey (MS-DOS)
|
||||
conskey (MS-DOS)
|
||||
*'cp'* *'nocompatible'* *'nocp'* *'compatible'* (Nvim is always "nocompatible".)
|
||||
'cpoptions' (gjkHw<*- and all POSIX flags were removed)
|
||||
'cpoptions' (gjpkHw<*- and all POSIX flags were removed)
|
||||
*'cryptmethod'* *'cm'* *'key'* (Vim encryption implementation)
|
||||
cscopepathcomp
|
||||
cscopeprg
|
||||
|
3
runtime/lua/vim/_meta/options.lua
generated
3
runtime/lua/vim/_meta/options.lua
generated
@ -1296,9 +1296,6 @@ vim.bo.ci = vim.bo.copyindent
|
||||
--- when it didn't exist when editing it. This is a
|
||||
--- protection against a file unexpectedly created by
|
||||
--- someone else. Vi didn't complain about this.
|
||||
--- *cpo-p*
|
||||
--- p Vi compatible Lisp indenting. When not present, a
|
||||
--- slightly better algorithm is used.
|
||||
--- *cpo-P*
|
||||
--- P When included, a ":write" command that appends to a
|
||||
--- file will set the file name for the current buffer, if
|
||||
|
@ -1167,9 +1167,6 @@ int get_lisp_indent(void)
|
||||
pos_T paren;
|
||||
int amount;
|
||||
|
||||
// Set vi_lisp to use the vi-compatible method.
|
||||
int vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);
|
||||
|
||||
pos_T realpos = curwin->w_cursor;
|
||||
curwin->w_cursor.col = 0;
|
||||
|
||||
@ -1247,36 +1244,74 @@ int get_lisp_indent(void)
|
||||
|
||||
char *that = get_cursor_line_ptr();
|
||||
|
||||
if (vi_lisp && (get_indent() == 0)) {
|
||||
amount = 2;
|
||||
char *line = that;
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
|
||||
while (*cts.cts_ptr != NUL && col > 0) {
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
col--;
|
||||
}
|
||||
amount = cts.cts_vcol;
|
||||
that = cts.cts_ptr;
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
// Some keywords require "body" indenting rules (the
|
||||
// non-standard-lisp ones are Scheme special forms):
|
||||
// (let ((a 1)) instead (let ((a 1))
|
||||
// (...)) of (...))
|
||||
if (((*that == '(') || (*that == '[')) && lisp_match(that + 1)) {
|
||||
amount += 2;
|
||||
} else {
|
||||
char *line = that;
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
|
||||
while (*cts.cts_ptr != NUL && col > 0) {
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
col--;
|
||||
if (*that != NUL) {
|
||||
that++;
|
||||
amount++;
|
||||
}
|
||||
colnr_T firsttry = amount;
|
||||
|
||||
init_chartabsize_arg(&cts, curwin, (colnr_T)(that - line),
|
||||
amount, line, that);
|
||||
while (ascii_iswhite(*cts.cts_ptr)) {
|
||||
cts.cts_vcol += lbr_chartabsize(&cts);
|
||||
cts.cts_ptr++;
|
||||
}
|
||||
amount = cts.cts_vcol;
|
||||
that = cts.cts_ptr;
|
||||
amount = cts.cts_vcol;
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
// Some keywords require "body" indenting rules (the
|
||||
// non-standard-lisp ones are Scheme special forms):
|
||||
// (let ((a 1)) instead (let ((a 1))
|
||||
// (...)) of (...))
|
||||
if (!vi_lisp && ((*that == '(') || (*that == '['))
|
||||
&& lisp_match(that + 1)) {
|
||||
amount += 2;
|
||||
} else {
|
||||
if (*that != NUL) {
|
||||
that++;
|
||||
amount++;
|
||||
if (*that && (*that != ';')) {
|
||||
// Not a comment line.
|
||||
// Test *that != '(' to accommodate first let/do
|
||||
// argument if it is more than one line.
|
||||
if ((*that != '(') && (*that != '[')) {
|
||||
firsttry++;
|
||||
}
|
||||
|
||||
parencount = 0;
|
||||
|
||||
init_chartabsize_arg(&cts, curwin,
|
||||
(colnr_T)(that - line), amount, line, that);
|
||||
if (((*that != '"') && (*that != '\'') && (*that != '#')
|
||||
&& (((uint8_t)(*that) < '0') || ((uint8_t)(*that) > '9')))) {
|
||||
int quotecount = 0;
|
||||
while (*cts.cts_ptr
|
||||
&& (!ascii_iswhite(*cts.cts_ptr) || quotecount || parencount)) {
|
||||
if (*cts.cts_ptr == '"') {
|
||||
quotecount = !quotecount;
|
||||
}
|
||||
if (((*cts.cts_ptr == '(') || (*cts.cts_ptr == '[')) && !quotecount) {
|
||||
parencount++;
|
||||
}
|
||||
if (((*cts.cts_ptr == ')') || (*cts.cts_ptr == ']')) && !quotecount) {
|
||||
parencount--;
|
||||
}
|
||||
if ((*cts.cts_ptr == '\\') && (*(cts.cts_ptr + 1) != NUL)) {
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
}
|
||||
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
}
|
||||
}
|
||||
colnr_T firsttry = amount;
|
||||
|
||||
init_chartabsize_arg(&cts, curwin, (colnr_T)(that - line),
|
||||
amount, line, that);
|
||||
while (ascii_iswhite(*cts.cts_ptr)) {
|
||||
cts.cts_vcol += lbr_chartabsize(&cts);
|
||||
cts.cts_ptr++;
|
||||
@ -1285,54 +1320,8 @@ int get_lisp_indent(void)
|
||||
amount = cts.cts_vcol;
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
if (*that && (*that != ';')) {
|
||||
// Not a comment line.
|
||||
// Test *that != '(' to accommodate first let/do
|
||||
// argument if it is more than one line.
|
||||
if (!vi_lisp && (*that != '(') && (*that != '[')) {
|
||||
firsttry++;
|
||||
}
|
||||
|
||||
parencount = 0;
|
||||
|
||||
init_chartabsize_arg(&cts, curwin,
|
||||
(colnr_T)(that - line), amount, line, that);
|
||||
if (vi_lisp || ((*that != '"') && (*that != '\'')
|
||||
&& (*that != '#')
|
||||
&& (((uint8_t)(*that) < '0') || ((uint8_t)(*that) > '9')))) {
|
||||
int quotecount = 0;
|
||||
while (*cts.cts_ptr
|
||||
&& (!ascii_iswhite(*cts.cts_ptr) || quotecount || parencount)
|
||||
&& (!((*cts.cts_ptr == '(' || *cts.cts_ptr == '[')
|
||||
&& !quotecount && !parencount && vi_lisp))) {
|
||||
if (*cts.cts_ptr == '"') {
|
||||
quotecount = !quotecount;
|
||||
}
|
||||
if (((*cts.cts_ptr == '(') || (*cts.cts_ptr == '[')) && !quotecount) {
|
||||
parencount++;
|
||||
}
|
||||
if (((*cts.cts_ptr == ')') || (*cts.cts_ptr == ']')) && !quotecount) {
|
||||
parencount--;
|
||||
}
|
||||
if ((*cts.cts_ptr == '\\') && (*(cts.cts_ptr + 1) != NUL)) {
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
}
|
||||
|
||||
cts.cts_vcol += lbr_chartabsize_adv(&cts);
|
||||
}
|
||||
}
|
||||
|
||||
while (ascii_iswhite(*cts.cts_ptr)) {
|
||||
cts.cts_vcol += lbr_chartabsize(&cts);
|
||||
cts.cts_ptr++;
|
||||
}
|
||||
that = cts.cts_ptr;
|
||||
amount = cts.cts_vcol;
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
if (!*that || (*that == ';')) {
|
||||
amount = firsttry;
|
||||
}
|
||||
if (!*that || (*that == ';')) {
|
||||
amount = firsttry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,6 @@
|
||||
#define CPO_NUMCOL 'n' // 'number' column also used for text
|
||||
#define CPO_LINEOFF 'o'
|
||||
#define CPO_OVERNEW 'O' // silently overwrite new file
|
||||
#define CPO_LISP 'p' // 'lisp' indenting
|
||||
#define CPO_FNAMEAPP 'P' // set file name for ":w >>file"
|
||||
#define CPO_JOINCOL 'q' // with "3J" use column after first join
|
||||
#define CPO_REDO 'r'
|
||||
|
@ -1709,9 +1709,6 @@ return {
|
||||
when it didn't exist when editing it. This is a
|
||||
protection against a file unexpectedly created by
|
||||
someone else. Vi didn't complain about this.
|
||||
*cpo-p*
|
||||
p Vi compatible Lisp indenting. When not present, a
|
||||
slightly better algorithm is used.
|
||||
*cpo-P*
|
||||
P When included, a ":write" command that appends to a
|
||||
file will set the file name for the current buffer, if
|
||||
|
@ -50,6 +50,7 @@ func Test_lisp_indent()
|
||||
|
||||
set lisp
|
||||
set lispwords&
|
||||
throw 'Skipped: cpo+=p not supported'
|
||||
let save_copt = &cpoptions
|
||||
set cpoptions+=p
|
||||
normal 1G=G
|
||||
|
Reference in New Issue
Block a user