Commit Graph

439 Commits

Author SHA1 Message Date
Thiago de Arruda
17a4bfe007 Remove os/provider.{c,h} and all of its references 2014-11-18 07:56:58 -03:00
Thiago de Arruda
3800b24c5a api: Add vim_input function and mark vim_feedkeys as deferred
The `vim_feedkeys` must be deferred because it can potentially free the buffer
passed to `os_inchar`(which in turns calls `vim_feedkeys` indirectly).

The new `vim_input` function can be used to emulate user input(Since it does not
mess with the typeahead, it is safe to execute without deferring).
2014-10-29 23:33:10 -03:00
Thiago de Arruda
94f59fc9be api: Implement vim_command_output function
This function can be used by API clients to execute a command and capture the
output.
2014-10-28 23:12:41 -04: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
Thiago de Arruda
b280308ac6 msgpack-rpc: Create subdirectory for msgpack-rpc modules
Create the msgpack_rpc subdirectory and move all modules that deal with
msgpack-rpc to it. Also merge msgpack_rpc.c into msgpack_rpc/helpers.c
2014-10-21 11:05:49 -03:00
Wayne Rowcliffe
683bc797a0 FOR_ALL_WINDOWS_IN_TAB and local variables in FOR_ALL_TAB_WINDOWS 2014-09-22 09:31:09 -05: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
cd2e46c078 api/msgpack-rpc: Refactor metadata object construction
Instead of building all metadata from msgpack-gen.lua, we now merge the
generated part with manual information(such as types and features). The metadata
is accessible through the api method `vim_get_api_info`.

This was done to simplify the generator while also increasing flexibility(by
being able to add more metadata)
2014-09-12 13:50:07 -03:00
Thiago de Arruda
15ca58d79f api: Implement vim_report_error function
This function is used to report errors caused by remote functions called by
channel_send_call
2014-09-12 13:50:07 -03:00
Thiago de Arruda
a1ce3a3acc provider: Major refactor
- Providers for features are now registered as a unit. For example, instead of
  calling `register_provider("clipboard_get")` and
  `register_provider("clipboard_set")`, clients call
  `register_provider("clipboard")` and nvim will assume it implements all
  methods of the "clipboard" feature
- Bootstrapping code was removed. With the `api_spawn` function exposed to
  vimscript, it's no longer necessary and will be handled by plugins
  distributed with nvim.
- Now the `has` function will return true if there's a live channel that
  has registered as a provider for the feature.
- 'initpython'/'initclipboard' options were removed
- A new API function was exposed: `vim_discover_features` which returns an
  object with information about pluggable features such as 'python' or
  'clipboard'
2014-09-12 13:25:29 -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
Rui Abreu Ferreira
2875ad865b Add API vim_replace_termcodes
- Add API function to call replace_termcodes
2014-08-07 12:03:27 -03:00
Rui Abreu Ferreira
1dea4044e7 Refactor vim_feedkeys and f_feedkeys
- To clean up the mix between feedkeys and replace_termcodes
  the vim_feedkeys API function now does the same thing as the
  vimscript feedkeys() function
- The original f_feedkeys() function now calls the vim_feedkeys()
  function from the API
2014-08-07 12:03:27 -03:00
Thiago de Arruda
887d32e546 provider: New module used to expose extension points for core services
Introducing the concept of providers: co-processes that talk with the editor
through the remote API and provide implementation for one or more core
services.

The `provider_register` function and it's API wrapper can be used by channels
that want to self-register as a service provider.

Some old builtin vim features will be re-implemented as providers. The
`provider_has_feature` function is used to check if a provider
implementing a certain feature is available(It will be called by the `has`
vimscript function to check for features in a vim-compatible way)

This implements the provider module without exposing any extension points, which
will be done in future commits.
2014-07-17 11:37:08 -03:00
Thiago de Arruda
f17668234a api: Refactor write_msg to use separate out/err buffers 2014-07-17 11:30:01 -03:00
Brandon Coleman
e69cfa6c15 move assert.h include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
82b71a3056 move ascii.h include out of vim.h 2014-07-09 00:18:18 +02:00
Rui Abreu Ferreira
67c5684e23 Add vim_feedkeys API function
- New API function to push data to the typeahead buffer - this should
  equivalent to the vimscript feedkeys() function
- In Vim there was a --remote-send command to insert input into a
  Vim server instance. Besides accepting key sequences it also
  translated special keys such as <CR> or <Leader>, backslash notation
  is ignored. This commit backports the original Vim handler for
  --remote-send as a bool option for vim_feedkeys()
- vim-patch:0
2014-07-07 12:18:36 -03:00
Thiago de Arruda
09605cec03 channel/msgpack_rpc: Refactor msgpack_rpc_notification/serialize_event
- Generalize some argument names(event type -> event name,
                                 event data -> event arg)
- Rename serialize_event to serialize_message
- Rename msgpack_rpc_notification to msgpack_rpc_message
- Extract the message type out of msgpack_rpc_message
- Add 'id' parameter to msgpack_rpc_message/serialize_message to create messages
  that are not notifications
2014-06-24 13:02:24 -03: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
Andrew Chin
785b16d905 Prevent null-pointer deference during vim_eval #785
If the eval_expr call in vim_eval returns NULL, a null-pointer deference
would happen a few frames down, in vim_to_object_rec
2014-06-10 02:39:39 -04:00
Nicolas Hillegeer
e1793949ab api: remove some redundant string copies
Now that incoming Pascal strings are NULL-terminated by default, we can skip
some spurious copies.
2014-06-08 19:21:30 +02:00
Nicolas Hillegeer
46e4bc0481 text: remove useless arg from mb_string2cells
mb_string2cells was always called like mb_string2cells(..., -1) so that was
the only codepath that was tested. @tarruda was the first to try to input an
actual length, after which valgrind detected that funny business was going
on.

It's not even possible to do the right thing with the current text codec
infrastructure: they all assume to be working with C strings. Meaning that
if there is no NUL-terminator, they will happily keep on reading past the
end of Pascal strings. Ergo, passing the length parameter is moot. The
condition in the for-loop was wrong as well (but that's no longer relevant).

Also change the return value to size_t, by analogy with strlen.

ref:
677d30d796
2014-06-08 12:48:22 -04: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
Thiago de Arruda
c3c826da34 API: Events: Add functions for {un}subscribing to broadcasted events 2014-05-28 08:52:54 -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
a842fe4dc1 API: Refactor: Return handles instead of indexes
- Define specialized arrays for each remote object type
- Implement msgpack_rpc functions for dealing with the new types
- Refactor all functions dealing with buffers, windows and tabpages to
  return/accept handles instead of list indexes.
2014-05-23 16:06:58 -03:00
Thiago de Arruda
f70f9bfac1 API: Refactor: Change the integer type of remote objects to uint64_t 2014-05-23 16:06:58 -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
399a0e3740 API: Bugfix: Terminate directory string in vim_change_directory
Also check that the string length is not equal or greater than MAXPATHL.
2014-05-23 16:06:46 -03:00
Thiago de Arruda
677d30d796 API: Bugfix: Use 0-terminated string in vim_strwidth
While the mb_string2cells function accepts a length parameter, it only seems to
work properly with 0-terminated strings, since valgrind reports a conditional
jump that depends on uninitialized values(means it reads after the string
boundaries which could result in overflows or wrong results)
2014-05-23 15:49:19 -03:00
Thiago de Arruda
c6483aa2fa API: Bugfix: Fix loop condition in vim_list_runtime_paths 2014-05-23 15:49:17 -03:00
Thiago de Arruda
45e5a18f3a Enable -Wconversion for API files and fix errors 2014-05-17 08:05:44 -03:00
Thiago de Arruda
76a2fb5667 Use more descriptive names for API primitive types
Instead of exposing native C types to a public API that can be consumed by other
platforms, we are now using the following translation:

int64_t -> Integer
double  -> Float
bool    -> Boolean
2014-05-17 08:05:44 -03:00
Eliseo Martínez
409cc138f2 Introduce nvim namespace: Fix project-local includes.
Prepend 'nvim/' in all project-local (non-system) includes.
2014-05-15 20:46:01 +02:00
Eliseo Martínez
e731a5edf8 Introduce nvim namespace: Fix relative includes.
Problem:  Some newly introduced files used includes relative to the
          current file, both of the form `include "../XXX.h"` and
          `include "XXX.h"`.
          Preferred form is relative to include root (src/ in our case).
Solution: Change includes to preferred form.
Note:     This is also done to ease next commit (prepend 'nvim/ to all
          project-local includes).
2014-05-15 20:46:01 +02:00
Eliseo Martínez
da51dc9cf2 Introduce nvim namespace: Move files.
Move files from src/ to src/nvim/.
- src/nvim/ becomes the new root dir for nvim executable sources.
- src/libnvim/ is planned to become root dir of the neovim library.
2014-05-15 20:46:01 +02:00