-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RFC] - Extended Marks #5031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] - Extended Marks #5031
Conversation
src/nvim/eval.c
Outdated
{ | ||
int fnum = 0; | ||
buf_T *buf; | ||
if (argvars[0].v_type != VAR_STRING){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not check VAR_STRING, use one of get_tv_string*
functions.
test/functional/api/arbmark_spec.lua
Outdated
@@ -0,0 +1,18 @@ | |||
-- Sanity checks for buffer_* API calls via msgpack-rpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api/ is for RPC calls or events, this should probably be directly in functional/. Also new tests are normally written with one variable per line, not local clear, nvim, buffer = …
. And I would suggest to never use nvim
, curbuf
, curwin
and avoid eval
: nvim('meth', …)
is meths.meth(…)
, same for curbuf and curwin (curbufmeths, curwinmeths), nvim('eval', 'arbmark_index(haha)')
is funcs.arbmark_index('haha')
(and note that you are trying to refer to variable haha
in your code, I guess you actually wanted string 'haha'
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests shouldn't live in functional/
top level, how about functional/viml
.
(dict_notifications_spec.lua
should be moved to functional/viml
...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what is supposed to be placed into functional/viml. dict_notifications_spec should be probably in eval. viml/function_spec should be in eval (and I have no idea what api_info
is doing in this file, I would place it separately because function_spec
is too generic; this is fine if you are testing generic function-related features like MAX_FUNC_ARGS handling, but this is no place for testing specific functions), as well as viml/errorlist_spec: other functions are tested there. Not sure about viml/lang_spec and viml/completion_spec: first may be in eval, second is such a feature that can have its own directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving viml/*
to eval/
is fine with me. I think they were created by coincidence long ago.
src/nvim/editor/arbmark.c
Outdated
static int pos_eq(pos_T *pos, pos_T *pos2); | ||
|
||
/* Create or update an arbmark, */ | ||
int arbmark_set(buf_T *buf, char_u *name, pos_T *pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, this ought to be char *
. char_u *
is deprecated, for strings you should use char *
, for sequence of numbers uint8_t *
(though mostly need to cast individual characters to uint8_t when appropriate). And, I guess, this should be const char *
.
src/nvim/api/mark_extended.c
Outdated
|
||
// TODO start with current buffer | ||
// TODO use a lru cache, | ||
buf_T *extmark_buf_from_fnum(int fnum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after #4934 find_buffer_by_handle
can be used for this
src/nvim/buffer_defs.h
Outdated
@@ -33,6 +33,7 @@ typedef struct file_buffer buf_T; // Forward declaration | |||
|
|||
#define MODIFIABLE(buf) (!buf->terminal && buf->b_p_ma) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many blank lines.
src/nvim/api/buffer.c
Outdated
/// @param name The mark's name | ||
/// @param[out] err Details of an error that may have occurred | ||
/// @return The (row, col) tuple | ||
ArrayOf(Integer, 2) mark_index(Buffer buffer, String name, Error *err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, while out of scope of this PR, some time later I would imagine all api functions that take a line number or a position (line,col) pair to be polymorphic and also take
It would also be useful to reuse the binary tree defined here for other kind of marks, like |
At the moment I am following the api for tk. Text tags have more functionality than text marks. Theyvprivide the functionalit you mentioned and more. The reason youbwould use tags for this is because they live in there own namespace, you can get a tag range for a specific tag type, while with marks you are limited to the one namespace. If later on one wanted ranges of different types of marks you have to switch to the tag api or handle some mapping yourself. That might be a reason the api doesnt exist, if people want I can add the range functionality to marks as well. |
I was thinking to introduce a namespace for the marks. This would mean bufhl and tags/ plugins create one mark that needs to be moved per position. when doing mark_next / mark_names etc, If we did not do this, queryibg marks will always give all marks, and not just those that a particular user of the api cares about. |
Yes, that would be very useful. That would in fact improve performance of "numerical marks". an rplugin could then increment a private counter itself, and do |
1628f48
to
5da842b
Compare
1b62e0b
to
0feacb1
Compare
39ba2fc
to
e63bbab
Compare
b4f8622
to
ac13873
Compare
ac13873
to
276786f
Compare
@@ -1449,6 +1479,22 @@ nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts}) | |||
nvim__inspect_cell({grid}, {row}, {col}) *nvim__inspect_cell()* | |||
TODO: Documentation | |||
|
|||
*nvim_init_mark_ns()* | |||
nvim_init_mark_ns({namespace}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function does not exists.
And nvim_create_namespace()
API is already added in neovim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.txt
is autogenerated. we can just delete this file from the PR.
|
||
|
||
*nvim_mark_get_ns_ids()* | ||
nvim_mark_get_ns_ids() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvim_buf_get_extmarks()
?
Hi, I have restarted deoppet.nvim development and I will test the branch. I think the documentation should be updated. |
PR thread is too long, lets continue in #11356. |
These are marks designed for developers who want to build plugins or embed neovim. (they follow all column and line changes)
issue #4816
:move
In app visual testing can be done with