igankevich / mesonic

Mesonic: A Vim plugin for Meson build system
48 stars 7 forks source link

syntax: Detect functions using a regex #13

Closed bartelsielski closed 3 years ago

bartelsielski commented 3 years ago

Some meson function names are reused as keyword arguments for other functions (include_directories for example). This means the coloring of these words based on a fixed list is sometimes incorrect. This commit replaces the detection of functions by using a regex based on the fact that function names are always followed by an opening parenthesis.

igankevich commented 3 years ago

That is certainly more efficient as you don't have to list all the builtin functions! But I feel uneasy that now object methods are also highlighted (e.g. dep.found()). Could you remove them from the regex? Also, I don't feel like removing mesonBuiltin class is a good idea as some vimrcs or color scheme plugins may rely on this name.

bartelsielski commented 3 years ago

Sorry for spamming you with updates. Was a little overzealous with pushing changes.

I've updated the pull request as you asked but this has a small issue when no space is used after a symbol right before a function call. For example, this plus would get colored along with the function name:

option_aaa = '-DOPTION_AAA=' +get_option('aaa')

Still looking for a fix for this.

Edit: This is fixed in the latest version of this pull request.

igankevich commented 3 years ago

Thank you for this code. The regex looks like a cipher, but it works!