Commit Graph

159 Commits

Author SHA1 Message Date
Björn Linse
f6968dc0f7 api: call multiple methods atomically (useful in async contexts)
remove unused response_id parameter of handle_nvim_... helpers
2016-10-22 10:51:32 +02:00
Björn Linse
cd08e6cf72 api: make nvim[_obj]_set_var and _del_var not return the old value 2016-09-15 10:44:38 +02:00
Justin M. Keyes
df072c3b2b refactor: eliminate misc2.c
move `call_shell` to misc1.c
Move some fns to state.c
Move some fns to option.c
Move some fns to memline.c
Move `vim_chdir*` fns to file_search.c
Move some fns to new module, bytes.c
Move some fns to fileio.c
2016-09-13 16:20:09 +02:00
Björn Linse
1c22cab2fd api: consistently use nvim_ prefix and update documentation 2016-08-31 21:57:06 +02:00
Björn Linse
e536abc1e1 api: Allow blacklist functions that shouldn't be accesible from eval
Blacklist deprecated functions and functions depending on channel_id
2016-08-31 21:57:06 +02:00
Björn Linse
87e054bb24 api: When calling get/set_lines from vimL, don't convert between "\n" and "\0". 2016-08-31 21:40:20 +02:00
Björn Linse
57ac9b0934 api: handle null string in buffer_add_highlight 2016-08-17 09:34:01 +02:00
ZyX
25bb08dad9 api: Add warnings about the returned value to \*del_var functions 2016-04-18 02:48:20 +03:00
ZyX
7cdd01983a api/documentation: Add a warning that nil may mean v:null 2016-04-18 02:48:20 +03:00
ZyX
f1ced96c28 api: Replace set_var(name, NIL) with del_var(name) 2016-04-18 02:47:13 +03:00
Björn Linse
6eda7c0e5f api/buffer: deprecate old line and line slice functions 2016-04-01 11:30:00 +02:00
Björn Linse
51c7818d42 api/buffer: introduce buffer_[gs]et_lines with new indexing convention.
-1 is index past the end, and -2 is the index of the last element.
This eliminates the need for include_start/include_end.

Allow the handling of out-of-bounds to be configurable.
2016-04-01 11:29:51 +02:00
Björn Linse
44b2cef83a bufhl: new mechanism for plugins to add highlights to a buffer 2016-02-23 21:29:01 +01:00
Rui Abreu Ferreira
4f24b9e06f Remove unnecessary includes for errno.h 2015-11-25 16:38:33 -05:00
Enrico Ghirardi
8ab09087da Fix append() without line argument
We want to switch include_start/end when the index is positive or
negative.
2015-09-20 12:38:41 +02:00
Enrico Ghirardi
1d1963e90e api: buffer_insert: fix bounds. #3315
buffer_insert calls buffer_set_line_slice excluding the start
line number and including the end, but it should be the opposite.

Closes https://github.com/neovim/neovim/issues/3212
Closes https://github.com/neovim/python-client/issues/103
2015-09-09 00:35:52 -04:00
Thiago de Arruda
ccdeb91e12 msgpack: Replace FUNC_ATTR_DEFERRED by FUNC_ATTR_ASYNC
API functions exposed via msgpack-rpc now fall into two categories:

- async functions, which are executed as soon as the request is parsed
- sync functions, which are invoked in nvim main loop when processing the
  `K_EVENT special key

Only a few functions which can be safely executed in any context are marked as
async.
2015-08-13 07:41:04 -03:00
Nick Hynes
7475c1c0f7 api: return error when starting a slice out of bounds. 2015-07-11 18:18:25 -04:00
Nick Hynes
90b4276d67 api: return empty array when slicing out of bounds. 2015-07-11 18:17:36 -04:00
Thiago de Arruda
34c48aaf12 memory: Add free wrapper and refactor project to use it
We already use wrappers for allocation, the new `xfree` function is the
equivalent for deallocation and provides a way to fully replace the malloc
implementation used by Neovim.
2015-04-13 08:22:44 -03:00
Thiago de Arruda
071aca9c8a api: Move switch_to_win_for_buf/restore_win_for_buf to api helpers 2015-03-25 18:57:35 -03:00
Mike Zeller
f28941b96d illumos requires the use of limits.h for things like INT_MAX #2049 2015-02-26 11:42:05 -05:00
Michael Reed
75a1006a20 api/*.c: Comment cleanup
- @justinmk: Clarify comments
- Match verbiage used in other api/*.c files
- Fix a few typos/missing words
2015-01-26 20:02:53 -05:00
Scott Prager
460843b4cd api: Handle NULs and newlines in buffer_*_line. 2014-12-06 17:29:38 -05:00
Thiago de Arruda
cf9571b7b1 api: Add FUNC_ATTR_DEFERRED attribute to a number of functions
Any function that can directly mutate the screen or execute vimscript had the
attribute applied.
2014-10-21 11:05:49 -03:00
Paul Jolly
8575f1b52a Use line-specific method names where possible to remove ambiguity and possibility of future clashes 2014-10-01 05:48:35 -03:00
Thiago de Arruda
4a8b52ea08 api/msgpack-rpc: Improve error infrastructure
- Add error type information to `Error`
- Rename `set_api_error` to `api_set_error` for consistency with other api_*
  functions/macros.
- Refactor the api_set_error macro to accept formatted strings and error types
- Improve error messages
- Wrap error messages with gettext macro
- Refactor msgpack-rpc serialization to transform Error instances into [type,
  message] arrays
- Add error type information to API metadata
- Normalize nvim->client and client->nvim error handling(change
  channel_send_call to accept an Error pointer instead of the `errored` boolean
  pointer)
- Use macro to initialize Error structures
2014-09-18 21:30:31 -03:00
Thiago de Arruda
545acf2024 api metadata: Allow typed container information in api functions
Adapt gendeclarations.lua/msgpack-gen.lua to allow the `ArrayOf(...)` and
`DictionaryOf(...)` types in function headers. These are simple macros that
expand to Array and Dictionary respectively, but the information is kept in the
metadata object, which is useful for building clients in statically typed
languages.
2014-09-12 13:50:07 -03:00
Thiago de Arruda
2792a0e33c api/msgpack-rpc: Remove Position type, using arrays instead. 2014-09-12 13:25:28 -03:00
Thiago de Arruda
d5a60d17fb api/msgpack-rpc: Remove specialized array types
Specialized array types(BufferArray, WindowArray, etc) were added to the API for
two main reasons:

- msgpack used to lack a way of serializing appliaction-specific types and there
  was no obvious way of making an API function accept/return arrays of custom
  objects such as buffers(which are represented as integers, so clients didn't
  have a way to distinguish from normal numbers)
- Let clients in statically-typed languages that support generics have a better
  typed API

With msgpack 2.0 EXT type the first item is no longer a factor and this commit
starts by removing the specialized array types. The second item will be
addressed in the future by making the API metadata return extra useful
information for statically-typed languages.
2014-09-12 13:25:28 -03:00
Wayne Rowcliffe
3599a834d5 Return bool from find_win_for_buf #1023 2014-08-07 00:42:13 -04:00
Thiago de Arruda
83cad98d5d api: make buffer_{get,set}_slice automatically assume include_end
This is for compatibility with python-vim interface: When passing an end index
with a value higher than the last index, assume the `include_end` flag
2014-07-17 11:37:41 -03:00
Pavel Platto
0868818d3e Include stdbool.h in some files which use it
Done by manual inspection of the output of this script:
grep -r -l -w "bool\|true\|false" * | grep 'c$\|h$' > has_bool
grep -r -l "stdbool.h" * | grep 'c$\|h$' > has_include
grep -F -x -v -f has_include has_bool
2014-07-11 18:33:07 -04:00
Brandon Coleman
0fff487690 move errno.h include out of vim.h 2014-07-09 00:18:20 +02:00
Thiago de Arruda
5aca2a6cd8 api: Rename find_{buffer,window,tabpage}
They were renamed to find_{buffer,window,tabpage}_by_handle to avoid conflicts
with existing functions of the same name.
2014-06-18 11:36:07 -03:00
Nicolas Hillegeer
54ca93465c api: unify string conversions, simplify interop
- The data member of String's can now be passed directly to functions
  expecting C strings, as we now guarantee that they are NUL-terminated.
  This obviates the need to use xstrndup and free, simplifying code and
  enhancing performance.
- Use xmemdupz instead of xstrndup for converting String's into C strings.
  It's faster because it doesn't calculate strlen(string.data) (which is
  unnecesary as that information is already provided in string.size anyway).
- Use cstr_to_string to convert from C strings to String, it is both shorter
  and faster than the usual strlen/xstrndup combo, which calls strlen twice.
  cstr_to_string internally calls strlen and then xmemdupz.
2014-06-08 19:21:35 +02:00
ZyX
70929f7e16 Add automatic generation of headers
- The 'stripdecls.py' script replaces declarations in all headers by includes to
  generated headers.
  `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'`
  was used for this.
- Add and integrate gendeclarations.lua into the build system to generate the
  required includes.
- Add -Wno-unused-function
- Made a bunch of old-style definitions ANSI

This adds a requirement: all type and structure definitions must be present
before INCLUDE_GENERATED_DECLARATIONS-protected include.

Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is
the only exception.
2014-06-02 11:04:17 -03:00
ZyX
880957ad4e Move documentation from function declarations to definitions
Uses a perl script to move it (scripts/movedocs.pl)
2014-06-02 11:04:04 -03:00
Justin M. Keyes
005a4254c0 Initialize Object, Position
fix #778
thanks @genisaguilar
2014-05-31 09:08:58 -04:00
Hinidu
e62722922b Extract cursor.h from misc{1,2}.h and memline.h 2014-05-28 10:42:06 -04:00
Thiago de Arruda
48ac06506b API: Bugfix: Remove possible double-free in buffer_get_line 2014-05-28 08:52:54 -03:00
Thiago de Arruda
cbf9564ee0 API: Bugfix: Remove memory leak from buffer_get_line 2014-05-26 14:02:13 -03:00
Thiago de Arruda
327347e3b4 API: Bugfix: Remove memory leak from buffer_set_name 2014-05-26 14:02:13 -03:00
Thiago de Arruda
807f940aa4 API: Bugfix: Remove memory leak from buffer_set_slice 2014-05-26 14:02:12 -03:00
Thiago de Arruda
4bac5e9ce1 API: Refactor: Duplicate/free string arguments coming from msgpack
When receiving strings *from* msgpack, we don't need to duplicate/free since
the data only lives in the msgpack parse buffer until the end of the call.

But in order to reuse `msgpack_rpc_free_object` when sending event data(which is
sent *to* msgpack), Strings must be freed, which means they must also be
allocated separately.
2014-05-26 14:02:12 -03:00
Thiago de Arruda
f03a7672e1 API: Refactor: Fix buffer_get_mark 2014-05-23 16:06:59 -03:00
Thiago de Arruda
9815688fbd API: Refactor: Use macro for initializing all arrays 2014-05-23 16:06:59 -03:00
Thiago de Arruda
1156360fe7 API: Refactor: Implement buffer_get_number 2014-05-23 16:06:59 -03:00
Thiago de Arruda
72e3125f45 API: Refactor: Move non-public files to private subdirectory 2014-05-23 16:06:58 -03:00
Thiago de Arruda
ee60683b9a API: Bugfix: Remove wrong increment statement from buffer_set_slice 2014-05-23 15:49:14 -03:00